k j
/
smart_drawer
sads
Fork of smart_drawer by
esp8266.h@1:4ffc39e81583, 2018-07-23 (annotated)
- Committer:
- plao
- Date:
- Mon Jul 23 06:22:33 2018 +0000
- Revision:
- 1:4ffc39e81583
dfs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
plao | 1:4ffc39e81583 | 1 | |
plao | 1:4ffc39e81583 | 2 | #include "mbed.h" |
plao | 1:4ffc39e81583 | 3 | |
plao | 1:4ffc39e81583 | 4 | class Esp8266 { //声明一个类 |
plao | 1:4ffc39e81583 | 5 | volatile bool network_start; |
plao | 1:4ffc39e81583 | 6 | volatile bool mqtt_start; |
plao | 1:4ffc39e81583 | 7 | volatile bool control_cmd; |
plao | 1:4ffc39e81583 | 8 | char esp_tokenBuf[32], esp_paramBuf[32]; // recv from esp8266 |
plao | 1:4ffc39e81583 | 9 | char control_buf[32]; |
plao | 1:4ffc39e81583 | 10 | bool esp_buf_ready; |
plao | 1:4ffc39e81583 | 11 | Serial ser2esp8266; |
plao | 1:4ffc39e81583 | 12 | |
plao | 1:4ffc39e81583 | 13 | protected: |
plao | 1:4ffc39e81583 | 14 | void esp8266_rxCallback(); |
plao | 1:4ffc39e81583 | 15 | void gotResponse(char *token, char *param); |
plao | 1:4ffc39e81583 | 16 | void buildCapability(char *out, const char* infoList[][2]); |
plao | 1:4ffc39e81583 | 17 | public: |
plao | 1:4ffc39e81583 | 18 | Esp8266(PinName TX, PinName RX, const char *wifi_ssid, const char *wifi_passwd); |
plao | 1:4ffc39e81583 | 19 | |
plao | 1:4ffc39e81583 | 20 | // 通用 |
plao | 1:4ffc39e81583 | 21 | bool reset(); |
plao | 1:4ffc39e81583 | 22 | |
plao | 1:4ffc39e81583 | 23 | // 连接模式 |
plao | 1:4ffc39e81583 | 24 | bool connect_wifi(const char *wifi_ssid, const char *wifi_passwd); |
plao | 1:4ffc39e81583 | 25 | bool weblogin(); |
plao | 1:4ffc39e81583 | 26 | bool connect_mqtt_broker(char *ip, const char *node_name, const char* sensors[][2], const char* actuator[][2]); |
plao | 1:4ffc39e81583 | 27 | bool is_connected(); |
plao | 1:4ffc39e81583 | 28 | |
plao | 1:4ffc39e81583 | 29 | bool publish_value(const char *topic, const char *data); |
plao | 1:4ffc39e81583 | 30 | bool subscribe_control(const char *topic, const char *data = NULL); |
plao | 1:4ffc39e81583 | 31 | bool is_control_available(void) { return control_cmd; } |
plao | 1:4ffc39e81583 | 32 | bool get_control_cmd(char* actuator, char* value); |
plao | 1:4ffc39e81583 | 33 | // 热点模式 |
plao | 1:4ffc39e81583 | 34 | }; |