This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
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

BLE Multilink example + Throughput example

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

Parents
  • Hi Cecylia

    It should not be possible that connecting to a second peripheral will change or affect the connection handle of the first application at all. Where exactly do you see that both connection handles are set to 1? There must be something in the connection process you've changed from the multilink_central example project, for something like this to occur. I think it should be sufficient to use the multilink central as is and change the LED button service instances to rather use the "AMTS" service you plan on using.

    What "more information" did you get from the debugging?

    Best regards,

    Simon

Reply
  • Hi Cecylia

    It should not be possible that connecting to a second peripheral will change or affect the connection handle of the first application at all. Where exactly do you see that both connection handles are set to 1? There must be something in the connection process you've changed from the multilink_central example project, for something like this to occur. I think it should be sufficient to use the multilink central as is and change the LED button service instances to rather use the "AMTS" service you plan on using.

    What "more information" did you get from the debugging?

    Best regards,

    Simon

Children
  • Hi Simon,

    After reading many resources I think there's a basic fallacy in my initial understanding that prompted this question.

    At first I thought I would run it like this:

    Central (running 2 amts)  ----------------------> Peripheral 1 (running amtc)
                                                        |

                                                        |________> Peripheral 2 (running amtc)

    But, amts from Nordic's throughput example is basically a GATT Server (thus the "s"), and you cannot have 2 GATT servers running in one device.  For example, mentioned here.  And upon further reading, actually the roles are reversed in my understanding.  The Peripherals who are going to send the data should run the GATT Server, while the central who's going to receive the data should run the GATT Client.  So it should be like this:

    Central (running 2 amtc)  ----------------------> Peripheral 1 (running amts)
                                                        |

                                                        |________> Peripheral 2 (running amts

    So I removed all amts code from my central, and replaced it with initialization of 2 amtc instances.  And, I put the amts code on my peripheral.  With this approach it works much better.

    Thanks,
    Cecyila

Related