code cleanups (removed unused vars) and futher prepare for ota
This commit is contained in:
@@ -13,6 +13,8 @@ WiFiClientSecure net;
|
||||
|
||||
//BearSSL::WiFiClientSecure net;
|
||||
|
||||
unsigned long ota_lastcheck = 0;
|
||||
|
||||
//
|
||||
// If the WifiManager configuration portal is called, we can do stuff
|
||||
//
|
||||
@@ -21,9 +23,13 @@ WiFiClientSecure net;
|
||||
//}
|
||||
|
||||
void wifi_associate() {
|
||||
char apname[80];
|
||||
settings.name.toCharArray(apname, 80);
|
||||
|
||||
WifiManager.setConfigPortalTimeout(300); // If no configuration is done in 5 mins, exit/restart quietly
|
||||
if (WifiManager.autoConnect(nodename)) { // @@@FIXME@@@ we should really set a PSK for the AP (but in my brief testing it crashed the ESP, so what's up with that)
|
||||
PRINTLN_SERIAL("Wifi connected");
|
||||
if (WifiManager.autoConnect(apname)) { // @@@FIXME@@@ we should really set a PSK for the AP (but in my brief testing it crashed the ESP, so what's up with that)
|
||||
settings.ip = WiFi.localIP().toString();
|
||||
PRINTLN_SERIAL("Wifi IP: " + settings.ip);
|
||||
|
||||
//wificlient.setFingerprint(WTR_SHA1);
|
||||
net.setInsecure(); // Do not check fingerprint
|
||||
@@ -55,10 +61,13 @@ void wifi_loop() {
|
||||
PRINTLN_SERIAL("Wifi disconnected, trying to reconnect");
|
||||
wifi_associate();
|
||||
}
|
||||
}
|
||||
|
||||
// OTA routine to be run once every X seconds
|
||||
unsigned long ota_check = millis()/1000;
|
||||
if((ota_lastcheck == 0) || ((ota_check - ota_lastcheck) > OTA_UPDATE_INTERVAL)) {
|
||||
PRINTLN_SERIAL("Checking for OTA update");
|
||||
/*
|
||||
// Check for firmware upgrades
|
||||
Serial.println("Checking for firmware upgrade");
|
||||
t_httpUpdate_return ret = ESPhttpUpdate.update(wificlient, WTR_SERVER, WTR_SRVPORT, "/fw/", nodeversion);
|
||||
switch(ret) {
|
||||
case HTTP_UPDATE_FAILED: // HTTP 403, 404
|
||||
@@ -72,4 +81,7 @@ void wifi_loop() {
|
||||
break;
|
||||
}
|
||||
|
||||
*/
|
||||
*/
|
||||
ota_lastcheck = ota_check;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user