Hello all,
Currently I am developing a code for a BLE central device that is supposed to receive data from a weight scale (peer). The peer has a service with a custom 128-bit UUID.
I am initializing the service like this:
uint32_t ble_wss_c_init(ble_wss_c_t * p_ble_wss_c, ble_wss_c_init_t * p_ble_wss_c_init)
{
uint32_t err_code;
ble_uuid_t wss_uuid;
ble_uuid128_t wss_base_uuid = {0x8B, 0x7D, 0x29, 0x78, 0xFF, 0x00, 0xCB, 0x80, \
0xFF, 0x1E, 0xE4, 0x1F, 0x00, 0x41, 0x43, 0x23};
VERIFY_PARAM_NOT_NULL(p_ble_wss_c);
VERIFY_PARAM_NOT_NULL(p_ble_wss_c_init);
VERIFY_PARAM_NOT_NULL(p_ble_wss_c_init->evt_handler);
p_ble_wss_c->conn_handle = BLE_CONN_HANDLE_INVALID;
p_ble_wss_c->peer_wss_db.wm_cccd_handle = BLE_GATT_HANDLE_INVALID;
p_ble_wss_c->peer_wss_db.wm_handle = BLE_GATT_HANDLE_INVALID;
p_ble_wss_c->evt_handler = p_ble_wss_c_init->evt_handler;
err_code = sd_ble_uuid_vs_add(&wss_base_uuid, &p_ble_wss_c->uuid_type);
if (err_code != NRF_SUCCESS)
{
}
VERIFY_SUCCESS(err_code);
wss_uuid.type = p_ble_wss_c->uuid_type;
wss_uuid.uuid = BLE_UUID_WEIGHT_SCALE_SERVICE;
return ble_db_discovery_evt_register(&wss_uuid);
}
I am being able to connect to the device. However, when the program reaches the function ble_wss_on_db_disc_evt() to confirm that the service was discovered, I get that the ble_db_discovery_evt_t is BLE_DB_DISCOVERY_SRV_NOT_FOUND.
void ble_wss_on_db_disc_evt(ble_wss_c_t * p_ble_wss_c, const ble_db_discovery_evt_t * p_evt)
{
if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE
&&
p_evt->params.discovered_db.srv_uuid.uuid == BLE_UUID_WEIGHT_SCALE_SERVICE
&&
p_evt->params.discovered_db.srv_uuid.type == p_ble_wss_c->uuid_type)
{
// Find the CCCD Handle of the WSS characteristic.
uint8_t i;
ble_wss_c_evt_t evt;
evt.evt_type = BLE_WSS_C_EVT_DISCOVERY_COMPLETE;
evt.conn_handle = p_evt->conn_handle;
NRF_LOG_INFO("Number of characteristics: %x", p_evt->params.discovered_db.char_count);
for (i = 0; i < p_evt->params.discovered_db.char_count; i++)
{
//NRF_LOG_INFO("Characteristic: %02x", p_evt->params.discovered_db.charateristics[i].characteristic.uuid.uuid);
if (p_evt->params.discovered_db.charateristics[i].characteristic.uuid.uuid ==
BLE_UUID_WEIGHT_MEASUREMENT_CHAR)
{
NRF_LOG_INFO("Found Weight Measurement characteristic");
// Found WSS characteristic. Store CCCD handle and break.
evt.params.peer_db.wm_cccd_handle =
p_evt->params.discovered_db.charateristics[i].cccd_handle;
evt.params.peer_db.wm_handle =
p_evt->params.discovered_db.charateristics[i].characteristic.handle_value;
p_ble_wss_c->peer_wss_db.wm_handle = p_evt->params.discovered_db.charateristics[i].characteristic.handle_value;
p_ble_wss_c->conn_handle = p_evt->conn_handle;
NRF_LOG_INFO("gm_handle: %02x",p_ble_wss_c->peer_wss_db.wm_handle);
NRF_LOG_INFO("conn_handle: %02x",p_ble_wss_c->conn_handle);
break;
}
}
NRF_LOG_INFO("Weight Service discovered at peer.");
//If the instance has been assigned prior to db_discovery, assign the db_handles
if (p_ble_wss_c->conn_handle != BLE_CONN_HANDLE_INVALID)
{
if ((p_ble_wss_c->peer_wss_db.wm_cccd_handle == BLE_GATT_HANDLE_INVALID)&&
(p_ble_wss_c->peer_wss_db.wm_handle == BLE_GATT_HANDLE_INVALID))
{
p_ble_wss_c->peer_wss_db = evt.params.peer_db;
}
}
p_ble_wss_c->evt_handler(p_ble_wss_c, &evt);
}
else
{
NRF_LOG_INFO("Weight Service discovery failure at peer. ");
printf("\nWeight Service discovery failure at peer. ");
}
}
Any ideas on why this might be happening? I have followed examples and everything seems to be correct, that is why I don´t know what is causing the issue.
Thanks in advance