I'm following this tutorial for creating a basic custom service using the ble_app_template from sdk 13 github.com/.../custom_ble_service_example
I've filled in the following function
/**@brief Function for initializing services that will be used by the application.
*/
static void services_init(void)
{
/* YOUR_JOB: Add code to initialize the services used by the application.
ret_code_t err_code;
ble_xxs_init_t xxs_init;
ble_yys_init_t yys_init;
// Initialize XXX Service.
memset(&xxs_init, 0, sizeof(xxs_init));
xxs_init.evt_handler = NULL;
xxs_init.is_xxx_notify_supported = true;
xxs_init.ble_xx_initial_value.level = 100;
err_code = ble_bas_init(&m_xxs, &xxs_init);
APP_ERROR_CHECK(err_code);
// Initialize YYY Service.
memset(&yys_init, 0, sizeof(yys_init));
yys_init.evt_handler = on_yys_evt;
yys_init.ble_yy_initial_value.counter = 0;
err_code = ble_yy_service_init(&yys_init, &yy_init);
APP_ERROR_CHECK(err_code);
*/
}
with the following as per the tutorial
/**@brief Function for initializing services that will be used by the application.
*/
static void services_init(void)
{
/* YOUR_JOB: Add code to initialize the services used by the application.*/
ret_code_t err_code;
ble_cus_init_t cus_init;
// Initialize CUS Service init structure to zero.
memset(&cus_init, 0, sizeof(cus_init));
err_code = ble_cus_init(&m_cus, &cus_init);
APP_ERROR_CHECK(err_code);
}
When build and flash, and chip does not blink and there are no advertisements.
When I comment out the following line of code in the above function
err_code = ble_cus_init(&m_cus, &cus_init);
like so
//err_code = ble_cus_init(&m_cus, &cus_init);
The lights blinks and I see advertisements.
This is what my ble_cus_init function looks like
uint32_t ble_cus_init(ble_cus_t * p_cus, const ble_cus_init_t * p_cus_init)
{
if (p_cus == NULL || p_cus_init == NULL)
{
return NRF_ERROR_NULL;
}
uint32_t err_code;
ble_uuid_t ble_uuid;
// Initialize service structure
p_cus->conn_handle = BLE_CONN_HANDLE_INVALID;
// Add Custom Service UUID
ble_uuid128_t base_uuid = {CUSTOM_SERVICE_UUID_BASE};
err_code = sd_ble_uuid_vs_add(&base_uuid, &p_cus->uuid_type);
VERIFY_SUCCESS(err_code);
ble_uuid.type = p_cus->uuid_type;
ble_uuid.uuid = CUSTOM_SERVICE_UUID;
// Add the Custom Service
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_cus->service_handle);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
return err_code;
}
Is there something wrong with my ble_cus_init function?
Thanks