gateway_collect.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef __GATEWAY_COLLECT_H__
  2. #define __GATEWAY_COLLECT_H__
  3. #include "stm32f10x.h"
  4. //#include "downlink.h"
  5. #include "../../APP/network/downlink.h"
  6. #include "../globalDef.h"
  7. #include "../ota/ota.h"
  8. /*采集器与网关通信的消息类型*/
  9. #define GATE_COLL_HEART_QUERY 0x56 //网关与采集器的下行心跳包
  10. #define COLL_GATE_HEART_QUERY 0x66 //网关与采集器的上行心跳包
  11. #define GATE_COLL_TAX_QUERY 0x57 //业务数据下行发送消息
  12. #define COLL_GATE_TAX_QUERY 0x67 //业务数据上行接收消息
  13. #define GATE_COLL_FIRMMSG_QUERY 0x58 //网关下发查询固件信息
  14. #define COLL_GATE_FIRMMSG_QUERY 0x68 //采集器上发固件信息
  15. #define COLL_GATE_RESTART_QUERY 0x59 //采集器设备重新启动
  16. #define YTSF_0XA2_0X00 0xA2
  17. #define YTSF_0XA1_0X11 0xA1
  18. #define YTSF_0XA1_0X14 0xA4
  19. #define FRAME_LEN 19
  20. #define PLAINTEXT 1 //明文
  21. #define CIPHERTEXT 2 //密文
  22. #define DISPLAY 3 //显示屏
  23. #define GATE_COLL_HEAD_LEN 12 // 网关与采集器通信的协议头为12个字节
  24. #define GATE_COLL_CMD5767_LEN 11 //0x57 0x67指令的长度
  25. #define GATE_COLL_CMD56_LEN 5 // 56命令的长度
  26. #define GATE_COLL_CMD58_LEN 5 // 58命令的长度
  27. #define GATE_COLL_CMD59_LEN 5 // 59命令的长度
  28. #define GATE_COLL_PROTOTYPE 0x11 // 网关与采集器通信协议的版本
  29. /*业务数据头0x17 0x27*/
  30. typedef struct _tax_query_info
  31. {
  32. uint32_t device_sn; //设备编号
  33. uint8_t device_type; // 设备类型 1:报税口 2:显示屏
  34. uint8_t msg_com; //串口号
  35. uint8_t coll_no; // 采集器索引 从1开始
  36. uint8_t tax_no; //报税口号 从1开始
  37. uint8_t gun_msgid; //枪号 从1开始
  38. uint8_t prot_type; //协议类型 1:明文 2:密文
  39. uint8_t status; //1:成功 2:数据超时
  40. char info[160];
  41. }__attribute__((packed)) tax_query_info_t;
  42. /* 心跳0x56 查询固件信息0x58 设备重新启动0x59*/
  43. typedef struct _TAX_COMM_HEAD_{
  44. uint32_t device_sn; // 设备编号
  45. uint8_t coll_no; // 采集器索引 从1开始
  46. }__attribute__((packed))taxComHead;
  47. /*心跳返回的数据0x56*/
  48. typedef struct _TAX_Encry_STATUS_{
  49. uint32_t device_sn; // 设备编号
  50. uint8_t coll_no; // 采集器索引 从1开始
  51. uint8_t factory; // 1:明文 2:密文
  52. }__attribute__((packed))taxEncryptStatus;
  53. /*固件信息返回0x58*/
  54. typedef struct _TAX_FIRM_MSG_{
  55. uint32_t device_sn; //设备SN
  56. uint8_t coll_no; // 采集器索引 从1开始
  57. uint32_t bootloaderVr; // bootloader版本事情
  58. uint32_t appVr; //APP版本号
  59. uint32_t resetNum; //复位次数
  60. uint8_t resetType; //最后一次复位类型
  61. uint32_t runTime; //运行时间
  62. uint8_t updateStatus; // 升级状态码
  63. uint8_t uuid[12]; //UUID
  64. char info[160]; //数据内容
  65. }__attribute__((packed))taxFirmMsg;
  66. typedef union TAX_DATA_INFO_{
  67. tax_query_info_t data; // 业务数据
  68. taxComHead comdata; //心跳 查询固件信息 设备重新启动信息
  69. taxFirmMsg firmMsg; //固件信息
  70. taxEncryptStatus taxEnStatus; // 心跳包的返回
  71. char info[160];
  72. }__attribute__((packed))taxDaInfo;
  73. /*网关向采集发送或是接收消息的结构体*/
  74. typedef struct _gateway_collect_com
  75. {
  76. uint16_t frame_header; //帧头
  77. uint8_t proto_ver; //协议版本 0x11
  78. uint32_t seq_no; //消息序列号
  79. uint8_t type; //一级消息类型
  80. uint16_t secondType; // 2级消息类型
  81. uint16_t len; //消息长度
  82. taxDaInfo taxinfo; //
  83. }__attribute__((packed)) gateway_collect_com_t;
  84. ///////////////////////////
  85. extern void gateway_net_send_gatewayMsg(void);
  86. #endif