I am trying to send/transmit #define DEF_SVC1_UART_TRANS_LEN 16 data and 5byte of data which i write in LED characteristics using user_svc1_adc_val_1_cfg_ind_handler. But only 16byte is received in BLE receiver.
In user_custs1_impl.c
void user_svc1_adc_val_1_cfg_ind_handler(ke_msg_id_t const msgid, struct custs1_val_write_ind const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id){ struct custs1_val_ntf_ind_req *req = KE_MSG_ALLOC_DYN(CUSTS1_VAL_NTF_REQ, prf_get_task_from_id(TASK_ID_CUSTS1), TASK_APP, custs1_val_ntf_ind_req, DEF_SVC1_ADC_VAL_1_CHAR_LEN);
// ADC value to be sampled memset(c_buffer, 48, sizeof(c_buffer)); // I am firsr initailising the buffer data to zero memcpy(c_buffer, buffer, sizeof(buffer)); // I am copying the uart buffer[16] data in c_buffer[21]. I assume the data in c_buffer[16-21] is zero memcpy(&c_buffer[16], buffer2, sizeof(buffer2)); // I am now copying LED write data in c_buffer[16-21] req->conidx = app_env->conidx; req->notification = true; req->handle = SVC1_IDX_ADC_VAL_1_VAL; // This length i have kept as 21byte where 16byte data i will send using uart and 5byte data i will write in LED req->length = DEF_SVC1_UART_TRANS_LEN; characteristics and append it in data[16] to data[20] memcpy(req->value, calibrated_buffer, DEF_SVC1_UART_TRANS_LEN); ke_msg_send(req); if (ke_state_get(TASK_APP) == APP_CONNECTED) { // Set it once again until Stop command is received in Control Characteristic timer_used = app_easy_timer(APP_PERIPHERAL_CTRL_TIMER_DELAY, app_adcval1_timer_cb_handler); }}
req->conidx = app_env->conidx;req->notification = true;req->handle = SVC1_IDX_ADC_VAL_1_VAL;req->length = DEF_SVC1_UART_TRANS_LEN; memcpy(req->value, &buffer, DEF_SVC1_UART_TRANS_LEN);
ke_msg_send(req);if (ke_state_get(TASK_APP) == APP_CONNECTED){// Set it once again until Stop command is received in Control Characteristictimer_used = app_easy_timer(APP_PERIPHERAL_CTRL_TIMER_DELAY, app_adcval1_timer_cb_handler);}}
Last time i faced the same issue while transmitting 15byte of data. That time i made a mistake in transmitting length size which was 10. I increased the size to 15 and it worked fine. In the above case, i am facing the same issue, only while advertising for the first time, i receive 21byte data, from 2nd data onwards only16byte data is transferred.
Hi Surya,
I see that in custs1_val_ntf_ind_req{} structure you are using DEF_SVC1_ADC_VAL_1_CHAR_LEN instead of DEF_SVC1_UART_TRANS_LEN . Can you please try to change it?
Please also share the user_custs1_def.c file so that I can understand the service definition.
Try also to increase the MTU size in user_gapm_conf{} structure.
Best regards,
Panos
Can you explain about MTU size in user_gapm_conf{} structure ???
The amount of bytes that a device can send over notification of a characteristic is limited by the MTU (Maximum Transfer Unit), the MTU by default is limited in 23 bytes including the ATT layer overhead, so the payload of a notification is 20 bytes. By increasing the MTU size you can send more bytes over one notification, so in your case the maximum transfer unit should be the amount of bytes you would like to send + 3 extra bytes. Please try to increase the MTU size and let us know if it works.
I would recommend also checking the following example from our GIT repo :
https://github.com/dialog-semiconductor/BLE_SDK6_examples/tree/main/features/dynamic_L2CAP_Packet_size_Optimization
It demonstrates how to request DLE and utilize larger packets to enhance throughput.
PM_renesas