wifi9113.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #ifndef _WIFI9113_H_
  2. #define _WIFI9113_H_
  3. #include "main.h"
  4. #define WiFi0824 0
  5. #define RS9113 0
  6. #define RS9110 1
  7. #define ESP8266 2
  8. #define WIFI_AS_SERVER 0
  9. #define WIFI_AS_CLIENT 1
  10. //#define CONNECT_Multiple_DEF //多路连接
  11. #define WIFIroute WiFi0824
  12. #define WIFImodule ESP8266
  13. #if(WIFIroute==WiFi0824)
  14. #define RouteName "WiFi0824-02"
  15. #define RoutePSk "1234567890"
  16. #endif
  17. #define AT_REPLY_OK ("OK")
  18. #define AT_REPLY_ERROR ("ERROR")
  19. #define AT_REPLY_NO_CHANGE ("no change")
  20. //启动
  21. #if(WIFImodule == ESP8266)
  22. #define CHECK_REPLY_Ready ("ready")//("System Ready")
  23. #endif
  24. #if(WIFIroute==WiFi0824)
  25. #define SERVER_IP_ADDRESS_DEFAULT "\"server0824.nat123.net\",7512"
  26. #endif
  27. //连接
  28. #if(WIFImodule == ESP8266)
  29. #define CONNECT_DOGOFF ("AT+CSYSWDTDISABLE")
  30. #define CONNECT_DOGON ("AT+CSYSWDTENABLE")
  31. #define CONNECT_RESET ("AT+RST\r\n")
  32. #define CONNECT_CWMODE ("AT+CWMODE=3\r\n")
  33. #define CONNECT_CWLAP ("AT+CWLAP\r\n")
  34. #define CONNECT_CWJAP ("AT+CWJAP=\""##RouteName##"\",\""##RoutePSk##"\"\r\n")
  35. #define CONNECT_CWJAP_CX ("AT+CWJAP?\r\n")
  36. #define CONNECT_CWJAP_CX_REPLY ("+CWJAP:\""##RouteName##"\"")
  37. #ifndef CONNECT_Multiple_DEF
  38. #define CONNECT_CIPMUX ("AT+CIPMUX=0\r\n")//0.单路连接
  39. #define CONNECT_CIPSTART ("AT+CIPSTART=\"TCP\","##SERVER_IP_ADDRESS_DEFAULT##"\r\n")
  40. #define CONNECT_CIPSEND ("AT+CIPSEND=15\r\n")
  41. #define CONNECT_CIPSEND_N ("AT+CIPSEND=")
  42. #else
  43. #define CONNECT_CIPMUX ("AT+CIPMUX=1\r\n")//1.0-4路连接
  44. #define CONNECT_CIPSTART ("AT+CIPSTART=4,\"TCP\","##SERVER_IP_ADDRESS_DEFAULT##"\r\n")
  45. #define CONNECT_CIPSEND ("AT+CIPSEND=4,15\r\n")
  46. #define CONNECT_CIPSEND_N ("AT+CIPSEND=4")
  47. #endif
  48. #define CONNECT_CIPSTART_Welcome ("Welcome to the server")
  49. #define CONNECT_CIPSTART_Port ("Port:7512")
  50. #define CONNECT_CIPSTART_NOWis ("Now is:")
  51. #define CONNECT_CIFSR ("AT+CIFSR\r\n")
  52. #define CONNECT_APIP ("+CIFSR:APIP,\"")
  53. #define CONNECT_APMAC ("+CIFSR:APMAC,\"")
  54. #define CONNECT_STAIP ("+CIFSR:STAIP,\"")
  55. #define CONNECT_STAMAC ("+CIFSR:STAMAC,\"")
  56. #define CONNECT_CIPCLOSE ("AT+ CIPCLOSE=4\r\n")
  57. #define CONNECT_SEND_EG ("I Can Hear You!\r\n")
  58. #endif
  59. //通讯
  60. #if(WIFImodule == ESP8266)
  61. #define AT_COMMAND_READ ("+IPD")
  62. #define AT_COMMAND_LTCP_CONNECT ("AT+RSI_LTCP_CONNECT")
  63. #define AT_COMMAND_CLOSE ("CLOSED")
  64. #define AT_COMMAND_LINK_ERROR ("link is not valid")
  65. #define AT_COMMAND_REGID_ERROR ("ERROR:Don't find your ID!")
  66. #define CONNECT_REPLY_CONNECT ("CONNECT")
  67. #define CONNECT_REPLY_ALREAY_CONNECT ("ALREADY CONNECTED")
  68. #define CHAT_REPLY4
  69. #endif
  70. //#define USB_AT_COMMAND_MAC "at+rsi_mac?\r\n"
  71. //#define USB_AT_COMMAND_MAC_LENGTH 13
  72. #define AT_COMMAND_FWVERSION "at+rsi_fwversion?"
  73. #define AT_COMMAND_FWVERSION_LENGTH 17
  74. #define AT_KRAIN_SERVER_IP "KRAIN_SERVER_IP="
  75. #if(WIFImodule == ESP8266)
  76. #define AT_COMMAND_SND_CMD "AT+CIPSEND=4,15\r\n"
  77. #define AT_COMMAND_SND_CMD_LENGTH 16
  78. #endif
  79. enum wifi_led_flag_
  80. {
  81. WIFI_CLOSE_FLAG,
  82. WIFI_JOIN_ROUTE_OK_FLAG,
  83. WIFI_LOAD_DONE_FLAG,
  84. WIFI_LTCP_CONNECT_FLAG,
  85. WIFI_DATA_COME_FLAG,
  86. WIFI_DATA_GO_FLAG,
  87. WIFI_MAX_FLAG
  88. };
  89. enum wifi_step_
  90. {
  91. WIFI_STEP_CHECK,
  92. WIFI_STEP_CONNECT,
  93. WIFI_STEP_CHAT,
  94. WIFI_STEP_MAX
  95. };
  96. #define COMMD_DATA_RETURN 0x00
  97. #define COMMD_CONSOLE 0x01
  98. #define COMMD_REG 0x02
  99. #define COMMD_TRANSMIT 0x03
  100. #define COMMD_AUTHORIZE 0x04
  101. extern char bAtSentBuff[255];
  102. extern char DoByteBuffer[255];
  103. extern char bAtRecBuff[255];
  104. extern unsigned char TxCounterWifi;
  105. extern unsigned char RxCounterWifi;
  106. extern unsigned char WifiDataToXmt;
  107. extern unsigned char Mac_Addr[];
  108. extern unsigned char Mac_Temp_Buff[];
  109. extern unsigned char Wifi_Rec_Buff[];
  110. extern unsigned char WifiProcessStep;
  111. extern unsigned char WifiCheckStep;
  112. extern unsigned char WifiConnectStep;
  113. extern unsigned char WifiConnectNext;
  114. extern unsigned long WifiTimeReset;// Rec9113_time=0;
  115. extern unsigned long WifiTimeLed;// Rec9113_time=0;
  116. extern unsigned char start;
  117. extern unsigned char TOTAL_MAC_LENGTH;
  118. extern bool WifiHaveRecFlag;
  119. extern unsigned char WifiDatCome;
  120. extern unsigned char TotalRecvBytes;//REC NUMBER
  121. extern unsigned char SERVER_IP_ADDRESS[];
  122. extern unsigned char WIFI_LED_FLAG;
  123. extern bool if_sent_data;
  124. extern char sent_data_buf[255];
  125. extern void AtSent ( char *SendBuff, unsigned int BuffCount );
  126. extern void wifi_connect ( void );
  127. extern void wifi_main ( void );
  128. extern void AT_command_send ( char *str, int handle, unsigned char n );
  129. extern char *FindStrPos ( char *socStr, u8 socSize, char *findStr, u8 findSize );
  130. extern char *FindATcommd ( char *findStr );
  131. extern void reg_server0824 ( u8 regID, u8 *inBuffer, u8 inSize );
  132. extern void sendto_server0824 ( u8 aimID, u8 myID, u8 *inBuffer, u8 inSize );
  133. extern void Refresh_DS1302_Time ( char data[] );
  134. #endif