proc.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef __PROC_H__
  2. #define __PROC_H__
  3. #include "stm32f10x.h"
  4. #include "gw_ctrl.h"
  5. #define FIRST_SYSTEM_TYPE 0x01 //系统类
  6. #define SECOND_SYSTEM_TRANS_DOWN 0x1052 //透传下行
  7. #define SECOND_SYSTEM_TRANS_UP 0x2052 //透传上行
  8. #define SECOND_SYSTEM_PROT_DOWN 0x1007 //版本问询下行
  9. #define SECOND_SYSTEM_PROT_UP 0x2007 //版本问询上行
  10. //3.0协议 透传指令下行
  11. typedef struct _transparent_down_3_t
  12. {
  13. uint16_t first_type; //一级设备类型
  14. uint32_t first_sn; //一级设备SN
  15. uint16_t des_type; //目标设备类型
  16. uint32_t des_sn; //目标设备SN
  17. uint8_t tax_no; //报税口号 从1开始, 从7开始显示屏的透传
  18. uint16_t data_len; //数据长度
  19. uint8_t data[BUSINESS_DATA_LEN]; //数据
  20. }__attribute__((packed)) transparent_down_3_t;
  21. //3.0协议 透传指令上行
  22. typedef struct _transparent_up_3_t
  23. {
  24. uint16_t first_type; //一级设备类型
  25. uint32_t first_sn; //一级设备SN
  26. uint16_t des_type; //目标设备类型
  27. uint32_t des_sn; //目标设备SN
  28. uint8_t tax_no; //报税口号 从1开始, 从7开始显示屏的透传
  29. uint8_t status; //状态(1:成功 ;2:读取数据超时;3:明文密文状态错误;4:报税口号或枪号错误;5:编码器指令错误;6:报税口正在加油)
  30. uint16_t data_len; //数据长度
  31. uint8_t data[BUSINESS_DATA_LEN]; //数据
  32. }__attribute__((packed)) transparent_up_3_t;
  33. //协议版本问询下行
  34. typedef struct _prot_check_down
  35. {
  36. uint16_t first_type; //一级设备类型
  37. uint32_t first_sn; //一级设备SN
  38. uint16_t rcv_type; //接收设备类型
  39. uint32_t rcv_sn; //接收设备sn
  40. uint16_t des_type; //目标设备类型
  41. uint32_t des_sn; //目标设备SN
  42. uint32_t reserve; //预留
  43. }__attribute__((packed)) prot_check_down_t;
  44. //协议版本问询上行
  45. typedef struct _prot_check_up
  46. {
  47. uint16_t first_type; //一级设备类型
  48. uint32_t first_sn; //一级设备SN
  49. uint16_t des_type; //目标设备类型
  50. uint32_t des_sn; //目标设备SN
  51. uint32_t reserve; //预留
  52. uint8_t prover; //协议版本
  53. }__attribute__((packed)) prot_check_up_t;
  54. #define TRANSP_DOWN_HEADER_LEN sizeof(transparent_down_3_t)-BUSINESS_DATA_LEN
  55. #define TRANSP_UP_HEADER_LEN sizeof(transparent_up_3_t)-BUSINESS_DATA_LEN
  56. #define PROT_DOWN_HEADER_LEN sizeof(prot_check_down_t)
  57. #define PROT_UP_HEADER_LEN sizeof(prot_check_up_t)
  58. //接收信息存储
  59. typedef struct _msg_rcv_info
  60. {
  61. uint16_t frame_header; //帧头
  62. uint8_t proto_Ver; //版本号
  63. uint32_t msg_id; //消息序列号
  64. uint8_t first_type; //一级消息类型
  65. uint16_t second_type; //二级消息类型
  66. uint16_t msg_len; //消息长度
  67. uint16_t first_device_type; //一级设备类型
  68. uint32_t first_device_sn; //一级设备SN
  69. uint16_t rcv_type; //接收设备类型
  70. uint32_t rcv_sn; //接收设备sn
  71. uint16_t des_type; //目标设备类型
  72. uint32_t des_sn; //目标设备SN
  73. uint8_t tax_no; //报税口号
  74. uint8_t gun_no; //枪号
  75. uint8_t uart; //串口号
  76. }__attribute__((packed)) msg_rcv_info_t;
  77. extern msg_rcv_info_t msg_rcv_info;
  78. void msg_rcv_info_init(void);
  79. void transparent_up_ver3_return(uint8_t state, uint8_t *data, uint16_t len);
  80. void coll_rcv_lora_ver3_handle(uint8_t *data, uint16_t len);
  81. void coll_rcv_lora_verff_handle(uint8_t *data, uint16_t len);
  82. #endif