diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 2c87099..dd4f453 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -452,7 +452,9 @@ void Span::checkConnect(){ if(otaEnabled){ if(esp_ota_get_running_partition()!=esp_ota_get_next_update_partition(NULL)){ ArduinoOTA.setHostname(hostName); - ArduinoOTA.setPasswordHash(otaPwd); + + if(otaAuth) + ArduinoOTA.setPasswordHash(otaPwd); ArduinoOTA .onStart([]() { @@ -485,7 +487,8 @@ void Span::checkConnect(){ Serial.print(displayName); Serial.print(" at "); Serial.print(WiFi.localIP()); - Serial.print("\n"); + Serial.print("\nAuthorization Password: "); + Serial.print(otaAuth?"Enabled\n\n":"DISABLED!\n\n"); } else { Serial.print("\n*** Warning: Can't enable OTA - Partition table used to compile this sketch is not configured for OTA.\n\n"); } diff --git a/src/HomeSpan.h b/src/HomeSpan.h index 00250b0..07cd569 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -103,6 +103,7 @@ struct Span{ char qrID[5]=""; // Setup ID used for pairing with QR Code boolean otaEnabled=false; // enables Over-the-Air ("OTA") updates char otaPwd[33]; // MD5 Hash of OTA password, represented as a string of hexidecimal characters + boolean otaAuth; // OTA requires password when set to true void (*wifiCallback)()=NULL; // optional callback function to invoke once WiFi connectivity is established WiFiServer *hapServer; // pointer to the HAP Server connection @@ -154,7 +155,7 @@ struct Span{ void setHostNameSuffix(const char *suffix){hostNameSuffix=suffix;} // sets the hostName suffix to be used instead of the 6-byte AccessoryID void setPortNum(uint16_t port){tcpPortNum=port;} // sets the TCP port number to use for communications between HomeKit and HomeSpan void setQRID(const char *id); // sets the Setup ID for optional pairing with a QR Code - void enableOTA(){otaEnabled=true;} // enables Over-the-Air updates + void enableOTA(boolean auth=true){otaEnabled=true;otaAuth=auth;} // enables Over-the-Air updates, with (auth=true) or without (auth=false) authorization password void setSketchVersion(const char *sVer){sketchVersion=sVer;} // set optional sketch version number const char *getSketchVersion(){return sketchVersion;} // get sketch version number void setWifiCallback(void (*f)()){wifiCallback=f;} // sets an optional user-defined function to call once WiFi connectivity is established diff --git a/src/src.ino b/src/src.ino index d1cc9df..cf8bb6f 100644 --- a/src/src.ino +++ b/src/src.ino @@ -14,7 +14,7 @@ void setup() { homeSpan.setPortNum(1200); homeSpan.setMaxConnections(6); // homeSpan.setQRID("One1"); - homeSpan.enableOTA(); +// homeSpan.enableOTA(false); homeSpan.setSketchVersion("Test 1.2.6"); homeSpan.setWifiCallback(wifiEstablished);