connecting to a specific peripheral in the UART sample code

Hi, 
I am currently working on UART sample codes and have 2 nrf5340 Audio DKs . One acts as peripheral and another as Central.
i want to modify the central board to connect to a specific Peripheral. I am working on a project where multiple people have similar boards and we always have to connect to the unnecessary ones using our mobile apps for the central to connect to the desired board.
 Can you guide me in resolving this issue?

Thanks & Regards

  • Hello,

    So if I understand correctly, you want to have a pair of devices to always connect to each other, even though there are similar devices in the vicinity, correct?

    There are several different approaches for this.

    1: You can have them use different service UUIDs, and one pair will advertise with this UUID, and the scanner will search for this UUID. This would require the devices to be pre-programmed with this specific UUID.

    2: You can use different advertising names. This is probably the easiest one to implement. Either have the user decide the name, or pre-program some default name followed by an ID (last 3 bytes of the BLE address, for example). The central will look for this specific name only. This would require the central to know what BLE name to look for.

    3: You can use the BLE address directly as a filter. Then the content of the advertisement is almost redunant. This would require the address of the peripheral to be programmed into the respective central. 

    4: you can pre-bond the devices during production. This can be done either by starting up two and two devices, and have them automatically bond. Another alternative is to have them "force save" bonding information during the first boot, if they see that they don't have any bonding data from before. This would require some shared secret to be programmed into each pair of devices.

    After they are bonded, you can have them exclusively look for, and only accept, devices that are already bonded.

    Almost all of these suggestions requires the users to either insert some information before building the application, or for you to pre-program some information into each pair. I don't know what your use case is. Are you developing some product that is sold in pairs, and you want this set up before shipping? Or do you want the users to specify at the first boot what device to connect to? And is security a big deal? What if I, as a user discovers that the device is looking for a specific address, and I build my own device using the same address as the peripheral. Is that a concern for you?

    Best regards,

    Edvin

Related