From 925eb790664c40e4081efdf636e6114dbf0018db Mon Sep 17 00:00:00 2001 From: tablatronix Date: Fri, 17 Sep 2021 08:43:01 -0500 Subject: [PATCH] clean up spiffs examples --- WiFiManager.h | 1 + .../AutoConnectWithFSParameters.ino | 22 +++++++++--------- ...AutoConnectWithFSParametersAndCustomIP.ino | 23 +++++++++---------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/WiFiManager.h b/WiFiManager.h index 677d401..d336fbe 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -32,6 +32,7 @@ #ifdef ARDUINO_ESP8266_RELEASE_2_3_0 #warning "ARDUINO_ESP8266_RELEASE_2_3_0, some WM features disabled" +// @todo check failing on platform = espressif8266@1.7.3 #define WM_NOASYNC // esp8266 no async scan wifi #define WM_NOCOUNTRY // esp8266 no country #define WM_NOAUTH // no httpauth diff --git a/examples/AutoConnect/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino b/examples/AutoConnect/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino index c62ca7b..2d41f5b 100644 --- a/examples/AutoConnect/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino +++ b/examples/AutoConnect/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino @@ -1,16 +1,16 @@ #include //this needs to be first, or it all crashes and burns... -#include //https://github.com/esp8266/Arduino -//needed for library -#include -#include #include //https://github.com/tzapu/WiFiManager +#ifdef ESP32 + #include +#endif + #include //https://github.com/bblanchon/ArduinoJson //define your default values here, if there are different values in config.json, they are overwritten. char mqtt_server[40]; char mqtt_port[6] = "8080"; -char blynk_token[34] = "YOUR_BLYNK_TOKEN"; +char api_token[34] = "YOUR_API_TOKEN"; //flag for saving data bool shouldSaveConfig = false; @@ -60,7 +60,7 @@ void setup() { Serial.println("\nparsed json"); strcpy(mqtt_server, json["mqtt_server"]); strcpy(mqtt_port, json["mqtt_port"]); - strcpy(blynk_token, json["blynk_token"]); + strcpy(api_token, json["api_token"]); } else { Serial.println("failed to load json config"); } @@ -77,7 +77,7 @@ void setup() { // id/name placeholder/prompt default length WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40); WiFiManagerParameter custom_mqtt_port("port", "mqtt port", mqtt_port, 6); - WiFiManagerParameter custom_blynk_token("blynk", "blynk token", blynk_token, 32); + WiFiManagerParameter custom_api_token("apikey", "API token", api_token, 32); //WiFiManager //Local intialization. Once its business is done, there is no need to keep it around @@ -92,7 +92,7 @@ void setup() { //add all your parameters here wifiManager.addParameter(&custom_mqtt_server); wifiManager.addParameter(&custom_mqtt_port); - wifiManager.addParameter(&custom_blynk_token); + wifiManager.addParameter(&custom_api_token); //reset settings - for testing //wifiManager.resetSettings(); @@ -124,11 +124,11 @@ void setup() { //read updated parameters strcpy(mqtt_server, custom_mqtt_server.getValue()); strcpy(mqtt_port, custom_mqtt_port.getValue()); - strcpy(blynk_token, custom_blynk_token.getValue()); + strcpy(api_token, custom_api_token.getValue()); Serial.println("The values in the file are: "); Serial.println("\tmqtt_server : " + String(mqtt_server)); Serial.println("\tmqtt_port : " + String(mqtt_port)); - Serial.println("\tblynk_token : " + String(blynk_token)); + Serial.println("\tapi_token : " + String(api_token)); //save the custom parameters to FS if (shouldSaveConfig) { @@ -141,7 +141,7 @@ void setup() { #endif json["mqtt_server"] = mqtt_server; json["mqtt_port"] = mqtt_port; - json["blynk_token"] = blynk_token; + json["api_token"] = api_token; File configFile = SPIFFS.open("/config.json", "w"); if (!configFile) { diff --git a/examples/AutoConnect/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino b/examples/AutoConnect/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino index e510a74..7da62d7 100644 --- a/examples/AutoConnect/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino +++ b/examples/AutoConnect/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino @@ -1,19 +1,18 @@ #include //this needs to be first, or it all crashes and burns... -#include //https://github.com/esp8266/Arduino - -//needed for library -#include -#include #include //https://github.com/tzapu/WiFiManager +#ifdef ESP32 + #include +#endif + #include //https://github.com/bblanchon/ArduinoJson //define your default values here, if there are different values in config.json, they are overwritten. //length should be max size + 1 char mqtt_server[40]; char mqtt_port[6] = "8080"; -char blynk_token[34] = "YOUR_BLYNK_TOKEN"; +char api_token[34] = "YOUR_APITOKEN"; //default custom static IP char static_ip[16] = "10.0.1.56"; char static_gw[16] = "10.0.1.1"; @@ -67,7 +66,7 @@ void setup() { strcpy(mqtt_server, json["mqtt_server"]); strcpy(mqtt_port, json["mqtt_port"]); - strcpy(blynk_token, json["blynk_token"]); + strcpy(api_token, json["api_token"]); if (json["ip"]) { Serial.println("setting custom ip from config"); @@ -88,7 +87,7 @@ void setup() { } //end read Serial.println(static_ip); - Serial.println(blynk_token); + Serial.println(api_token); Serial.println(mqtt_server); @@ -97,7 +96,7 @@ void setup() { // id/name placeholder/prompt default length WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40); WiFiManagerParameter custom_mqtt_port("port", "mqtt port", mqtt_port, 5); - WiFiManagerParameter custom_blynk_token("blynk", "blynk token", blynk_token, 34); + WiFiManagerParameter custom_api_token("apikey", "API token", api_token, 34); //WiFiManager //Local intialization. Once its business is done, there is no need to keep it around @@ -117,7 +116,7 @@ void setup() { //add all your parameters here wifiManager.addParameter(&custom_mqtt_server); wifiManager.addParameter(&custom_mqtt_port); - wifiManager.addParameter(&custom_blynk_token); + wifiManager.addParameter(&custom_api_token); //reset settings - for testing //wifiManager.resetSettings(); @@ -149,7 +148,7 @@ void setup() { //read updated parameters strcpy(mqtt_server, custom_mqtt_server.getValue()); strcpy(mqtt_port, custom_mqtt_port.getValue()); - strcpy(blynk_token, custom_blynk_token.getValue()); + strcpy(api_token, custom_api_token.getValue()); //save the custom parameters to FS if (shouldSaveConfig) { @@ -162,7 +161,7 @@ void setup() { #endif json["mqtt_server"] = mqtt_server; json["mqtt_port"] = mqtt_port; - json["blynk_token"] = blynk_token; + json["api_token"] = api_token; json["ip"] = WiFi.localIP().toString(); json["gateway"] = WiFi.gatewayIP().toString();