2020-09-01 10:32 AM
Hello,
I'm working with BlueNRG-M0.
All is fine when I work with 1 little service. Today I need to implement lot of services and I'm stuck with the error 0x1F from aci_gatt_add_serv() function.
My init is this:
/*----- CODE -----*/
uint8_t SERVER_BDADDR[] = {0x12, 0x34, 0x00, 0xE1, 0x80, 0x02};
uint8_t bdaddr[6];
uint8_t role = 0x02;
int ret;
hci_init(Srv_BLE_Core_user_notify, NULL);
hci_reset();
HAL_Delay(100);
BLUENRG_memcpy(bdaddr, SERVER_BDADDR, sizeof(SERVER_BDADDR));
ret = aci_hal_write_config_data(CONFIG_DATA_PUBADDR_OFFSET,CONFIG_DATA_PUBADDR_LEN,bdaddr);
ret = aci_hal_write_config_data(CONFIG_DATA_MODE_OFFSET, CONFIG_DATA_MODE_LEN, &role);
ret = aci_gatt_init();
ret = aci_gap_init_IDB05A1(GAP_PERIPHERAL_ROLE_IDB05A1, 0,NAME_SIZE_MAX, &service_handle, &dev_name_char_handle, &appearance_char_handle);
ret = aci_gatt_add_serv(UUID_TYPE_128,(uint8_t *)UUID_SRV_PWR,PRIMARY_SERVICE,20,&Handle_SRV_PWR);
ret = aci_gatt_add_serv(UUID_TYPE_128,(uint8_t *)UUID_SRV_SYS,PRIMARY_SERVICE,10,&Handle_SRV_SYS);
ret = aci_gatt_add_serv(UUID_TYPE_128,(uint8_t *)UUID_SRV_DBG,PRIMARY_SERVICE,28,&Handle_SRV_DBG);
ret = aci_gatt_add_serv(UUID_TYPE_128,(uint8_t *)UUID_SRV_GPS,PRIMARY_SERVICE,8,&Handle_SRV_GPS); /* here ret = 0x1F */
/*------ END OF CODE ------*/
I read lot of forum, most of the time the problem comes from the function aci_gatt_add_char because the parameter "max_attr_records" is to small. In my case, I don't call the function aci_gatt_add_char to reduce the field of problem.
On the document http://www.emcu.eu/wp-content/uploads/2016/11/BlueNRG-MS-connections-and-attributes-capabilties.pdf I can see that in mode 2, the attribute record for characteristic is 700 byte so in my case I use only 20 + 10 + 28 + 8 = 66 bytes.
I'm confused about this error. Where is the problem ? How can I add services without this error ? What is the real memory available on the Bluenrg-M0 for attributes and services ?
Note: in order to reduce memory impact I may use UUID on 2 bytes
Thank in advance for help.
Regards,
Dams