IoT demo

Dependencies:   mbed

Fork of my_example_esp8266 by liang brain

Committer:
zhangyx
Date:
Tue Nov 07 03:15:44 2017 +0000
Revision:
1:3b487c4813a2
Parent:
0:63af4719467f
Child:
2:b10925c474fc
new class interface

Who changed what in which revision?

UserRevisionLine numberNew contents of line
brainliang 0:63af4719467f 1
zhangyx 1:3b487c4813a2 2 #include "mbed.h"
brainliang 0:63af4719467f 3
brainliang 0:63af4719467f 4 class Esp8266 { //声明一个类
brainliang 0:63af4719467f 5 bool network_start;
brainliang 0:63af4719467f 6 bool mqtt_start;
zhangyx 1:3b487c4813a2 7 char esp_token[1024], esp_param[2048];
zhangyx 1:3b487c4813a2 8 char esp_tokenBuf[1024], esp_paramBuf[2048]; // recv from esp8266
zhangyx 1:3b487c4813a2 9 bool esp_buf_ready;
zhangyx 1:3b487c4813a2 10 Serial ser2esp8266;
zhangyx 1:3b487c4813a2 11
zhangyx 1:3b487c4813a2 12 protected:
zhangyx 1:3b487c4813a2 13 void esp8266_rxCallback();
brainliang 0:63af4719467f 14 public:
zhangyx 1:3b487c4813a2 15 Esp8266(PinName TX, PinName RX, const char *wifi_ssid, const char *wifi_passwd);
brainliang 0:63af4719467f 16
brainliang 0:63af4719467f 17 // 通用
brainliang 0:63af4719467f 18 bool reset();
brainliang 0:63af4719467f 19
brainliang 0:63af4719467f 20 // 连接模式
zhangyx 1:3b487c4813a2 21 bool connect_wifi(const char *wifi_ssid, const char *wifi_passwd);
brainliang 0:63af4719467f 22 bool weblogin();
brainliang 0:63af4719467f 23 bool connect_mqtt_broker(char *ip);
brainliang 0:63af4719467f 24
brainliang 0:63af4719467f 25 bool publish(char *topic, char *data, int size = -1);
brainliang 0:63af4719467f 26 bool subscribe_poll(char *topic, char *data, int size = -1);
brainliang 0:63af4719467f 27 // 热点模式
brainliang 0:63af4719467f 28 };