NRF52810 data i/o characteristic help sought

The peripheral application I'm working on implements a service which must handle multi-byte incoming messages from a central device and would welcome a pointer to any example code that demonstrates how I might code this. (I am working on a ublox BMD-330 dev board targeting nrf52810 and using the BLE Scanner app on my iPhone for testing so do not know how this app is actually sending the data, but there is a button to send either a single byte or a string.)

The single byte is being received fine but when I try to send e.g. "zz" nothing is received (apparently).  I have based my code on the example MIDI code here - www.novelbits.io/.../ - the 'on_write()' function in midi_service.c seems to have code for processing either 1 or 2 bytes but debugging this function seems to show that it is never even hit unless the incoming data is a single byte.

There is a comment in the 'ble_gatts_evt_write_t' structure (where the 'data' member is an array of size 1) that says:

/**< Received data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */

However I can find nothing in the sdk doc related to sd_ble_evt_get that mentions anything about handling multi-byte data. I am happy to share if necessary such code as I have but really all I need is a pointer to an example of what the 'on_write' event handler should look like or if my service needs some extra code.

Thanks for any help.

Parents
  • Hello,

    Since the MIDI code on NovelBits was not provided by us, I don't dare to say why it works with one byte, but doesn't work with two bytes. May I suggest you to look into the ble_app_uart example from our SDK. It looks like the midi example provided on novelbits.io is also based on the SDK, so I guess you already have it. I am not saying you need to use ble_app_uart in the end, but perhaps you can compare the two samples, and see how ble_app_uart handles the initialization and the events where the messages contain more than one byte.

    Best regards,

    Edvin

  • Thanks for the reply, Edvin.

    The MIDI code was indeed based on the ble_app_template example in your sdk.  Originally I did look in the sdk for the example code I wanted but I obviously failed to spot what I was looking for in the uart example!  I'll take a look there as soon as I have managed to get my project to build (configuring the project for AES-128 ECB only is proving very difficult!).

    Thanks again,

    Pete

Reply
  • Thanks for the reply, Edvin.

    The MIDI code was indeed based on the ble_app_template example in your sdk.  Originally I did look in the sdk for the example code I wanted but I obviously failed to spot what I was looking for in the uart example!  I'll take a look there as soon as I have managed to get my project to build (configuring the project for AES-128 ECB only is proving very difficult!).

    Thanks again,

    Pete

Children
No Data
Related