Dev - #3
Merged
Merged
Conversation
jonasniesner
pushed a commit
that referenced
this pull request
Jul 19, 2026
#108) * fix(ble): defer NimBLE onConnect/onDisconnect work to loop() (race audit #1-3,6) The Bluedroid->NimBLE migration left heavyweight, state-mutating work running inline inside the ESP32 server callbacks on the NimBLE host task, racing the Arduino loop() task. Make the callbacks flag-only and service the flags from loop(), mirroring the existing bleRestartAdvertisingPending pattern. - onDisconnect: EPD session teardown (bbepSleep/delay/SPI.end + rail cut), partial + pipe cleanup, and resetPipeWriteState() ran on the host task while loop() streamed SPI via bbepWriteData and processed pipe frames. The only guard (epdRefreshInProgress) covered the refresh phase, not streaming. Now sets bleDisconnectCleanupPending; serviced by serviceBleDisconnectCleanup() in loop() (preserving the epdRefreshInProgress deferral), run before the advertising restart. (#1 critical, #2 high, #6 medium) - onConnect: updatemsdata() polled I2C and mutated the shared advertisement vector that loop() also drives on its 60s cadence -> heap corruption. Now sets msdUpdatePending; loop() calls updatemsdata(). (#3 high) - updatemsdata(): drop the connected-branch that rebuilt *advertisementData but never pushed it via setAdvertisementData() -- dead work, no behavior change. All ESP32-guarded; nRF/Bluefruit path untouched. Builds clean on esp32-s3-N16R8, esp32-c3-N16, nrf52840custom. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Replace protocol magic numbers with canonical named constants Follow-up to the header vendoring (3f09f6d): sweep the remaining hand-coded protocol literals across the BLE command handlers and use the constants from the vendored opendisplay_protocol.h. Value-for-value, no wire-behavior change; all CI envs build clean. - encryption.cpp: auth-status frames -> RESP_ACK/RESP_AUTHENTICATE + AUTH_STATUS_*; CCM envelope sizes -> BLE_CMD_HEADER_SIZE/ ENCRYPTION_NONCE_SIZE/ENCRYPTION_TAG_SIZE (handshake nonces left as-is). - communication.cpp: handler response codes -> RESP_* (incl. RESP_AUTH_REQUIRED); config limits -> CONFIG_CHUNK_SIZE*/ MAX_CONFIG_CHUNKS/MAX_RESPONSE_DATA_SIZE; envelope sizes. - device_control.cpp / buzzer_control.cpp: LED, deep-sleep, and buzzer ack/nack frames -> RESP_*. - display_service.cpp: direct-write/refresh frames -> RESP_DIRECT_WRITE_*; pipe-start errors -> OD_ERR_PIPE_START_*; deleted the local ERR_* shadow copies of OD_ERR_PARTIAL_* in favor of the canonical names. Pipe/partial-write opcode-echo bytes (0x76/0x80/0x81/0x82), the pipe data-phase error codes, and the START response-flags bit stay raw with TODO(protocol) markers: the canonical header defines no RESP_* mirror or data-phase error namespace for them yet. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.
No description provided.