This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to manually choose device to connect with same service UUID?

Hi all,

I am now using nrf52840DK and llpm example in nrf connect sdk 1.7.1.

Now I have three nrf52840DK, one as master ,and the others are slaves, they both use Latency Service UUID.

So, by this function" bt_scan_filter_add() " in  scanning module, Master will automatically select one slave with the same UUID to connect.    

What I want to is print out the device name("Slave1" , "Slave2") in PUTTY and let user select which slave to connect, Is there any suggestion to do this, plz help,thanks.

Best Regards,

Hao. 

Parents
  • Looking at scan_init() I can find that the example by default .connect_if_match = true, so that needs to be set to false.

    Then in scan_filter_match() you can likely print the information you are looking for to the user.

    Then you need to add UART handling in uart_cb() from the user by for instance looking at this answer:
    https://devzone.nordicsemi.com/f/nordic-q-a/83791/question-about-uart-configurations-for-nrf52832-and-nrf52840/348449#348449 

    You can find in scan.c example on how to connect to a peer by looking at the implementation of scan_connect_with_target(). This then needs to be added to the uart_cb() callback of the UART above.

    Best regards,
    Kenneth

  • thanks a lot, do you mean using other UART approach to connect to broad ?

    Currently I use serial port to connect to broad, can I add  bt_conn_le_create()  in scan_filter_match part after I set  

    .connect_if_match = false(In other's post, I see this approach which seems easier for me as beginner)

    What I am going to do is

    1.using uuid filter to list all the devices with the same uuid and different device name

    2.list all the devices' name on putty

    3.let user input device name and connect to that device

    If I can do by this approach, plz give me some hint using bt_conn_le_create() ,thanks a lot!!

    I will also try the approach you suggest me.

    Best regards,

    Hao

  • Feel free to modify this as you best see fit, my previous reply should provide some guideance on where you can find code that you can use for reference.

    Kenneth

  • Got it ,really thanks for your help.

    Now,I complete using bt_data_parse() in  scan_filter_match() to print out device names with same uuid,

    I originally want to add bt_conn_le_creat() to connect specific device, but this approach can't work because scan_filter_match() keep looping, could you give me some way to do this?

    Best regards

    Hao

Reply
  • Got it ,really thanks for your help.

    Now,I complete using bt_data_parse() in  scan_filter_match() to print out device names with same uuid,

    I originally want to add bt_conn_le_creat() to connect specific device, but this approach can't work because scan_filter_match() keep looping, could you give me some way to do this?

    Best regards

    Hao

Children
Related