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