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

error when writing more bytes than the "long char" buffer length

Hi all,

I have implemented a service with various "long char" characteristics. The buffer that I use to receive the data wrote to the "long char" characteristics is this:

#define CHAR_LENGTH_MAX 160
#define BUFF_SIZE       CEIL_DIV(CHAR_LENGTH_MAX,18)*24+2 

static uint8_t              m_cb_name_mem[BUFF_SIZE] = {0};
static ble_user_mem_block_t m_cb_name_mem_block =
{
    .p_mem = m_cb_name_mem,
    .len = BUFF_SIZE
};

I set the length of the longest characteristic as the buffer size. All works fine until the value write to the largest characteristic has a length higher than CHAR_LENGTH_MAX, when this happens I obtain the error NRF_ERROR_INVALID_STATE in function sd_ble_gatts_rw_authorize_replywhen the operation BLE_GATTS_OP_PREP_WRITE_REQis executing.

I suppose that this error is obtained because the data overflows the buffer. There's any way to limit or control the bytes wrote in "long characteristics" to not obtain this error and not overflow the buffer?

I'm using: NRF52832QFAAB0 s132 3.1 SDK 12.2

Thanks

Related