I have a device which advertises some services, I want to discover those services and write to those characteristics. However I can only find one service and not multiple.
I have the following code that registers one service:
static void db_discovery_init(void)
{
uint32_t err_code = ble_db_discovery_init(db_disc_handler);
APP_ERROR_CHECK(err_code);
ble_uuid_t auth_uuid;
ble_uuid128_t auth_base_uuid = {{0xa0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x13, 0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x13}};
auth_uuid.type = 1;
auth_uuid.uuid = 0x5678;
err_code = sd_ble_uuid_vs_add(&auth_base_uuid, &auth_uuid.type);
if (err_code != NRF_SUCCESS)
{
NRF_LOG_INFO("err: %d\n", err_code);
return;
}
err_code = ble_db_discovery_evt_register(&auth_uuid);
APP_ERROR_CHECK(err_code);
}
But I also have the following service that I want to discover:
ble_uuid128_t other_service_base_uuid = {{0xf3, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x13, 0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x13}}; which has the same 0x5678 uuid as the other.
I'm thinking maybe there is a way to register a service based on the full uuid, rather than two bytes.
I use sdk 12.3.0 for my nrf51802 with s130.
Edit 1:
I've remade the function so that I register both services to the discovery module and changed the ble_enable_params.common_enable_params.vs_uuid_count to 2. New code:
static void db_discovery_init(void)
{
uint32_t err_code = ble_db_discovery_init(db_disc_handler);
APP_ERROR_CHECK(err_code);
ble_uuid_t auth_uuid;
ble_uuid128_t auth_base_uuid = {{0xa0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x13, 0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x13}};
auth_uuid.type = 1;
auth_uuid.uuid = 0x5678;
err_code = sd_ble_uuid_vs_add(&auth_base_uuid, &auth_uuid.type);
if (err_code != NRF_SUCCESS)
{
NRF_LOG_INFO("err: %d\n", err_code);
return;
}
err_code = ble_db_discovery_evt_register(&auth_uuid);
APP_ERROR_CHECK(err_code);
// Second service:
ble_uuid_t ctrl_uuid;
ble_uuid128_t ctrl_base_uuid = {{0xf3, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x13, 0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x13}};
ctrl_uuid.type = 1;
ctrl_uuid.uuid = 0x5678;
err_code = sd_ble_uuid_vs_add(&ctrl_base_uuid, &ctrl_uuid.type);
if (err_code != NRF_SUCCESS)
{
NRF_LOG_INFO("err: %d\n", err_code);
return;
}
err_code = ble_db_discovery_evt_register(&ctrl_uuid);
APP_ERROR_CHECK(err_code);
}
These are my logs:
BLEDRV:INFO:Scanning started, waiting for device... BLEDRV:INFO:Found the device, connecting... BLEDRV:INFO:Device connected BLE_DB_DISC:INFO:Starting discovery of service with UUID 0x5678 for Connection handle 0 BLE_DB_DISC:INFO:Found service UUID 0x5678 BLE_DB_DISC:INFO:Discovery of service with UUID 0x5678 completed with success for Connection handle 0 BLE_DB_DISC:INFO:Starting discovery of service with UUID 0x5678 for Connection handle 0 BLE_DB_DISC:INFO:Service UUID 0x5678 Not found BLEDRV:INFO:db disc evt type: 0 BLEDRV:INFO:db disc evt type: 2