Created
December 16, 2018 22:11
-
-
Save tizoc/81b241498879af15496220e7ec86a1b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rc/iSpindel.cpp b/pio/src/iSpindel.cpp | |
index a3d92ee..062c7bb 100644 | |
--- a/pio/src/iSpindel.cpp | |
+++ b/pio/src/iSpindel.cpp | |
@@ -79,6 +79,7 @@ char my_polynominal[70] = "-0.00031*tilt^2+0.557*tilt-14.054"; | |
String my_ssid; | |
String my_psk; | |
+uint8_t my_wifi_timeout = 5; | |
uint8_t my_api; | |
uint32_t my_sleeptime = 15 * 60; | |
uint16_t my_port = 80; | |
@@ -194,6 +195,8 @@ bool readConfig() | |
my_ssid = (const char *)json["SSID"]; | |
if (json.containsKey("PSK")) | |
my_psk = (const char *)json["PSK"]; | |
+ if (json.containsKey("WiFiTimeout")) | |
+ my_wifi_timeout = json["WiFiTimeout"]; | |
if (json.containsKey("POLY")) | |
strcpy(my_polynominal, json["POLY"]); | |
@@ -333,6 +336,8 @@ bool startConfiguration() | |
TKIDSIZE * 2); | |
WiFiManagerParameter custom_sleep("sleep", "Update Interval (s)", | |
String(my_sleeptime).c_str(), 6, TYPE_NUMBER); | |
+ WiFiManagerParameter custom_wifi_timeout("wifi_timeout", "WiFi connect timeout (s)", | |
+ String(my_wifi_timeout).c_str(), 6, TYPE_NUMBER); | |
WiFiManagerParameter custom_token("token", "Token", htmlencode(my_token).c_str(), | |
TKIDSIZE * 2); | |
WiFiManagerParameter custom_server("server", "Server Address", | |
@@ -355,6 +360,7 @@ bool startConfiguration() | |
wifiManager.addParameter(&custom_name); | |
wifiManager.addParameter(&custom_sleep); | |
+ wifiManager.addParameter(&custom_wifi_timeout); | |
wifiManager.addParameter(&custom_vfact); | |
WiFiManagerParameter custom_tempscale_hint("<label for=\"TS\">Unit of temperature</label>"); | |
@@ -398,6 +404,7 @@ bool startConfiguration() | |
validateInput(custom_job.getValue(), my_job); | |
validateInput(custom_instance.getValue(), my_instance); | |
my_sleeptime = String(custom_sleep.getValue()).toInt(); | |
+ my_wifi_timeout = String(custom_wifi_timeout.getValue()).toInt(); | |
my_api = String(custom_api.getValue()).toInt(); | |
my_port = String(custom_port.getValue()).toInt(); | |
@@ -446,6 +453,7 @@ bool saveConfig() | |
json["Name"] = my_name; | |
json["Token"] = my_token; | |
json["Sleep"] = my_sleeptime; | |
+ json["WiFiTimeout"] = my_wifi_timeout; | |
// first reboot is for test | |
my_sleeptime = 1; | |
json["Server"] = my_server; | |
@@ -1192,12 +1200,12 @@ void setup() | |
unsigned long startedAt = millis(); | |
CONSOLE(F("After waiting ")); | |
// int connRes = WiFi.waitForConnectResult(); | |
- uint8_t wait = 0; | |
+ uint16_t wait = my_wifi_timeout * 10; | |
while (WiFi.status() == WL_DISCONNECTED) | |
{ | |
delay(100); | |
- wait++; | |
- if (wait > 50) | |
+ wait--; | |
+ if (wait < 1) | |
break; | |
} | |
auto waited = (millis() - startedAt); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment