Merge upstream/dev (16 commits) [upstream-sync]
pub-release / release (push) Successful in 37m31s

This commit is contained in:
upstream-sync-bot committed 2026-11-14 05:06:06 +00:00
commit fbefa417b9
19 files changed
+973 -22

No files matched your search

+44 -10
View File
@@ -50,6 +50,8 @@ bool CommonGpsPrefs::apply(SensorManager& sensors) const {
LocationProvider* location = sensors.getLocationProvider();
if (location == nullptr) return false;
applyGuardReference(sensors);
uint32_t first_fix;
if (getFirstFixTimeout(first_fix)) location->setFirstFixTimeout(first_fix);
location->setGpsPeriod(getGpsPeriod());
location->setGpsOn(isGpsEnabled());
return true;
@@ -66,6 +68,20 @@ static void formatDuration(char* buf, size_t size, uint32_t seconds) {
}
}
// "<n>[s|m|h|d]", seconds by default
static bool parseDuration(const char* text, uint32_t& seconds) {
char* end;
unsigned long value = strtoul(text, &end, 10);
unsigned long mult = 1;
if (*end == 'm') mult = 60;
else if (*end == 'h') mult = 3600;
else if (*end == 'd') mult = 86400;
if (mult > 1 || *end == 's') end++; // skip the suffix char
if (text[0] == '\0' || *end != '\0') return false;
seconds = (uint32_t)(value * mult);
return true;
}
bool CommonGpsPrefs::handleCommand(const char* command, SensorManager& sensors, char* reply) {
if (strcmp(command, "gps") == 0) {
LocationProvider* location = sensors.getLocationProvider();
@@ -184,17 +200,10 @@ bool CommonGpsPrefs::handleCommand(const char* command, SensorManager& sensors,
return true;
}
if (memcmp(command, "gps period ", 11) == 0) {
char* end;
unsigned long period = strtoul(command + 11, &end, 10);
unsigned long mult = 1;
if (*end == 'm') mult = 60;
else if (*end == 'h') mult = 3600;
else if (*end == 'd') mult = 86400;
if (mult > 1 || *end == 's') end++; // skip the suffix char
if (command[11] == '\0' || *end != '\0') {
uint32_t period;
if (!parseDuration(command + 11, period)) {
strcpy(reply, "Error, invalid gps period");
} else if (!setGpsPeriod(sensors, (uint32_t)(period * mult)) ||
} else if (!setGpsPeriod(sensors, period) ||
!setGpsEnabled(sensors, true)) {
strcpy(reply, "Error, gps provider not found");
} else {
@@ -202,6 +211,31 @@ bool CommonGpsPrefs::handleCommand(const char* command, SensorManager& sensors,
}
return true;
}
if (strcmp(command, "gps firstfix") == 0) {
LocationProvider* location = sensors.getLocationProvider();
if (location == nullptr) {
strcpy(reply, "Error, gps provider not found");
} else if (location->getFirstFixTimeout() == 0) {
strcpy(reply, "> 0 (no limit)");
} else {
sprintf(reply, "> %lu", (unsigned long)location->getFirstFixTimeout());
}
return true;
}
if (memcmp(command, "gps firstfix ", 13) == 0) {
LocationProvider* location = sensors.getLocationProvider();
uint32_t seconds;
if (location == nullptr) {
strcpy(reply, "Error, gps provider not found");
} else if (!parseDuration(command + 13, seconds) || seconds > 86400UL) { // at most a day
strcpy(reply, "Error, invalid first fix timeout");
} else {
location->setFirstFixTimeout(seconds);
setFirstFixTimeout(seconds); // saved by the caller (isDirty)
strcpy(reply, "OK");
}
return true;
}
if (memcmp(command, "gps sync", 8) == 0) {
LocationProvider* location = sensors.getLocationProvider();
if (location == nullptr) {