diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index b7fc62f5..70dd9aae 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -652,6 +652,12 @@ uint8_t MyMesh::onContactRequest(const ContactInfo &contact, uint32_t sender_tim permissions &= perm_mask; if (permissions & TELEM_PERM_BASE) { // only respond if base permission bit is set + if (permissions & TELEM_PERM_LOCATION) { + // Nudge a duty-cycled GPS awake. This reply still carries the position + // we already have -- the fix is ~65 s away and the reply goes out now -- + // but the next request lands after the window and gets a fresh one. + sensors.requestLocationRefresh(); + } telemetry.reset(); telemetry.addVoltage(TELEM_CHANNEL_SELF, (float)board.getBattMilliVolts() / 1000.0f); // query other sensors -- target specific diff --git a/src/helpers/SensorManager.h b/src/helpers/SensorManager.h index b6878ca0..a7f62c85 100644 --- a/src/helpers/SensorManager.h +++ b/src/helpers/SensorManager.h @@ -44,6 +44,17 @@ public: virtual bool setSettingValue(const char* name, const char* value) { return false; } virtual LocationProvider* getLocationProvider() { return NULL; } + // Asked for when someone with LOCATION permission requests telemetry, so a + // duty-cycled receiver does not answer with a position that is up to + // GPS_DUTY_SYNC_INTERVAL_SECS old for the rest of that window. + // + // It deliberately does NOT wait for the fix -- the reply is assembled and + // sent synchronously (BaseChatMesh.cpp), while a warm fix measured on a + // T1000-E took ~65 s. So this request answers with what is known and pulls + // the next window forward; the FOLLOWING request gets the fresh position. + // With a periodic collector that costs one cycle and needs no scheduling. + virtual void requestLocationRefresh() { } + // Live I2C scan, written into dest as text. Returns the number of devices // that answered, or -1 when the platform has no bus to scan. // diff --git a/src/helpers/sensors/EnvironmentSensorManager.cpp b/src/helpers/sensors/EnvironmentSensorManager.cpp index ddc8fe57..de767ff9 100644 --- a/src/helpers/sensors/EnvironmentSensorManager.cpp +++ b/src/helpers/sensors/EnvironmentSensorManager.cpp @@ -963,6 +963,15 @@ void EnvironmentSensorManager::start_gps() { // fix as valid. A provider-driven re-arm would therefore sync the RTC to a // half-hour-old timestamp. Hence syncTime() (which clears the parser) on every // wake, and our own timer for when the next wake is due. +// Pull the next duty window forward to now -- see SensorManager::requestLocationRefresh. +void EnvironmentSensorManager::requestLocationRefresh() { + #if ENV_INCLUDE_GPS + if (gps_duty && !gps_active) { + gps_wake_at = millis(); + } + #endif +} + void EnvironmentSensorManager::gpsDutyLoop() { if (!gps_duty) return; diff --git a/src/helpers/sensors/EnvironmentSensorManager.h b/src/helpers/sensors/EnvironmentSensorManager.h index 533ac574..dc524036 100644 --- a/src/helpers/sensors/EnvironmentSensorManager.h +++ b/src/helpers/sensors/EnvironmentSensorManager.h @@ -46,6 +46,7 @@ public: #if ENV_INCLUDE_GPS EnvironmentSensorManager(LocationProvider &location): _location(&location){}; LocationProvider* getLocationProvider() { return _location; } + void requestLocationRefresh() override; #else EnvironmentSensorManager(){}; #endif diff --git a/variants/t1000-e/target.cpp b/variants/t1000-e/target.cpp index e3e02f7c..e00e9e4b 100644 --- a/variants/t1000-e/target.cpp +++ b/variants/t1000-e/target.cpp @@ -199,6 +199,15 @@ void T1000SensorManager::loop() { } } +// Pull the next duty window forward to now. Only meaningful while duty-cycling: +// with `gps on` the receiver is already up, and with `gps off` the user asked for +// silence and a telemetry request must not override that. +void T1000SensorManager::requestLocationRefresh() { + if (gps_duty && !gps_active) { + gps_wake_at = millis(); + } +} + int T1000SensorManager::getNumSettings() const { return 1; } // just one supported: "gps" (power switch) const char* T1000SensorManager::getSettingName(int i) const { diff --git a/variants/t1000-e/target.h b/variants/t1000-e/target.h index 3d28c908..baec4e71 100644 --- a/variants/t1000-e/target.h +++ b/variants/t1000-e/target.h @@ -36,6 +36,7 @@ public: int getNumSettings() const override; const char* getSettingName(int i) const override; const char* getSettingValue(int i) const override; + void requestLocationRefresh() override; bool setSettingValue(const char* name, const char* value) override; LocationProvider* getLocationProvider() { return _nmea; } };