From 2ab0b674586ab7d071b09bd6fa278dd68539d691 Mon Sep 17 00:00:00 2001 From: i3water <121024123@qq.com> Date: Wed, 13 Jun 2018 01:41:16 +0800 Subject: [PATCH 1/2] update codes, fix bug. --- src/BlinkerSimpleESP32_MQTT.h | 12 +++++------ src/BlinkerSimpleESP32_WS.h | 18 ++++++++--------- src/BlinkerSimpleESP8266_MQTT.h | 35 +++++++++++++++++---------------- src/BlinkerSimpleESP8266_WS.h | 22 ++++++++++----------- 4 files changed, 44 insertions(+), 43 deletions(-) diff --git a/src/BlinkerSimpleESP32_MQTT.h b/src/BlinkerSimpleESP32_MQTT.h index df1788a3..620fbb13 100644 --- a/src/BlinkerSimpleESP32_MQTT.h +++ b/src/BlinkerSimpleESP32_MQTT.h @@ -14,21 +14,21 @@ class BlinkerSimpleESP32_MQTT {} #if defined(BLINKER_ESP_SMARTCONFIG) - void begin(const char* auth) { + void begin(const char* _auth) { Base::begin(); smartconfig(); - this->conn.begin(auth); + this->conn.begin(_auth); BLINKER_LOG1("ESP32_MQTT Initialled..."); } #endif - void begin( const char* auth, + void begin( const char* _auth, const char* ssid, const char* pswd) { Base::begin(); connectWiFi(ssid, pswd); - this->conn.begin(auth); + this->conn.begin(_auth); BLINKER_LOG1("ESP32_MQTT Initialled..."); } @@ -40,14 +40,14 @@ class BlinkerSimpleESP32_MQTT BLINKER_LOG1("Waiting for SmartConfig."); while (!WiFi.smartConfigDone()) { - delay(500); + ::delay(500); } BLINKER_LOG1("SmartConfig received."); BLINKER_LOG1("Waiting for WiFi"); while (WiFi.status() != WL_CONNECTED) { - delay(500); + ::delay(500); } BLINKER_LOG1("WiFi Connected."); diff --git a/src/BlinkerSimpleESP32_WS.h b/src/BlinkerSimpleESP32_WS.h index 187c9aa1..39d5c5a6 100644 --- a/src/BlinkerSimpleESP32_WS.h +++ b/src/BlinkerSimpleESP32_WS.h @@ -23,11 +23,11 @@ class BlinkerSimpleESP32_WS } #endif - void begin(const char* ssid, - const char* pswd) + void begin(const char* _ssid, + const char* _pswd) { Base::begin(); - connectWiFi(ssid, pswd); + connectWiFi(_ssid, _pswd); BLINKER_LOG1("ESP32_WiFi Initialled..."); } @@ -74,17 +74,17 @@ class BlinkerSimpleESP32_WS this->conn.begin(macDeviceName()); } - void connectWiFi(const char* ssid, const char* pswd) + void connectWiFi(const char* _ssid, const char* _pswd) { uint32_t connectTime = millis(); - BLINKER_LOG2(BLINKER_F("Connecting to "), ssid); + BLINKER_LOG2(BLINKER_F("Connecting to "), _ssid); WiFi.mode(WIFI_STA); - if (pswd && strlen(pswd)) { - WiFi.begin(ssid, pswd); + if (_pswd && strlen(_pswd)) { + WiFi.begin(_ssid, _pswd); } else { - WiFi.begin(ssid); + WiFi.begin(_ssid); } while (WiFi.status() != WL_CONNECTED) { @@ -92,7 +92,7 @@ class BlinkerSimpleESP32_WS if (millis() - connectTime > BLINKER_CONNECT_TIMEOUT_MS && WiFi.status() != WL_CONNECTED) { connectTime = millis(); - BLINKER_LOG1(("WiFi connect timeout, please check ssid and pswd!")); + BLINKER_LOG1(("WiFi connect timeout, please check _ssid and _pswd!")); BLINKER_LOG1(("Retring WiFi connect again!")); } } diff --git a/src/BlinkerSimpleESP8266_MQTT.h b/src/BlinkerSimpleESP8266_MQTT.h index 1c4cfb41..3ab861e3 100644 --- a/src/BlinkerSimpleESP8266_MQTT.h +++ b/src/BlinkerSimpleESP8266_MQTT.h @@ -2,7 +2,8 @@ #define BlinkerSimplerESP8266_MQTT_H #include "Adapters/BlinkerMQTT.h" -// #include +#include +#include class BlinkerSimpleESP8266_MQTT : public BlinkerProtocol @@ -15,40 +16,40 @@ class BlinkerSimpleESP8266_MQTT {} #if defined(BLINKER_ESP_SMARTCONFIG) - void begin(const char* auth) { + void begin(const char* _auth) { Base::begin(); smartconfig(); - this->conn.begin(auth); + this->conn.begin(_auth); BLINKER_LOG1("ESP8266_MQTT Initialled..."); } #endif - void begin( const char* auth, - const char* ssid, - const char* pswd) + void begin( const char* _auth, + const char* _ssid, + const char* _pswd) { Base::begin(); - connectWiFi(ssid, pswd); - this->conn.begin(auth); + connectWiFi(_ssid, _pswd); + this->conn.begin(_auth); BLINKER_LOG1("ESP8266_MQTT Initialled..."); } private : - #if defined(BLINKER_ESP_SMARTCONFIG) +#if defined(BLINKER_ESP_SMARTCONFIG) void smartconfig() { WiFi.mode(WIFI_STA); WiFi.beginSmartConfig(); BLINKER_LOG1("Waiting for SmartConfig."); while (!WiFi.smartConfigDone()) { - delay(500); + ::delay(500); } BLINKER_LOG1("SmartConfig received."); BLINKER_LOG1("Waiting for WiFi"); while (WiFi.status() != WL_CONNECTED) { - delay(500); + ::delay(500); } BLINKER_LOG1("WiFi Connected."); @@ -74,17 +75,17 @@ class BlinkerSimpleESP8266_MQTT // this->conn.begin(macDeviceName()); // } - void connectWiFi(const char* ssid, const char* pswd) + void connectWiFi(const char* _ssid, const char* _pswd) { uint32_t connectTime = millis(); - BLINKER_LOG2(("Connecting to "), ssid); + BLINKER_LOG2(("Connecting to "), _ssid); WiFi.mode(WIFI_STA); - if (pswd && strlen(pswd)) { - WiFi.begin(ssid, pswd); + if (_pswd && strlen(_pswd)) { + WiFi.begin(_ssid, _pswd); } else { - WiFi.begin(ssid); + WiFi.begin(_ssid); } while (WiFi.status() != WL_CONNECTED) { @@ -92,7 +93,7 @@ class BlinkerSimpleESP8266_MQTT if (millis() - connectTime > BLINKER_CONNECT_TIMEOUT_MS && WiFi.status() != WL_CONNECTED) { connectTime = millis(); - BLINKER_LOG1(("WiFi connect timeout, please check ssid and pswd!")); + BLINKER_LOG1(("WiFi connect timeout, please check _ssid and _pswd!")); BLINKER_LOG1(("Retring WiFi connect again!")); } } diff --git a/src/BlinkerSimpleESP8266_WS.h b/src/BlinkerSimpleESP8266_WS.h index 58cb4c36..9d15c436 100644 --- a/src/BlinkerSimpleESP8266_WS.h +++ b/src/BlinkerSimpleESP8266_WS.h @@ -23,11 +23,11 @@ class BlinkerSimpleESP8266_WS } #endif - void begin(const char* ssid, - const char* pswd) + void begin(const char* _ssid, + const char* _pswd) { Base::begin(); - connectWiFi(ssid, pswd); + connectWiFi(_ssid, _pswd); BLINKER_LOG1("ESP8266_WiFi Initialled..."); } @@ -39,14 +39,14 @@ class BlinkerSimpleESP8266_WS BLINKER_LOG1("Waiting for SmartConfig."); while (!WiFi.smartConfigDone()) { - delay(500); + ::delay(500); } BLINKER_LOG1("SmartConfig received."); BLINKER_LOG1("Waiting for WiFi"); while (WiFi.status() != WL_CONNECTED) { - delay(500); + ::delay(500); } BLINKER_LOG1("WiFi Connected."); @@ -74,17 +74,17 @@ class BlinkerSimpleESP8266_WS this->conn.begin(macDeviceName()); } - void connectWiFi(const char* ssid, const char* pswd) + void connectWiFi(const char* _ssid, const char* _pswd) { uint32_t connectTime = millis(); - BLINKER_LOG2(BLINKER_F("Connecting to "), ssid); + BLINKER_LOG2(BLINKER_F("Connecting to "), _ssid); WiFi.mode(WIFI_STA); - if (pswd && strlen(pswd)) { - WiFi.begin(ssid, pswd); + if (_pswd && strlen(_pswd)) { + WiFi.begin(_ssid, _pswd); } else { - WiFi.begin(ssid); + WiFi.begin(_ssid); } while (WiFi.status() != WL_CONNECTED) { @@ -92,7 +92,7 @@ class BlinkerSimpleESP8266_WS if (millis() - connectTime > BLINKER_CONNECT_TIMEOUT_MS && WiFi.status() != WL_CONNECTED) { connectTime = millis(); - BLINKER_LOG1(("WiFi connect timeout, please check ssid and pswd!")); + BLINKER_LOG1(("WiFi connect timeout, please check _ssid and _pswd!")); BLINKER_LOG1(("Retring WiFi connect again!")); } } From d1732ae5074cb25518f584973caeac212ca35a0b Mon Sep 17 00:00:00 2001 From: i3water <121024123@qq.com> Date: Wed, 13 Jun 2018 01:44:45 +0800 Subject: [PATCH 2/2] update codes --- src/BlinkerSimpleESP32_MQTT.h | 16 ++++++++-------- src/BlinkerSimpleESP32_WS.h | 2 +- src/BlinkerSimpleESP8266_MQTT.h | 2 +- src/BlinkerSimpleESP8266_WS.h | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/BlinkerSimpleESP32_MQTT.h b/src/BlinkerSimpleESP32_MQTT.h index 620fbb13..da5501ad 100644 --- a/src/BlinkerSimpleESP32_MQTT.h +++ b/src/BlinkerSimpleESP32_MQTT.h @@ -23,11 +23,11 @@ class BlinkerSimpleESP32_MQTT #endif void begin( const char* _auth, - const char* ssid, - const char* pswd) + const char* _ssid, + const char* _pswd) { Base::begin(); - connectWiFi(ssid, pswd); + connectWiFi(_ssid, _pswd); this->conn.begin(_auth); BLINKER_LOG1("ESP32_MQTT Initialled..."); } @@ -59,17 +59,17 @@ class BlinkerSimpleESP32_MQTT } #endif - void connectWiFi(const char* ssid, const char* pswd) + void connectWiFi(const char* _ssid, const char* _pswd) { uint32_t connectTime = millis(); - BLINKER_LOG2(("Connecting to "), ssid); + BLINKER_LOG2(("Connecting to "), _ssid); WiFi.mode(WIFI_STA); - if (pswd && strlen(pswd)) { - WiFi.begin(ssid, pswd); + if (_pswd && strlen(_pswd)) { + WiFi.begin(_ssid, _pswd); } else { - WiFi.begin(ssid); + WiFi.begin(_ssid); } while (WiFi.status() != WL_CONNECTED) { diff --git a/src/BlinkerSimpleESP32_WS.h b/src/BlinkerSimpleESP32_WS.h index 39d5c5a6..9d203d6f 100644 --- a/src/BlinkerSimpleESP32_WS.h +++ b/src/BlinkerSimpleESP32_WS.h @@ -92,7 +92,7 @@ class BlinkerSimpleESP32_WS if (millis() - connectTime > BLINKER_CONNECT_TIMEOUT_MS && WiFi.status() != WL_CONNECTED) { connectTime = millis(); - BLINKER_LOG1(("WiFi connect timeout, please check _ssid and _pswd!")); + BLINKER_LOG1(("WiFi connect timeout, please check ssid and pswd!")); BLINKER_LOG1(("Retring WiFi connect again!")); } } diff --git a/src/BlinkerSimpleESP8266_MQTT.h b/src/BlinkerSimpleESP8266_MQTT.h index 3ab861e3..910af07d 100644 --- a/src/BlinkerSimpleESP8266_MQTT.h +++ b/src/BlinkerSimpleESP8266_MQTT.h @@ -93,7 +93,7 @@ class BlinkerSimpleESP8266_MQTT if (millis() - connectTime > BLINKER_CONNECT_TIMEOUT_MS && WiFi.status() != WL_CONNECTED) { connectTime = millis(); - BLINKER_LOG1(("WiFi connect timeout, please check _ssid and _pswd!")); + BLINKER_LOG1(("WiFi connect timeout, please check ssid and pswd!")); BLINKER_LOG1(("Retring WiFi connect again!")); } } diff --git a/src/BlinkerSimpleESP8266_WS.h b/src/BlinkerSimpleESP8266_WS.h index 9d15c436..b1433703 100644 --- a/src/BlinkerSimpleESP8266_WS.h +++ b/src/BlinkerSimpleESP8266_WS.h @@ -92,7 +92,7 @@ class BlinkerSimpleESP8266_WS if (millis() - connectTime > BLINKER_CONNECT_TIMEOUT_MS && WiFi.status() != WL_CONNECTED) { connectTime = millis(); - BLINKER_LOG1(("WiFi connect timeout, please check _ssid and _pswd!")); + BLINKER_LOG1(("WiFi connect timeout, please check ssid and pswd!")); BLINKER_LOG1(("Retring WiFi connect again!")); } }