![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Kuo Yiching
Fork of iot_example by
Diff: esp8266.h
- Revision:
- 3:06080fa094a0
- Parent:
- 2:b10925c474fc
diff -r b10925c474fc -r 06080fa094a0 esp8266.h --- a/esp8266.h Tue Nov 07 04:09:57 2017 +0000 +++ b/esp8266.h Mon Nov 13 20:25:48 2017 +0800 @@ -4,14 +4,16 @@ class Esp8266 { //声明一个类 volatile bool network_start; volatile bool mqtt_start; -// char esp_token[1024], esp_param[2048]; + volatile bool control_cmd; char esp_tokenBuf[32], esp_paramBuf[32]; // recv from esp8266 + char control_buf[32]; bool esp_buf_ready; Serial ser2esp8266; protected: void esp8266_rxCallback(); void gotResponse(char *token, char *param); + void buildCapability(char *out, const char* infoList[][2]); public: Esp8266(PinName TX, PinName RX, const char *wifi_ssid, const char *wifi_passwd); @@ -21,10 +23,12 @@ // 连接模式 bool connect_wifi(const char *wifi_ssid, const char *wifi_passwd); bool weblogin(); - bool connect_mqtt_broker(char *ip); + bool connect_mqtt_broker(char *ip, const char* sensors[][2], const char* actuator[][2]); bool is_connected(); - bool publish(char *topic, char *data, int size = -1); - bool subscribe_poll(char *topic, char *data, int size = -1); + bool publish_value(const char *topic, const char *data); + bool subscribe_control(const char *topic, const char *data = NULL); + bool is_control_available(void) { return control_cmd; } + bool get_control_cmd(char* actuator, char* value); // 热点模式 }; \ No newline at end of file