Minimum pairing key size [BLE]

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

Minimum pairing key size [BLE]

Postby phantomBlurrr » Wed Nov 13, 2019 2:25 pm

Hello,
I am getting some seriously strange behavior from BLE. When I set the pairing key on the esp to 4 digits the esp can successfully pair as long as the connecting device is iOS. However, if we try to pair an android device the pairing process fails. On an android device, we must pad the key input with two zeros in order for the pairing process to succeed.

For example: ESP BLE pairing key is set to 252525 (6 digits). iOS and Android can connect by input 252525, the pairing process succeeds.

For example: ESP BLE pairing key is set to 2525 (4 digits). iOS can input 2525 and the pairing process will succeed. Android can input 2525 and the pairing process will FAIL. Abdroid can input 002525 and the pairing process will succeed.

Is there a pairing key limitation that I missed or what? Does anyone have any insight into what might be happening here?

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

Re: Minimum pairing key size [BLE]

Postby chegewara » Thu Nov 14, 2019 12:07 pm

I cant find it now, but long time ago i asked the same quetion on github and answer is that you need to add 0s in front to have 6 digits long pin. I dont know why.

ESP_sushant
Posts: 8
Joined: Mon Aug 26, 2019 6:10 am

Re: Minimum pairing key size [BLE]

Postby ESP_sushant » Sat Nov 16, 2019 1:45 pm

As per spec Bluetooth, BLE passkey needs to be 6 digits long when using LE passkey entry pairing procedure.
You might be getting it confused with 4 digit PIN used in case of Bluetooth Classic pairing procedure.
Android devices are behaving correctly by rejecting the 4-digit key.
0's appended at the beginning of the passkey are allowed by the spec, but total number of digits should be 6.
In ESP-IDF code comments, I can see the mention of 6-digit passkey.
Please let me know where you are able to set the 4-digit passkey in ESP-IDF; I will check if any fix is needed in the code.
Thanks!

Who is online

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