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:
parent
f1c3684e1c
commit
35c8f5b48c
|
|
@ -452,7 +452,9 @@ void Span::checkConnect(){
|
||||||
if(otaEnabled){
|
if(otaEnabled){
|
||||||
if(esp_ota_get_running_partition()!=esp_ota_get_next_update_partition(NULL)){
|
if(esp_ota_get_running_partition()!=esp_ota_get_next_update_partition(NULL)){
|
||||||
ArduinoOTA.setHostname(hostName);
|
ArduinoOTA.setHostname(hostName);
|
||||||
ArduinoOTA.setPasswordHash(otaPwd);
|
|
||||||
|
if(otaAuth)
|
||||||
|
ArduinoOTA.setPasswordHash(otaPwd);
|
||||||
|
|
||||||
ArduinoOTA
|
ArduinoOTA
|
||||||
.onStart([]() {
|
.onStart([]() {
|
||||||
|
|
@ -485,7 +487,8 @@ void Span::checkConnect(){
|
||||||
Serial.print(displayName);
|
Serial.print(displayName);
|
||||||
Serial.print(" at ");
|
Serial.print(" at ");
|
||||||
Serial.print(WiFi.localIP());
|
Serial.print(WiFi.localIP());
|
||||||
Serial.print("\n");
|
Serial.print("\nAuthorization Password: ");
|
||||||
|
Serial.print(otaAuth?"Enabled\n\n":"DISABLED!\n\n");
|
||||||
} else {
|
} else {
|
||||||
Serial.print("\n*** Warning: Can't enable OTA - Partition table used to compile this sketch is not configured for OTA.\n\n");
|
Serial.print("\n*** Warning: Can't enable OTA - Partition table used to compile this sketch is not configured for OTA.\n\n");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ struct Span{
|
||||||
char qrID[5]=""; // Setup ID used for pairing with QR Code
|
char qrID[5]=""; // Setup ID used for pairing with QR Code
|
||||||
boolean otaEnabled=false; // enables Over-the-Air ("OTA") updates
|
boolean otaEnabled=false; // enables Over-the-Air ("OTA") updates
|
||||||
char otaPwd[33]; // MD5 Hash of OTA password, represented as a string of hexidecimal characters
|
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
|
void (*wifiCallback)()=NULL; // optional callback function to invoke once WiFi connectivity is established
|
||||||
|
|
||||||
WiFiServer *hapServer; // pointer to the HAP Server connection
|
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 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 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 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
|
void setSketchVersion(const char *sVer){sketchVersion=sVer;} // set optional sketch version number
|
||||||
const char *getSketchVersion(){return sketchVersion;} // get 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
|
void setWifiCallback(void (*f)()){wifiCallback=f;} // sets an optional user-defined function to call once WiFi connectivity is established
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ void setup() {
|
||||||
homeSpan.setPortNum(1200);
|
homeSpan.setPortNum(1200);
|
||||||
homeSpan.setMaxConnections(6);
|
homeSpan.setMaxConnections(6);
|
||||||
// homeSpan.setQRID("One1");
|
// homeSpan.setQRID("One1");
|
||||||
homeSpan.enableOTA();
|
// homeSpan.enableOTA(false);
|
||||||
homeSpan.setSketchVersion("Test 1.2.6");
|
homeSpan.setSketchVersion("Test 1.2.6");
|
||||||
homeSpan.setWifiCallback(wifiEstablished);
|
homeSpan.setWifiCallback(wifiEstablished);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue