Short sleeps when phone disconnects#1686
Open
weebl2000 wants to merge 5 commits intomeshcore-dev:devfrom
Open
Conversation
Use millisHasNowPassed() (2's complement safe) instead of direct comparison, consistent with the repeater's sleep timing logic. Co-Authored-By: Wessel <weebl@users.noreply.github.com>
When BLE is enabled but no phone has been connected for 60 seconds, enter a 12s sleep / 3s awake cycle to conserve power while remaining discoverable. On wake, BLE advertising is restarted so phones can reconnect. The cycle exits immediately when a connection is detected. Adds hasPendingConnection() to BaseSerialInterface (defaults to isConnected()). The ESP32 BLE override uses getConnectedCount() > 0 to detect mid-bonding connections, preventing sleep during the authentication handshake. Guarded by #ifndef WIFI_SSID — WiFi builds are unaffected.
|
I would test this in my lab and verify, put up a test bin here pls. |
Contributor
Author
v4 companion BLE? |
Contributor
Author
You should be able to build an image here. Let me know if it doesn't work. http://mcimages.weebl.me/?commitId=short-sleeps-when-phone-disconnects |
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.
PR #1347 adds power saving for companion radios when BLE is manually disabled by the user. But when the phone simply walks away or goes to sleep, BLE stays enabled and advertising, and the radio stays fully awake. This is wasted power in a common scenario.
This adds a second power-saving mode: when BLE is enabled but no phone has been connected for 60 seconds, enter a 12s sleep / 3s awake cycle. On each wake, BLE advertising is restarted (light sleep powers down the BLE radio) so phones can reconnect. The cycle exits immediately when a connection is detected.
Tested on my Heltec v4 companion and it works. Would be good if other people can test.
Build firmware: Build from this branch