I have a long PDU which I need to send fragmented by indications.
So in a while loop I populate a ble_gatts_hvx_params_t hvx_params struct and call
error_code = sd_ble_gatts_hvx(m_adapter, m_connection_handle, &hvx_params);
The code sequence is
hvx_params.handle = global_indicate_handle;
hvx_params.type = BLE_GATT_HVX_INDICATION;
hvx_params.offset = global_indicate_offset;
hvx_params.p_len = &hvx_length;
hvx_params.p_data = global_indicate_data;
printf("hvx_params.handle 0x%04X\nhvx_params.offset %u bytes\nhvx_params.p_len %u\nhvx_params.p_data 0x%X\n",
hvx_params.handle, hvx_params.offset, *hvx_params.p_len, hvx_params.p_data);
error_code = sd_ble_gatts_hvx(m_adapter, m_connection_handle, &hvx_params);
The PDU is 61 bytes
send 1 is 20 bytes from offset 0
send 2 is 20 bytes from offset 20
send 3 is 20 bytes from offset 40 - fails with error 0x0C (incorrect size). What?
Here is the log
Send # 1: Sending 20 bytes of 61 total from offset 0 at time 5391 on attribute handle 0x0013
hvx_params.handle 0x0013
hvx_params.offset 0 bytes
hvx_params.p_len 20
hvx_params.p_data 0xBEAF52F0
Confirmation of indication on handle 19 received at time 5469
(wait on sem)
Send # 2: Sending 20 bytes of 61 total from offset 20 at time 5469 on attribute handle 0x0013
hvx_params.handle 0x0013
hvx_params.offset 20 bytes
hvx_params.p_len 20
hvx_params.p_data 0xBEAF52F0
Confirmation of indication on handle 19 received at time 5578
(wiat on sem)
Send # 3: Sending 20 bytes of 61 total from offset 40 at time 5578 on attribute handle 0x0013
hvx_params.handle 0x0013
hvx_params.offset 40 bytes
hvx_params.p_len 20
hvx_params.p_data 0xBEAF52F0
Failed doing the indication. Error code: 0x0C
I know the length field is a pointer so I print the contents of the pointer.
On the Android i receive 20 bytes on the two successful indications, but the same 20 bytes. What am I doing wrong?
WOULD YOU PLEASE ADD A PC_BLE_DRIVER tag!!!