Added option to disable OTA password

homeSpan.enableOTA() is now homeSpan.enableOTA(boolean auth=true).  Set auth=false to disable password authentication.  Set to true, or leave blank, to enable password authentication.
This commit is contained in:
Gregg 2021-02-13 21:24:46 -06:00
parent f1c3684e1c
commit 35c8f5b48c
3 changed files with 8 additions and 4 deletions

View File

@ -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");
}

View File

@ -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

View File

@ -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);