Add opt-in low power Sensor dog tracking
Acquire fresh GPS and validated UTC, check an authenticated owner Companion, and apply saved lost-status cadence with bounded awake windows. Persist request tags, routes, and six-hour flood reservations; preserve the four-day cutoff across sleep and restart. Keep Dispatcher recovery active after a failed radio wake, honor denied flood retries after lost TxDone, and qualify GPS ownership and clock corrections. Add executable regression tests and nRF52/ESP32 Sensor build jobs. Validation: six firmware builds, 1829 native test cases, sanitized tracker/storage/GPS/sleep/recovery tests, and strict documentation build. Bluetooth Find My advertising and automatic Room mailbox polling remain separate work.
This commit is contained in:
1 parent
90b12f6fa3
commit
1f1a499482
43 files changed
+4684
-17
No files matched your search
@@ -83,6 +83,12 @@ fix, no WiFi connection, an inactive bridge, or an nRF52 bootloader without
|
||||
|
||||
## Companion framed CLI
|
||||
|
||||
GPS-equipped Sensor builds also provide the local-only
|
||||
[dog tracker settings](sensor_tracker.md): `get tracker`,
|
||||
`get/set tracker.owner`, `get/set tracker.mode`, `get/set tracker.interval`,
|
||||
`get/set tracker.lost.interval`, `get/set tracker.path`, and `tracker check`.
|
||||
They are excluded from compact STM32 defaults. LoRa CLI cannot change them.
|
||||
|
||||
Companion builds are not represented by the role/profile matrices below. Their
|
||||
local terminal and command `0x42` (`CMD_RUN_CLI_COMMAND`) expose these settings
|
||||
over the normal binary USB, BLE, or TCP connection:
|
||||
|
||||
@@ -43,14 +43,20 @@ When the tracker sends `Am I lost?` privately to that reachable Companion, it
|
||||
receives the selected answer, even when the owner's phone is disconnected.
|
||||
The same configured answer applies to all eligible contacts on this Companion.
|
||||
|
||||
A tracker client can use that answer to choose its reporting behavior, but its
|
||||
check-in schedule, sleep/wake policy and GPS reporting must be configured in
|
||||
the tracker client firmware. The tracker must stay awake for the separate
|
||||
private answer; a delivery ACK for the question is not that answer. These plain
|
||||
text answers have no request ID, so a delayed answer cannot be precisely
|
||||
correlated with a newer check-in. The responding Companion must be powered on
|
||||
and reachable when a question arrives. For mail that waits while a tracker sleeps,
|
||||
use [a personal room mailbox](room_services.md#sleeping-tracker-example).
|
||||
The opt-in [Sensor dog tracker](sensor_tracker.md) implements periodic fresh
|
||||
GPS acquisition, low power sleep, and owner check-ins. It uses a tagged encrypted
|
||||
request and response rather than parsing plain `Yes` or `No` text, so old answers
|
||||
cannot change a newer check-in. Store the Sensor as a persistent Sensor contact
|
||||
on the owner's Companion. The same saved `lost.reply` setting answers those
|
||||
checks; `off` returns Unknown. A fresh accepted GPS position updates the contact
|
||||
location through normal contact notifications.
|
||||
|
||||
Other clients can still use the plain text question. They must stay awake for
|
||||
the separate private answer; a delivery ACK is not that answer. Plain text
|
||||
answers have no request ID. The responding Companion must be powered on and
|
||||
reachable. [Personal room mailboxes](room_services.md#sleeping-tracker-example)
|
||||
provide store-and-forward mail; automatic mailbox polling is not yet implemented
|
||||
in the Sensor tracker.
|
||||
|
||||
## Matching and traffic limits
|
||||
|
||||
|
||||
@@ -225,6 +225,10 @@ DEBUG: PWRMGT: LPCOMP wake configured (AIN7, ref=3/8 VDD)
|
||||
|
||||
## Further power-management work (Planned)
|
||||
|
||||
For the opt-in Sensor check-in workflow using System ON idle sleep and bounded
|
||||
GPS acquisition, see [Sensor dog tracker](sensor_tracker.md). It is separate
|
||||
from the battery-protection SYSTEMOFF shutdown described here.
|
||||
|
||||
- A voltage state machine (Normal -> Warning -> Critical -> Shutdown)
|
||||
- Configurable wake comparator thresholds
|
||||
- Load shedding callbacks for power reduction
|
||||
|
||||
@@ -116,6 +116,7 @@ For the common chat/server helpers in `BaseChatMesh`, the current request type v
|
||||
| `0x06` | get neighbors | node neighbors query |
|
||||
| `0x08` | subscribe | subscribe to telemetry push |
|
||||
| `0x09` | ubsubscribe | unsubscribe from telemetry push |
|
||||
| `0x0C` | tracker status | encrypted Sensor dog tracker check to a configured owner's Companion; [wire format](sensor_tracker.md#encrypted-check-format) |
|
||||
|
||||
#### Get stats
|
||||
|
||||
|
||||
@@ -109,6 +109,10 @@ For a reachable owner's Companion, the optional
|
||||
[lost-status auto responder](companion_lost_reply.md) can also answer a private
|
||||
`Am I lost?` question with a saved `Yes` or `No`.
|
||||
|
||||
The opt-in [Sensor dog tracker](sensor_tracker.md) currently checks a reachable
|
||||
owner's Companion through tagged encrypted requests. It does not yet log in
|
||||
to a Room Server or automatically poll these mailboxes.
|
||||
|
||||
### Wi-Fi mailbox management
|
||||
|
||||
Open `/room`, join with your room credentials, and open **Personal mailbox**.
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
<!-- meshcore-hosted-doc-link:start -->
|
||||
<p class="meshcore-hosted-doc-link"><a href="https://mikecarper.github.io/MeshCore/sensor_tracker/">View this page on MeshCore Docs</a>.</p>
|
||||
<!-- meshcore-hosted-doc-link:end -->
|
||||
|
||||
# Sensor dog tracker
|
||||
|
||||
Dog tracker mode is an optional mode in the Sensor firmware. It acquires a new
|
||||
GPS position, sends an encrypted check to one configured owner's Companion,
|
||||
and waits for that owner's saved lost status. The owner's answer controls the
|
||||
tracker's reporting rate and awake window.
|
||||
|
||||
Tracker mode starts off. It is compiled by default for GPS Sensor builds on
|
||||
nRF52, ESP32, and RP2040; compact STM32 builds exclude it by default. A build
|
||||
can override `MESH_ENABLE_SENSOR_TRACKER`. GPS hardware must be detected and
|
||||
available for position acquisition.
|
||||
|
||||
## Set up the owner
|
||||
|
||||
Use a Companion build with lost replies enabled. Add the tracker as a saved
|
||||
contact on the owner's Companion, using its full public key. The responder
|
||||
accepts saved Chat or Sensor contacts for the encrypted tracker check.
|
||||
|
||||
Set the answer locally on the owner's Companion:
|
||||
|
||||
```text
|
||||
set lost.reply no
|
||||
get lost.reply
|
||||
```
|
||||
|
||||
Use `set lost.reply yes` when the dog is lost. Use `set lost.reply off` to
|
||||
return an unknown status. These are owner settings; an incoming tracker check
|
||||
cannot change them. A normal private `Am I lost?` message also receives the
|
||||
saved answer where the text responder is available, but the automatic Sensor
|
||||
tracker uses an encrypted request with a matching response tag.
|
||||
|
||||
The owner must be reachable during the tracker's receive window. A Room or
|
||||
public message board does not substitute for the owner's Companion in this
|
||||
mode.
|
||||
|
||||
## Set up the tracker
|
||||
|
||||
Configure the Sensor through its local text console. Replace the key below
|
||||
with the owner's full 64-character hexadecimal public key:
|
||||
|
||||
```text
|
||||
set tracker.owner <owner-public-key>
|
||||
set tracker.interval 1800
|
||||
set tracker.lost.interval 60
|
||||
set tracker.path direct
|
||||
set tracker.mode dog
|
||||
get tracker status
|
||||
```
|
||||
|
||||
Check `clock` on both devices before enabling the mode. If needed, use
|
||||
`time <current-UTC-epoch-seconds>` to set the tracker clock. The owner's
|
||||
Companion accepts map coordinates only when the request time is within five
|
||||
minutes of its own clock. Tracker acquisition waits for the provider's validated
|
||||
multi-sample GPS clock sync as well as its position, allowing cold-start clock
|
||||
recovery within the acquisition window. If clock sync cannot finish, an operator
|
||||
can still set the clock locally. Saved routing limits do not reset to grant
|
||||
floods after clock loss.
|
||||
|
||||
`direct` selects a direct radio path with no repeaters. If a repeater path is
|
||||
known, use comma-separated repeater prefixes, for example
|
||||
`set tracker.path aa,bb` or `set tracker.path aabb,ccdd`. All prefixes must have
|
||||
the same length: one, two, or three bytes. `set tracker.path clear` keeps the
|
||||
path unknown; the flood fallback delay
|
||||
still applies. Encrypted path replies can update the retained path.
|
||||
|
||||
| Command | Meaning |
|
||||
| --- | --- |
|
||||
| `get tracker status` | Show mode, saved owner status, intervals, flood lock, clock and storage state. |
|
||||
| `get tracker.owner` | Show the configured owner's full public key. |
|
||||
| `get tracker.path` | Show whether the route is direct, saved, or unknown, and its hop count. |
|
||||
| `set tracker.owner <full-key>` | Save the destination identity. |
|
||||
| `set tracker.mode dog` | Enable automatic checks and tracker power control. |
|
||||
| `set tracker.mode off` | Stop automatic checks and restore normal Sensor operation. |
|
||||
| `set tracker.interval <seconds>` | Normal interval, 60 to 86400 seconds; default 1800. |
|
||||
| `set tracker.lost.interval <seconds>` | Lost interval, 60 to 86400 seconds; default 60. |
|
||||
| `set tracker.path <hex\|direct\|clear>` | Save a known path or mark it unknown. |
|
||||
| `tracker check` | Schedule a check now, if no check is already pending. |
|
||||
|
||||
Tracker configuration and routing checkpoints use a separate durable store.
|
||||
Mode changes do not replace the saved manual GPS or power-saving preferences.
|
||||
If storage cannot safely retain configuration or a flood reservation, automatic
|
||||
tracker checks fail closed. Volatile filesystem recovery is unsuitable for this
|
||||
mode because a restart could otherwise reset the flood limits.
|
||||
|
||||
## Reporting and sleep
|
||||
|
||||
Each check asks the GPS manager for a new position and validated GPS clock
|
||||
sync. It discards the previous parser fix and previous time-validation samples,
|
||||
then stops once both are ready or after 120 seconds.
|
||||
An old cached position is not reported as a new tracker fix. If acquisition
|
||||
gets a position but clock sync times out, the fresh position is retained. If no
|
||||
position is acquired, the encrypted check marks the failure and carries no
|
||||
position. A retained parser fix or one unvalidated time sample cannot set the
|
||||
tracker clock.
|
||||
|
||||
The tracker then allows 20 seconds for the tagged owner response. `No` uses the
|
||||
normal reporting interval. `Yes` uses the shorter lost interval and requests a
|
||||
120-second awake window, renewed by further `Yes` responses. This permits the
|
||||
tracker to remain reachable while the owner continues to report it as lost.
|
||||
An unknown answer does not replace the last saved `Yes` or `No`. Intervals run
|
||||
from the completed check; GPS acquisition and the response window add time.
|
||||
|
||||
Between active windows, tracker mode pauses radio reception when there is no
|
||||
queued radio work, temporary radio setting, update operation, or active console
|
||||
that needs service. The radio resumes before the next check. Unsolicited
|
||||
messages sent while reception is paused cannot be received; the owner should
|
||||
set the status and wait for the next check. A delivery ACK alone does not
|
||||
contain the owner's lost answer.
|
||||
|
||||
Tracker mode temporarily suppresses ordinary periodic advertisements,
|
||||
subscriptions, and Sensor alerts. Manual requests can still be served while
|
||||
the radio is awake. Leaving tracker mode restores the normal Sensor behavior.
|
||||
|
||||
This uses idle or light sleep while retaining runtime state. It does not use
|
||||
the nRF52 battery-protection SYSTEMOFF path described in
|
||||
[nRF52 power management](nrf52_power_management.md). Receiver power control
|
||||
depends on the hardware: T1000-E retains the GPS backup supply for faster fixes,
|
||||
and shared GPS power rails may prevent physically cutting receiver power.
|
||||
|
||||
nRF52 tracker sleep arms a real one-shot software timer before each System ON
|
||||
wait. Failure to allocate or queue that timer keeps the loop polling. Sleep
|
||||
chunks are at most 30 seconds so clock and watchdog housekeeping continue.
|
||||
ESP32 light sleep uses the board's existing timer wake. RP2040 uses the core's
|
||||
interrupt-driven idle wait; its physical tracker wake behavior is not yet
|
||||
qualified by these host tests.
|
||||
|
||||
## Flood fallback
|
||||
|
||||
Automatic tracker checks retain a known direct path and try it while the
|
||||
owner cannot be reached. A failed check starts an outage; further failures do
|
||||
not restart that outage's six-hour clock.
|
||||
|
||||
- A recovery flood is eligible only after six hours without a qualifying owner
|
||||
response, six hours without hearing a repeater, and six hours since the last
|
||||
recovery flood.
|
||||
- Hearing a repeater starts another six-hour wait. It does not clear the
|
||||
four-day outage limit.
|
||||
- At most one automatic recovery flood is reserved per six hours. It does not
|
||||
schedule additional flood retries.
|
||||
- After four days without qualifying owner success, automatic floods
|
||||
stop. Known direct paths can still be tried. An authenticated matching direct
|
||||
owner response can clear the lockout. A bare delivery ACK cannot do this.
|
||||
|
||||
The cutoff and flood checkpoint survive sleep and restart. Invalid or backward
|
||||
clock changes prevent fresh flood eligibility. A forward GPS or manual clock
|
||||
correction starts another conservative six-hour quiet wait; it does not reset
|
||||
the outage or the flood checkpoint. Repeater observations and
|
||||
unrelated public traffic cannot unlock a stopped tracker. Ordinary Room
|
||||
responses, login traffic, and manual messaging keep their existing routing.
|
||||
|
||||
## Encrypted check format
|
||||
|
||||
This uses the existing encrypted peer `PAYLOAD_TYPE_REQ` and
|
||||
`PAYLOAD_TYPE_RESPONSE` datagrams. Request subtype `0x0C` is inside the
|
||||
encrypted body; it is separate from the packet header's OTA payload type.
|
||||
All multi-byte fields are little-endian.
|
||||
|
||||
| Request field | Bytes | Meaning |
|
||||
| --- | --- | --- |
|
||||
| Tag | 4 | RTC-based request identity, durably increasing across reboot. |
|
||||
| Subtype | 1 | `0x0C`. |
|
||||
| Version | 1 | `1`. |
|
||||
| Flags | 1 | `1` for fresh GPS, `2` for failed acquisition, or `0` for no position; other flags are rejected. |
|
||||
| Latitude | 4 | Signed degrees times 10,000,000. |
|
||||
| Longitude | 4 | Signed degrees times 10,000,000. |
|
||||
| Battery | 2 | Millivolts; carried for reporting, not a lost-status decision. |
|
||||
|
||||
The request has 17 logical plaintext bytes and zero padding to 32 bytes.
|
||||
Latitude and longitude must be zero when no fresh position is present.
|
||||
|
||||
| Response field | Bytes | Meaning |
|
||||
| --- | --- | --- |
|
||||
| Tag | 4 | Exact request tag. |
|
||||
| Subtype | 1 | `0x0C`. |
|
||||
| Version | 1 | `1`. |
|
||||
| Status | 1 | `0` Unknown, `1` Safe, `2` Lost. |
|
||||
| Awake lease | 2 | Seconds; the Companion requests 120 for Lost and zero otherwise. |
|
||||
|
||||
The response has nine logical plaintext bytes and zero padding to 16 bytes.
|
||||
The client authenticates the configured owner's complete public key, requires
|
||||
the pending tag within its receive window, and caps an awake lease at 300
|
||||
seconds. Short, oversized, nonzero-padded and unknown-version bodies are
|
||||
rejected. An encrypted returned-path packet may bundle the same response and
|
||||
provide a route for subsequent direct checks.
|
||||
|
||||
## Remaining work
|
||||
|
||||
This mode implements GPS checks and an owner's saved lost answer. It does not
|
||||
provide Bluetooth pings every 30 seconds, an automatic Room mailbox poller,
|
||||
public-board subscriptions, or a mailbox command interpreter. Room private
|
||||
mailboxes and the public board remain separate features. Mail text is not
|
||||
executed as a tracker or console command.
|
||||
|
||||
Battery life and reliable wake behavior still need measurements on the actual
|
||||
hardware, including GPS reception, repeater availability, and the chosen
|
||||
reporting intervals.
|
||||
@@ -41,6 +41,7 @@ Completed validation reports, experiments, and test guides are collected here. O
|
||||
## Companion, USB, BLE, and display
|
||||
|
||||
- [Companion lost-status replies](companion_lost_reply.md)
|
||||
- [Sensor dog tracker checks](sensor_dog_tracker.md)
|
||||
- [Contact-cache and NimBLE RAM qualification](companion_contact_cache_results.md)
|
||||
- [USB Companion ASCII default validation](companion_usb_ascii_validation.md)
|
||||
- [USB Companion client compatibility](companion_usb_client_validation.md)
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<!-- meshcore-hosted-doc-link:start -->
|
||||
<p class="meshcore-hosted-doc-link"><a href="https://mikecarper.github.io/MeshCore/test-results/sensor_dog_tracker/">View this page on MeshCore Docs</a>.</p>
|
||||
<!-- meshcore-hosted-doc-link:end -->
|
||||
|
||||
# Sensor dog tracker validation
|
||||
|
||||
The opt-in [Sensor dog tracker](../sensor_tracker.md) was checked on
|
||||
2026-10-10 using executable host tests and firmware builds. This report
|
||||
qualifies the code paths named below; no radio was flashed for these checks,
|
||||
and battery current, GPS acquisition outdoors, and live RF delivery were not
|
||||
measured.
|
||||
|
||||
## Executed regressions
|
||||
|
||||
| Suite | Checks |
|
||||
| --- | --- |
|
||||
| `test_tracker_route_policy.py` | 99 boundary and byte-format assertions: six-hour gates, repeater postponement, sticky four-day cutoff, invalid clocks, overflow and restart. |
|
||||
| `test_sensor_tracker_store.py` | 6,063 storage and failure scenarios over five filesystem API modes, including torn saves, unavailable storage, durable flood reservations and a monotonic request-tag floor. |
|
||||
| `test_sensor_tracker_client.py` | 22 tests execute actual `Tracker.cpp`, peer dispatch, route/store/codec and packet hash implementation: setup, Safe/Lost/Unknown cadence, fresh GPS, transmit-based response deadline, exact owner identity, nonce reuse across reboot, path updates and packet ownership. |
|
||||
| `test_tracker_owner_response.py` | Actual Companion responder across four feature configurations: persistent contact authentication, flags and padding, time-bounded position updates, rate limits, and preserved ordinary message state. |
|
||||
| `test_sensor_tracker_gps.py` | 5 tests: fresh parser/PVT samples, GPS ownership, 120-second bound, validated UTC recovery after a cold start, stale sync notifications and saved preference restoration. |
|
||||
| `test_sensor_tracker_sleep.py` | 4 tests: actual sleep gates, nRF52 timer allocation/queue failures, warm radio pause and resume, Dispatcher watchdog anchors, and feature defaults. |
|
||||
| `test_sensor_subscriptions.py` | 18 tests: existing delivery behavior plus suppression in dog mode and restoration after leaving it. |
|
||||
| `test_radio_interrupt_recovery.py` | 9 tests: radio recovery preserves the no-flood-retry policy when a missing transmit-complete interrupt could conceal a transmission. |
|
||||
|
||||
Host C++ tests use AddressSanitizer and UndefinedBehaviorSanitizer where
|
||||
available. Negative controls intentionally remove guards and verify that
|
||||
assertions detect the resulting regressions. Transport, UART, receiver and
|
||||
filesystem hardware are replaced by bounded adapters; they do not qualify
|
||||
physical RF range or current draw.
|
||||
|
||||
The ordinary PlatformIO suites `native`, `native_kiss_modem` and
|
||||
`native_ota_channel` also passed: 1,829 test cases, with no failures.
|
||||
|
||||
The client checks also cover:
|
||||
|
||||
- A backward RTC change while already asleep remains latched after the clock
|
||||
is restored, until a matching authenticated owner response.
|
||||
- A forward UTC correction cannot manufacture six hours of RF silence.
|
||||
- A flood reply crossing the exact four-day boundary retains the cutoff;
|
||||
a subsequent matching direct response clears it.
|
||||
- A failed warm radio wake attempts peripheral recovery and restores the
|
||||
dispatcher's watchdog ownership even when recovery fails.
|
||||
- An unset RTC defers the request without being reported as a storage failure.
|
||||
- The GPS manager completes its bounded position/time acquisition before the
|
||||
client consumes the result.
|
||||
|
||||
## Firmware builds
|
||||
|
||||
All six firmware builds passed their flash and runtime memory checks. Values
|
||||
below are linked firmware bytes, rather than measured running heap usage.
|
||||
|
||||
| Environment | Flash used / limit | Static RAM used | Runtime internal RAM available / required |
|
||||
| --- | --- | --- | --- |
|
||||
| `t1000e_sensor` | 377,520 / 811,008 | 64,400 | 171,112 / 54,320 |
|
||||
| `RAK_WisMesh_Tag_sensor` | 421,084 / 815,104 | 66,336 | 169,176 / 54,320 |
|
||||
| `heltec_v4_sensor` | 1,490,461 / 6,553,600 | 97,024 | 277,760 / 95,296 |
|
||||
| `t1000e_companion_radio_usb` | 427,964 / 708,608 | 187,272 | 48,240 / 38,944 |
|
||||
| `RAK_3x72_companion_radio_usb` | 229,000 / 229,376 | 39,780 | 24,728 / 17,408 |
|
||||
| `wio-e5-mini_companion_radio_usb` | 229,012 / 229,376 | 39,804 | 24,704 / 17,408 |
|
||||
|
||||
The compact STM32 Companion retains its existing feature exclusions and
|
||||
application/storage boundary. Its limited remaining flash is checked by the
|
||||
existing CI build. The workflow now also builds T1000-E and RAK Tag Sensors
|
||||
and the ESP32-S3 V4 Sensor, in addition to the executable tracker regressions.
|
||||
The Wio-E5 Mini check uses the complete
|
||||
`v1.17.1.9-halo-keymind-cascade-dev` version string and USA Cascade profile.
|
||||
|
||||
## Limits
|
||||
|
||||
Bluetooth Find My/OpenHaystack advertising and automatic Room mailbox polling
|
||||
are not implemented by this change. RP2040's interrupt-driven physical wake
|
||||
has not been tested on a board. The GPS/RF and current measurements still
|
||||
needed on T1000-E and RAK Tag are listed in the
|
||||
[tracker guide](../sensor_tracker.md#remaining-work).
|
||||
Reference in new issue
Block a user