Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TW#25833] unable to set password in gatt_security_server example #2322

Closed
sw-dev-code opened this issue Aug 23, 2018 · 15 comments
Closed

[TW#25833] unable to set password in gatt_security_server example #2322

sw-dev-code opened this issue Aug 23, 2018 · 15 comments

Comments

@sw-dev-code
Copy link

Hi everyone,

I want to implement BLE security using password authentication. My device don't have Display or Keyboard and I want to connect to it using Android. My idea is to enter six digit key on Android side which I manually set in ESP firmware.

For start I'm using gatt_security_server example from ESP-IDF and I can't find the way to manually set BLE password, every time ESP generates random six digit password.

Is there a way to set manual password and to disable random password generation in gatt_security_server example?

Thank you all for advises in advance.

@FayeY FayeY changed the title unable to set password in gatt_security_server example [TW#25833] unable to set password in gatt_security_server example Aug 28, 2018
@Weijian-Espressif
Copy link
Collaborator

@MIlan991 I have added an API to set static passkey, it will be merged into IDF next week.

@sw-dev-code
Copy link
Author

@Weijian-Espressif Great, thank you.

@sw-dev-code
Copy link
Author

Solved in 892fc4a.

@chegewara
Copy link
Contributor

@Weijian-Espressif thanks for that feature

@chegewara
Copy link
Contributor

@Weijian-Espressif
I have to add, probably its how it suppose to be, but this only works with 6 digit passkey.

@Weijian-Espressif
Copy link
Collaborator

The spec define:
Numeric value (passkey) entered by user. Valid values are decimal 000000 - 999999.

for example:
uint16_t passkey = 123;
esp_ble_gap_set_security_param(ESP_BLE_SM_SET_STATIC_PASSKEY, &passkey, sizeof(uint16_t));

for some phones , it is ok that you enter 123, but some other phones maybe need you enter 000123.

@chegewara
Copy link
Contributor

@Weijian-Espressif I did test and for me works only 0 or 000000 and all 6 digit values. Ive been trying 1234 and 12345 but could not pair/bond with nRF connect android smartphone.

I did not try 001234 on smartphone because with dynamic passkey when i have had 5 digit passkey it was enough to validate without leading 0. I will try with leading 0's and leave feedback.

PS i am using uint32_t instead, but it should not be an issue.

@chegewara
Copy link
Contributor

@Weijian-Espressif
I can confirm, leading 0s help and it works. Thanks.

@marcolettieri
Copy link

I 'm using the example server gatt security...with iphone and android with NRF app it connects without prompt passkey... already checked if i've the last commits

@chegewara
Copy link
Contributor

Im guessing you have this setting not changed:
https://github.com/espressif/esp-idf/blob/master/examples/bluetooth/gatt_security_server/main/example_ble_sec_gatts_demo.c#L557

It needs to be changed to ESP_IO_CAP_DISPLAY if i remember.

@marcolettieri
Copy link

marcolettieri commented Nov 7, 2018 via email

@chegewara
Copy link
Contributor

Yes, thats the one.

@marcolettieri
Copy link

but why static passkey changes?
i receive the passkey Notify number overwrite my passkey

@chegewara
Copy link
Contributor

@chegewara
Copy link
Contributor

I dont know, i just copy pasted this part of code to my (Kolban's) library and it works like expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants