This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Adding Custom Service to Buttonless DFU example results in fatal error

Hi, 

I am working on NRF52840 preview DK using SDK version 15.3

I have compiled and loaded the Secure DFU bootloader onto the device, and also successfully got the BLE_BUTTONLESS_DFU template to work by uploading it through the DfuTarg.

but, once I try to write my own service in the template the app crashes with a 'fatal error' and the device keeps resetting.

Here is my service_init function

static void services_init(void)
{
    uint32_t                  err_code;
    nrf_ble_qwr_init_t        qwr_init  = {0};
    ble_dfu_buttonless_init_t dfus_init = {0};

    // Initialize Queued Write Module.
    qwr_init.error_handler = nrf_qwr_error_handler;

    err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init);
    APP_ERROR_CHECK(err_code);

    dfus_init.evt_handler = ble_dfu_evt_handler;

    err_code = ble_dfu_buttonless_init(&dfus_init);
    APP_ERROR_CHECK(err_code);
    err_code = ble_dfu_buttonless_async_svci_init();
    APP_ERROR_CHECK(err_code);

    ble_uuid_t        service_uuid;
    ble_uuid128_t     base_uuid = BLE_UUID_OUR_BASE_UUID;
    service_uuid.uuid = BLE_UUID_OUR_SERVICE_UUID;
    err_code = sd_ble_uuid_vs_add(&base_uuid, &service_uuid.type);
    APP_ERROR_CHECK(err_code);    

    // Add our service
    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                            &service_uuid,
                            &p_our_service.service_handle);
    
    APP_ERROR_CHECK(err_code);
}

some of the settings related to service is as follows

// Defining 16-bit service and 128-bit base UUIDs
#define BLE_UUID_OUR_BASE_UUID              {{0x23, 0xD1, 0x13, 0xEF, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00}} // 128-bit base UUID
#define BLE_UUID_OUR_SERVICE_UUID                0xF00D // Just a random, but recognizable value


typedef struct
{
    uint16_t service_handle;                /**< Handle of Our Service (as provided by the BLE stack). */
}ble_os_t;

ble_os_t p_our_service;

static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID;                            /**< Handle of the current connection. */
static void advertising_start(bool erase_bonds);                                    /**< Forward declaration of advertising start function */

// YOUR_JOB: Use UUIDs for service(s) used in your application.
static ble_uuid_t m_adv_uuids[] = {{BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE}, {BLE_UUID_OUR_SERVICE_UUID, BLE_UUID_TYPE_VENDOR_BEGIN}};

I also changed 

NRF_SDH_BLE_VS_UUID_COUNT to 2 

and 

NRF_SDH_BLE_SERVICE_CHANGED = 1

in sdk_config.h

Parents Reply Children
Related