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

concurrent characteristic

I have nrf51822 with latest sd130.

I need to implement central what connects to smartphone. Phone has two characteristics with HVX. First char is sending one byte after 80 ms. Second char is sending bigger data after 100 ms. Second char data processing takes 400ms and I do it in read response. When I am processing second char data is the first char data coming in concurrently or is the second char blocking until I return read response?

  • I don't understand. You do the processing in a read response?

  • I was hoping you would elaborate a bit more, but ok. You say that you are implementing a central device, which connects to a phone, which means that the phone is a peripheral device. The phone has two characteristics which can be notified, which means that the server is on the phone, and the central device is a client. After 80 ms the first characteristic on the phone sends a notification to central device. After 100 ms the seconds characteristic sends a notification to the central device. This takes 400 ms and you do it in a read response. This doesn't make sense to me. Firstly, you don't need to send a read response when a notification is received. Secondly, as a client, it is not possible to send a read response, only a read request, and the server answers with a read response. Please clarify.

  • I add my code flow to understand better

    I register ble event handler softdevice_ble_evt_handler_set(ble_evt_dispatch);

    in central side after discovery I configure read characteristics to get HVX notification. Character A Character B

    Now when when HWX is triggered I got event to ble_evt_dispatch event id is BLE_GATTC_EVT_HVX

    In my case I get it from Character A after every 80 ms and from CHaracter B after every 100 ms.

    Now when Character A HWX comes in I set only one boolean in BLE_GATTC_EVT_HVX event. When Character B HWX comes in I start to read data because I get more than 100 bytes in. I do it so that in BLE_GATTC_EVT_HVX event I call sd_ble_gattc_read. Then I get event BLE_GATTC_EVT_READ_RSP and inside that event I call again sd_ble_gattc_read and get again BLE_GATTC_EVT_READ_RSP. I do it until when all data is readed. After reading I process the data and that takes 400 ms. I call data processing function directly from BLE_GATTC_EVT_READ_RSP event.

    Question is: when I call data processing function directly inside BLE_GATTC_EVT_READ_RSP then is Character A HVX coming in parallel?

  • Please have a look at Exception (interrupt) management with a SoftDevice

    I have made a diagram to illustrate what will happen. Exactly when what will happen is difficult to say, it depends on the connection interval, the number of packets that are/can be received in a connection interval.

    I don't know if you are using a scheduler, this would put the application events in a buffer in the application space and run them from main context, instead of App(L).

    Without a scheduler something like this will happen:

    image description

    • PE - Protocol Event
    • LL - Link Layer
    • AE - Application Event

    You can see that when you do processing from the BLE_GATTC_EVT_READ_RSP you will be in App(L). The SoftDevice will interrupt this if is needed, i.e. the LL will receive the notification, but the application wouldn't know until you are finished with the App(L) processing.

    There is a limited amount of AEs that can be kept by the buffers in the SoftDevice, so if you process in App(L) for too long they will get full. When they are full the link layer will begin to nack packets.

Related