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

Error Writing Large Characteristics

I am working on a BLE peripheral. I have a large, variable length characteristic I need to set from the central.

When the central is the BTool, I can write up to the maximum size of my characteristic, which is 512 bytes. It carves it into 90 byte blocks, and sends them 18 bytes at a time.

When the central is Android, any write more than 18 bytes fails. In the onCharacteristicWrite callback I receive status 133 (GATT_ERROR).

Any ideas why I would get this error?

Edit 1: I also have a Windows client implementation. There, the function BluetoothGATTSetCharacteristicValue() returns 58, ERROR_BAD_NET_RESP, "The specified server cannot perform the requested operation.".

I have a test point that I set when I am copying the bytes from each packet into the blob. I can see that with both the Windows and Android implementations I am only getting the first packet.

Parents
  • I'm not an Android expert, but Aleksander Nowakowski is, and according to him it should work. How are you handling this in the peripheral application? If you have Sniffer traces, could you edit your question and upload them?

  • Peter,

    Thanks, your reply led me to the answer. In response to BLE_EVT_USER_MEM_REQUEST I was calling sd_ble_user_mem_reply() with a NULL mem_block, just like in the template example. If I instead provide a large memory block, the long write works.

    If I may, a few comments.

    1. It would be nice if the template example illustrated this technique, even if it isn't technically necessary.
    2. It would be nice if the documentation for either BLE_EVT_USER_MEM_REQUEST or sd_ble_user_mem_reply() indicated what size the memory block should be, and under what conditions it was needed. Right now the documentation for sd_ble_user_mem_reply() is "Provide a user memory block."
    3. Why is this even necessary? I am using a user-buffer for the characteristic. Why can't I just copy the data into it as it comes? RAM is very tight in my application.

    Regards, Bill

Reply
  • Peter,

    Thanks, your reply led me to the answer. In response to BLE_EVT_USER_MEM_REQUEST I was calling sd_ble_user_mem_reply() with a NULL mem_block, just like in the template example. If I instead provide a large memory block, the long write works.

    If I may, a few comments.

    1. It would be nice if the template example illustrated this technique, even if it isn't technically necessary.
    2. It would be nice if the documentation for either BLE_EVT_USER_MEM_REQUEST or sd_ble_user_mem_reply() indicated what size the memory block should be, and under what conditions it was needed. Right now the documentation for sd_ble_user_mem_reply() is "Provide a user memory block."
    3. Why is this even necessary? I am using a user-buffer for the characteristic. Why can't I just copy the data into it as it comes? RAM is very tight in my application.

    Regards, Bill

Children
No Data
Related