Skip to content

fix: device sleep (part 1) - #3590

Merged
thebentern merged 10 commits into
masterfrom
fix-sleep
Apr 12, 2024
Merged

fix: device sleep (part 1)#3590
thebentern merged 10 commits into
masterfrom
fix-sleep

Conversation

@mverch67

@mverch67 mverch67 commented Apr 10, 2024

Copy link
Copy Markdown
Collaborator

This PR fixes some issues introduced in #3251 (e.g. router/repeater/powersave wakeup issues) and does a few debug cosmetics:

The function enableLoraInterrupt() assumes that all LORA/DIO1/CS/RESET GPIOs are RTC GPIOs which is not true (e.g. only RTC GPIOs can be used for ext0).
As a result there are error messages in the log and all devices where the DIO1 pin is not an RTC GPIO will fail to wake up from sleep when a LoRa packet is received (one packet is received though, but processed on the next scheduled wakeup).

E (221030) RTCIO: rtc_gpio_pulldown_en(129): RTCIO number error
E (72312) RTCIO: rtc_gpio_pullup_en(109): RTCIO number error
E (72313) RTCIO: rtc_gpio_pullup_en(109): RTCIO number error

This PR replaces the RTC GPIO functions by generic functions which check for RTC GPIO internally and does a check for the validity of RTC GPIOs for DIO1.

@mverch67
mverch67 marked this pull request as draft April 11, 2024 06:25
@mverch67
mverch67 marked this pull request as ready for review April 11, 2024 10:30
@mverch67

mverch67 commented Apr 11, 2024

Copy link
Copy Markdown
Collaborator Author

Tested with tbeam, t3s3, heltec v3 and heltec wireless paper. Now all wake up from router mode. In case you still experience issues in sleep mode (e.g unresponsive, noise) you'll have to do a factory reset, there may be some wrong setting.

@mverch67

mverch67 commented Apr 11, 2024

Copy link
Copy Markdown
Collaborator Author

As the PR re-introduces GPIO wakeup source for all hardware devices that don't have RTC GPIO DIO1 some code changes from #3521 had to be reverted in the same fashion as in #2412 (to avoid screen turn on with every single packet).

@mverch67
mverch67 marked this pull request as draft April 11, 2024 12:01
@mverch67
mverch67 marked this pull request as ready for review April 11, 2024 14:16
Comment thread src/sleep.cpp
#endif
#ifdef RF95_IRQ
gpio_wakeup_enable((gpio_num_t)RF95_IRQ, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high
#if defined(RF95_IRQ) && (RF95_IRQ != RADIOLIB_NC)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Technically we have targets like the T-Beam that have RF95 macros for the SX1276 and also SX126X ones, so runtime discrimination probably heads off some potential issues there hopefully.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I've tested that already. Working as expected.

@thebentern
thebentern merged commit 4c9646f into master Apr 12, 2024
@mverch67
mverch67 deleted the fix-sleep branch April 27, 2024 19:02
jeek pushed a commit to jeek/Meshtastic-Exploiteers-Hacker-Pager that referenced this pull request Jun 30, 2026
* fix sleep part 1

* always show wakeup reason in debug log

* fix screen turn on issue

* avoid unnecessary reboot when entering light sleep

* set DIO1 based on radio type

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
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.

2 participants