Make region changes take effect immedately

1.2-legacy
Kevin Hester 2020-10-29 13:26:36 +08:00
rodzic f698883c02
commit cfcb62bd18
3 zmienionych plików z 12 dodań i 11 usunięć

Wyświetl plik

@ -198,7 +198,10 @@ void MeshService::loop()
bool MeshService::reloadConfig() bool MeshService::reloadConfig()
{ {
// If we can successfully set this radio to these settings, save them to disk // If we can successfully set this radio to these settings, save them to disk
// This will also update the region as needed
bool didReset = nodeDB.resetRadioConfig(); // Don't let the phone send us fatally bad settings bool didReset = nodeDB.resetRadioConfig(); // Don't let the phone send us fatally bad settings
configChanged.notifyObservers(NULL); configChanged.notifyObservers(NULL);
nodeDB.saveToDisk(); nodeDB.saveToDisk();

Wyświetl plik

@ -150,6 +150,9 @@ bool NodeDB::resetRadioConfig()
radioConfig.preferences.region = RegionCode_TW; radioConfig.preferences.region = RegionCode_TW;
} }
// Update the global myRegion
initRegion();
return didFactoryReset; return didFactoryReset;
} }
@ -245,9 +248,6 @@ void NodeDB::init()
} }
} }
// Update the global myRegion
initRegion();
strncpy(myNodeInfo.firmware_version, optstr(APP_VERSION), sizeof(myNodeInfo.firmware_version)); strncpy(myNodeInfo.firmware_version, optstr(APP_VERSION), sizeof(myNodeInfo.firmware_version));
strncpy(myNodeInfo.hw_model, HW_VENDOR, sizeof(myNodeInfo.hw_model)); strncpy(myNodeInfo.hw_model, HW_VENDOR, sizeof(myNodeInfo.hw_model));

Wyświetl plik

@ -30,15 +30,13 @@ const RegionInfo *myRegion;
void initRegion() void initRegion()
{ {
if (!myRegion) { const RegionInfo *r = regions;
const RegionInfo *r = regions; for (; r->code != RegionCode_Unset && r->code != radioConfig.preferences.region; r++)
for (; r->code != RegionCode_Unset && r->code != radioConfig.preferences.region; r++) ;
; myRegion = r;
myRegion = r; DEBUG_MSG("Wanted region %d, using %s\n", radioConfig.preferences.region, r->name);
DEBUG_MSG("Wanted region %d, using %s\n", radioConfig.preferences.region, r->name);
myNodeInfo.num_channels = myRegion->numChannels; // Tell our android app how many channels we have myNodeInfo.num_channels = myRegion->numChannels; // Tell our android app how many channels we have
}
} }
/** /**