espressif / esp-nimble

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

Nimble RPA/NRPA Timeout error #52

Closed veneno-529 closed 1 year ago

veneno-529 commented 1 year ago

I have been using bleprph example. I tried enabling RPA to so that I won't have to pair it again and again. Below is the configuration I did in bleprph_on_sync funtion. Note : own_address is set to BLE_ADDR_RANDOM. `ble_hs_pvcy_rpa_config(true); rc = ble_hs_util_ensure_addr(1); assert(rc == 0);

/* Figure out address to use while advertising (no privacy for now) */
rc = ble_hs_id_infer_auto(1, &own_addr_type);
if (rc != 0) {
    MODLOG_DFLT(ERROR, "error determining address type; rc=%d\n", rc);
    return;
}`

In app main file i did the below configuration. I have included the #include "host/ble_hs_pvcy.h" too. `ble_hs_cfg.reset_cb = bleprph_on_reset; ble_hs_cfg.sync_cb = bleprph_on_sync; ble_hs_cfg.gatts_register_cb = gatt_svr_register_cb; ble_hs_cfg.store_status_cb = ble_store_util_status_rr;

ble_hs_cfg.sm_io_cap = BLE_HS_IO_NO_INPUT_OUTPUT;
ble_hs_cfg.sm_bonding = 1;
ble_hs_cfg.sm_mitm = 1;
ble_hs_cfg.sm_sc = 1;
ble_hs_cfg.sm_our_key_dist = 3;
ble_hs_cfg.sm_their_key_dist = 3;`

After doing this configuration when I connect my android for the first time it pairs , bonds and can access characteristic. If I disconnect or turn off - on bluetooth or restart esp32 then I have to forget the old bond repair it. The whole idea of RPA is to avoid this thing but it seems to be not working in my case.

When viewing logs I observed D (183546) NimBLE: RPA/NRPA Timeout; start active adv & scan with new Private address ␛[0m ␛[0;32mI (183546) NimBLE: GAP procedure initiated: stop advertising.

Also HCI lld_pdu_get_tx_flush_nb HCI packet count mismatch (1, 2) error is displayed when I disconnect after pairing and try to reconnect.

I'm kinda hardstuck on this issue please help me out. It's been a week. I've been going through many open issues I've tried their solutions but none of them seem to work. I'm using esp idf v4.4.2 and nimble version 1.3.0. I'm developing my project using platformio esp idf framework