Files
kunlun/app/iot_sniffer/inc/iot_proto_sila.h
2024-09-28 14:24:04 +08:00

99 lines
3.4 KiB
C
Executable File

/****************************************************************************
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_PROTO_SILA_H
#define IOT_PROTO_SILA_H
/* common includes */
#include "iot_utils_api.h"
#include "iot_plc_msg_cco_api.h"
#ifdef __cplusplus
extern "C" {
#endif
#define SILA_FRAME_MAX_LEN (512)
#define SILA_FRAME_MIN_LEN (10)
#define SILA_FRAME_CHECKSUM_LEN (2)
#define SILA_FRAME_HEAD_BYTE (0x48)
#define SILA_FRAME_CTRL_DIR_DN (0x00)
#define SILA_FRAME_CTRL_DIR_UP (0x80)
#define SILA_FRAME_CTRL_PRM_HOST (0x40)
#define SILA_FRAME_CTRL_PRM_SLAVE (0x00)
#define SILA_FRAME_CTRL_PRM_MASK (0x40)
#define SILA_FRAME_CTRL_RESPONSE (SILA_FRAME_CTRL_DIR_UP |\
SILA_FRAME_CTRL_PRM_SLAVE)
#define SILA_FRAME_CTRL_REQ (SILA_FRAME_CTRL_DIR_DN |\
SILA_FRAME_CTRL_PRM_HOST)
#define SILA_CRC_HIGH_BIT_OFFSET (8)
#define PROTO_RET_CODE_SUCCESS (0x00)
#define PROTO_RET_CODE_FAILED (0x01)
enum sila_proto_cmd {
ID_PROTO_CMD_BAND_QUERY = 0x0050,
ID_PROTO_CMD_BAND_SET = 0x0051,
ID_PROTO_CMD_DATA_TRANS_TX = 0x0100,
ID_PROTO_CMD_DATA_TRANS_RX = 0x0101,
ID_PROTO_CMD_REMOTE_CMD_TX = 0x0110,
ID_PROTO_CMD_REMOTE_CMD_RX = 0x0111,
ID_PROTO_CMD_HILINK_DATA_TRANS = 0x0120
};
#pragma pack(push) // save the pack status
#pragma pack(1) // 1 byte align
typedef struct {
uint8_t head;
uint8_t ctrl;
uint16_t cmd;
uint16_t seq;
uint16_t length;
uint8_t data[0];
} proto_sila_frame_head;
typedef struct {
uint8_t dst_addr[IOT_MAC_ADDR_LEN]; /* destination communication address */
uint16_t data_length; /* User data length */
uint8_t data[0]; /* User data */
} proto_sila_tx_t;
typedef proto_sila_tx_t proto_sila_transmit_tx_t;
typedef proto_sila_tx_t proto_sila_remote_cmd_tx_t;
typedef proto_sila_tx_t proto_sila_hilink_tx_t;
typedef struct {
uint8_t band; /* work band */
uint8_t rsv[3];
} proto_get_work_band_ind;
typedef proto_get_work_band_ind proto_set_work_band_req;
typedef struct {
uint8_t ret_code; /* Error code. 0: success; 1: failure */
uint8_t rsv[3];
} proto_set_work_band_ind;
#pragma pack(pop) /* restore the pack status */
void iot_sniffer_fix_send_sila_data(iot_plc_msdu_app_sniffer_recv_t *msdu);
void iot_proto_sila_parse_handle(uint8_t *buffer, uint32_t buffer_len);
#ifdef __cplusplus
}
#endif
#endif /* IOT_PROTO_SILA_H */