feat: send 0x71 image-data chunks with BLE write-without-response (+ deep sleep command)#126
Merged
Merged
Conversation
Add the deep-sleep command to put a device into deep sleep, plus a convenience predicate for detecting sleep-configured devices. This is Phase 0 of the OpenDisplay deep-sleep plan (D9). - CommandCode.DEEP_SLEEP = 0x0052 and build_deep_sleep_command() - OpenDisplayDevice.deep_sleep(): sends 0x0052 and tolerates the link dropping during/after the command (ESP32 power-latch ACK-then-power-off, ESP32 no-latch immediate sleep, Silabs Flex ACK-then-close-and-EM4). A disconnect or missing ACK is treated as success; an explicit 0xFF52 not-supported error frame raises ProtocolError. - PowerOption.deep_sleep_enabled: power_mode == BATTERY and deep_sleep_time_seconds > 0, mirroring the firmware sleep-entry condition. - CLI: `opendisplay sleep <device>` subcommand. - Unit tests for the builder, the device method (all firmware response shapes), and the config predicate. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
feat: add deep sleep command (0x0052)
Switch DIRECT_WRITE_DATA (0x71) chunks from write-with-response to BLE Write Without Response, removing the ATT write-confirmation round-trip per chunk (~2x fewer round-trips, largest win over an ESPHome BLE proxy). The per-chunk application ACK is still awaited, so exactly one write is in flight and firmware flow control is preserved — no firmware change is required. Both ESP32 (PROPERTY_WRITE_NR) and nRF (BLEWriteWithoutResponse) already advertise the property and ACK every 0x71 chunk. write_command() takes a response flag, threaded through _write() and opted into only by the two 0x71 loops (_send_data_chunks, _send_partial_chunks). The characteristic is probed for the write-without-response property and falls back to write-with-response when it is absent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
write-without response was tested and working, but does not speed up transfers by itself. Deep sleep command is implemented but needs to be further enhanced with a "Sleep For X Seconds" to do what user intends. Otherwise if deep sleep is commanded on a target without a preconfigured sleep timer, it won't do anything on the firmware side. This update has some dependencies for the latest home assistant deep sleep integration updates. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
g4bri3lDev
approved these changes
Jul 11, 2026
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.
Summary
This PR contains two changes (two commits), with the BLE throughput change built on top of the deep-sleep command:
1. BLE Write Without Response for image-data chunks (
3f1a0c1)Switches
DIRECT_WRITE_DATA(0x71) chunks from write-with-response to BLE Write Without Response, removing the ATT write-confirmation round-trip per chunk (~2× fewer round-trips; the largest win is over an ESPHome BLE proxy, where each ATT round-trip crosses the network).PROPERTY_WRITE_NR) and nRF (BLEWriteWithoutResponse) already advertise the property and ACK every 0x71 chunk.write_command()gains aresponseflag, threaded through_write()and opted into only by the two 0x71 loops (_send_data_chunks,_send_partial_chunks). All other commands keep write-with-response.2. Deep sleep command 0x0052 (
f78908c)CommandCode.DEEP_SLEEP = 0x0052andbuild_deep_sleep_command()OpenDisplayDevice.deep_sleep(): sends 0x0052 and tolerates the link dropping during/after the command (ESP32 power-latch ACK-then-power-off, ESP32 no-latch immediate sleep, Silabs Flex ACK-then-close-and-EM4). A disconnect or missing ACK is treated as success; an explicit 0xFF52 not-supported error frame raisesProtocolError.PowerOption.deep_sleep_enabled:power_mode == BATTERY and deep_sleep_time_seconds > 0, mirroring the firmware sleep-entry condition.opendisplay sleep <device>subcommand.Happy to split these into separate PRs if preferred.
Testing
pytest tests/unit), including new tests for the write-without-response probe/fallback (tests/unit/test_connection_write_no_response.py) and the deep-sleep command across all firmware response shapes (tests/unit/test_device_deep_sleep.py).🤖 Generated with Claude Code