downlink.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #ifndef __DOWNLINK_H__
  2. #define __DOWNLINK_H__
  3. #include "stm32f10x.h"
  4. #include "../network_mgr/net_proc.h"
  5. #define COLLECT_MAX_NUM 16
  6. #define TAX_MAX_NUM 2
  7. #define GUN_MAX_NUM 8
  8. #define DOWNLINK_CONFIG_TYPE 0x10 //0x65
  9. #define CONFIG_ADDR 0X100
  10. #define CONFIG_WRITE 0x01
  11. //typedef struct _tax_conf
  12. //{
  13. // uint8_t tax_id; //报税口编号
  14. // uint8_t gun_num; //加油枪数量
  15. // uint8_t gunid[GUN_MAX_NUM]; //加油枪编号
  16. // uint8_t alrd_sn; //是否查询过加油机的信息
  17. // uint8_t factory; /*厂家 1:英泰 2:拓盛 */
  18. // uint8_t status; // 报税口的状态 ,是否连接
  19. // uint8_t encryption; // 报税口的加密状态 ,由服务器下发的,暂停没有用于
  20. // uint8_t monitor_serino[16]; //序列号
  21. //}__attribute__((packed)) tax_conf_t;
  22. //
  23. //typedef struct _collect_conf
  24. //{
  25. // uint32_t collect_no; //采集器编号
  26. // uint8_t tax_num; //报税口数量
  27. // uint8_t tax_type; //报税口类型,明文或密文
  28. // uint8_t collect_status; // 采集器的状态 在线或是离线 0 离线 1:在线
  29. // uint8_t coll_send_num; // 采集器发送的次数
  30. // tax_conf_t tax_conf[TAX_MAX_NUM];
  31. //}__attribute__((packed)) collect_conf_t;
  32. typedef struct _downlink_config
  33. {
  34. uint8_t config_flag; //采集器配置标记
  35. uint32_t gateway_id; //网关id
  36. // uint8_t collect_num; //采集器数量
  37. // collect_conf_t collect_conf[COLLECT_MAX_NUM];
  38. }__attribute__((packed)) downlink_config_t;
  39. extern downlink_config_t downlink_config;
  40. /*==============================================================*/
  41. /* 以下是服务器下发 需要用到的解析*/
  42. /* 升级信息下行 0x1001 */
  43. typedef struct _downlink_system_cmd_0x1001 {
  44. uint16_t targetType; // 设备类型(0x0101:网关;0x0201;采集器:0x0301:液位仪采集器;0x0401:屏采集器)
  45. uint32_t sn; // sn 编号
  46. uint16_t taskNo; // 任务号
  47. uint8_t urlLen; // URL长度
  48. char url[128]; // url地址
  49. }__attribute__((packed)) downlinkSysCmd0x1001;
  50. /* 切换mqtt IP地址 0x1003 */
  51. typedef struct _downlink_system_cmd_0x1003 {
  52. uint32_t gateway_sn; // 网关SN
  53. uint16_t targettype; // 类型 0x0101网关 0x0201:采集器 0x0301:液位仪
  54. uint8_t iplen; // ip地址长度
  55. uint8_t portlen; // 端口长度
  56. uint8_t userlen; // 用户名长度
  57. uint8_t pwdlen; // 密码长度
  58. // char port[6]; // 端口号
  59. // char ip[32]; //IP地址
  60. // char admin[8]; // 用户名
  61. // char password[16]; // 密码
  62. uint8_t str[76];
  63. }__attribute__((packed)) downlinkSysCmd0x1003;
  64. /* 采集器路由信息初始化 0x1011 */
  65. typedef struct _configmsg_{
  66. uint32_t collectSn;
  67. uint8_t comEncrypt[2]; //报税口的加密状态
  68. }__attribute__((packed)) configMsg;
  69. typedef struct _downlink_system_cmd_0x1011 {
  70. uint32_t gateway_id; //网关SN
  71. uint8_t collect_num; //采集器数量
  72. configMsg cfigMsg[16];
  73. }__attribute__((packed)) downlinkSysCmd0x1011;
  74. /* 刷新税控序列号 0x1012*/
  75. typedef struct _downlink_system_cmd_0x1012_{
  76. uint32_t gateway_sn; // 网关SN
  77. uint32_t coll_sn; // 采集器编号
  78. uint8_t tax_no; // 报税口编号
  79. }__attribute__((packed)) downlinkSysCmd0x1012;
  80. /* 设备重新启动 0x1021*/
  81. typedef struct _downlink_system_cmd_0x1021_{
  82. uint16_t targetType; // 设备类型(0x0101:网关;0x0201;采集器:0x0301:液位仪采集器;0x0401:屏采集器)
  83. uint32_t sn; // 设备sn号
  84. }__attribute__((packed)) downlinkSysCmd0x1021;
  85. /* 状态信息 固件信息下行 0x1001*/
  86. typedef struct _downlink_status_cmd_0x1001_{
  87. uint32_t gateway_sn; // 网关ID
  88. uint16_t targetType; // 设备类型(0x0101:网关;0x0201;采集器:0x0301:液位仪采集器;0x0401:屏采集器)
  89. uint32_t sn; // 设备编号
  90. }__attribute__((packed)) downlinkStatusCmd0x1001;
  91. typedef struct _downlink_data_oil_cmd_0x1021_{
  92. uint32_t gateway_sn; // 网关编号
  93. }__attribute__((packed)) downlinkDataOilCmd0x1021;
  94. typedef struct _downlink_sys_oil_cmd_0x1031_{
  95. uint32_t gateway_sn; // 网关编号
  96. uint16_t paraLen; // 参数长度
  97. char param[48]; // 参数
  98. }__attribute__((packed)) downlinkSysOilCmd0x1031;
  99. void downlink_init(void);
  100. int downlink_gateway_analyze(uint8_t *data, uint16_t len);
  101. #endif