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

sending data to a particular peripheral in multi connection in central

hai ,

  i am connecting 5 peripherals in one central (used ble_central example modified like multilink central)

i referred this link for sending particular data...

https://devzone.nordicsemi.com/f/nordic-q-a/47745/multi-link-central-uart-with-multiple-peripheral/190997#190997

i can able to get connection handle for each link count ,i need to match a mac id of the device and connection handle

now my question is ,

how to send data to particular peripheral and where to choose the connection handle and mac id to send data ??

if you have any sample code on this kindly share the code

regards,

Sowmiya

Parents
  • Hi,

    Peer address can be found in connection event data passed along with BLE_GAP_EVT_CONNECTED event. You can create a map that will store connection handle and corresponding peer address for each connection.

    if (evt->header.evt_id == BLE_GAP_EVT_CONNECTED) {
        uint16_t handle = evt->evt.gap_evt.conn_handle;
        uint8_t *addr = evt->evt.gap_evt.params.connected.peer_addr.addr;
        // add handle:addr pair to the map
    }

  • yes ,thank you ..i can able to get evt->evt.gap_evt.conn_handle and evt->evt.gap_evt.params.connected.peer_addr.addr

     for every connection.

    but in my application after 5 connections of peripheral to one central , i will send data along with anyone of the connected peripheral peer address that time,

     1.how can i choose in central to send data to a particular peripheral  ??

     2 .how can i map the peer address with that id ??

    for (uint32_t i = 0; i< NRF_SDH_BLE_CENTRAL_LINK_COUNT; i++)
    {
    err_code = ble_lbs_led_status_send(&m_lbs_c[i], 0);
    if (err_code != NRF_SUCCESS &&
    err_code != BLE_ERROR_INVALID_CONN_HANDLE &&
    err_code != NRF_ERROR_INVALID_STATE)
    {
    return err_code;
    }

    if i used like above function , its sending data to all peripherals , here how can i differentiate the one peripheral and that connection id???

Reply
  • yes ,thank you ..i can able to get evt->evt.gap_evt.conn_handle and evt->evt.gap_evt.params.connected.peer_addr.addr

     for every connection.

    but in my application after 5 connections of peripheral to one central , i will send data along with anyone of the connected peripheral peer address that time,

     1.how can i choose in central to send data to a particular peripheral  ??

     2 .how can i map the peer address with that id ??

    for (uint32_t i = 0; i< NRF_SDH_BLE_CENTRAL_LINK_COUNT; i++)
    {
    err_code = ble_lbs_led_status_send(&m_lbs_c[i], 0);
    if (err_code != NRF_SUCCESS &&
    err_code != BLE_ERROR_INVALID_CONN_HANDLE &&
    err_code != NRF_ERROR_INVALID_STATE)
    {
    return err_code;
    }

    if i used like above function , its sending data to all peripherals , here how can i differentiate the one peripheral and that connection id???

Children
Related