| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- #ifndef _cmdDecode_H
- #define _cmdDecode_H
- #include <stdbool.h>
- #include <stdint.h>
- #define CLIENT_NUMBER 2
- #define CLIENT_PRODUCT_TYPE_X 0
- typedef enum
- {
- DOG_SLT_NONE,
- DOG_SLT_A,
- DOG_SLT_B,
- DOG_SLT_AB,
- MAX_DOG_SLT_COUNT,
- }dogSelect_te;
- typedef struct
- {
- uint8_t head1; //固定=0x57
- uint8_t head2; //固定=0xab
- uint8_t cmd; //
- uint8_t buffer[4];
- }intCmdFram_ts;
- typedef enum
- {
- CMD_SET_RF_CHANNEL = 0x01,
- CMD_SET_RF_FREQ_BAND = 0x02,
- CMD_SET_RF_POWER = 0x03,
- CMD_SET_RF_BAUDRATE = 0x04,
- CMD_SET_UART_BAUDRATE = 0x05,
- CMD_TRIGGLE_RF_PERIOD_SEND = 0x06,
- CMD_GET_RF_RSSI = 0x07,
- CMD_SET_PACKET_FORMAT = 0x08,
- CMD_SET_RF_ACK = 0x09,
- CMD_SET_DATA_DIRECT = 0x0A,
- CMD_SET_RF_FREQ_STEP = 0x0B,
- CMD_LOGIN_SERVER_PASSWORD = 0x0C,
- CMD_DEVICE_IMEI = 0x0D,
- CMD_TARGET_IMEI = 0x0E,
- CMD_RF_SYNC_WORD = 0x0F,
- CMD_GET_POWER_VALUE = 0x20,
- CMD_PARAMS_FACTORY = 0x21,
- CMD_RESET_DEVICE = 0x22,
- CMD_RF_CARRIY_WAVE = 0x23,
- CMD_GET_ALL_PARAMS = 0x24,
- CMD_GET_SOFTWARE_VERSION = 0x25,
- CMD_ENTER_CONFIG_MODE = 0x26,
- CMD_TEST_RF_RX_SENSTY = 0x27,
- CMD_SET_GROUP_ID = 0x28,
-
- CMD_DEVICE_PAIR = 0x10,
- CMD_TRIGLE_VIRBRA = 0x11,
- CMD_TRIGLE_ELECTR = 0x12,
- CMD_TRIGLE_LAMP = 0x13,
- CMD_TRIGLE_TRAIN_VOL = 0x14,
- CMD_REBACK_SEND = 0x15,
- CMD_ACK = 0x16,
- CMD_DIRECT_DATA = 0x52, //透传数据
- CMD_TO_BOOTLOADER = 0x53,
- CMD_HEART = 0x54,
- CMD_ACK_ERROR = 0xEE,
- CMD_WRITE_ROLL_ID = 0xFE,
- }cmd_te;
- typedef enum
- {
- UART_BAUDRATE_xxxx,
- UART_BAUDRATE_2400,
- UART_BAUDRATE_4800,
- UART_BAUDRATE_9600,
- UART_BAUDRATE_38400,
- UART_BAUDRATE_57600,
- UART_BAUDRATE_115200,
- UART_BAUDRATE_460800,
- UART_BAUDRATE_19200,
- MAX_UART_BAUDRATE_COUNT,
- }uartBaudrate_te;
- typedef enum
- {
- CMD_SRC_UART1,
- CMD_SRC_UART2,
- }cmdSrc_te;
- typedef enum
- {
- DD_RF_TO_UART, //
- DD_RF_TO_RF, //
- DD_PROTOCOL_ID, //
- DD_PROTOCOL_ID_CHL, //
- DD_PROTOCOL, //
- DD_PROTOCOL_POT, //
- DD_MAX_COUNT, //
- }dataDirect_te;
- typedef enum
- {
- PKT_FMT_NORMAL,
- PKT_FMT_PACKET_RSSI, //
- PKT_FMT_PACKET_RSSI_ID, //
- MAX_PKT_FMT_COUNT,
- }packetFormat_te;
- typedef struct
- {
- uint8_t len; //[0]LEN(cmd)+LEN(bufferByte)+LEN(crc1)
- uint8_t cmd; //[1]
- uint8_t bufferByte;//[2],LEN=(len -4) + 1
- uint8_t crc1; //[len-1]
- }baseCmdFram_ts;
- #pragma pack(1)
- typedef struct
- {
- uint32_t id;
- uint8_t flag; //固定=0x7e
- }deviceIdFram_ts;
- typedef struct
- {
- uint8_t wafer_lot_number[6];
- }wafer_lot_number_ts;
- typedef struct
- {
- uint8_t wafer_lot_number[6];
- uint8_t wafer_X;
- uint8_t wafer_Y;
- uint8_t wafer_number;
- uint8_t revId;
- }uid_ts;
- typedef enum
- {
- PD_RL_NODE, //终端节点
- PD_RL_LOWPWR_NODE, //低功耗终端节点
- PD_RL_MID, //中继设备
- PD_RL_NET, //网关主机
- }product_role_te;
- typedef struct
- {
- uint32_t id;
- uint8_t rfChannel; //
- uint8_t bufferAddr; //
- }targetPacketFram_ts;
- typedef struct
- {
- uint32_t id;
- uint8_t bufferAddr; //
- }targetPacketIdFram_ts;
- typedef union
- {
- uint32_t value;
- struct
- {
- uint32_t cmd : 5;
- uint32_t rfChannel : 5;
- uint32_t type : 2;
- uint32_t deviceId : 20;
- }infor;
- }clientInfor_tu;
- typedef struct
- {
- uint8_t len;
- clientInfor_tu clientInfor;
- uint32_t value;
- uint8_t crc;
- }devicePairFram_ts;
- typedef struct
- {
- uint8_t len; //
- uint8_t cmd;
- clientInfor_tu clientInfor;
- uint32_t deviceId;
- uint32_t targetId;
- uint32_t buffer;
- uint8_t crc8; //
- }rfProtocol4ByteBuffer_ts;
- typedef struct
- {
- uint8_t len; //
- uint8_t cmd;
- clientInfor_tu clientInfor;
- uint32_t deviceId;
- uint32_t targetId;
- //⬇⬇⬇⬇⬇⬇ payload ⬇⬇⬇⬇⬇⬇
- uint8_t bufferAddr;
- //⬆⬆⬆⬆⬆⬆ payload ⬆⬆⬆⬆⬆⬆
- uint8_t crc8; //
- }rfProtocol_ts;
- typedef struct
- {
- uint8_t len; //[0]LEN(cmd)+LEN(bufferByte)+LEN(crc1)
- uint8_t cmd; //[1]
- uint32_t buffer;//[2],
- uint8_t crc1; //[len-1]
- }ipCmdFram_ts;
- typedef struct
- {
- uint8_t len; //[0]LEN(cmd)+LEN(bufferByte)+LEN(crc1)
- uint8_t cmd; //[1]
- uint16_t buffer;//[2],
- uint8_t crc1; //[len-1]
- }ipCmdFram2_ts;
- typedef enum
- {
- VIBR_LEVEL_1,
- VIBR_LEVEL_2,
- VIBR_LEVEL_3,
- VIBR_LEVEL_4,
- VIBR_LEVEL_5,
- VIBR_LEVEL_6,
- MAX_VIBR_LEVEL_COUNT,
- }vibrLevel_te;
- typedef enum
- {
- TRAIN_VOL_LEVEL_1,
- TRAIN_VOL_LEVEL_2,
- TRAIN_VOL_LEVEL_3,
- MAX_TRAIN_VOL_LEVEL_COUNT,
- }trainVol_te;
- typedef enum
- {
- ELECT_LEVEL_1,
- ELECT_LEVEL_2,
- ELECT_LEVEL_3,
- ELECT_LEVEL_4,
- ELECT_LEVEL_5,
- ELECT_LEVEL_6,
- ELECT_LEVEL_7,
- ELECT_LEVEL_8,
- ELECT_LEVEL_9,
- ELECT_LEVEL_99 = 98,
- MAX_ELECT_LEVEL_COUNT,
- }electLevel_te;
- typedef enum
- {
- CHG_MD_NONE = 0,
- CHG_MD_TONE = 1,
- CHG_MD_VIBR = 2,
- CHG_MD_ELECT = 3,
- }changeMode_te;
- typedef struct
- {
- uint8_t len; //
- uint8_t cmd;
- uint8_t dhcpEnable;
- uint8_t deviceIpAddr[4];
- uint8_t deviceSubMask[4];
- uint8_t deviceNetIpAddr[4];
- uint8_t netMode; //@ netMode_te
- uint8_t randLocalPortEnable;
- uint8_t targetIp[4];
- uint16_t targetPort;
- uint16_t localPort;
- uint8_t crc1; //
- }intInfor_ts;
- typedef struct
- {
- uint8_t len; //
- uint8_t cmd;
- uint8_t channel;
- uint8_t freqBand; //@freqBand_te
- uint8_t rfPower;
- uint8_t freqStep; //freqStep*10kHz,范围:250k~2MHz
- uint8_t syncWord; //同步字
- uint32_t targetImei; //目标ID号
- uint8_t dogABselect; // =0 选择AB, =1 选择A, =2 选择B
- uint8_t crc1; //
- }deviceInfor_ts;
- typedef struct
- {
- uint8_t len; //
- uint8_t cmd;
- uint8_t updateFlag; //
- uint8_t eraseFlag; //
- uint8_t version; //
- // uint8_t appVersion; //
- uint32_t uartBr; //
- uint32_t appAddr; //
- uint8_t crc; //
- }deviceBootInfor_ts;
- #pragma pack()
- extern uint8_t levelChangeMode;
- extern bool safeKeyLockFlag;
- extern bool localOpenFlag;
- extern bool remoteLampOpenFlag;
- extern deviceInfor_ts deviceInfor;
- extern uint8_t remoteBatLevel;
- bool checkFramLegal(uint8_t *srcBuffer, uint8_t srcLen);
- void completFramParams(uint8_t *srcBuffer, uint8_t srcLen);
- #endif
|