Files
kunlun/app/bsrm/iot_bsrm_rec.h
2024-09-28 14:24:04 +08:00

132 lines
4.0 KiB
C

/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#ifndef IOT_BSRM_REC_H
#define IOT_BSRM_REC_H
#include "os_types_api.h"
#include "iot_pkt_api.h"
/* iot common header files */
#include "iot_config_api.h"
#include "iot_bsrm_common.h"
#ifdef __cplusplus
extern "C" {
#endif
#if IOT_BSRM_MODE
/* branch event number of data */
#define IOT_BSRM_BRANCH_EVT_ENTRY_INFO_NUM 4
#pragma pack(push) /* save the pack status */
#pragma pack(1) /* 1 byte align */
/* branch detect recording formats */
typedef struct {
/* time stamp of received identification signal */
uint32_t ts;
/* success flag */
uint8_t is_vaild : 1,
/* phase see, IOT_PLC_PHASE_XXX */
phase : 2,
/* reserved */
reserved1 : 5;
/* signal intensity 1, unit: 1.0A */
float signal1_rssi;
/* signal intensity 2, unit: 1.0A */
float signal2_rssi;
/* base wave intensity */
float base_rssi;
/* background noise, unit: 1.0A */
float noise;
/* identification code len */
uint8_t id_code_len;
/* identification code */
uint8_t id_code[IOT_BSRM_BRANCH_ID_CODE_MAX];
/* reserved */
uint8_t reserved2[16];
} iot_bsrm_branch_info_entry_t;
/* branch event entry descriptor */
typedef struct {
/* number of records of this event */
uint8_t data_cnt;
/* data of records of this event */
iot_bsrm_branch_info_entry_t record_data[IOT_BSRM_BRANCH_EVT_ENTRY_INFO_NUM];
} iot_bsrm_branch_evt_rec_entry_t;
#pragma pack(pop)
/**
* @brief iot_bsrm_info_rec() - information data record.
* @param ts: time stamp.
* @param len: data len.
* @param data: data pointer.
*/
void iot_bsrm_info_rec(uint32_t ts, uint8_t len, uint8_t *data);
/**
* @brief iot_bsrm_info_rec_read() - reading information record.
* @param ts: specify the start time, and return the time of the first point of
* successful lookup
* @param total_cnt: return The number of the latest records in the current ts.
* @param n: specifies the number of points to be read, returns the number of
* points actually read.
* @param pkt: return reading information record pointer.
* @param start_index: the number after idx found according to ts.
* @retval: ERR_OK - successfully, otherwise - error code
*/
uint8_t iot_bsrm_info_rec_read(uint32_t *ts, uint16_t *total_cnt,
uint8_t *n, iot_pkt_t **pkt, uint16_t start_index);
/**
* @brief iot_bsrm_rec_init() - initialization recording Module
* @retval: ERR_OK - successfully, otherwise - error code
*/
uint32_t iot_bsrm_rec_init(void);
/**
* @brief iot_bsrm_evt_read() - read event record.
* @param evt_num: read event number.
* @param evt: return data pointer.
*/
uint8_t iot_bsrm_evt_read(uint32_t evt_num, uint8_t **evt);
/**
* @brief iot_bsrm_evt_rec_write() - write event record.
* @param evt_buf: data to be written.
*/
void iot_bsrm_evt_rec_write(uint8_t *evt_buf);
/**
* @brief iot_bsrm_rec_info_clear() - clear information data record.
*/
void iot_bsrm_rec_info_clear(void);
/**
* @brief iot_bsrm_rec_evt_clear() - clear event record.
*/
void iot_bsrm_rec_evt_clear(void);
#endif
#ifdef __cplusplus
}
#endif
#endif /* IOT_BSRM_REC_H */