YX ZHANG
/
iot_example
IoT demo
Fork of my_example_esp8266 by
esp8266.h@2:b10925c474fc, 2017-11-07 (annotated)
- Committer:
- zhangyx
- Date:
- Tue Nov 07 04:09:57 2017 +0000
- Revision:
- 2:b10925c474fc
- Parent:
- 1:3b487c4813a2
- Child:
- 3:06080fa094a0
changes for IoT node
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
brainliang | 0:63af4719467f | 1 | |
zhangyx | 1:3b487c4813a2 | 2 | #include "mbed.h" |
brainliang | 0:63af4719467f | 3 | |
brainliang | 0:63af4719467f | 4 | class Esp8266 { //声明一个类 |
zhangyx | 2:b10925c474fc | 5 | volatile bool network_start; |
zhangyx | 2:b10925c474fc | 6 | volatile bool mqtt_start; |
zhangyx | 2:b10925c474fc | 7 | // char esp_token[1024], esp_param[2048]; |
zhangyx | 2:b10925c474fc | 8 | char esp_tokenBuf[32], esp_paramBuf[32]; // 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(); |
zhangyx | 2:b10925c474fc | 14 | void gotResponse(char *token, char *param); |
brainliang | 0:63af4719467f | 15 | public: |
zhangyx | 1:3b487c4813a2 | 16 | Esp8266(PinName TX, PinName RX, const char *wifi_ssid, const char *wifi_passwd); |
brainliang | 0:63af4719467f | 17 | |
brainliang | 0:63af4719467f | 18 | // 通用 |
brainliang | 0:63af4719467f | 19 | bool reset(); |
brainliang | 0:63af4719467f | 20 | |
brainliang | 0:63af4719467f | 21 | // 连接模式 |
zhangyx | 1:3b487c4813a2 | 22 | bool connect_wifi(const char *wifi_ssid, const char *wifi_passwd); |
brainliang | 0:63af4719467f | 23 | bool weblogin(); |
brainliang | 0:63af4719467f | 24 | bool connect_mqtt_broker(char *ip); |
zhangyx | 2:b10925c474fc | 25 | bool is_connected(); |
brainliang | 0:63af4719467f | 26 | |
brainliang | 0:63af4719467f | 27 | bool publish(char *topic, char *data, int size = -1); |
brainliang | 0:63af4719467f | 28 | bool subscribe_poll(char *topic, char *data, int size = -1); |
brainliang | 0:63af4719467f | 29 | // 热点模式 |
brainliang | 0:63af4719467f | 30 | }; |