BLE Security Passcode

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

Re: BLE Security Passcode

Postby chegewara » Tue Dec 31, 2019 6:33 pm

bobolink wrote:
Tue Dec 31, 2019 4:33 pm
Arduino passcode doesn’t work.
Need to use IDF examples.
Why do you think it does not work?

vs_slavchev
Posts: 2
Joined: Sat Jun 06, 2020 5:44 pm

Re: BLE Security Passcode

Postby vs_slavchev » Sat Jun 06, 2020 6:08 pm

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!

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

Re: BLE Security Passcode

Postby chegewara » Tue Jun 09, 2020 1:18 am

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

vs_slavchev
Posts: 2
Joined: Sat Jun 06, 2020 5:44 pm

Re: BLE Security Passcode

Postby vs_slavchev » Thu Jun 25, 2020 6:43 pm

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:

Code: Select all

  BLESecurity *pSecurity = new BLESecurity();
  pSecurity->setCapability(ESP_IO_CAP_NONE);
  pSecurity->setStaticPIN(123456);
  pSecurity->setAuthenticationMode(ESP_LE_AUTH_REQ_SC_ONLY);
and in packages/esp32/hardware/esp32/1.0.4/libraries/BLE/src I pasted the implementation of the

Code: Select all

void BLESecurity::setStaticPIN(uint32_t pin)
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!

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

Re: BLE Security Passcode

Postby chegewara » Mon Jul 06, 2020 7:22 am

Example with static pin is very simple and it works. All you have to do is to add 2 lines to your code:

Code: Select all

  BLESecurity *pSecurity = new BLESecurity();
  pSecurity->setStaticPIN(123456); 
  
https://github.com/nkolban/esp32-snippe ... ticPIN.ino

Who is online

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