We need to connect 2 peripherals with single central device.I have taken ble_app_multilink_central from SDK 15.3 and integrated the ble_app_uart_c in this. I am using the service ble_nus_c instead of ble_lbs_c.
My peripherals are sending periodic data at ~20 ms to the central. In the ble_nus_c_handler(), I want to know which peripheral has sent the data and take different action based on the source of the data. I read that this can be done using the p_ble_nus_evt->conn_handle. However, through the debugger, I found that when I get BLE_NUS_C_EVT_DISCOVERY_COMPLETE, the conn_handle is able to distinguish which peripheral caused this state, but when it gets to the periodic state BLE_NUS_C_EVT_NUS_TX_EVT on receiving packets from the peripheral, the conn_handle is always 0. So, for both devices, this same event is triggered and the conn_handle is of no use to distinguish the source of data.
What is the best way to know from exactly which peripheral the central has received the periodic data?
This is by init function:
BLE_NUS_C_ARRAY_DEF(m_ble_nus_c, NRF_SDH_BLE_CENTRAL_LINK_COUNT); //NRF_SDH_BLE_CENTRAL_LINK_COUNT set to 2 static void nus_c_init(void) { ret_code_t err_code; ble_nus_c_init_t init; init.evt_handler = ble_nus_c_evt_handler; err_code = ble_nus_c_init(&m_ble_nus_c[0], &init); APP_ERROR_CHECK(err_code); err_code = ble_nus_c_init(&m_ble_nus_c[1], &init); APP_ERROR_CHECK(err_code); }