Modified 'O' command so that a blank entry cancels the request to update the OTA password

This commit is contained in:
Gregg 2021-02-08 18:31:51 -06:00
parent 01d48e73ec
commit 98cfde8aa9
1 changed files with 17 additions and 8 deletions

View File

@ -593,15 +593,24 @@ void Span::processSerialCommand(const char *c){
case 'O': {
char textPwd[33]="\0";
char textPwd[34]="\0";
while(!strlen(textPwd)){
Serial.print("\n>>> OTA Password (32 characters max): ");
readSerial(textPwd,32);
Serial.print(mask(textPwd,2));
Serial.print("\n");
Serial.print("\n>>> New OTA Password, or <return> to cancel request: ");
readSerial(textPwd,33);
if(strlen(textPwd)==0){
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;
otaPwdHash.begin();
otaPwdHash.add(textPwd);
@ -610,9 +619,9 @@ void Span::processSerialCommand(const char *c){
nvs_set_str(HAPClient::otaNVS,"OTADATA",otaPwd); // update data
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)
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");
}
break;