ec800m.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef _EC800M_H
  2. #define _EC800M_H
  3. #include "gd32f10x.h"
  4. #include "device_message.h"
  5. #define AT(cmd) "AT+"##cmd
  6. #define RSP_READY "RDY"
  7. #define RSP_OK "OK"
  8. #define RSP_CONNECT "CONNECT"
  9. #define CLIENTID "device_test"
  10. #define CMD_SET_PDP "AT+QICSGP=1,1,\"CTNET\",\"\",\"\",1\r\n" // UNINET?? CMNET?? CTNET??
  11. #define CMD_SET_ACTIVE "AT+QIACT=1\r\n"
  12. #define CMD_SET_URL "AT+QHTTPURL=%d\r\n"
  13. #define CMD_GET "AT+QHTTPGET=100\r\n"
  14. #define CMD_GET_TO_FILE "AT+QHTTPREADFILE=\"UFS:http.txt\",80\r\n"
  15. #define CMD_HTTP_GET "QHTTPGET:"
  16. #define CMD_READ_FILE "AT+QFDWL=http.txt\r\n"
  17. #define OPEN_otaMSG_FILE "AT+QFOPEN=\"otaMSG.txt\",1\r\n"
  18. #define WRITE_otaMSG_FILE "AT+QFWRITE=1,1024,3\r\n"
  19. #define CLOSE_otaMSG_FILE "AT+QFCLOSE=1\r\n"
  20. #define LOAD_otaMSG_FILE "AT+QFDWL=otaMSG.txt\r\n"
  21. #define DEL_otaMSG_FILE "AT+QFDEL=otaMSG.txt\r\n"
  22. #define OPEN_otaDATA_FILE "AT+QFOPEN=\"otaDATA.txt\",1\r\n"
  23. #define WRITE_otaDATA_FILE "AT+QFWRITE=1,128,2\r\n"
  24. #define CLOSE_otaDATA_FILE "AT+QFCLOSE=1\r\n"
  25. #define LOAD_otaDATA_FILE "AT+QFDWL=otaDATA.txt\r\n"
  26. #define DEL_otaDATA_FILE "AT+QFDEL=otaDATA.txt\r\n"
  27. #define ATI "ATI"
  28. #define CMD_MQTT_DISCONNECT "AT+QMTDISC=0\r\n"
  29. // ??MQTT??3.1.1 ??????--4(mqtt 3.1.1 )3(mqtt 3.1)
  30. #define CMD_MQTT_VERSION "AT+QMTCFG=\"version\",0,4\r\n"
  31. #define CMD_MQTT_KEEPALIVE "AT+QMTCFG=\"qmtping\",0,30\r\n" // 30????
  32. #define CMD_MQTT_OPENET "AT+QMTOPEN=0,\"36.134.23.11\",1883\r\n"
  33. // #define CMD_MQTT_CONNECT "AT+QMTCONN=0,\"%s\",\"%s\",\"%s\"\r\n"// ?????clientid,username,password
  34. #define CMD_MQTT_CONNECT "AT+QMTCONN=0,\"device_test\",\"\",\"\"\r\n"
  35. #define CMD_MQTT_RECEIVE "AT+QMTCFG=\"recv/mode\",0,0,1\r\n"
  36. #define CMD_MQTT_SEND "AT+QMTCFG=\"send/mode\",0,0,1\r\n"
  37. // ???? ???????--??????--
  38. #define CMD_MQTT_SUBSCRIBE "AT+QMTSUB=0,1,\"%s\",0\r\n" // ????????
  39. #define CMD_SERVICE_Operatortyp "AT+COPS?\r\n"
  40. #define CMD_SERVICE_Networktyp "AT+CREG?\r\n"//7
  41. #define CMD_SERVICE_Networkstatu "AT+COPS?\r\n"
  42. #define CMD_SERVICE_SIMcardstatus "AT+CLCK=\"SC\",2\r\n"
  43. #define CMD_SERVICE_SIMcardICCID "AT+QCCID\r\n"
  44. #define CMD_SERVICE_IMEInumber "AT+GSN\r\n"
  45. #define CMD_SERVICE_Signalstrength "AT+CSQ\r\n"
  46. #define AT_CMD_HEAD "AT"
  47. #define AT_CMD_CFG "+QMTCFG="
  48. #define AT_CMD_TEST "?"
  49. #define AT_CMD_VER "version"
  50. //#define AT_CMD_T "AT+QMTCFG=?\r\n"
  51. #define AT_CMD_T "ATI\r\n"
  52. #define true 1
  53. #define false 0
  54. void EC800MPwoerOn(void);
  55. void EC800MSendCmd(char *buf, uint16_t len);
  56. void EC800MWaitReady(void);
  57. bool WaitResponse(char * expectStr, int timeout);
  58. void ConnectMQTTSever(uint8_t *host,uint16_t port,uint8_t keepalive,uint8_t *clientid);
  59. void EC800MSetPDP(void);
  60. bool EC800MGetUrl(char *url,char *dmaBuffer,uint32_t bufferSize);
  61. void MQTTPublish(void);
  62. void MQTTSubTopic(uint8_t *commandTopic);
  63. void ec800m_information_service(GATEWAY_PARAMS *gateway);
  64. #endif