Skip to content

Big GPS refactor - #3753

Open
fdlamotte wants to merge 27 commits into
meshcore-dev:devfrom
fdlamotte:gps_refactor
Open

fdlamotte wants to merge 27 commits into
meshcore-dev:devfrom
fdlamotte:gps_refactor

Conversation

@fdlamotte

Copy link
Copy Markdown
Collaborator

Following #3684 I'll work here on refactoring GPS management

The idea is to keep LocationProvider as the interface to the loop, but adding GpsDriver class to manage low-level things

I also tried to pull all i2c RAK GPS related things out of EnvironmentSensorManager ... this was huge and I hope I didn't do any mistake as I don't have i2c rak gps ... if someone can help me with testing ...

periodic wakeup has been added, and a command is available for the repeater CLI, will make a GPSPrefs class to share gps command between repeater and companion

Still a long way to go (as I've seen lots of bad things in current code with active waits on gps frames for instance !)

@cwichura

cwichura commented Nov 2, 2026

Copy link
Copy Markdown

This is exciting to see. Please make sure to factor in the NMEA auto-baud selection from #3729. This fixes GROVE GPS modules from M5Stack, for example. And it would also be good to fold in #3736.

Also, does the common virtual API of the base class facilitate devices like the Thinknode M1 that have a physical on/off switch that relies on the firmware to actually disable/enable the GPS (as opposed to a switch that physically disconnects power from the GPS module)?

@fdlamotte

fdlamotte commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

This is exciting to see. Please make sure to factor in the NMEA auto-baud selection from #3729. This fixes GROVE GPS modules from M5Stack, for example. And it would also be good to fold in #3736.

Yes, #3729 can easily be implemented in GpsDriver, I think #3736 would better sit in LocationProvider

Also, does the common virtual API of the base class facilitate devices like the Thinknode M1 that have a physical on/off switch that relies on the firmware to actually disable/enable the GPS (as opposed to a switch that physically disconnects power from the GPS module)?

Are you sure the physical button on M1 is not an hw switch as on M5 ?

I've just refactored both to use the same path (because if switch is HW there is no need to poll) but your comment make me think maybe I'm wrong (and I still don't have the M1 to test that)

edit: I have confirmation the switch is purely software on M1 ... too bad. I should probably take care of sw gps switch in the driver then (to keep coherent with the gps state)

@cwichura

cwichura commented Nov 2, 2026

Copy link
Copy Markdown

I own a v1 M1. The switch is just a GPIO input; it does not physically disconnect/power down the GPS module in the M1.

Some targets have been modified to meet the new interface

Most of the low level stuff has moved to the GpsDriver class

The most impacted ports are :
 - Nano G2 Ultra
 - MeshTracker X1
 - Heltec Tracker
 - both Muzi SuperIO radios
 - T1000E
 - ThinkNode M1/M5
 - Heltec Mesh Solar
 - MeshAdventurer

Builds run on all these highly impacted variants, but could only test on
T1000e and ThinkNode M1.

Meshsolar has strange build issues as companion but it probably predates
the refactoring, builds well as repeater
@fdlamotte

fdlamotte commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Ok, the refactoring has been ported to all ports.

I think I now need some feedbacks on what I possibly have broken ;)

I'm doing tests on my side with what I have ...

The feedback I'd need would be on:

  • any RAK board with i2c gps
  • Nano G2 Ultra
  • MeshTracker X1
  • Heltec Tracker
  • both Muzi SuperIO radios
  • ThinkNode M1
  • Heltec Mesh Solar
  • MeshAdventurer

I've notice a build issue with meshsolar companions, this predates this PR (also happens in dev)

@cwichura

cwichura commented Nov 4, 2026

Copy link
Copy Markdown

I just saw #3760 got opened, which suggests it too has a software GPS switch. (I don't own this hardware, so can't check, myself.)

@IoTThinks

Copy link
Copy Markdown
Contributor

Look like the new GPS module is coming.
Great.

@fdlamotte

Copy link
Copy Markdown
Collaborator Author

I just checked the rak serial nmea gps path using a modified variant using rak classes and it works

Still need some input from people using rak with i2c gps module

fdlamotte and others added 2 commits November 4, 2026 12:02
The refactor no longer calls Serial1.setPins() on nRF52, so Serial1 uses
PIN_SERIAL1_RX/TX directly. Those were swapped (the GPS transmits on
P0.20), so no data was received. Fix them and define PIN_GPS_TX/RX by the
gps module's side, as other variants do.

The ATGM336H keeps its NMEA output config across power cycles, and other
firmware may leave every sentence disabled. Re-enable GGA + RMC after each
power-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nGoline

nGoline commented Nov 4, 2026

Copy link
Copy Markdown

Tested on a Muzi Base Uno + SuperIO, following up on #3760.

As-is, the Muzi GPS gets no data: the refactor no longer calls Serial1.setPins() on nRF52, and the Muzi variant.h had PIN_SERIAL1_RX/TX swapped (main only worked because setPins(PIN_GPS_TX, PIN_GPS_RX) swapped them back). Any other nRF52 variant whose PIN_SERIAL1_* doesn't match its real GPS wiring will break the same way, so it may be worth a check.

The new switch handling works well: off at boot in the middle position, on at the top, and both the switch and the UI toggle power the GPS down and back up correctly.

PR with the pin fix and the ATGM336H NMEA re-enable on top of your branch: fdlamotte#1

muzi_base: fix GPS UART pins and re-enable ATGM336H NMEA output
@fdlamotte

Copy link
Copy Markdown
Collaborator Author

Tested on a Muzi Base Uno + SuperIO, following up on #3760.

As-is, the Muzi GPS gets no data: the refactor no longer calls Serial1.setPins() on nRF52, and the Muzi variant.h had PIN_SERIAL1_RX/TX swapped (main only worked because setPins(PIN_GPS_TX, PIN_GPS_RX) swapped them back). Any other nRF52 variant whose PIN_SERIAL1_* doesn't match its real GPS wiring will break the same way, so it may be worth a check.

The new switch handling works well: off at boot in the middle position, on at the top, and both the switch and the UI toggle power the GPS down and back up correctly.

PR with the pin fix and the ATGM336H NMEA re-enable on top of your branch: fdlamotte#1

Thank you very much ...

So I'll check for lost assignations I could have missed in the process ;)

@fdlamotte

Copy link
Copy Markdown
Collaborator Author

I'm restoring setPins

Think I found some way to simplify things too

@fdlamotte fdlamotte changed the title WIP: GPS refactor Big GPS refactor Nov 5, 2026

This branch has not been deployed

No deployments
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.

4 participants