小车 走

Dependencies:   mbed

Committer:
xmwmx
Date:
Sat Aug 04 04:17:02 2018 +0000
Revision:
2:4a9ba34cd90a
Parent:
1:d89a943c462e
?????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
xmwmx 1:d89a943c462e 1 #ifndef ESP8266_H
xmwmx 1:d89a943c462e 2 #define ESP8266_H
xmwmx 0:5d8b03e224fd 3 #include "mbed.h"
xmwmx 0:5d8b03e224fd 4
xmwmx 0:5d8b03e224fd 5 class Esp8266 { //声明一个类
xmwmx 0:5d8b03e224fd 6 volatile bool network_start;
xmwmx 0:5d8b03e224fd 7 volatile bool mqtt_start;
xmwmx 0:5d8b03e224fd 8 volatile bool control_cmd;
xmwmx 0:5d8b03e224fd 9 char esp_tokenBuf[32], esp_paramBuf[32]; // recv from esp8266
xmwmx 0:5d8b03e224fd 10 char control_buf[32];
xmwmx 0:5d8b03e224fd 11 bool esp_buf_ready;
xmwmx 0:5d8b03e224fd 12 Serial ser2esp8266;
xmwmx 0:5d8b03e224fd 13
xmwmx 0:5d8b03e224fd 14 protected:
xmwmx 0:5d8b03e224fd 15 void esp8266_rxCallback();
xmwmx 0:5d8b03e224fd 16 void gotResponse(char *token, char *param);
xmwmx 0:5d8b03e224fd 17 void buildCapability(char *out, const char* infoList[][2]);
xmwmx 0:5d8b03e224fd 18 public:
xmwmx 0:5d8b03e224fd 19 Esp8266(PinName TX, PinName RX, const char *wifi_ssid, const char *wifi_passwd);
xmwmx 0:5d8b03e224fd 20
xmwmx 0:5d8b03e224fd 21 // 通用
xmwmx 0:5d8b03e224fd 22 bool reset();
xmwmx 0:5d8b03e224fd 23
xmwmx 0:5d8b03e224fd 24 // 连接模式
xmwmx 0:5d8b03e224fd 25 bool connect_wifi(const char *wifi_ssid, const char *wifi_passwd);
xmwmx 0:5d8b03e224fd 26 bool weblogin();
xmwmx 0:5d8b03e224fd 27 bool connect_mqtt_broker(char *ip, const char *node_name, const char* sensors[][2], const char* actuator[][2]);
xmwmx 0:5d8b03e224fd 28 bool is_connected();
xmwmx 0:5d8b03e224fd 29
xmwmx 0:5d8b03e224fd 30 bool publish_value(const char *topic, const char *data);
xmwmx 0:5d8b03e224fd 31 bool subscribe_control(const char *topic, const char *data = NULL);
xmwmx 0:5d8b03e224fd 32 bool is_control_available(void) { return control_cmd; }
xmwmx 0:5d8b03e224fd 33 bool get_control_cmd(char* actuator, char* value);
xmwmx 0:5d8b03e224fd 34 // 热点模式
xmwmx 0:5d8b03e224fd 35 };
xmwmx 1:d89a943c462e 36 #endif