How to handle multiple simultaneous centrals with different security levels

Hello,

We are working with an NRF5340 and SDK 2.5.0. Things are generally going very well, but I think Ive hit a snag for which im not sure how to proceed.

Our device needs to handle two centrals connected simultaneously. Our device exposes two services, a custom service similar to NUS and an HID mouse service.

The challenge is that the HID mouse requires security level 2 to work, but the program that connected to the NUS-like service doesnt support security and wants just-works.

The way I handled this previously was when the input_ccc_changed would get called for the service that requires the security, I would call bt_conn_set_security.

Im not sure how to proceed here; bt_conn_set_security wants a conn* object. While I store all the connection objects in an array, I dont know how to figure out which connection object is the one that wants the security upgrade; input_ccc_changed only gets a bt_gatt_attr, and I dont see a way to link that to a conn object.

What is the correct approach here? Do you have an example of someone doing something similar I can use?

Thanks for your help?

Parents
  • Hi i_4556,

    In your scenario, you should setup the two characteristics to require different level of security. In that way, only the central with Security level 2 can access both HIDS and NUS, and the central with Just-work can only access NUS.

    Regarding differentiating the two connections, you can use bt_conn_get_dst() to get the address of the central in a connection and keep track of it.

    Hieu

  • Hello,

    thank you for your answer, but I am afraid I dont fully understand it. Do you have an example of how to set the characteristics to require different security levels, perhaps that might help me better understand, or just and example where a specific characteristic has a specific security level?

    My understanding was the usual way was to just declare everything, then connect and then after the connection was established to manually call bt_conn_set_security?

  • Hi,

    Using bt_conn_set_security() on the peripheral simply "requests" the central to establish security. Whether security is actually achieved still depends on the central.

    Also, if the characteristics themselves don't have security access requirements, then a central can still access it even if the link isn't secured.

    Changing the security requirements of certain characteristics is covered in Exercise 1, Lesson 5, of our free online course Bluetooth Low Energy Fundamentals.

    Could you please take a look at that and let me know if you have any questions?

    Hieu 

Reply
  • Hi,

    Using bt_conn_set_security() on the peripheral simply "requests" the central to establish security. Whether security is actually achieved still depends on the central.

    Also, if the characteristics themselves don't have security access requirements, then a central can still access it even if the link isn't secured.

    Changing the security requirements of certain characteristics is covered in Exercise 1, Lesson 5, of our free online course Bluetooth Low Energy Fundamentals.

    Could you please take a look at that and let me know if you have any questions?

    Hieu 

Children
No Data
Related