BLE requires another pairing process after ESP reboots? esp-idf, BLE

phantomBlurrr
Posts: 19
Joined: Mon Jun 10, 2019 4:01 pm

BLE requires another pairing process after ESP reboots? esp-idf, BLE

Postby phantomBlurrr » Thu May 28, 2020 2:40 pm

Hello,
So I'm developing an application that should exhibit very similar behavior to the bluetooth capabilities in a car. In that scenario, suppose you buy a new car and you want to connect your phone to it for the first time. You just enable pairing on the car, then connect to it on your phone, both devices exchange keys and all that, boom, the phone is paired. Then, this is my desired behavior, if you turn off the car your phone will of course lose connection with the car. Then when you turn the car back on, the phone automatically reconnects to it.

You only had to pair once and as long as your phone has bluetooth enabled, then the phone will automatically reconnect without requiring another pair sequence.

So in my project, I implemented the BLE functionality on the ESP and everything is working fine. Whenever the ESP is turn on for the first time (or reflashed) the phone can connect to it, enter the BT pin, and pair. Then if the phone disconnects by getting too far away or disabling/enabling the BT radio, the phone can reconnect and pairing is not necessary. It doesn't do that automatically but that's fine, the behavior I'm after is that it doesn't require another pairing process.

Now here's the problem: If the ESP is reboot, maybe I unplugged it from the outlet and then replugged it in the outlet or maybe the power went out and then returned, the ESP is functioning fine except when I try to reconnect a previously paired phone to the ESP, the ESP now requires another pairing process. The solution is to unpair the ESP from the Android phone paired devices list, then do the pairing process again and this will fix it. This is what I'm trying to fix, I want to make it so that you only have to pair once and that's it (unless you reflash the ESP). If the power goes out, if the device gets out of range, whatever, as long as the ESP isn't reflashed, any devices that were paired should NOT require another pairing process in order to reconnect.

So my question is, is there a setting somewhere that is telling the ESP to re-do the paired devices if there is a reboot? Maybe the paired devices list gets flushed out on reboot? Do cars have a battery that keeps BT on in order to keep the pair data between car boots? What am I missing?

chegewara
Posts: 2306
Joined: Wed Jun 14, 2017 9:00 pm

Re: BLE requires another pairing process after ESP reboots? esp-idf, BLE

Postby chegewara » Thu May 28, 2020 9:16 pm

esp_ble_auth_req_t auth_req = ESP_LE_AUTH_REQ_SC_BOND;

amoghjain
Posts: 16
Joined: Mon Nov 30, 2020 9:04 am

Re: BLE requires another pairing process after ESP reboots? esp-idf, BLE

Postby amoghjain » Thu Sep 08, 2022 6:38 am

Hi @phantomBlurrr

Were you able to figure out the solution? I am having the exact same issue,with pre-reboot bond not working with android after esp reboot.

Who is online

Users browsing this forum: No registered users and 264 guests