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

ATT_MTU Throuput Example Setup GATTS & GATTC

Hello Community,

I have been trying to avoid asking this question here (it may be trivial) but I guess the answer will help other people as well. 

In the ATT_MTU throughput example (SDK15.2.0 and previous ones) one unit is set as Central and the other as Peripheral. 

The 'tester' board is the Central and is doing all the transmission of the data while the 'responder' board is the peripheral that receives the data. 

What I cannot understand is why both devices are initialized as client and server at the same time. (?) 

I can see that the 'tester' (aka Client) is using functions in amts.c to notify the 'responder' (aka server) while the latter is using amtc.c routines to receive them.

Obviously the case is that the client can send data to the server and the other way round but why should each unit run both client_init and server_init routines?

Thank you for your answers.

Parents
  • Hi Vasileios,

    I believe it's just to simplify the firmware. This way we can have both side running on same firmware. We setup the same GATT client and server on both side. And depend on which feature we choose on the board, tester or responder, the client or the server will be used.

    Setting both client and server on the devices wouldn't affect the performance. If you create dedicated firmware for tester and responder, you can remove the client/server accordingly.

  • Hello Hung Bui,

    Thanks for answering so quickly. 

    At first this is what I thought but to test what you are saying I removed from the responder (aka server) the client observer by commenting out the:

    //NRF_SDH_BLE_OBSERVER(m_amtc_ble_obs, BLE_AMTC_BLE_OBSERVER_PRIO, nrf_ble_amtc_on_ble_evt, &m_amtc);

    and also did not initialize the client at all by commenting out

    //client_init();

    Then I run the test. 

    Although the two devices connect, database deiscovery fails and I get a weak fault in the responder.

    If what you are suggesting above is correct then it should not be a problem me removing the client initialization and observer from the server device.

    should it?

  • Hi,

    When you see a fault/assert could you check what it was about ?

    Most likely it was because of the ble_db_discovery_start() call inside on_ble_gap_evt_connected(). The db discovery module is not initialized if you comment out client_init()

  • Hello Hung Bui,

    Check below the tester output:

    throughput example:~$ run
    [00:00:00.000,152] <info> app: Preparing the test.
    [00:00:00.000,183] <info> app: Starting advertising.
    [00:00:00.000,335] <info> app: Starting scanning.
    [00:00:00.046,295] <info> app: Device "Nordic_ATT_MTU" found, sending a connection request.
    [00:00:00.091,949] <info> app: Connected as a central.
    [00:00:00.091,979] <info> app: Discovering GATT database...
    throughput example:~$

    And the responder output:

    [00:00:00.000,183] <info> app: ATT MTU example started.

    [00:00:00.000,213] <info> app: Press button 3 on the board connected to the PC.
    [00:00:00.000,213] <info> app: Press button 4 on other board.
    [00:00:00.101,287] <info> app: This board will act as responder.
    [00:00:00.101,318] <info> app: Starting advertising.
    [00:00:00.101,440] <info> app: Starting scanning.
    [00:00:00.036,834] <info> app: Connected as a peripheral.
    [00:00:00.036,865] <info> app: Discovering GATT database...
    [00:00:00.050,689] <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at C:\nRF52840\SDK\nRF5_SDK_15.2.0_9412b96\examples\ble_central_and_peripheral\experimental\ble_app_att_mtu_throughput\main.c:269
    PC at: 0x00034569
    [00:00:00.071,350] <error> app: End of error report

    so the error is ERROR 8 -> NRF_INVALID_STATE

    Does the database discovery need to run in both the client and server? I though that the client initiates a database discovery and the server reveals its services.

    Thank you for your help.

  • No, it's not needed on the server side, that's why it shouldn't be called. please remove any call to db_discovery in your server. (of course you can keep them if you do initialization for the db_discovery module, if not, please remove the call ble_db_discovery_start() 

Reply Children
  • Hello Hung Bui,

    Did that. The effect is very strange. 

    In the first kit I downloaded the ATT_MTU example as is.

    In the second kit I removed all references to client initialization and the BLE observer and also commented out the ble_db_discovery_start()

    Now the result is that the test does not fail but also it does not start. 

    This is the 1st dev kit:

    throughput example:~$ run
    [00:00:00.000,152] <info> app: Preparing the test.
    [00:00:00.000,183] <info> app: Starting advertising.
    [00:00:00.000,335] <info> app: Starting scanning.
    [00:00:00.038,146] <info> app: Connected as a peripheral.
    [00:00:00.038,208] <info> app: Discovering GATT database...
    [00:00:00.038,238] <info> app: Sending PHY Update, 2 Mbps.
    [00:00:00.054,321] <info> app: ATT MTU exchange completed. MTU set to 247 bytes.
    [00:00:00.004,486] <info> app: PHY update accepted. PHY set to 2 Mbps.
    [00:00:00.006,439] <info> app: Data length updated to 27 bytes.
    [00:00:00.028,839] <info> app: AMT service discovered at peer.
    throughput example:~$

    and this is the 2nd kit

    [00:00:00.000,183] <info> app: ATT MTU example started.
    [00:00:00.000,213] <info> app: Press button 3 on the board connected to the PC.
    [00:00:00.000,213] <info> app: Press button 4 on other board.
    [00:00:00.130,279] <info> app: This board will act as responder.
    [00:00:00.130,279] <info> app: Starting advertising.
    [00:00:00.130,432] <info> app: Starting scanning.
    [00:00:00.055,358] <info> app: Device "Nordic_ATT_MTU" found, sending a connection request.
    [00:00:00.094,085] <info> app: Connected as a central.
    [00:00:00.010,070] <info> app: ATT MTU exchange completed. MTU set to 247 bytes.
    [00:00:00.060,516] <info> app: PHY update accepted. PHY set to 2 Mbps.
    [00:00:00.069,946] <info> app: Data length updated to 27 bytes.
    [00:00:00.092,437] <info> app: Notifications enabled.
    throughput example:~$

    for some reason although the 2nd board is configured responder, when it is connected it assumes the central role. This happens although I have not initialized client_init().

    This is strange but I don't want to bother you anymore. It is enough that you explained why you are initializing client and server at the same time and also that the database discovery only needs to run from the client. 

    Thank you for your help.

Related