From 1d027d665c138f6f4566e8d29fa16877d976d20e Mon Sep 17 00:00:00 2001 From: universam1 Date: Fri, 9 Feb 2018 20:11:20 +0100 Subject: [PATCH] transmitting RSSI Wifi strength fix #137 --- README.md | 1 + pio/lib/Globals/Globals.h | 2 +- pio/lib/Sender/Sender.cpp | 4 ++++ pio/lib/Sender/Sender.h | 1 + pio/lib/WiFiManagerKT/WiFiManagerKT.cpp | 8 +------- pio/src/iSpindel.cpp | 19 +++++++++++-------- platformio.ini | 19 +++++++++++-------- 7 files changed, 30 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index dcb49640..3372463c 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Check out *IOT DEVICE PULLS ITS WEIGHT IN HOME BREWING* at http://hackaday.com/2 ## News +> 09.02.2018 Firmware 5.8.0: Transmitting the Wifi strength RSSI to insight of the reception > 07.02.2018 Firmware 5.7.1: Allow longer sleep intervals longer up to 99999s == 27 days > 03.02.2018 Firmware 5.7.0: Introduce Factory Reset feature > 02.02.2018 Firmware 5.6.2: Support for Wifi credentials with special characters diff --git a/pio/lib/Globals/Globals.h b/pio/lib/Globals/Globals.h index 579fd887..a12aad51 100644 --- a/pio/lib/Globals/Globals.h +++ b/pio/lib/Globals/Globals.h @@ -21,7 +21,7 @@ extern Ticker flasher; // defines go here -#define FIRMWAREVERSION "5.7.0" +#define FIRMWAREVERSION "5.8.0" #define API_FHEM true diff --git a/pio/lib/Sender/Sender.cpp b/pio/lib/Sender/Sender.cpp index f2f64de5..d9fc23e1 100644 --- a/pio/lib/Sender/Sender.cpp +++ b/pio/lib/Sender/Sender.cpp @@ -26,6 +26,10 @@ void SenderClass::add(String id, uint32_t value) { _jsonVariant[id] = value; } +void SenderClass::add(String id, int32_t value) +{ + _jsonVariant[id] = value; +} bool SenderClass::sendTCP(String server, uint16_t port) { diff --git a/pio/lib/Sender/Sender.h b/pio/lib/Sender/Sender.h index 0848a832..5a130640 100644 --- a/pio/lib/Sender/Sender.h +++ b/pio/lib/Sender/Sender.h @@ -24,6 +24,7 @@ class SenderClass bool sendTCONTROL(String server, uint16_t port); void add(String id, float value); void add(String id, String value); + void add(String id, int32_t value); void add(String id, uint32_t value); // ~SenderClass(); diff --git a/pio/lib/WiFiManagerKT/WiFiManagerKT.cpp b/pio/lib/WiFiManagerKT/WiFiManagerKT.cpp index 7119697e..3120e525 100644 --- a/pio/lib/WiFiManagerKT/WiFiManagerKT.cpp +++ b/pio/lib/WiFiManagerKT/WiFiManagerKT.cpp @@ -402,7 +402,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswor DEBUG_WM("Timed out connection result: "); DEBUG_WM(getStatus(connRes)); } - server.reset(); + // server.reset(); Apparently broken! dnsServer.reset(); return WiFi.status() == WL_CONNECTED; } @@ -438,12 +438,6 @@ int WiFiManager::connectWifi(String ssid, String pass) DEBUG_WM("Connection result: "); DEBUG_WM(getStatus(connRes)); //not connected, WPS enabled, no pass - first attempt - if (_tryWPS && connRes != WL_CONNECTED && pass == "") - { - startWPS(); - //should be connected at the end of WPS - connRes = waitForConnectResult(); - } return connRes; } diff --git a/pio/src/iSpindel.cpp b/pio/src/iSpindel.cpp index 55800017..8060d2d2 100644 --- a/pio/src/iSpindel.cpp +++ b/pio/src/iSpindel.cpp @@ -106,7 +106,6 @@ void SerialOut() { SerialOut(""); } // callback notifying us of the need to save config void saveConfigCallback() { - // SerialOut(F("Should save config")); // WiFi.setAutoReconnect(true); shouldSaveConfig = true; } @@ -396,11 +395,12 @@ bool startConfiguration() return false; } -void formatSpiffs() { - SerialOut(F("\nneed to format SPIFFS: "), false); - SPIFFS.end(); - SPIFFS.begin(); - SerialOut(SPIFFS.format()); +void formatSpiffs() +{ + SerialOut(F("\nneed to format SPIFFS: "), false); + SPIFFS.end(); + SPIFFS.begin(); + SerialOut(SPIFFS.format()); } bool saveConfig() @@ -410,7 +410,7 @@ bool saveConfig() // if SPIFFS is not usable if (!SPIFFS.begin() || !SPIFFS.exists(CFGFILE) || !SPIFFS.open(CFGFILE, "w")) - formatSpiffs(); + formatSpiffs(); DynamicJsonBuffer jsonBuffer; JsonObject &json = jsonBuffer.createObject(); @@ -465,7 +465,9 @@ bool uploadData(uint8_t service) sender.add("temperature", Temperatur); sender.add("battery", Volt); sender.add("gravity", Gravity); - SerialOut(F("\ncalling Ubidots")); + sender.add("interval", my_sleeptime); + sender.add("RSSI", WiFi.RSSI()); + SerialOut(F("\ncalling Ubidots"), true); return sender.sendUbidots(my_token, my_name); } #endif @@ -483,6 +485,7 @@ bool uploadData(uint8_t service) sender.add("battery", Volt); sender.add("gravity", Gravity); sender.add("interval", my_sleeptime); + sender.add("RSSI", WiFi.RSSI()); if (service == DTHTTP) { diff --git a/platformio.ini b/platformio.ini index bd157e4b..ff8dfe5e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,17 +9,20 @@ ; http://docs.platformio.org/page/projectconf.html [platformio] +env_default = d1_mini_stage lib_dir = pio/lib src_dir = pio/src -; [env:d1_mini] -; platform = espressif8266 -; board = d1_mini -; framework = arduino -; lib_deps = -; ArduinoJson -; ESPAsyncWebServer -; ESPAsyncTCP +[env:d1_mini] +platform = espressif8266 +board = d1_mini +framework = arduino +monitor_baud = 115200 +upload_speed = 921600 +lib_deps = + ArduinoJson + ESPAsyncWebServer + ESPAsyncTCP [env:d1_mini_stage] platform = https://github.com/platformio/platform-espressif8266.git#feature/stage