Skip to content

Short sleeps when phone disconnects#11

Open
weebl2000 wants to merge 6 commits intodevfrom
short-sleeps-when-phone-disconnects
Open

Short sleeps when phone disconnects#11
weebl2000 wants to merge 6 commits intodevfrom
short-sleeps-when-phone-disconnects

Conversation

@weebl2000
Copy link
Owner

PR meshcore-dev#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


Mirror of meshcore-dev#1686

@weebl2000 weebl2000 force-pushed the short-sleeps-when-phone-disconnects branch from 0f64ac5 to 0473b6b Compare February 28, 2026 18:05
weebl2000 and others added 6 commits February 28, 2026 19:07
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.
@weebl2000 weebl2000 force-pushed the short-sleeps-when-phone-disconnects branch from 0473b6b to 4d49849 Compare March 3, 2026 14:39
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