Why do you think it does not work?
BLE Security Passcode
-
- Posts: 2
- Joined: Sat Jun 06, 2020 5:44 pm
Re: BLE Security Passcode
Hi chegewara, could you explain in a bit more detail where to use this or the idf demo? I am having the same troubles as the others.
Thanks for all your efforts btw!
Re: BLE Security Passcode
If you need arduino with static pass key then take this example and use it. If it not works, then please give us more detail, why its not working, what peer device you are trying to connect with.
If you need esp-idf code here is example:
https://github.com/espressif/esp-idf/bl ... #L555-L575
If you need esp-idf code here is example:
https://github.com/espressif/esp-idf/bl ... #L555-L575
-
- Posts: 2
- Joined: Sat Jun 06, 2020 5:44 pm
Re: BLE Security Passcode
I did read the same highlighted lines you mentioned earlier but I don't know where to put them.
What I did is:
in Arduino/libraries/ESP32-BLE-Keyboard I changed the secutiry to:
and in packages/esp32/hardware/esp32/1.0.4/libraries/BLE/src I pasted the implementation of the method.
It compiles and uploads to the esp32, but when I try to connect from my android phone to it: a message on the phone pops up and gives me a random 6-digit code and disappears immediately.
I was hoping that setting the capability to ESP_IO_CAP_NONE would make it so I don't need to do any I/O on the esp32 for pairing.
I want to just input a hardcoded pin on the phone to connect to the esp32.
Thanks for your time!
What I did is:
in Arduino/libraries/ESP32-BLE-Keyboard I changed the secutiry to:
Code: Select all
BLESecurity *pSecurity = new BLESecurity();
pSecurity->setCapability(ESP_IO_CAP_NONE);
pSecurity->setStaticPIN(123456);
pSecurity->setAuthenticationMode(ESP_LE_AUTH_REQ_SC_ONLY);
Code: Select all
void BLESecurity::setStaticPIN(uint32_t pin)
It compiles and uploads to the esp32, but when I try to connect from my android phone to it: a message on the phone pops up and gives me a random 6-digit code and disappears immediately.
I was hoping that setting the capability to ESP_IO_CAP_NONE would make it so I don't need to do any I/O on the esp32 for pairing.
I want to just input a hardcoded pin on the phone to connect to the esp32.
Thanks for your time!
Re: BLE Security Passcode
Example with static pin is very simple and it works. All you have to do is to add 2 lines to your code:
https://github.com/nkolban/esp32-snippe ... ticPIN.ino
Code: Select all
BLESecurity *pSecurity = new BLESecurity();
pSecurity->setStaticPIN(123456);
Re: BLE Security Passcode
Hi, I'm successfully BLE Security class with passcode as suggested by chegewara, anyway I need to restart advertising after the disconnection of my client (a smartphone) from my ESP32 devkit C board (server).
When the disconnection event (ondisconnect()) is detected, I restart advertising doing this:
My problem is that the bonding information seems not retained, because if I try to reconnect the smartphone the server requires a new authentication with password, instead I want to bypass that step because the devices are already bonded.
My sequence:
- provide power supply to the board (server)
- connect with client and request a characteristic read: server requires authentication (OK)
- read characteristic (OK)
- smartphone request disconnection => server restart advertising (OK)
- smartphone try to reconnect and request a characteristic read: server requires authentication (NOK: I want to connect without reauthentication procedure)
When the disconnection event (ondisconnect()) is detected, I restart advertising doing this:
Code: Select all
pServer->startAdvertising();
My sequence:
- provide power supply to the board (server)
- connect with client and request a characteristic read: server requires authentication (OK)
- read characteristic (OK)
- smartphone request disconnection => server restart advertising (OK)
- smartphone try to reconnect and request a characteristic read: server requires authentication (NOK: I want to connect without reauthentication procedure)
Who is online
Users browsing this forum: Bing [Bot] and 149 guests