feat(gps): Do not start gps if lora region is unset (#10386)

* Disable gps thread on startup if lora region is unset

There is little reason to waste battery on the gps if the data cannot
yet be used.

* fix goobered merge

Refactor GPS enabling logic and remove duplicate code.

* trunk

---------

Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz>
This commit is contained in:
webgeek1234
2026-06-28 18:22:09 -05:00
committed by GitHub
co-authored by GitHub Jonathan Bennett
parent 29b3cfaeca
commit 9cef69a9d3
5 changed files with 27 additions and 0 deletions
+8
View File
@@ -1020,6 +1020,14 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c, bool fromOthers)
}
#endif
#if !MESHTASTIC_EXCLUDE_GPS
// Enable gps if it was previously disabled due to region not being set
if (!requiresReboot && config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_UNSET && gps != nullptr &&
!gps->isEnabled() && config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED) {
gps->enable();
}
#endif
config.lora = validatedLora; // Finally, return the validated config back to the main config
break;