BLE Pairing with a button

JilChab
Posts: 1
Joined: Fri Feb 01, 2019 10:05 am

BLE Pairing with a button

Postby JilChab » Fri Feb 01, 2019 10:18 am

Hi,

I am currently working on a project where I need to have a Bluetooth connection with an app. My ESP32 is a secure GATT Server and I would like to get this behaviour:

- If the phone (the central) is not bonded yet, it can start the secure connection only if the user press a button (like a pairing button).

- If the phone is already bonded, it can connect to the esp32 without the need to press any button.

The BLE code is directly based on the Secure GATT Server Example, with MITM encryption and the Just Work method (I just have a button).

Does anyone have ever try to get this behaviour ?

bpfeiffer
Posts: 2
Joined: Wed Mar 27, 2019 6:26 am

Re: BLE Pairing with a button

Postby bpfeiffer » Wed Mar 27, 2019 6:56 am

Hi,

you found a solution for this?
I'm working on a simmilar project like this.

beni0664
Posts: 4
Joined: Fri Feb 10, 2017 1:11 pm

Re: BLE Pairing with a button

Postby beni0664 » Thu Jul 02, 2020 10:53 am

Hi @all,

I have the same request/problem with denying devices to pair with the ESP32.

I've tried to return false with esp_ble_gap_security_rsp
on the GAP event ESP_GAP_BLE_SEC_REQ_EVT.

But this event seems to never occur.

Events on pairing are:
ESP_GAP_BLE_KEY_EVT
ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT
(Android).

Nevertheless, I don't see a possibility to deny a connection there....

Do you have any suggestions how to solve this problem?

Best regards

beni0664
Posts: 4
Joined: Fri Feb 10, 2017 1:11 pm

Re: BLE Pairing with a button

Postby beni0664 » Thu Jul 02, 2020 12:41 pm

Another approach I was thinking of:

-) Use different advertising policies: ADV_FILTER_ALLOW_SCAN_ANY_CON_WLST or ADV_FILTER_ALLOW_SCAN_WLST_CON_WLST if no public pairing should be possible, ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY if in pairing mode
-) If a connection is established, add the BT-MAC to the whitelist

BUT: whitelisting seems to be broken for random addresses (used on Android):

https://github.com/espressif/esp-idf/issues/1368
https://github.com/espressif/esp-idf/issues/2262

The comments of Espressif state, that this is a hardware bug?!?
It seems there is no possible fix for this.

@Espressif: any updates/roadmap for this bug? Or is the whitelist option simply not possible with ESP32D0WDQ6 rev0 and we have to wait for another chip revision?

felixcollins
Posts: 125
Joined: Fri May 24, 2019 2:02 am

Re: BLE Pairing with a button

Postby felixcollins » Sun Feb 20, 2022 9:54 pm

Has anyone looked at this again with IDF 4.4?

Who is online

Users browsing this forum: Baidu [Spider] and 74 guests