mongoose-os-libs/bt-common

Requesting encryption to an already paired device

Opened this issue · 0 comments

In the file esp32_bt_gatts.c, the if-statement on row 453 checks the currently set security level, and then sends an encryption request to the device.

However, this check is not necessary when a device is already paired, correct? The ESP32 should already know the encryption keys when the device is found in the list?

I am currently running into an issue where the bt-common library is fully functional on Android devices when pairing and reconnecting, but not on iOS devices. iOS devices seem to only work when pairing for the first time. At a reconnect, iOS will not trigger the ESP_GAP_BLE_AUTH_CMPL_EVT event (<-- this is assumed, there is no log when the "continue" triggers in line 723).

Adding !is_paired(p->remote_bda) to row 453 in esp32_bt_gatts.c seems to fix this issue, making it effectively: if (sec_act != 0 && !is_paired(p->remote_bda)) {

Is this solving this issue the wrong way? Or is this a bug in esp32_bt_gatts.c? It just does not seem logical to me to request encryption again for an already paired device. With this change, everything now works fine on Android and iOS.

My settings:

  • bt.gatts.min_sec_level = 1
  • bt.gatts.require_pairing = true