NRF52 BLE peripheral- pairing and bonding questions in NCS

Hi

I am working on a BLE project and it requires some specific functionalities. I am not sure if all of them are doable. I have some questions about these. So, if someone could answer them, it would be very much helpful. I am using NRF52832 and 840 with NCS 2.1.x

1) I have a bluetooth android application and my NRF52 is my peripheral. What i want to do is every time my application attempts to connect to the NRF52 peripheral, it must be prompted to enter a passkey which is known at the NRF52 side. From what I understand, it is the central which initially enforces the passkey, which in my case is my phone. Is there some way I can do the other way around ? i.e configure my peripheral to enforce that the user should enter a passkey to connect with it ? If yes, how can it be done ? Is there an example I could refer to ?

2) My second idea is to update the passkey in discussion dynamically through an i2c channel. We can update the device information service parameters on the fly. Is there a similar functionality in case of BLE passkeys too ? I mean, can I send a new passkey via I2C or some other interface and use that as the new passkey so that the next time my application tries to connect, my peripheral would enforce the new passkey ?

I am pretty much new to all these and I am sorry for any dumb questions. But any help would be appreciated. Thanks in advance !!

Parents
  • Hello,

    AFAIK, Your use case is possible but I don't have dedicated sample which I can point to you in NCS. But this sample from our old SDK shows your use case.

    Coming to NCS you can refer to this thread from my colleague showing how to implement a pass key while establishing a connection. Keep this blog as reference for building the application in NCS.

    Please let me know if you need more clarification or help on this.

    Kind Regards,

    Abhijith

  • Hi, thanks for the links given. They helped me to get a basic idea and I got the static passkey functionality to work. There is one more thing that I want though. Right now, I have to explicitly use the BOND function in the NRF Connect android application for the fixed passkey functionality to work. What I want to do is that whenever I try to CONNECT the device, the prompt for the fixed passkey must be shown. Not only for bonding but just for connecting too. Is it possible ?

    For the same application, I tried using the same changes as suggested in this thread. However, it didnt work out as I expected it to. It connects and then disconnects itself almost instantly. This is the log.

    Bluetooth initializedConnected 72:83:E0:51:81:1D (random) Disconnected: 72:83:E0:51:81:1D (random) (reason 19)

    Can someone please guide me here ?

  • Hello,

    Sorry for the late response. I was on my vacation last week

    Midhunjac said:
    What I want to do is that whenever I try to CONNECT the device, the prompt for the fixed passkey must be shown. Not only for bonding but just for connecting too. Is it possible

    Did you mean a notification for entering the passkey for making the connection/bond? If so it is possible, I think the sample I pointed in my last response does this. And also take a look at the peripheral_bms sample in NCS which is only one according to your use case (I guess).

    Your disconnection reason 19 is not an error. This happens when the peer decided to disconnect for some reason. Are you getting another error or reason? This can also be specific to the device you are using.

    Kind Regards,

    Abhijith

Reply
  • Hello,

    Sorry for the late response. I was on my vacation last week

    Midhunjac said:
    What I want to do is that whenever I try to CONNECT the device, the prompt for the fixed passkey must be shown. Not only for bonding but just for connecting too. Is it possible

    Did you mean a notification for entering the passkey for making the connection/bond? If so it is possible, I think the sample I pointed in my last response does this. And also take a look at the peripheral_bms sample in NCS which is only one according to your use case (I guess).

    Your disconnection reason 19 is not an error. This happens when the peer decided to disconnect for some reason. Are you getting another error or reason? This can also be specific to the device you are using.

    Kind Regards,

    Abhijith

Children
No Data
Related