Hello,
I am using NUS service as a peripheral with read and write characteristics and tested on master control panel. Now I am using S120 stack for central device and able to scan for the device. But when central tries to connect, I am getting Service not found event. Can anyone tell me the cause for this?
Update: I added uuid in both server and client, still I am getting BLE_DB_DISCOVERY_SRV_NOT_FOUND event.
Here is the code snippet for peripheral:
ble_uuid_t service_uuid;
ble_uuid128_t base_uuid = BLE_UUID_OUR_BASE_UUID;
service_uuid.uuid = BLE_UUID_NUS_SERVICE;
// Initialize the service structure.
p_hrs->conn_handle = BLE_CONN_HANDLE_INVALID;
p_hrs->data_handler = p_hrs_init->evt_handler;
p_hrs->is_notification_enabled = false;
// add custom base UUID
err_code = sd_ble_uuid_vs_add(&base_uuid, &p_hrs->uuid_type);
if(err_code != NRF_SUCCESS)
{
return err_code;
}
service_uuid.type = p_hrs->uuid_type;
// Add the service
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
&service_uuid,
&p_hrs->service_handle);
if(err_code != NRF_SUCCESS)
{
return err_code;
}
// Add the RX Characteristic.
err_code = heart_rate_measurement_char_add(p_hrs, p_hrs_init);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
err_code = heart_rate_measurement_read_char_add(p_hrs, p_hrs_init);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
return NRF_SUCCESS;
Here is the code snippet for central:
void client_handling_init(void)
{
uint32_t err_code;
uint32_t i;
ble_uuid128_t base_uuid = BLE_UUID_OUR_BASE_UUID;
err_code = sd_ble_uuid_vs_add(&base_uuid, &m_base_uuid_type);
APP_ERROR_CHECK(err_code);
for (i = 0; i < MAX_CLIENTS; i++)
{
m_client[i].state = IDLE;
}
m_client_count = 0;
db_discovery_init();
// Register with discovery module for the discovery of the service.
ble_uuid_t uuid;
uuid.type = m_base_uuid_type;
uuid.uuid = BLE_UUID_DEVICE_INFORMATION_SERVICE;
err_code = ble_db_discovery_evt_register(&uuid,
db_discovery_evt_handler);
APP_ERROR_CHECK(err_code);
}
Regards,
Sowmya