Repository navigation
Conversation
GATT client reads and writes reported ATT errors from the peer as
"Unknown system firmware error: 261" and the like. They now go through
`check_ble_error()`, which maps the common ones:
- 0x02, 0x03: `BluetoothError("read not permitted")` / `"write not permitted"`
- 0x05: `SecurityError("Insufficient authentication")`
- 0x08: `SecurityError("Insufficient authorization")`
- 0x0C, 0x0F: `SecurityError("Insufficient encryption")`
- 0x0D: `ValueError("Invalid length")`
- other ATT errors: "Unknown gatt error: 0x01xx"
`check_nimble_error()` only sees NimBLE return codes, so its fallback now
says "Unknown BLE error" instead of "Unknown system firmware error". Both
fallbacks print the code as `0x%04x`, the form NimBLE's return-code
documentation uses (e.g. 0x0213 for HCI error 0x13).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 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.
Code by Claude, reviewed by @dhalbert.
Problems
SecurityErroror another specific exception.check_nimble_error()called unknown NimBLE return codes "system firmware" errors.Changes
bleio_gattc_read()andbleio_gattc_write()pass ATT error statuses tocheck_ble_error(), which now maps the common ones:BluetoothError: read not permittedBluetoothError: write not permittedSecurityError: Insufficient authenticationSecurityError: Insufficient authorizationSecurityError: Insufficient encryptionValueError: Invalid lengthBluetoothError: Unknown gatt error: 0x01xx(nordic's existing message)check_nimble_error()andcheck_ble_error()both print "Unknown BLE error: 0x%04x". NimBLE's return-code documentation lists codes in that form, e.g. 0x0213 for HCI error 0x13.Testing
Metro ESP32-S3 as central, Feather nRF52840 on nordic 11.0.0-alpha.1 as peripheral:
NO_ACCESScharacteristicBluetoothError: read not permittedNO_ACCESScharacteristicBluetoothError: write not permittedENCRYPT_NO_MITMcharacteristic without pairingSecurityError: Insufficient authenticationfixed_lengthcharacteristicValueError: Invalid length0x08, 0x0C and other ATT errors could not be produced with a CircuitPython peripheral.
Not changed
connect()to an absent device usually returns aConnectionthat is not connected instead of raising. That will be a separate PR.