reciver changes

This commit is contained in:
2019-10-06 17:27:58 +02:00
parent 53c42b050a
commit d91e08db15
6 changed files with 37 additions and 22 deletions

View File

@ -49,7 +49,7 @@ inline static void printHelp(Serial* serial)
serial->write_p(PSTR("Available Commands: \n\
help : Show this prompt.\n\
relay add [id] [name] : Add Wireless Relay.\n\
relay delete : Delete last Relay.\n\
relay delete [n] : Delete n'th Relay.\n\
relay [on/off] [nn] : Turn on/off nth relay.\n\
relay resend [on/off] : Turn on/off periodic auto resend.\n\
state : Get machine readable state.\n\
@ -134,11 +134,14 @@ void relayDispatch(SVector<WirelessRelay, MAX_RELAYS>* relays, Pwm16b* auxPwm, c
}
else if( strcmp(token, "delete") == 0 )
{
token = strtok(NULL, " \n");
if(relays->count() > 0)
{
relays->erase(relays->count());
snprintf(buffer, SNPRINTF_BUFFER_SIZE, "Deleting relay NUMBER: %u NAME: %s\n", relays->count(), relays->at(relays->count()).getName());
uint16_t index = relays->count();
if( token != NULL) index = atoi(token);
snprintf(buffer, SNPRINTF_BUFFER_SIZE, "Deleting relay NUMBER: %u NAME: %s\n", index, relays->at(index).getName());
serial->write(buffer, SNPRINTF_BUFFER_SIZE);
relays->erase(index);
save();
}
}