Hello,
my BLE application needs at least 5 different services to transmit different sensor data to a GATT client. I´m wondering how I can add that many UUIDs in my packet package. I use the following code:
static ble_uuid_t BLE_UUID[] =
{
{BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE},
{BLE_UUID_BATTERY_SERVICE, BLE_UUID_TYPE_BLE},
{BLE_TIME_SERVICE, BLE_UUID_TYPE_VENDOR_BEGIN},
{BLE_SENSOR_SERVICE, BLE_UUID_TYPE_VENDOR_BEGIN}
};
static void Init_Advertising(void)
{
ble_advertising_init_t Adv_Params;
NRF_LOG_DEBUG(" Initialize advertising module...");
memset(&Adv_Params, 0, sizeof(Adv_Params));
Adv_Params.advdata.name_type = BLE_ADVDATA_FULL_NAME;
Adv_Params.advdata.include_appearance = true;
Adv_Params.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
Adv_Params.advdata.uuids_complete.uuid_cnt = 2;
Adv_Params.advdata.uuids_complete.p_uuids = &BLE_UUID[0];
Adv_Params.srdata.uuids_more_available.uuid_cnt = 2;
Adv_Params.srdata.uuids_more_available.p_uuids = &BLE_UUID[2];
Adv_Params.config.ble_adv_fast_enabled = true;
Adv_Params.config.ble_adv_fast_interval = BLE_ADV_INTERVAL;
Adv_Params.config.ble_adv_fast_timeout = BLE_ADV_DURATION;
Adv_Params.evt_handler = Advertising_On_Event_Handler;
APP_ERROR_CHECK(ble_advertising_init(&Advertising, &Adv_Params));
ble_advertising_conn_cfg_tag_set(&Advertising, BLE_CONN_CFG_TAG);
}
This code produces the error 12 in ble_advertising_init, because there are too many data bytes for the advertisment and the scan response packet. So I reduce the number of custom services in the scan response packet to 1 instead of 2 and the application doesn´t crash and I see all services through the nRF Connect app. But I believe this is not an ideal solution....
How can I use more than one custom service with my BLE application? Do I have to send more than one scan response packets or how can I handle it?