Hi there,
I'm trying to combine the BLE Multilink example with the Throughput example, with the hope that I can connect 1 Central to 2 Peripherals and get a high throughput.
In creating the AMTS instance, I'm a bit unsure of which ones have to be 2 instances and which one can share the function.
For example:
1) I created 2 instances of m_amts
nrf_ble_amts_t m_amts[2]
2) I only call NRF_SDH_BLE_OBSERVER once, since I assume I can reuse the m_amts_ble_obs and the handler nrf_ble_amts_on_ble_evt for both connection.
NRF_SDH_BLE_OBSERVER(m_amts_ble_obs, BLE_AMTS_BLE_OBSERVER_PRIO, nrf_ble_amts_on_ble_evt, NULL);
--> I'm thinking to put the condition inside nrf_ble_amts_on_ble_evt. So conn_handle==0 will use m_amts[0] and conn_handle==1 will use m_amts[1]
3) I called nrf_ble_amts_init twice, but with different m_amts
nrf_ble_amts_init(&m_amts[0], amts_evt_handler, ...)
nrf_ble_amts_init(&m_amts[1], amts_evt_handler, ...)
4) I reuse the UUID for both, ie AMT_SERVICE_UUID, AMTS_CHAR_UUID, AMT_RCV_BYTES_CNT_CHAR_UUID are used for both m_amts[0] and m_amts[1]
So far I can connect to 2 Peripherals. However, it fails in the "on_write" function inside nrf_ble_amts_on_ble_evt.
In this check
if ((p_evt_write->handle == p_ctx->amts_char_handles.cccd_handle) && (p_evt_wirte->len ==2)) {
//CCCD written, call the application event handler...
...
}
The 2nd connection always fails because for the 2nd connection the "p_evt_write->handle" is 13 or 14 and "p_ctx->amts_char_handles.cccd_handle" for the 2nd connection is 19 or 20.
Should I have created new set of services for the 2nd peripheral? Or other things I can do for workaround this?
Thanks,
Cecylia