Modified 'O' command so that a blank entry cancels the request to update the OTA password
This commit is contained in:
parent
01d48e73ec
commit
98cfde8aa9
|
|
@ -593,15 +593,24 @@ void Span::processSerialCommand(const char *c){
|
||||||
|
|
||||||
case 'O': {
|
case 'O': {
|
||||||
|
|
||||||
char textPwd[33]="\0";
|
char textPwd[34]="\0";
|
||||||
|
|
||||||
while(!strlen(textPwd)){
|
Serial.print("\n>>> New OTA Password, or <return> to cancel request: ");
|
||||||
Serial.print("\n>>> OTA Password (32 characters max): ");
|
readSerial(textPwd,33);
|
||||||
readSerial(textPwd,32);
|
|
||||||
Serial.print(mask(textPwd,2));
|
if(strlen(textPwd)==0){
|
||||||
Serial.print("\n");
|
Serial.print("(cancelled)\n\n");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strlen(textPwd)==33){
|
||||||
|
Serial.print("\n*** Sorry, 32 character limit - request cancelled\n\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.print(mask(textPwd,2));
|
||||||
|
Serial.print("\n");
|
||||||
|
|
||||||
MD5Builder otaPwdHash;
|
MD5Builder otaPwdHash;
|
||||||
otaPwdHash.begin();
|
otaPwdHash.begin();
|
||||||
otaPwdHash.add(textPwd);
|
otaPwdHash.add(textPwd);
|
||||||
|
|
@ -610,9 +619,9 @@ void Span::processSerialCommand(const char *c){
|
||||||
nvs_set_str(HAPClient::otaNVS,"OTADATA",otaPwd); // update data
|
nvs_set_str(HAPClient::otaNVS,"OTADATA",otaPwd); // update data
|
||||||
nvs_commit(HAPClient::otaNVS);
|
nvs_commit(HAPClient::otaNVS);
|
||||||
|
|
||||||
Serial.print("\nPassword change will take effect after next restart.\n");
|
Serial.print("... Accepted! Password change will take effect after next restart.\n");
|
||||||
if(!otaEnabled)
|
if(!otaEnabled)
|
||||||
Serial.print("Note: OTA has not been enabled in this sketch.\n");
|
Serial.print("... Note: OTA has not been enabled in this sketch.\n");
|
||||||
Serial.print("\n");
|
Serial.print("\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue