How to get passkey on bluetooth terminal.

Hello,

I have a question regarding BLE connection with passkey.

In my sample, I have implemented  passkey and it is working fine

When starting connection and pairing process, a  passkey can display on my bluetooth settings .So ,My question is how display passkey on play store application named (Serial bluetooth Terminal).

When the pairing is start and connection with bluetooth and Passkey is display on bluetooth settings and I entered  the passkey that is connected , and in bluetooth  terminal they connected easily without asking passkey.

So, the passkey is not available that is not connected  with bluetooth terminal.

My understand is Enable the CONFIG_BT_SMP_APP_PAIRING_ACCEPT=y ,so they  set in code but they not working.

My question is , I display the  passkey in bluetooth terminal.

This is interface of bluetooth settings asking passkey.

  • Hi Abhay, 
    I'm sorry that I don't fully understand what you want to achieve here. 

    When you do passkey pairing, which device is the device that display the passkey, was it on the nRF53 or it's on the phone ? 

    You mentioned that "I have implemented  passkey and it is working fine", so what is the change you want to implement here ? 

    Do you want to display the passkey in your app and then the end user can look at your app to get the key and then enter it into the Bluetooth pairing pop up on the phone? 

    It's possible to do that by modifying your app to send the passkey via BLE to the phone and display that on the phone. However, this remove the advantage of the passkey pairing that the passkey is display in another mean than using BLE. If you do this, an attacker with a sniffer can catch the passkey and can decrypt your encryption. And also it won't be able to give you Man in the middle (MITM) protection as you can't be sure the device you talk to is the device you are looking at. 

  • When you do passkey pairing, which device is the device that display the passkey, was it on the nRF53 or it's on the phone ?

    I have 2 devices, one is the thingy53 and other is the mobile(having an app names as "Bluetooth serial terminal")..The passkey will be pre-known and already statically set in the thingy53. 
    I want that whenever a user uses the "serial terminal" app to connect to the thingy53, a popup should be shown, which says to enter the passkey in the app itself. As soon as the user enter that static passkey, board will connect to the app else will disconnect automatically.

    Paskey request will be shown on the "Bluetooth serial terminal" app or if any app will try to connect to board, it will be prompted for providing passkey.

    You mentioned that "I have implemented  passkey and it is working fine", so what is the change you want to implement here ? 

    I have added a passkey callback with this function

     bt_conn_auth_cb_register(&auth_cb_display);
        unsigned int passkey=123456;
        err = bt_passkey_set(passkey);
        if (err) {
            printk("set passkey (err %d)\n", err);
            }
    static struct bt_conn_auth_cb auth_cb_display = {
    	 .passkey_display = auth_passkey_display,
    	 .passkey_entry = NULL,
    	  .cancel = auth_cancel,
    	.pairing_confirm = pairing_confirm,
    	.pairing_complete = pairing_complete,
        .pairing_failed = pairing_failed,
    	.pairing_accept= pairing_accept,
    	
    };

    and provided a fixed passskey. Now when I tried to connect to the board from the android bluetooth setting, it asks for passkey, but I not in the case with the app, it simply connect to it.
    Do you want to display the passkey in your app and then the end user can look at your app to get the key and then enter it into the Bluetooth pairing pop up on the phone?
    No, I already explained this, the passkey is pre-set in the board, the end user will have to enter it, only and only then he will be allowed to connect to board.
    NOTE:- Please answer max. question in every reply, so that the issue will be resolved in minimum days.  
  • Hi Abhay,

    If you do passkey pairing, the popup window from Bluetooth Setting in Android/iOS is unavoidable. It's not allowed for the app to handle it. It's how it works with Android and iOS. So all the pairing is going through the OS not the app. 

    My suggestion is to do your own encryption and authentication. So basically you will do open connection (or if you want you can do Just work) and then do encryption on the application. You can have a look at this blog:  Simple Application-level Authentication 
    It cover the authentication part, you can implement encryption on top of that. 

    By the way, please note that doing static passkey is strongly not recommended, especially with LESC. It just need a few retrys (only maximum 20 times) to crack that. 

  • My suggestion is to do your own encryption and authentication. So basically you will do open connection (or if you want you can do Just work) and then do encryption on the application. You can have a look at this blog:  Simple Application-level Authentication 

    how  to implement  it.  I didn't know.

    Please suggest any code or sample regarding this problem

    Can't I get the popup for pairing request in the app? even if it supports pairing?

    Note: I am a beginner in zypher os

  • Related