← index #13639Issue #8263
Related · high · value 2.013
QUERY · ISSUE

STM32: BLE Bonding Example does not work

openby hoihuopened 2024-02-11updated 2025-03-03
bugport-stm32

I'm using a Pyboad SF2 and nightly build as of
MicroPython v1.23.0-preview.90.ged15b3c6c on 2024-02-06; PYBD-SF2W with STM32F722IEK

When trying the bonding example:
https://github.com/micropython/micropython/blob/master/examples/bluetooth/ble_bonding_peripheral.py

I got the following response:

no secrets available
get secret: 2 0 None
get secret: 10 0 b'irk'
set secret: (10, b'irk') b'\xdc$W\xae\xf1I\xb9\xee\xc0\x9f\xc7\xed,\x82\t\x94'
Traceback (most recent call last):
  File "<stdin>", line 199, in <module>
  File "<stdin>", line 184, in demo
  File "<stdin>", line 81, in __init__
  File "<stdin>", line 158, in _advertise
OSError: -513

the problem seems to be related to the ble.config's addr_mode. If I uncomment the call here:
https://github.com/micropython/micropython/blob/master/examples/bluetooth/ble_bonding_peripheral.py#L75
and here:
https://github.com/micropython/micropython/blob/master/examples/bluetooth/ble_bonding_peripheral.py#L157
it doesn't throw the error.

I understand that the ble bonding is still a work in progress demo. However I wanted to have a go on implementing bonding support for the pico_w. , and for this I thought I'd first start with a working example from a supported platform (even if it's from nimble - so another ble stack than on the pico_w).

Also.. is addr_mode set to 2 required for ble bonding?

Thanks for hints and clarifications!

CANDIDATE · ISSUE

example->bluetooth->ble_bonding_peripheral.py error with NUCLEO-WB55

openby dmazzellaopened 2022-02-05updated 2026-03-19
bugport-stm32

Hi,
i have tried example/bluetooth/ble_bonding_peripheral.py with NUCLEO-WB55.

The first connection and pairing are done correctly, I can read from the feature, the device is associated with my iPhone SE (2nd Gen), but when disconnected, all subsequent connections fail.

I attach photos and logs for more details.

MicroPython v1.18-99-g203ec8ca7-dirty on 2022-02-05; NUCLEO-WB55 with STM32WB55RGV6
Type "help()" for more information.
>>> import stm
>>> stm.rfcore_fw_version(0)
(1, 2, 0, 0, 0)
>>> stm.rfcore_fw_version(1)
(1, 13, 0, 0, 5)
>>> stm.rfcore_status()
0
>>> from ble_bonding_peripheral import demo
>>> demo()
no secrets available
get secret: 2 0 None
get secret: 10 0 b'irk'
set secret: (10, b'irk') b'\xcd\xdc\xbfZQuq/\x99\x01\x00\x0e\xc9\xb2B\xae'
get secret: 2 0 None
get secret: 2 0 None
get secret: 2 0 None
passkey action 2049 4 607677
accept? 607677
encryption update 2049 1 1 1 16
set secret: (1, b'\x00\xfc-\x95\x9f\xf3\x00') b'\x00\xfc-\x95\x9f\xf3\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00D\xf9\x86\xdd\xd3\x926\xa3&\xf3\x96as\x16,D\x01\xcd\xdc\xbfZQuq/\x99\x01\x00\x0e\xc9\xb2B\xae\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00'
set secret: (2, b'\x00\xfc-\x95\x9f\xf3\x00') b'\x00\xfc-\x95\x9f\xf3\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00D\xf9\x86\xdd\xd3\x926\xa3&\xf3\x96as\x16,D\x01\xe52\xcd\xf1\x9f\xe1\xf6\x88{\xb0\x054!\xaa\xec\x1c\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00'
get secret: 1 0 b'\x00\x00\x00\x00\x00\x00\x00'
get secret: 1 0 b'\x00\x00\x00\x00\x00\x00\x00'

Pairing success:

IMG_5833

Paired with iOS device:

IMG_32F03F1DD77A-1
IMG_CA73068250EC-1

Error in second attempt of connection

IMG_56C763E58F8D-1

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