init

Dependencies:   mbed

Fork of iot_example by YX ZHANG

Revision:
2:b10925c474fc
Parent:
1:3b487c4813a2
Child:
3:06080fa094a0
--- a/esp8266.h	Tue Nov 07 03:15:44 2017 +0000
+++ b/esp8266.h	Tue Nov 07 04:09:57 2017 +0000
@@ -2,15 +2,16 @@
 #include "mbed.h"
 
 class Esp8266 {                                                                 //声明一个类
-    bool network_start;
-    bool mqtt_start;
-    char esp_token[1024], esp_param[2048];
-    char esp_tokenBuf[1024], esp_paramBuf[2048];   // recv from esp8266
+    volatile bool network_start;
+    volatile bool mqtt_start;
+//    char esp_token[1024], esp_param[2048];
+    char esp_tokenBuf[32], esp_paramBuf[32];   // recv from esp8266
     bool esp_buf_ready;
     Serial ser2esp8266;
     
 protected:
     void esp8266_rxCallback();
+    void gotResponse(char *token, char *param);
 public:
     Esp8266(PinName TX, PinName RX, const char *wifi_ssid, const char *wifi_passwd);
     
@@ -21,6 +22,7 @@
     bool connect_wifi(const char *wifi_ssid, const char *wifi_passwd);
     bool weblogin();
     bool connect_mqtt_broker(char *ip);
+    bool is_connected();
     
     bool publish(char *topic, char *data, int size = -1);
     bool subscribe_poll(char *topic, char *data, int size = -1);