espressif / esp-nimble

A fork of NimBLE stack, for use with ESP32 and ESP-IDF
Apache License 2.0
76 stars 50 forks source link

NimBLE client cannot reconnect to bonded peer when both devices use RPA. #10

Closed h2zero closed 4 years ago

h2zero commented 4 years ago

Easy to reproduce, if a NimBLE client device enables RPA and bonds with a peripheral using RPA they will connect and pair/bond. However if one of them disconnects, the client will try to reconnect using the peripheral ID address, which the peripheral does not respond to.

Commenting out this section resolves the issue but does not allow the client/app to obtain the peer ID address for identification.

prasad-alatkar commented 4 years ago

Hi @h2zero Thank you for the issue and fix. I could observe the issue and yes it gets resolved with removing code block wherein we replace the peer_addr in ADV_REPORT with its stored Identity address. This should be handled in BLE_HCI_LE_SUBEV_ENH_CONN_COMPLETE. Can you please update existing PR(https://github.com/espressif/esp-nimble/pull/7) with this fix as additional commit ?

but does not allow the client/app to obtain the peer ID address for identification.

I could not face this issue. I could see ID addresses being updated in LE connection complete event. Please let me know if I am missing anything.

h2zero commented 4 years ago

What I meant by that was in the scan discovery event the client would not be able to identify the peer by ID address.

For instance if connection is lost and we were trying to reconnect. While scanning for that device it may have changed its advertising address and if we don’t resolve it to an ID we wouldn’t know if it’s the correct device.

I assume that’s the reason the code exists?