Popup pin on connection vs writing to a characteristic as in the Dev Academy lesson

I was following this lesson on paring and passkey authentication:

Exercise 1 - Nordic Developer Academy (nordicsemi.com)

Is there a way to get the popup for the pin to appear on connection vs trying to write to a characteristic?

  • Hi Leo,

    To have the  popup for the pin to appear on connection, you will need to set the security requirements of the connection itself to require pairing.
    The pairing process and the popup are handled by the Bluetooth stack of your OS and not directly by the application. So, triggering the pairing process upon connection might depend on the capabilities of the specific Bluetooth stack of the operating system you are using. Please take a look at this ticket and let me know how it goes: https://devzone.nordicsemi.com/f/nordic-q-a/98970/how-to-get-passkey-on-bluetooth-terminal?ReplySortBy=CreatedDate&ReplySortOrder=Ascending 

    -Priyanka

  • I read the link. Thank you. It doesn't make sense to me that "To be able to trigger the phone to pair with your device you would need to read/write a characteristic that requires encryption/pairing." Why doesn't this happen on a connection? Also, what if I want all characteristics to require identity, does the passkey just happen once for all of them? What if there are multiple services each with multiple characteristics, can the passkey be added once?

    It somehow doesn't make sense for me that an unauthorized central can connect at all.

  • Hi Leo,

    lcj said:
    It doesn't make sense to me that "To be able to trigger the phone to pair with your device you would need to read/write a characteristic that requires encryption/pairing." Why doesn't this happen on a connection?

    This means that the central device (phone) will initiate pairing if it attempts to access a characteristic that requires a secure connection. The characteristic itself doesn't handle the pairing but enforces it by not allowing access unless pairing is complete.

    lcj said:
    what if I want all characteristics to require identity, does the passkey just happen once for all of them? What if there are multiple services each with multiple characteristics, can the passkey be added once?

    Pairing usually happens once per connection. Once devices are paired, they establish an encrypted connection for all interactions, not just for one characteristic.
    You don’t need to pair separately for each characteristic or service. After pairing, all characteristics that require encryption will use the established keys and security settings.

    lcj said:
    It somehow doesn't make sense for me that an unauthorized central can connect at all.

    An unauthorized central device cannot access characteristics that require pairing or encryption if it hasn't gone through the pairing process.
    If a central device can connect but doesn't have the necessary security credentials, it will not be able to read or write to characteristics that are protected by pairing.

    -Priyanka

Related