NimBLE: Failed to restore IRKs from store

bakadave
Posts: 2
Joined: Thu Oct 26, 2023 12:39 pm

NimBLE: Failed to restore IRKs from store

Postby bakadave » Thu Oct 26, 2023 3:46 pm

I am trying to persists BLE pairing with NimBLE. Bonding perists if I restart the phone application but does not persists over ESP reset and I get the following error message:

Code: Select all

NimBLE: Failed to restore IRKs from store; status=8
  • ESP-IDF version is: 5.1.1
  • "Persist the BLE Bonding keys in NVS" is enabled in menuconfig
BLE security manager setup:

Code: Select all

    ble_hs_cfg.sm_io_cap         = BLE_SM_IO_CAP_NO_IO;
    ble_hs_cfg.sm_mitm           = true;
    ble_hs_cfg.sm_sc             = true;
    ble_hs_cfg.sm_bonding        = true;
    ble_hs_cfg.sm_our_key_dist   = BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID;
    ble_hs_cfg.sm_their_key_dist = BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID;
Any help is appreciated

irahul
Posts: 46
Joined: Fri Jun 18, 2021 10:07 am

Re: NimBLE: Failed to restore IRKs from store

Postby irahul » Mon Oct 30, 2023 8:32 am

Looks like somehow store_read_cb is not getting populated. Is there any change done at your end for the storage functions ? If not, then which IDF example are you using which shows this behaviour ?

dani987
Posts: 1
Joined: Thu Nov 23, 2023 2:27 pm

Re: NimBLE: Failed to restore IRKs from store

Postby dani987 » Thu Nov 23, 2023 2:50 pm

Hi,

Thanks irahul for pointing out to the missing store_read_cb callback. I work with the Dave on the same project and allocating callbacks to ble_hs_cfg from ble_store_config.c got us further.

Code: Select all

    ble_hs_cfg.reset_cb        = bleprph_on_reset;
    ble_hs_cfg.sync_cb         = ble_app_on_sync;
    ble_hs_cfg.store_status_cb = ble_store_util_status_rr;
    ble_hs_cfg.store_read_cb   = ble_store_config_read;
    ble_hs_cfg.store_write_cb  = ble_store_config_write;
    ble_hs_cfg.store_delete_cb = ble_store_config_delete;
Now if I wish to connect to the device with an iPhone (via nRF connect), I will get a prompt to pair the device, that's cool. Once I unplug and plug the device back in and want to establish a connection, the phone refuses to connect saying that the device has no pairing info, like the device has forgotten it.

All in all the requirements would be the following:
- Once the device is paired with a phone, the device shall not be seen by other phones even if the paired phones is out of range (now the device reappears (for an Android phone for instance) once I disconnect from phone.)
- In case multiple device are up I can see that the name of the device is changing from one name (ble interface name) to another, like some kind of key rotation would be taking place.
- I want to be able to unpair the device by pressing one of the buttons of the device (any GPIO).

Now the biggest hurdle of mine is the first bullet point.

I have attached some parts of the code. Any help is highly appreciated!

Thank you,
Dani
Attachments
Nimble.zip
(5.79 KiB) Downloaded 225 times

irahul
Posts: 46
Joined: Fri Jun 18, 2021 10:07 am

Re: NimBLE: Failed to restore IRKs from store

Postby irahul » Wed Nov 29, 2023 2:42 pm

Hi Dani,

Recently a fix was made , can you please confirm if this helps. https://github.com/espressif/esp-nimble ... 1284ae21ed

Who is online

Users browsing this forum: Bing [Bot] and 120 guests