Skip to content

Short sleeps when phone disconnects#1686

Open
weebl2000 wants to merge 5 commits intomeshcore-dev:devfrom
weebl2000:short-sleeps-when-phone-disconnects
Open

Short sleeps when phone disconnects#1686
weebl2000 wants to merge 5 commits intomeshcore-dev:devfrom
weebl2000:short-sleeps-when-phone-disconnects

Conversation

@weebl2000
Copy link
Contributor

@weebl2000 weebl2000 commented Feb 13, 2026

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

weebl2000 and others added 3 commits February 6, 2026 02:44
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.
@towerviewcams
Copy link

I would test this in my lab and verify, put up a test bin here pls.

@weebl2000
Copy link
Contributor Author

I would test this in my lab and verify, put up a test bin here pls.

v4 companion BLE?

@weebl2000
Copy link
Contributor Author

weebl2000 commented Feb 15, 2026

I would test this in my lab and verify, put up a test bin here pls.

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

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