Identification of connected APP in NRF52840 devices.

Hello Everyone,

                           I am a beginner for working on Nordic devices. I have one query. I have to build a firmware in NRF52840. Now 2 different apps will be connecting to this NRF52840. I will be configuring NRF52840 as a peripheral device. Now there are 2 apps. Both the apps are different and have different functionality:-

1) 1st app.(APP A) -- after connection with BLE, the device will continuously send some data to this app.

2) 2nd app (APP B)- The device will start some activity after BLE authentication.

My question is how will the device(NRF52840) know which app is connected to the device? What code do I write in the device so that device will identify which app is connected to the device? Will I have to create 2 different services for 2 different apps?

Please help me on this.

Parents Reply Children
  • The hrs example has multiple services enabled and uses bonding and encryption.
    nRF5_SDK_17.0.2_d674dde\examples\ble_peripheral\ble_app_hrs

    So lets say App A Connects to the device without bonding and encryption and reads/writes from an unprotected service/characteristic.

    App B connects and bonds to the device and reads/writes to a protected service/characteristic.

    App B bonding to the device will cause a "BLE_GAP_EVT_AUTH_STATUS" event with status success. Here you will know that App B is connected and bonded.

    Maybe it might be better to actually tell the device what App is connecting to the device, through writing to a characteristic. To avoid the confusion if App A also bonds.

  • Hi I tried to test the example you shared. The NRF connect app still gets connected without any authentication. Please help me on this. 

    I was not able to compile the sdk17 version ble_app_hrs. It gave me some errors.

    tried testing with sdk15 version code. Still no authentication.

  • Hi,

    Since our DK doesn't have a display or keyboard most example does not enable the Authentication feature. but you could look at the nRF5_SDK_17.1.0_ddde560\examples\ble_peripheral\ble_app_gls example. and remember to connect to the comport to see the passkey. See Glucose Application for additional details.

  • Yes Thank you so much. I was able to test the Glucose application in sdk15. Sdk 17 I got compilation errors. I understand how the authentication works. I have 2 services for 2 respective apps in my project. So can I add the authentication only for one service in the code?

  • You can configure different security levels for different services. So it can be possible to require Authentication for only one service. But if you are planning to require bonding for the other service as well, you need to remember that the security level is "negotiated" between the devices, so after they exchange capabilities they will use the highest possible security level based on those capabilities. If you control both ends of the link I guess you could have an open characteristic that you use to tell the peer which capabilities it should use during bonding, but not sure why you would want that...

Related