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).

  • Hi Havard,

    I tried to write the characteristic with nrf connect and it worked.

    I added logs in tx_buffer_process() so we can see what is happenning : 

    It gave me this result : 

    Here we can see the value I wented to write (05 00 33 79 81 02 36 11 11 11 11 11 11 11 11 01 00 00 00 00) and then we the variables used in sd_ble_gattc_write() . All the variables except the conn_handle are different than what I was expecting.

  • Well, that certainly looks like error code 7 (NRF_ERROR_INVALID_PARAM).

    It's hard from looking at these screenshots what happened to your variables. I would preferably step in the code with a debugger, or like you are doing, add more prints to figure out if you have any problems with pointers or scope of your variables.

Reply Children
Related