admin ops

This commit is contained in:
Kevin Hester
2021-02-21 14:03:44 +08:00
parent 99467cd874
commit c6091338ab
10 changed files with 164 additions and 77 deletions

View File

@@ -78,20 +78,6 @@ void PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
// this will break once we have multiple instances of PhoneAPI running independently
break;
case ToRadio_set_owner_tag:
DEBUG_MSG("Client is setting owner\n");
handleSetOwner(toRadioScratch.set_owner);
break;
case ToRadio_set_radio_tag:
DEBUG_MSG("Client is setting radio\n");
handleSetRadio(toRadioScratch.set_radio);
break;
case ToRadio_set_channel_tag:
DEBUG_MSG("Client is setting channel\n");
handleSetChannel(toRadioScratch.set_channel);
break;
default:
DEBUG_MSG("Error: unexpected ToRadio variant\n");
break;
@@ -255,52 +241,6 @@ bool PhoneAPI::available()
return false;
}
//
// The following routines are only public for now - until the rev1 bluetooth API is removed
//
void PhoneAPI::handleSetOwner(const User &o)
{
int changed = 0;
if (*o.long_name) {
changed |= strcmp(owner.long_name, o.long_name);
strcpy(owner.long_name, o.long_name);
}
if (*o.short_name) {
changed |= strcmp(owner.short_name, o.short_name);
strcpy(owner.short_name, o.short_name);
}
if (*o.id) {
changed |= strcmp(owner.id, o.id);
strcpy(owner.id, o.id);
}
if (changed) // If nothing really changed, don't broadcast on the network or write to flash
service.reloadOwner();
}
void PhoneAPI::handleSetChannel(const Channel &cc)
{
channels.setChannel(cc);
bool didReset = service.reloadConfig();
if (didReset) {
state = STATE_SEND_MY_INFO; // Squirt a completely new set of configs to the client
}
}
void PhoneAPI::handleSetRadio(const RadioConfig &r)
{
radioConfig = r;
bool didReset = service.reloadConfig();
if (didReset) {
state = STATE_SEND_MY_INFO; // Squirt a completely new set of configs to the client
}
}
/**
* Handle a packet that the phone wants us to send. It is our responsibility to free the packet to the pool
*/