AnsweredAssumed Answered

Problem setting up service on BlueNRG-MS

Question asked by Ricardo Hassan on Jun 29, 2017
Latest reply on Aug 1, 2017 by Ricardo Hassan

Hi,

    I'm using a BlueNRG-MS attached to an STM32l4 via SPI.   I've got the connection working all right.  When I try to define a custom service with 6 characteristics, the first 2 work fine, but the rest of the aci_gall_add_char(...) calls return 0x1F, Out of Memory.  I can't believe the BlueNRG chip is already out of memory with just one service and 2 characteristics.  What am I doing wrong?  Here's the code I'm using to set it up:

 

HCI_Init();
BlueNRG_RST();
tBleStatus status;

uint8_t hwVersion = 0;
uint16_t fwVersion = 0;
getBlueNRGVersion(&hwVersion, &fwVersion);
BlueNRG_RST();

uint8_t bdaddr[] = {0xaa, 0x00, 0x00, 0xE1, 0x80, 0x02};
aci_hal_write_config_data(CONFIG_DATA_PUBADDR_OFFSET, CONFIG_DATA_PUBADDR_LEN, bdaddr);
status = aci_gatt_init();
if (status != 0) { while(1); }
uint16_t default_service_handle;
status = aci_gap_init_IDB05A1(GAP_PERIPHERAL_ROLE_IDB05A1, 0, 10, &default_service_handle, &device_name_handle_, &appearance_handle_);
if (status != 0) { while(1); }

// set up the service with it's characteristics, as defined in the comm spec
status = aci_gatt_add_serv(UUID_TYPE_16, kMyService, PRIMARY_SERVICE, 6, &service_handle_);
status = aci_gatt_add_char(service_handle_, UUID_TYPE_128, kChar1Uuid, 8,
CHAR_PROP_WRITE, ATTR_PERMISSION_NONE, 0, 0, 1, &session_key_write_handle_);
status = aci_gatt_add_char(service_handle_, UUID_TYPE_128, kChar2Uuid, 8,
CHAR_PROP_NOTIFY, ATTR_PERMISSION_NONE, 0, 0, 1, &session_key_read_handle_);
status = aci_gatt_add_char(service_handle_, UUID_TYPE_128, kChar3Uuid, 17,
CHAR_PROP_WRITE, ATTR_PERMISSION_NONE, 0, 0, 1, &energizer_tx_handle_);
status = aci_gatt_add_char(service_handle_, UUID_TYPE_128, kChar4Uuid, 17,
CHAR_PROP_NOTIFY, ATTR_PERMISSION_NONE, 0, 0, 1, &energizer_rx_handle_);
status = aci_gatt_add_char(service_handle_, UUID_TYPE_128, kChar5Uuid, 17,
CHAR_PROP_WRITE, ATTR_PERMISSION_NONE, 0, 0, 1, &implant_tx_handle_);
status = aci_gatt_add_char(service_handle_, UUID_TYPE_128, kChar6Uuid, 17,
CHAR_PROP_NOTIFY, ATTR_PERMISSION_NONE, 0, 0, 1, &implant_rx_handle_);

const char my_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME, 'M', 'y', ' ', 'E', 'N', 'G'};
hci_le_set_scan_resp_data(16, kMyService);

// start advertising
aci_gap_set_discoverable(ADV_IND, 0, 0, PUBLIC_ADDR, NO_WHITE_LIST_USE, sizeof(my_name), my_name,
16, (uint8_t*)kMyService, 0, 0);

 

At the end it does advertise with the 2 successfully added characteristics.

Outcomes