This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Multiperipheral UART Example

I am using 3 nrf52 DKs with S132 and SDK13 to try and implement a combination of the multilink and UART examples. I started with the ble_app_uart_c example and added the relevant code from the ble_app_multilink_central example to connect to multiple (in my case 2) peripherals via the NUS instead of the device name as it does in the multilink example. I programmed the two peripherals with the standard ble_app_uart example code, and it works -- the peripherals connect and I can see that the central has assigned connection handles to each of the devices.

However, when I try to send data from the peripherals to the central via a terminal I only get the output from one peripheral, and it's always the one that connected first. BUT if I connect both peripherals, and then unpower the one that connected first, the second one starts to work.

Has anyone seen this problem? One possible clue is the handles for the two devices. Namely, the nus_* handles are all zero for the second device. Could this be the problem?

The first peripheral: {uuid_type = 2 '\002', conn_handle = 0, handles = {nus_tx_handle = 18, nus_tx_cccd_handle = 19, nus_rx_handle = 16}, evt_handler = 0x22121 <ble_nus_c_evt_handler>}

And the second: {uuid_type = 2 '\002', conn_handle = 1, handles = {nus_tx_handle = 0, nus_tx_cccd_handle = 0, nus_rx_handle = 0}, evt_handler = 0x22121 <ble_nus_c_evt_handler>}

Parents
  • I found the problem with my code:

    The two lines in ble_nus_c_evt_handler should actually have been:

    ble_nus_c_handles_assign(p_ble_nus_c, p_ble_nus_evt->conn_handle, &p_ble_nus_evt->handles);
    ble_nus_c_tx_notif_enable(p_ble_nus_c);
    

    I was treating the pointer passed to ble_nus_c_evt_handler like the global variable m_ble_nus_c and trying to index into it, when in fact I already had the client handle.

Reply
  • I found the problem with my code:

    The two lines in ble_nus_c_evt_handler should actually have been:

    ble_nus_c_handles_assign(p_ble_nus_c, p_ble_nus_evt->conn_handle, &p_ble_nus_evt->handles);
    ble_nus_c_tx_notif_enable(p_ble_nus_c);
    

    I was treating the pointer passed to ble_nus_c_evt_handler like the global variable m_ble_nus_c and trying to index into it, when in fact I already had the client handle.

Children
No Data
Related