Files
kunlun/app/iot_sniffer/inc/iot_sniffer_task.h

135 lines
4.5 KiB
C
Raw Permalink Normal View History

2024-09-28 14:24:04 +08:00
/****************************************************************************
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_SNIFFER_TASK_H
#define IOT_SNIFFER_TASK_H
/* common includes */
#include "iot_plc_api.h"
#include "iot_queue_api.h"
#include "iot_utils_api.h"
#include "iot_task_api.h"
#include "iot_uart_api.h"
#ifdef __cplusplus
extern "C" {
#endif
#define BIT(x) (1<<(x))
#ifndef MAC_FMT
#define MAC_FMT "%02X%02X%02X%02X%02X%02X"
#endif
#ifndef MAC_ARG
#define MAC_ARG(x) ((uint8_t*)(x))[0],((uint8_t*)(x))[1],((uint8_t*)(x))[2],\
((uint8_t*)(x))[3],((uint8_t*)(x))[4],((uint8_t*)(x))[5]
#endif
/* define sniffer module message queue count and priorities,
* the higer the priority, the lower the queue number.
*/
#define IOT_SNIFFER_MSG_QUEUE_HP (0)
#define IOT_SNIFFER_MSG_QUEUE_LP (1)
#define IOT_SNIFFER_MSG_QUEUE_MAX_PRIO (2)
/* message type definition */
/* messages from sniffer module interface */
/* messages from PLC */
#define IOT_SNIFFER_MSG_TYPE_PLC (1)
/* messages from uart */
#define IOT_SNIFFER_MSG_TYPE_UART (2)
/* PLC type message id definition */
/* message delivered from PLC */
#define IOT_SNIFFER_MSG_ID_PLC_MSG (1)
/* message delivered from uart */
#define IOT_SNIFFER_MSG_ID_UART_DATA (1)
#define IOT_SNIFFER_STR_MAC_HEAD_LEN (36)
#define IOT_SNIFFER_STR_RSSI_SNR_LEN (20)
#define IOT_SNIFFER_STR_HEAD_LEN (IOT_SNIFFER_STR_MAC_HEAD_LEN + \
IOT_SNIFFER_STR_RSSI_SNR_LEN)
#define PLC_TEI_CCO (1)
/* PLC data transmit */
#define ID_PLC_DATA_TRANSMIT 0x50
/* PLC remote cmd */
#define ID_PLC_REMOTE_CMD 0x51
/* PLC bypass*/
#define ID_PLC_DATA_BYPASS 0x52
/*AT remote cmd*/
#define ID_PLC_REMOTE_AT 0x53
/*AT PLC TEST*/
#define ID_PLC_DATA_TEST 0x54
/*PLC HILINK cmd*/
#define ID_PLC_DATA_HILINK 0x55
/*AT hex data*/
#define ID_PLC_AT_DATA 0x56
/*AT string data*/
#define ID_PLC_AT_STRING 0x57
/*AT delay time*/
#define ID_PLC_AT_DELAYTIME 0x58
/* the protocol sniffer app supported */
enum _iot_sniffer_proto {
IOT_SNIFFER_PROTO_GE,
IOT_SNIFFER_PROTO_AT,
IOT_SNIFFER_PROTO_SILA,
IOT_SNIFFER_PROTO_BYPASS
};
#define IOT_SNIFFER_PROTO_DEFALT IOT_SNIFFER_PROTO_AT
#define IOT_SNIFFER_FREQ_BAND_DEFALT PLC_LIB_FREQ_BAND_2
#define IOT_SNIFFER_FREQ_BAND_MIN PLC_LIB_FREQ_BAND_0
#define IOT_SNIFFER_FREQ_BAND_MAX PLC_LIB_FREQ_BAND_MAX
typedef struct {
uint16_t id; /* PLC packet ID */
uint8_t mac[IOT_MAC_ADDR_LEN]; /* destination address */
} app_custom_data;
/* sniffer module message */
typedef struct _iot_sniffer_msg {
/* iot task message */
iot_task_msg_t task_msg;
/* pointer to message data */
void *data;
/* another data field */
uint32_t data2;
} iot_sniffer_msg_t;
/* sniffer global descriptor */
typedef struct _iot_sniffer_global {
/* sniffer module task configuration */
iot_task_config_t task_cfg;
/* sniffer module task handle */
iot_task_h task_h;
/* handle of registered plc app */
iot_plc_app_h plc_app_h;
/* sniffer module 485 uart handle*/
iot_uart_h handle;
} iot_sniffer_global_t;
void iot_sniffer_send_data(iot_pkt_t *pkt);
void iot_sniffer_set_band(uint8_t freq_band);
#ifdef __cplusplus
}
#endif
#endif /* IOT_SNIFFER_TASK_H */