ML307A.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef __ML307A_H
  2. #define __ML307A_H
  3. #include "main.h"
  4. #include <stdbool.h> // bool
  5. //extern bool reset4Gmodule;
  6. //extern bool module4G_F;
  7. extern bool MgnssFlag;
  8. //extern bool resetBTmodule;
  9. void USART_SendString(UART_HandleTypeDef *huart,char *str);// 封装串口发送4G AT命令函数
  10. uint8_t sendCmd_4G(char *pCmd, char *pRes, uint32_t timeOut, uint8_t sendNum);// 发送4G串口命令
  11. uint8_t sendCmd_4G_2(char *pCmd, char *pRes1, char *pRes2, uint32_t timeOut, uint8_t sendNum);
  12. //uint8_t sendCmd_4G_2(char *pCmd, char **pRes, uint32_t timeOut, uint8_t sendNum);
  13. //uint8_t sendCmd_4G_3(char *pCmd, char **pRes, uint32_t timeOut, uint8_t sendNum, char **receivedRes);
  14. uint8_t sendCmd_4G_3(char *pCmd, char *pRes1, char *pRes2, uint32_t timeOut, uint8_t sendNum);
  15. void process_uart3_buffer(void);
  16. int wait_uart3_multi_response(const char* keywords[], int keyword_count, char* buffer, uint16_t buffer_len, uint32_t timeout_ms);
  17. void extract_and_parse_trdtc(const char* buffer);
  18. void process_MIPURC_data(uint8_t *buf, uint16_t len);
  19. void parse_JT808_frame(uint8_t *frame, uint16_t length);
  20. void parse_JT808_8103(uint8_t *payload, uint16_t length);
  21. int hexStringToBytes(const char *hexStr, uint8_t *outBytes, int maxLen);
  22. uint8_t mqttconn(char *IpAddr, uint16_t port, char *ID, char *User, char *Passwd, char* pRes);// 封装MQTT连接至MQTT服务器
  23. void MQTTCONN(void);// MQTT连接至MQTT服务器,订阅
  24. uint8_t MQTT_PUB(uint8_t connect_id, char *topic, char *mesg, char* pRes);// 发布消息QoS=0;
  25. void MQTTDISCONN(void);// 断开MQTT连接
  26. void tcpconn(char *value, uint8_t cid, char *IPaddr, uint16_t port, uint8_t tcpConnmode);// 建立TCP连接
  27. void TCPCONN(void);
  28. void GNSSLOC(void);
  29. void ML307A_INIT(void);
  30. void ML307A_Init(void);
  31. void ML307AReset(void);
  32. //*tt808
  33. #define JIALONGip "121.199.29.128"
  34. #define JIALONGport 7342 //测试平台
  35. //#define JLPTPORT 9021 //正式平台
  36. //#define JLPTIP "118.31.22.26"//徐工平台
  37. //#define JLPTPORT 8901
  38. #define MQTTADDR "127.0.0.1"
  39. #define MQTTPORT 1883
  40. #define MQTTUSER "0527"
  41. #define MQTTPSWD "05270527"
  42. //*订阅b
  43. //#define PCMQTTTOPIC_PREFIX "DCCtopic/#"
  44. #define Publish_Topic "DCCtopic/#"
  45. #define Subscribe_Topic "DCCtopic/b"
  46. #define MessageID_authentication 0x0102 //鉴权
  47. #define MessageID_heartbeat 0x0002 //心跳
  48. #define MessageID_location 0x0200 //地址
  49. #define MessageID_Retrans 0x0704 //地址补传
  50. #define MessageID_Getauth 0x0223 //权限获取
  51. #define TCPJMFSRSA 0x001
  52. #define TCPJMFSNULL 0x000
  53. #define TT808FLAG 0x7E
  54. #define TCPHeadBYTE 0x2A
  55. #define TCPTAILBYTE 0x23
  56. #define XXID_pttyyd 0x8001 //通用应答
  57. #define XXID_ptxxtc 0x8900 //下行透传
  58. #define XXID_zdtyyd 0x0001 //终端通用应答
  59. void Send_AT_Command(char *command) ;
  60. void Receive_Response(char *buffer, uint16_t size);
  61. int Check_Response(char *buffer, uint16_t size);
  62. int Send_Command_Check_Response(char *command, char *response_buffer, uint16_t buffer_size) ;
  63. void MQTT_Process(void);
  64. bool checkForMATREADY(void);
  65. void ML307A_MQTT_Init(void);
  66. void ML307A_NET_Init(void);
  67. void check_network_connection(void);
  68. #endif /*__ML307A_H*/