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

How can I read the payload data sent from service?

I am using the nRF52840 Preview DK with BLE 5.0. In the BLE ATT_MTU Throughput Example,I use several api such as sd_ble_gatts_value_get and so on,but i still can not read the correct data. How can I read the payload data correctly with a correct api? I want to read 1 MB of data sent from the tester board and store it into the buffer.

  • Hi Zway,

    The way we send data in the example is the one connect to PC will be the peripheral and have a server. The other peer is central and has a client. The peripheral will send data to the central via notification from the server to the client.

    If you have a look at NRF_BLE_AMT_C_EVT_NOTIFICATION in amtc_evt_handler() you can find where the data is arrived and notified to the application.

  • I have carefully looked at the example .On the NRF_BLE_AMT_C_EVT_NOTIFICATION branch,it just counts how many bytes the client have received and give a callback to the service finally. But it didn't use an api to get the data and store into buffer.

  • Hi zway,

    Sorry that I didn't notice we don't handle the data inside that function (because it's not needed for the throughput test as data is simply dummy data).

    You can then access the data in the notification event from the softdevice BLE_GATTC_EVT_HVX. In atmc.c it's handled in on_hvx() and you can access the data in p_ble_evt->evt.gattc_evt.params.hvx.data.

    The length of the array is in p_ble_evt->evt.gattc_evt.params.hvx.len

Related