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

How to do a write request on a 20 bytes characteristic?

Hi,

I have a problem when I do a write request on a 20 bytes characteristic from a custom service.

The funtion sd_ble_gattc_write return error 0x7 but I can't find what it means.

I found out that the write request work when I only write 1, 2, 3 or 4 bytes but no more.

I tried to set a bigger number for NRF_SDH_BLE_GATT_MAX_MTU_SIZE (153) and NRF_SDH_BLE_GAP_DATA_LENGTH (157) but it didn't work.

This is how I define the characteristic on my peripheral : 

This is the write request function in my central :

Parents
  • Hi,

    Sounds cryptic that you can write 4 bytes but not more. In fact, vlen = 0 means that the length of the characteristic should always be 20 (CONCENTRATOR_FRAME_SIZE). In the "write" screenshot above I see that you are using CONCENTRATOR_FRAME_SIZE so if that is 20 then it should be fine.

    Could you run the project in debug mode, and post the state of the variables just as you are calling sd_ble_gattc_write() from the central?

    It may give us some useful clues.

    Have you tried writing to this characteristic from other sources (nRF Connect for PC or mobile?) I just want to confirm that the problem is on the client-side where you are seeing the error code (and not the server-side).

Reply
  • Hi,

    Sounds cryptic that you can write 4 bytes but not more. In fact, vlen = 0 means that the length of the characteristic should always be 20 (CONCENTRATOR_FRAME_SIZE). In the "write" screenshot above I see that you are using CONCENTRATOR_FRAME_SIZE so if that is 20 then it should be fine.

    Could you run the project in debug mode, and post the state of the variables just as you are calling sd_ble_gattc_write() from the central?

    It may give us some useful clues.

    Have you tried writing to this characteristic from other sources (nRF Connect for PC or mobile?) I just want to confirm that the problem is on the client-side where you are seeing the error code (and not the server-side).

Children
Related