Thinknode M6 Repeater Enable LEDs and Function Button#2605
Open
AtlavoxDev wants to merge 7 commits into
Open
Conversation
See if we can modify the behavior so the LEDs work
…hinknode-m6-power-button
Author
|
Hey MeshCore team, this is my first ever attempt to contribute to a repo. Let me know if there are any questions or if there's something I should do differently next time. I only targeted the Repeater firmware this time, but will explore the other M6 firmware too for feature parity. Note I used Claude to assist and manually reviewed all code. Novice developer, wanted to take a stab at adding these critical features myself and contributing to the project. Tested over the past couple days. |
Remove device-specific code from the universal main.cpp file
The M6 follows a cleaner version of the existing SenseCAP Solar pattern: device-specific button logic lives in the variant (ThinkNodeM6Board::pollButton()), with a minimal dispatch call in main.cpp. The buttonStateChanged() methods on ThinkNodeM3Board, T1000eBoard, and PromicroBoard were defined but never connected to any caller — those boards could adopt the same pollButton() pattern in follow-up PRs if button UX is wanted.
Author
|
I moved as much as a could out of main.cpp. Only a couple small blocks inside main.cpp are minimal dispatch calls (board.bootComplete() and board.pollButton()) to enable boot monitoring and button functionality. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
On the original M6 repeater build:
poweroffdidn't actually sleep the chip. The original code called a SoftDevice API (sd_power_system_off()) that requires SoftDevice to be running — but SoftDevice isn't enabled in the repeater build, so the call silently failed and the chip stayed awake. No button mapped to poweroff.variant.hbut never read or armed as a wake source or poweroff.What this adds
poweroffCLI: same shutdown cue.enterDeepSleep()helper with SoftDevice/direct-register fallback. Arms Function Button asSENSE-LOWwake source.RESETREAScaptured in a priority-101 constructor (before Nordic's errata-136 workaround scrubsRESETPIN).GPREGRET2user-intent flag distinguishes deliberate shutdown from transient resets. SurvivesSYSTEMOFF, cleared by full power loss. Result: device stays off when you asked it to, but self-heals from brownouts and auto-boots when a dead battery recovers.Implementation notes
#if defined(THINKNODE_M6)-guarded.SYSTEMOFFfix but not the repeater UX.analogWritePWM-binds pins on the Adafruit nRF52 core — boot path usedigitalWriteto keep blue compatible with the existing LoRa TX LED indicator.Test plan
Verified on hardware:
poweroffover serial → realSYSTEMOFFNot field-verified:
Out of scope
EXT_PWR_DETECT/EXT_CHRG_DETECTand a wake-on-charge mode) — planned follow-up.