Hi we implement a project for gatt peripheral mode. We have a 1 service and 2 properties in the service. Also every properties have 1 characteric.
const struct attm_desc_128 custs1_att_db[SVC_INDEX_MAX] =
{
[SVC_INDEX_SERVICE] = { (uint8_t*)&att_decl_service, ATT_UUID_128_LEN, PERM(RD, ENABLE),
sizeof(lt_service_uuid), sizeof(svc_uuid), (uint8_t*)&svc_uuid},
[SVC_INDEX_GET_CHAR] = { (uint8_t*)&att_decl_characteristic, ATT_UUID_16_LEN, PERM(RD, DISABLE),
0,0, NULL },
[SVC_INDEX_GET_VAL] = { get_char_uuid, ATT_UUID_128_LEN, PERM(WR, ENABLE) | PERM(WRITE_REQ, ENABLE),
PERM(RI,ENABLE) | 1024 ,0 , NULL},
[SVC_INDEX_SEND_CHAR] = { (uint8_t*)&att_decl_characteristic, ATT_UUID_16_LEN, PERM(RD, ENABLE),
0, 0 , NULL},
[SVC_INDEX_SEND_VAL] = { send_char_uuid, ATT_UUID_128_LEN, PERM(RD, ENABLE),
PERM(RI, ENABLE) | 1024, 0, NULL },
};
we defined that cust_att_db. But when we connect them we can send it 256 bytes in one command. But we want to write 512 bytes the application frozen after accept write request (from CUSTS1_ATT_INFO_REQ in user_catch_rest_hndl).
Summary, how many bytes write (from central) to da14585 in peripheral mode? Where did we make mistake?
Additionaly, how can we catch the write buffer overflow? And can we give another buffer to custs1_att_db. Example like that?
extern userBuffer[1024];
const struct attm_desc_128 custs1_att_db[SVC_INDEX_MAX] =
{
[SVC_INDEX_SERVICE] = { (uint8_t*)&att_decl_service, ATT_UUID_128_LEN, PERM(RD, ENABLE),
sizeof(lt_service_uuid), sizeof(svc_uuid), (uint8_t*)&svc_uuid},
[SVC_INDEX_GET_CHAR] = { (uint8_t*)&att_decl_characteristic, ATT_UUID_16_LEN, PERM(RD, DISABLE),
0,0, NULL },
[SVC_INDEX_GET_VAL] = { get_char_uuid, ATT_UUID_128_LEN, PERM(WR, ENABLE) | PERM(WRITE_REQ, ENABLE),
PERM(RI,ENABLE) | 1024 ,0 , userBuffer},
[SVC_INDEX_SEND_CHAR] = { (uint8_t*)&att_decl_characteristic, ATT_UUID_16_LEN, PERM(RD, ENABLE),
0, 0 , NULL},
[SVC_INDEX_SEND_VAL] = { send_char_uuid, ATT_UUID_128_LEN, PERM(RD, ENABLE),
PERM(RI, ENABLE) | 1024, 0, NULL },
};
Best Regards...
Hi ltdev,
According to BKLE specs, the maximum length of an attribute is 512 bytes. The ble_app_peripheral example of the SDK inlcudes a “Write Long Characteristic”. Please, take a look at this example of the SDK. If the length of the characteristic value to be written is greater than 20 bytes, then the user_svc1_long_val_att_info_req_handler() in the user_catch_rest_hndl() function will be triggered. If the length is less than 20 bytes the user_svc1_long_val_wr_ind_handler () will be executed. So, if you want to send more than 20 bytes without MTU exchange, you should do the same implementation as in the user_svc1_long_val_att_info_req_handler() function of the ble_app_peripheral example. Since you do that, the master will send a “Prepare Write Request” and the slave will response with a “Prepare Write Response”. Of cousem the characteristic should have 512 bytes length - DEF_SVC1_LONG_VALUE_CHAR_LEN.
Thanks, PM_Dialog
Hi, i think i couldn't explain my problem. I already can write more than 20 Bytes. But when i defined CHAR_LEN as 512 Bytes, i can write only 315 bytes. if i try to write more than 315 bytes, the application frozen and watchdog not working.
Additionaly can i catch write buffer overflow? and can i use any buffer for char value buffer?
Edit : In my debug with nrf connect mobile;
I defined; #define DEF_SVC1_LONG_VALUE_CHAR_LEN 50
and i want to send 51Bytes nrf connect get GATT_ATTR_LEN Error. Can i catch that in my application?
Hi ltdev,
Would it be possible to share a screenshot showing where the application freezes? Is it due to WDOG expiration?
If you increase the DEF_SVC1_LONG_VALUE_CHAR_LEN, are you able to send more than 51 bytes?
>>>”Additionaly can i catch write buffer overflow?”
Can you please clarify this above statement?
Thanks, PM_Dialog