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

Write Queued Characteristic with Less than 20 bytes

Good afternoon,

Following up my previous case, to which I got no reply, how can I use a queued write characteristic to write less than 20 bytes of data?

I'm using it to mainly write more than 20 bytes of data but when I write less than 20 bytes it just halts the application. How can I overcome it?

Thank you,

João

Parents
  • HI Joao, 

    I've been looking a bit more into the QWR module code and looking at a sniffer trace when you write less than 20bytes to the QWR characteristic. 

    So if you write less than 20 bytes to the QWR characteristic using nRF Connect for Android/iOS or Desktop, then it will send a regular Write Request that needs to be authorized and not a Prepare Write Request

    The code I sent you in my previous reply modifies the QWR event handler to handle a Write Request, but the Write Request is not preceeded by a User Memory Request, the SD is asking the Application for a memory section to store the incoming data in, so invoking the nrf_ble_qwrs_on_qwr_evt() handler and passing NRF_BLE_QWR_EVT_EXECUTE_WRITE as the event type is not possible as it will trigger the nrf_ble_qwr_value_get() call, which in turn will try to use a buffer that is never allocated

    So I am not sure if it is the right way to go as the module would work as it should if the less than 20 byte data is sent as a prepare write request followed by an Execute Write Now Request. 

    You could of course create a separate event type NRF_BLE_QWR_EVT_WRITE_REQ and then handle that in nrf_ble_qwrs_on_qwr_evt(), but then you would have to modify the nrf_ble_qwrs_on_qwr_evt() handler so that nrf_ble_qwr_value_get() is not called when the NRF_BLE_QWR_EVT_WRITE_REQ event is received.

    What is your use case for queued writes, are you planning on writing to multiple characteristic handles or is it just one characteristic handle? Also what are you planning on using as the central device, a smartphone or another nordic device?

    Best regards

    Bjørn 

  • Hi Bjørn,

    Thank you for your reply.

    I understand the clarified implications.

    Our peripheral is intended to interact with Smartphone central apps on both Android and iOS, and we make use of multiple services/characteristics along with the Queued Write Service and its containing Queued Write Characteristic. We can write either less or more than 20 bytes through the Queued Write Characteristic. So what would be the best way to solve this issue? Is there a way to force a "Prepare Write Request" through the Smartphone central app on both Android and iOS or should we change the nrf_ble_qwr/nrf_ble_qwrs events to deal with both types of data lengths? For the suggested solution, what exactly should we code?

    Looking forward to your reply,

    Thank you,

    João

Reply
  • Hi Bjørn,

    Thank you for your reply.

    I understand the clarified implications.

    Our peripheral is intended to interact with Smartphone central apps on both Android and iOS, and we make use of multiple services/characteristics along with the Queued Write Service and its containing Queued Write Characteristic. We can write either less or more than 20 bytes through the Queued Write Characteristic. So what would be the best way to solve this issue? Is there a way to force a "Prepare Write Request" through the Smartphone central app on both Android and iOS or should we change the nrf_ble_qwr/nrf_ble_qwrs events to deal with both types of data lengths? For the suggested solution, what exactly should we code?

    Looking forward to your reply,

    Thank you,

    João

Children
No Data
Related