← index #13599PR #6651
Related · high · value 0.681
QUERY · ISSUE

The BLE.Config gives `ValueError: unknown config param` with pairing parameters

openby brianreinholdopened 2024-02-05updated 2024-02-15
bug

When running the example 'ble_bonding_peripheral.py' on the PICO-W the BLE.config method (line 70) gives ValueError: unknown config param. This error is repeated for all the pairing parameters. Given that it occurs at the low level, the aioble library gives the same result when calling the pairing methods.

Reproduce: Run the ble_bonding_peripheral.py example on the PICO-W (all I have).

  • firmware file name: firmware.uf2 (according to a Bing AI search)
  • git commit: 9b8c64c
  • version: 3.4.0; MicroPython v1.22.1 on 2024-01-05
CANDIDATE · PULL REQUEST

extmod/modbluetooth: Add pairing/bonding support.

closedby jimmoopened 2020-11-26updated 2021-05-30
extmod

WIP, looking for feedback on the approach.

Much of this work was done by @andrewleech in #6289, #6312, and #6447. This PR changes:

  • Moved the bonding secret store into Python (via _IRQ_GET_SECRET and _IRQ_SET_SECRET events).
  • Adds characteristic flags to enable auto-pairing (e.g. READ_ENCRYPTED)
  • Adds passkey authentication.
  • gap_pair just takes conn_handle, and pairing/bonding parameters are set via config().
  • Documentation

Currently only supported on NimBLE on STM32 and Unix, as it requires synchronous (non-ringbuffer) events. Enabled via MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING macro (which is now enabled by default for NimBLE STM32/Unix). Some BlueKitchen support is implemented, but will need to wait until it's migrated to synchronous events. The secret store is designed to be compatible with BlueKitchen's TLV store API.

Tested against Android and BlueZ.

This PR adds:

  • Better error handling for oversize characteristic reads.
  • An _IRQ_CONNECTION_UPDATE event. Not specifically related to pairing and bonding, but useful information about the connection state.
  • An _IRQ_ENCRYPTION_UPDATE event to get notified about pairing/bonding state change.
  • Widens characteristic flags to 16-bit and allows for setting encryption/authentication/authorisation requirements.
  • Allows the user to fail the read request IRQ with a custom error code.
  • Configuration of pairing/bonding parameters (le_secure, bond, mitm, io)
  • gap_pair() method to initiate pairing.
  • _IRQ_GET_SECRET and IRQ_SET_SECRET events for persistent key management.
  • Simplify the handing of numeric arguments in invoke_irq_handler (used in synchronous events).
  • An _IRQ_PASSKEY_ACTION event to be notified of an authentication request.
  • gap_passkey() method to respond to an authentication request.
  • ble_bonding_peripheral.py example, showing implementation of key persistence and authentication. (WIP)

Four major outstanding pieces:

  • Write multi-test.
  • Support address resolving in central mode (perhaps via a _IRQ_RESOLVED_SCAN_RESULT event)
  • Improve handing of RPA mode. NimBLE doesn't seem to support using a non-fixed IRK (see https://github.com/apache/mynewt-nimble/issues/887)
  • PYBD doesn't work with RPA mode. (Works fine on Unix+Zephyr and WB55)

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied