Repository navigation
Conversation
`check_gatt_status()` now maps the same ATT errors as espressif:
- 0x02, 0x03: `BluetoothError("read not permitted")` / `"write not permitted"`
- 0x08: `SecurityError("Insufficient authorization")`
- 0x0C: `SecurityError("Insufficient encryption")`, like 0x0F
- 0x0D: `ValueError("Invalid length")`
Other ATT errors still report "Unknown gatt error: 0x01xx". Statuses
outside the ATT range, such as `BLE_GATT_STATUS_UNKNOWN`, now report
"Unknown BLE error" instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`bleio_gattc_write()` sent a write request and returned without waiting for the response, so an error from the peer was never seen and the write appeared to succeed. It now waits for `BLE_GATTC_EVT_WRITE_RSP` (or a disconnect) and passes the status to `check_gatt_status()`, as `bleio_gattc_read()` does. Writes without response are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
If the connection dropped during `bleio_gattc_read()`, the `bleio_check_connected()` check raised before the event handler was removed. The handler stayed registered with a pointer to the dead stack frame, and wrote through it on the next disconnect event. Remove the handler first. Co-Authored-By: Claude Opus 5.5 <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.
Diagnosis and code by Claude, reviewed by @dhalbert.
Error reporting
check_gatt_status()printed only insufficient authentication and encryption errors with readable text. Every other status, including ones that are not ATT errors, reported "Unknown gatt error".BluetoothError: read not permittedBluetoothError: write not permittedSecurityError: Insufficient authenticationSecurityError: Insufficient authorizationSecurityError: Insufficient encryptionValueError: Invalid lengthBluetoothError: Unknown gatt error: 0x01xxBLE_GATT_STATUS_UNKNOWN, raise "Unknown BLE error: 0x%04x".Bug fixes
bleio_gattc_write()did not wait for the response to a write request, so errors from the peer were never reported, and a rejected write appeared to succeed.BLE_GATTC_EVT_WRITE_RSPor a disconnect and checks the status. Writes without response are unchanged.bleio_gattc_read(), its event handler stayed registered with a pointer to a dead stack frame, and wrote through it on the next disconnect event.Testing
Feather nRF52840 with this PR, Metro ESP32-S3 on espressif
mainplus #11552:NO_ACCESS, unpaired read ofENCRYPT_NO_MITM, over-length write tofixed_lengthread not permitted,write not permitted,Insufficient authentication,Invalid lengthENCRYPT_NO_MITM, over-length write tofixed_lengthInsufficient authentication,Invalid lengthble_uart_echo_test.py/ble_uart_echo_client.pyfrom the BLE library examples, both directionsConnectionError, then no problems