This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BLE passkey connection

Hello,

Currently working with Segger 4.42 and SDK 15.0

I've searched around the devzone on doing a passkey connection between my server and central.

I've used the ble_app_gls as an example since most people use this regarding passkey connection.

The problem I'm currently facing is getting the app to work :/

In the beginning when I first compiled and tested I could connect with my phone but because I was stupid and forgot the RTT logging I disconnected, turned it on and recompiled.

This time I could actually see the key I needed to enter for the connection to be established.

After this I searched for a way to add a static key as I am unable to make device A read the serial port of device B in order to get the key.

I've found the following code: 

uint8_t passkey[] = "123456";
ble_opt_t ble_opt;
ble_opt.gap_opt.passkey.p_passkey = &passkey[0];
(void) sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &ble_opt);

This code was added in the gap_params_init() file, I tested it and it failed to make a secured connection. 

All right, I remove the code, upload it again and tested it with a random generated key.

Guess what, <info> app: Failed to secure connection. Disconnecting.

I even re downloaded the SDK and tried it again but it still failed to secure the connection.

What did I do wrong and how do I get it working with a static key?

Parents
  • Hi

    Can you provide some more information? What phone and what application (on the phone) are you using? Some services, like for example passkeys, are not natively supported on most phones. I suggest using the nRFConnect app when connecting and see if that makes a  difference

    Is there any log messages at all that you get on either the phone or nRF debug log?

    Best regards,

    Simon

Reply
  • Hi

    Can you provide some more information? What phone and what application (on the phone) are you using? Some services, like for example passkeys, are not natively supported on most phones. I suggest using the nRFConnect app when connecting and see if that makes a  difference

    Is there any log messages at all that you get on either the phone or nRF debug log?

    Best regards,

    Simon

Children
  • I am using an android 10 Nokia phone with the nRFConnect app.

    The situation is that I was able to connect the first time using my phone and the 52 dev kit, I could even disconnect and reconnect using the peer manager's bonding table. As soon as I deleted the bonding information on my phone I cannot connect to my device anymore. Even if I erase my 52 dev kit and reprogram it. It is only allowing my phone to connect if I program a completely different project first of my project I'm testing with.

    When my project reaches the "PM_EVT_CONN_SEC_FAILED" event inside the peer manager, I get the peer ID from the connection handle and I flag it to be deleted from the bonding table, followed by sd_ble_gap_disconnect. In my ble_evt_handler under disconnect it then deletes the bond. Apparently my phone's credentials are still stored somewhere as I cannot reconnect afterwards. 


    The strangest part is that a friend of mine connected and disconnected his phone multiple times without a problem, same as my windows PC which is also works fine. 

    I shall finish the client side today and see if it has the same problems as my phone or not.

Related