Skip to content

ThinkNode M6: make GPS usable in the repeater and room server builds - #3288

Open
andyhoobing wants to merge 1 commit into
meshcore-dev:devfrom
andyhoobing:m6-gps-defaults
Open

ThinkNode M6: make GPS usable in the repeater and room server builds#3288
andyhoobing wants to merge 1 commit into
meshcore-dev:devfrom
andyhoobing:m6-gps-defaults

Conversation

@andyhoobing

Copy link
Copy Markdown

Split out of #3287 as one self-contained fix, per the one-fix-per-PR guideline.
The companion PR covers the M6 status LED and shares no files with this one.

Problem

On a sealed Elecrow ThinkNode M6 (nRF52840 + SX1262 + soldered-on L76K GNSS,
IP65 solar enclosure) the GNSS could not be used at all:

  1. simple_repeater and simple_room_server both default gps_enabled = 0, so
    sensors.begin() detected the L76K and then immediately powered it back down
    via _location->stop() (which drives PIN_GPS_EN low). The M6 has no button
    or screen, so there was no way to switch it on short of a USB console.
  2. Both default advert_loc_policy to ADVERT_LOC_PREFS, so adverts carried
    the fixed ADVERT_LAT/ADVERT_LON (0,0) and ignored the GNSS entirely.
  3. The 1-second "is a GPS attached?" probe in initBasicGPS() gates the gps
    setting; losing that race leaves GPS unreachable until reboot. The M6 always
    has the module fitted.

Approach

Rather than changing behaviour for every board, the two example defaults become
build-time overridable:

#ifndef GPS_ENABLED_DEFAULT
  #define GPS_ENABLED_DEFAULT 0
#endif
#ifndef ADVERT_LOC_POLICY_DEFAULT
  #define ADVERT_LOC_POLICY_DEFAULT ADVERT_LOC_PREFS
#endif

Every other board keeps its existing defaults. Only the M6 repeater and
room_server envs opt in, and they also set ENV_SKIP_GPS_DETECT. Both
settings remain adjustable at runtime via gps on/gps off and
gps advert prefs|share|none.

Each example declares the defines where it already keeps its ADVERT_*
fallbacks — MyMesh.cpp for the repeater, MyMesh.h for the room server — to
match each example's own convention rather than imposing one layout on both.

Testing

  • ThinkNode_M6_repeater, ThinkNode_M6_room_server, RAK_4631_repeater and
    RAK_4631_room_server all build against dev.
  • pio run -t envdump confirms the new flags resolve for the M6 envs and are
    absent for the RAK envs, so other boards are provably untouched.
  • Confirmed on real M6 hardware over the serial CLI: gps -> on, active, fix, 13 sats, gps advert -> share, surviving a reboot.

Note for maintainers

One pre-existing behaviour worth being aware of (not changed by this PR): these
compiled defaults only apply to a fresh install. A UF2 update does not erase
InternalFS, so a device that has run MeshCore before keeps its saved prefs and
silently ignores new defaults — it must be reconfigured at runtime or factory
reset. This cost me some debugging and may be worth documenting.


Authored with assistance from Claude (see Co-Authored-By trailers).

On a sealed ThinkNode M6 (nRF52840 + soldered-on L76K GNSS, IP65 solar
enclosure) the GNSS could not be used at all:

1. simple_repeater and simple_room_server both default gps_enabled=0, so
   sensors.begin() detected the L76K and then immediately powered it back
   down via _location->stop() (which drives PIN_GPS_EN low). The M6 has no
   button or screen, so there was no way to switch it on short of a USB
   console.
2. Both default advert_loc_policy to ADVERT_LOC_PREFS, so adverts carried
   the fixed ADVERT_LAT/ADVERT_LON (0,0) and ignored the GNSS entirely.
3. The 1s "is a GPS attached?" probe in initBasicGPS() gates the 'gps'
   setting; losing that race leaves GPS unreachable until reboot. The M6
   always has the module fitted.

Rather than changing behaviour for every board, the two example defaults
become build-time overridable:

  #ifndef GPS_ENABLED_DEFAULT
    #define GPS_ENABLED_DEFAULT 0
  #endif
  #ifndef ADVERT_LOC_POLICY_DEFAULT
    #define ADVERT_LOC_POLICY_DEFAULT ADVERT_LOC_PREFS
  #endif

Every other board keeps its existing defaults; only the M6 repeater and
room_server envs opt in, and they also skip the GPS probe. Both settings
remain adjustable at runtime via 'gps on'/'gps off' and
'gps advert prefs|share|none'.

Each example declares the defines where it already keeps its ADVERT_*
fallbacks -- MyMesh.cpp for the repeater, MyMesh.h for the room server --
to match each example's own convention.

Verified: ThinkNode_M6_repeater, ThinkNode_M6_room_server,
RAK_4631_repeater and RAK_4631_room_server all build; envdump confirms the
new flags resolve for the M6 envs and are absent for RAK, so other boards
are untouched. Confirmed on real M6 hardware: 'gps -> on, active, fix,
13 sats' with 'gps advert -> share', persisting across reboot.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H7b3E6KcBEGZ2zr2jZMrBL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant