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

Eddystone & DFU Buttonless

Hi, I just started working with NRF52-DK and SDK 15.0.
I tried to test the ble_peripheral examples and they work properly.
Then I tried to add the buttonless dfu inside the Blinky example and this works too.
Now I would need to add the DFU buttonless service within the Eddystone application. The Secure DFU Service appears among those available but when I try to load a new code (a .zip file with the secure bootloader) I get an error ("Fatal error"). I believe it is a conflict or something similar but I can not solve it.
Can someone help me?

I have attached the main file, the configuration file (sdk_config.h), log by smartphone and the log that shows the moment when the error occurs

Thank you

sdk_config.h

/**
 * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA
 * 
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 * 
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 * 
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 * 
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 * 
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 */
/** @file
 *
 * @defgroup nrf5_sdk_for_eddystone main.c
 * @{
 * @ingroup nrf5_sdk_for_eddystone
 * @brief Eddystone Beacon GATT Configuration Service + EID/eTLM sample application main file.
 *
 * This file contains the source code for an Eddystone
 * Beacon GATT Configuration Service + EID/eTLM sample application.
 */

#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "bsp.h"
#include "ble_conn_params.h"
#include "ble_advertising.h"
#include "nrf_sdh.h"
#include "nrf_sdh_ble.h"
#include "app_timer.h"
#include "es_app_config.h"
#include "app_scheduler.h"
#include "nrf_ble_es.h"
#include "nrf_ble_gatt.h"
#include "nrf_pwr_mgmt.h"

#include "es_adv.h"
#include "nordic_common.h"
#include "nrf.h"
#include "app_error.h"
#include "ble.h"
#include "ble_hci.h"
#include "ble_srv_common.h"
#include "ble_advdata.h"
#include "ble_advertising.h"
#include "ble_conn_params.h"
#include "nrf_sdh.h"
#include "nrf_sdh_soc.h"
#include "nrf_sdh_ble.h"
#include "app_timer.h"
#include "fds.h"
#include "peer_manager.h"
#include "ble_dfu.h"
#include "ble_conn_state.h"
#include "nrf_ble_qwr.h"

//#include "SEGGER_RTT.h"
#include "nrf_log.h" //aggiunto da Simone
#include "nrf_log_ctrl.h" //aggiunto da Simone
#include "nrf_log_default_backends.h" //aggiunto da Simone




#define DEAD_BEEF                       0xDEADBEEF          //!< Value used as error code on stack dump, can be used to identify stack location on stack unwind.
#define NON_CONNECTABLE_ADV_LED_PIN     BSP_BOARD_LED_0     //!< Toggles when non-connectable advertisement is sent.
#define CONNECTED_LED_PIN               BSP_BOARD_LED_1     //!< Is on when device has connected.
#define CONNECTABLE_ADV_LED_PIN         BSP_BOARD_LED_2     //!< Is on when device is advertising connectable advertisements.

/**@brief   Priority of the application BLE event handler.
 * @note    You shouldn't need to modify this value.
 */
#define APP_BLE_OBSERVER_PRIO 3

NRF_BLE_QWR_DEF(m_qwr); 
NRF_BLE_GATT_DEF(m_gatt); //!< GATT module instance.

/**@brief Callback function for asserts in the SoftDevice.
 *
 * @details This function will be called in case of an assert in the SoftDevice.
 *
 * @warning This handler is an example only and does not fit a final product. You need to analyze
 *          how your product is supposed to react in case of Assert.
 * @warning On assert from the SoftDevice, the system can only recover on reset.
 *
 * @param[in]   line_num   Line number of the failing ASSERT call.
 * @param[in]   file_name  File name of the failing ASSERT call.
 */
void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name)
{
    app_error_handler(DEAD_BEEF, line_num, p_file_name);
}


/**@brief Function for handling BLE events.
 *
 * @param[in]   p_ble_evt   Bluetooth stack event.
 * @param[in]   p_context   Unused.
 */
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    ret_code_t err_code;

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
            // Pairing not supported
            err_code = sd_ble_gap_sec_params_reply(p_ble_evt->evt.common_evt.conn_handle,
                                                   BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP,
                                                   NULL,
                                                   NULL);
            APP_ERROR_CHECK(err_code);
            break;

        case BLE_GATTS_EVT_SYS_ATTR_MISSING:
            // No system attributes have been stored.
            err_code = sd_ble_gatts_sys_attr_set(p_ble_evt->evt.common_evt.conn_handle, NULL, 0, 0);
            APP_ERROR_CHECK(err_code);
            break;

        case BLE_GAP_EVT_CONNECTED:
            bsp_board_led_on(CONNECTED_LED_PIN);
            bsp_board_led_off(CONNECTABLE_ADV_LED_PIN);
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            // LED indication will be changed when advertising starts.
            break;

        case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
        {
            ble_gap_phys_t const phys =
            {
                .rx_phys = BLE_GAP_PHY_AUTO,
                .tx_phys = BLE_GAP_PHY_AUTO,
            };
            err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys);
            APP_ERROR_CHECK(err_code);
        } break;

        default:
            // No implementation needed.
            break;
    }
}


/**@brief Function for the GAP initialization.
*
* @details This function will set up all the necessary GAP (Generic Access Profile) parameters of
*          the device. It also sets the permissions and appearance.
*/
static void gap_params_init(void)
{
   ret_code_t              err_code;
   ble_gap_conn_params_t   gap_conn_params;
   ble_gap_conn_sec_mode_t sec_mode;
   uint8_t                 device_name[] = APP_DEVICE_NAME;

   BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);

   err_code = sd_ble_gap_device_name_set(&sec_mode,
                                         device_name,
                                         strlen((const char *)device_name));
   APP_ERROR_CHECK(err_code);

   memset(&gap_conn_params, 0, sizeof(gap_conn_params));

   gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
   gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
   gap_conn_params.slave_latency     = SLAVE_LATENCY;
   gap_conn_params.conn_sup_timeout  = CONN_SUP_TIMEOUT;

   err_code = sd_ble_gap_ppcp_set(&gap_conn_params);

   APP_ERROR_CHECK(err_code);
}


/**@brief Function for initializing the GATT module.
 */
static void gatt_init(void)
{
    ret_code_t err_code = nrf_ble_gatt_init(&m_gatt, NULL);
    APP_ERROR_CHECK(err_code);
}


/**@brief Function for initializing the BLE stack.
 *
 * @details Initializes the SoftDevice and the BLE event interrupt.
 */
static void ble_stack_init(void)
{
    ret_code_t err_code;

    err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);

    uint32_t ram_start = 0;
    err_code = nrf_sdh_ble_app_ram_start_get(&ram_start);
    APP_ERROR_CHECK(err_code);

    // Overwrite some of the default configurations for the BLE stack.
    ble_cfg_t ble_cfg;

    // Configure the maximum number of connections.
    memset(&ble_cfg, 0, sizeof(ble_cfg));
    ble_cfg.gap_cfg.role_count_cfg.periph_role_count  = 1;
#if !defined (S112)
    ble_cfg.gap_cfg.role_count_cfg.central_role_count = 0;
    ble_cfg.gap_cfg.role_count_cfg.central_sec_count  = 0;
#endif // !defined (S112)
    err_code = sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &ble_cfg, ram_start);
    APP_ERROR_CHECK(err_code);

    // Enable BLE stack.
    err_code = nrf_sdh_ble_enable(&ram_start);
    APP_ERROR_CHECK(err_code);

    // Register a handler for BLE events.
    NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
}


/**@brief Function for initializing the Connection Parameters module.
 */
static void conn_params_init(void)
{
    ret_code_t             err_code;
    ble_conn_params_init_t cp_init;

    memset(&cp_init, 0, sizeof(cp_init));

    cp_init.p_conn_params                  = NULL;
    cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
    cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
    cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
    cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
    cp_init.disconnect_on_fail             = false;

    err_code = ble_conn_params_init(&cp_init);
    APP_ERROR_CHECK(err_code);

}


/**@brief Function for initializing power management.
 */
static void power_management_init(void)
{
    ret_code_t err_code;
    err_code = nrf_pwr_mgmt_init();
    APP_ERROR_CHECK(err_code);
}


/**@brief Function for handling the idle state (main loop).
 *
 * @details If there is no pending log operation, then sleep until next the next event occurs.
 */
static void idle_state_handle(void)
{
    app_sched_execute();
    nrf_pwr_mgmt_run();
}


/**@brief Function for handling Eddystone events.
 *
 * @param[in] evt Eddystone event to handle.
 */
static void on_es_evt(nrf_ble_es_evt_t evt)
{
    switch (evt)
    {
        case NRF_BLE_ES_EVT_ADVERTISEMENT_SENT:
            NRF_LOG_INFO("ADVERTISEMENT_SENT.");
            bsp_board_led_invert(NON_CONNECTABLE_ADV_LED_PIN);
            break;

        case NRF_BLE_ES_EVT_CONNECTABLE_ADV_STARTED:
            NRF_LOG_INFO("CONNECTABLE_ADV_STARTED.");
            bsp_board_led_on(CONNECTABLE_ADV_LED_PIN);
            break;

        case NRF_BLE_ES_EVT_CONNECTABLE_ADV_STOPPED:
            NRF_LOG_INFO("CONNECTABLE_ADV_STOPPED");
            bsp_board_led_off(CONNECTABLE_ADV_LED_PIN);
            break;

        default:
            break;
    }
}


/**@brief Function for handling button events from app_button IRQ
 *
 * @param[in] pin_no        Pin of the button for which an event has occured
 * @param[in] button_action Press or Release
 */
static void button_evt_handler(uint8_t pin_no, uint8_t button_action)
{
    if (button_action == APP_BUTTON_PUSH && pin_no == BUTTON_1)
    {
        nrf_ble_es_on_start_connectable_advertising();
    }
}


/**
 * @brief Function for initializing the registation button
 *
 * @retval Values returned by @ref app_button_init
 * @retval Values returned by @ref app_button_enable
 */
static void button_init(void)
{
    ret_code_t              err_code;
    const uint8_t           buttons_cnt  = 1;
    static app_button_cfg_t buttons_cfgs =
    {
        .pin_no         = BUTTON_REGISTRATION,
        .active_state   = APP_BUTTON_ACTIVE_LOW,
        .pull_cfg       = NRF_GPIO_PIN_PULLUP,
        .button_handler = button_evt_handler
    };

    err_code = app_button_init(&buttons_cfgs, buttons_cnt, APP_TIMER_TICKS(100));
    APP_ERROR_CHECK(err_code);

    err_code = app_button_enable();
    APP_ERROR_CHECK(err_code);
}


static void timers_init(void)
{
    ret_code_t err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);
}


static void leds_init(void)
{
    ret_code_t err_code = bsp_init(BSP_INIT_LEDS, NULL);
    APP_ERROR_CHECK(err_code);
}


static void scheduler_init(void)
{
    APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
}


static void log_init(void)
{
    ret_code_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
}



/**@brief Function for handling Queued Write Module errors.
 *
 * @details A pointer to this function will be passed to each service which may need to inform the
 *          application about an error.
 *
 * @param[in]   nrf_error   Error code containing information about what went wrong.
 */
static void nrf_qwr_error_handler(uint32_t nrf_error)
{
    APP_ERROR_HANDLER(nrf_error);
}

// YOUR_JOB: Update this code if you want to do anything given a DFU event (optional).
/**@brief Function for handling dfu events from the Buttonless Secure DFU service
 *
 * @param[in]   event   Event from the Buttonless Secure DFU service.
 */
static void ble_dfu_evt_handler(ble_dfu_buttonless_evt_type_t event)
{
    switch (event)
    {
				
        case BLE_DFU_EVT_BOOTLOADER_ENTER_PREPARE:
            NRF_LOG_INFO("Device is preparing to enter bootloader mode.");
            // YOUR_JOB: Disconnect all bonded devices that currently are connected.
            //           This is required to receive a service changed indication
            //           on bootup after a successful (or aborted) Device Firmware Update.
            break;

        case BLE_DFU_EVT_BOOTLOADER_ENTER:
            // YOUR_JOB: Write app-specific unwritten data to FLASH, control finalization of this
            // by delaying reset by reporting false in app_shutdown_handler
            NRF_LOG_INFO("Device will enter bootloader mode.");
            break;

        case BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED:
            NRF_LOG_ERROR("Request to enter bootloader mode failed asynchroneously.");
            // YOUR_JOB: Take corrective measures to resolve the issue
            //           like calling APP_ERROR_CHECK to reset the device.
            break;

        case BLE_DFU_EVT_RESPONSE_SEND_ERROR:
            NRF_LOG_ERROR("Request to send a response to client failed.");
            // YOUR_JOB: Take corrective measures to resolve the issue
            //           like calling APP_ERROR_CHECK to reset the device.
            APP_ERROR_CHECK(false);
            break;

        default:
            NRF_LOG_ERROR("Unknown event from ble_dfu_buttonless.");
            break;
    }
}

/**@brief Function for initializing services that will be used by the application.
 */
static void services_init(void)
{
    ret_code_t         err_code;
    //ble_lbs_init_t     init     = {0};
    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);

    // Initialize LBS.
    //init.led_write_handler = led_write_handler;
    //err_code = ble_lbs_init(&m_lbs, &init);
    //APP_ERROR_CHECK(err_code);


    // Initialize the async SVCI interface to bootloader.
    err_code = ble_dfu_buttonless_async_svci_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);
}


/**
 * @brief Function for application main entry.
 */
int main(void)
{
    // Initialize.
    log_init();//aggiunto da Simone per log sulla Uart
    timers_init();
    leds_init();
    button_init();
    scheduler_init();
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();

    services_init();//aggiunto da simone per buttonless dfu
    conn_params_init();
    nrf_ble_es_init(on_es_evt);
    



    
    
    
    NRF_LOG_INFO("Eddystone Simone example started: %i",1);
    //printf("ssss");
    // Enter main loop.
    for (;;)
    {
        idle_state_handle();
    }
}

/**
 * @}
 */
<info> app: Setting vector table to bootloader: 0x00078000
<info> app: Setting vector table to main app: 0x00026000
<info> app: Eddystone Simone example started: 1
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: CONNECTABLE_ADV_STARTED.
<info> app: BLE_GAP_EVT_CONNECTED
<info> app: ADVERTISEMENT_SENT.
<info> app: BLE_GATTS_EVT_WRITE
<info> app: on_write
<info> app: ADVERTISEMENT_SENT.
<info> app: BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
<info> app: BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
<info> app: BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
<info> app: BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
<info> app: BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
<info> app: BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
<info> app: BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
<info> app: BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
<info> app: BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
<info> app: BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
<info> app: BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT_SENT.
<info> app: ADVERTISEMENT<info> app: BLE_GATTS_EVT_WRITE
<info> app: on_write
<info> app: Received indication state 1
<error> app: Fatal error
<warning> app: System reset
<info> app: Setting vector table to bootloader: 0x00078000
<info> app: Setting vector table to main app: 0x00026000
<info> app: Eddystone Simone example started: 1
<info> app: ADVERTISEMENT_SENT.
nRF Connect, 2018-06-28
nRF5x_Eddys (D1:29:6A:15:9B:CB)
V	16:18:53.408	Connecting to D1:29:6A:15:9B:CB...
D	16:18:53.408	gatt = device.connectGatt(autoConnect = false)
D	16:18:54.374	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
I	16:18:54.374	Connected to D1:29:6A:15:9B:CB
D	16:18:54.388	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
V	16:18:54.390	Discovering services...
D	16:18:54.390	gatt.discoverServices()
D	16:18:57.416	[Callback] Services discovered with status: 0
I	16:18:57.416	Services discovered
V	16:18:57.461	Generic Access (0x1800)
- Device Name [R W] (0x2A00)
- Appearance [R] (0x2A01)
- Peripheral Preferred Connection Parameters [R] (0x2A04)
- Central Address Resolution [R] (0x2AA6)
Generic Attribute (0x1801)
- Service Changed [I] (0x2A05)
   Client Characteristic Configuration (0x2902)
Secure DFU Service (0xFE59)
- Buttonless DFU [I W] (8ec90003-f315-4f60-9fb8-838830daea50)
   Client Characteristic Configuration (0x2902)
Eddystone Configuration Service (a3c87500-8ed3-4bdf-8a39-a01bebede295)
- Capabilities [R] (a3c87501-8ed3-4bdf-8a39-a01bebede295)
- Active Slot [R W] (a3c87502-8ed3-4bdf-8a39-a01bebede295)
- Advertising Interval [R W] (a3c87503-8ed3-4bdf-8a39-a01bebede295)
- Radio Tx Power [R W] (a3c87504-8ed3-4bdf-8a39-a01bebede295)
- (Advanced) Advertised Tx Power [R W] (a3c87505-8ed3-4bdf-8a39-a01bebede295)
- Lock State [R W] (a3c87506-8ed3-4bdf-8a39-a01bebede295)
- Unlock [R W] (a3c87507-8ed3-4bdf-8a39-a01bebede295)
- Public ECDH Key [R] (a3c87508-8ed3-4bdf-8a39-a01bebede295)
- EID Identity Key [R] (a3c87509-8ed3-4bdf-8a39-a01bebede295)
- ADV Slot Data [R W] (a3c8750a-8ed3-4bdf-8a39-a01bebede295)
- (Advanced) Factory Reset [W] (a3c8750b-8ed3-4bdf-8a39-a01bebede295)
- (Advanced) Remain Connectable [R W] (a3c8750c-8ed3-4bdf-8a39-a01bebede295)
D	16:18:57.461	gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
D	16:18:57.467	gatt.setCharacteristicNotification(8ec90003-f315-4f60-9fb8-838830daea50, true)
V	16:19:01.022	Starting pairing...
D	16:19:01.022	device.createBond()
D	16:19:01.161	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
D	16:19:01.277	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_NONE (10)
I	16:19:01.277	Bonding failed
D	16:19:01.367	[Callback] Connection state changed with status: 0 and new state: DISCONNECTED (0)
I	16:19:01.367	Disconnected
D	16:19:01.369	gatt.refresh() (hidden)
D	16:19:01.625	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
D	16:19:04.659	gatt.close()
D	16:19:04.661	wait(200)
V	16:19:04.870	Connecting to D1:29:6A:15:9B:CB...
D	16:19:04.870	gatt = device.connectGatt(autoConnect = false)
D	16:19:07.317	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
I	16:19:07.317	Connected to D1:29:6A:15:9B:CB
D	16:19:07.346	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
V	16:19:07.351	Discovering services...
D	16:19:07.351	gatt.discoverServices()
D	16:19:07.618	[Callback] Services discovered with status: 129
E	16:19:07.618	Error 129 (0x81): GATT INTERNAL ERROR
D	16:19:07.619	[Callback] Connection state changed with status: 133 and new state: DISCONNECTED (0)
E	16:19:07.619	Error 133 (0x85): GATT ERROR
I	16:19:07.619	Disconnected
D	16:19:07.726	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
D	16:19:07.864	gatt.close()
D	16:19:07.865	wait(200)
V	16:19:08.066	Connecting to D1:29:6A:15:9B:CB...
D	16:19:08.066	gatt = device.connectGatt(autoConnect = false)
I	16:19:08.069	Disconnected
D	16:19:08.537	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
I	16:19:08.537	Connected to D1:29:6A:15:9B:CB
D	16:19:08.559	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
V	16:19:08.560	Discovering services...
D	16:19:08.560	gatt.discoverServices()
D	16:19:11.618	[Callback] Services discovered with status: 0
I	16:19:11.618	Services discovered
V	16:19:11.673	Generic Access (0x1800)
- Device Name [R W] (0x2A00)
- Appearance [R] (0x2A01)
- Peripheral Preferred Connection Parameters [R] (0x2A04)
- Central Address Resolution [R] (0x2AA6)
Generic Attribute (0x1801)
- Service Changed [I] (0x2A05)
   Client Characteristic Configuration (0x2902)
Secure DFU Service (0xFE59)
- Buttonless DFU [I W] (8ec90003-f315-4f60-9fb8-838830daea50)
   Client Characteristic Configuration (0x2902)
Eddystone Configuration Service (a3c87500-8ed3-4bdf-8a39-a01bebede295)
- Capabilities [R] (a3c87501-8ed3-4bdf-8a39-a01bebede295)
- Active Slot [R W] (a3c87502-8ed3-4bdf-8a39-a01bebede295)
- Advertising Interval [R W] (a3c87503-8ed3-4bdf-8a39-a01bebede295)
- Radio Tx Power [R W] (a3c87504-8ed3-4bdf-8a39-a01bebede295)
- (Advanced) Advertised Tx Power [R W] (a3c87505-8ed3-4bdf-8a39-a01bebede295)
- Lock State [R W] (a3c87506-8ed3-4bdf-8a39-a01bebede295)
- Unlock [R W] (a3c87507-8ed3-4bdf-8a39-a01bebede295)
- Public ECDH Key [R] (a3c87508-8ed3-4bdf-8a39-a01bebede295)
- EID Identity Key [R] (a3c87509-8ed3-4bdf-8a39-a01bebede295)
- ADV Slot Data [R W] (a3c8750a-8ed3-4bdf-8a39-a01bebede295)
- (Advanced) Factory Reset [W] (a3c8750b-8ed3-4bdf-8a39-a01bebede295)
- (Advanced) Remain Connectable [R W] (a3c8750c-8ed3-4bdf-8a39-a01bebede295)
D	16:19:11.674	gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
D	16:19:11.675	gatt.setCharacteristicNotification(8ec90003-f315-4f60-9fb8-838830daea50, true)
A	16:19:23.292	Checking Lock state...
V	16:19:23.292	Reading characteristic a3c87506-8ed3-4bdf-8a39-a01bebede295
D	16:19:23.292	gatt.readCharacteristic(a3c87506-8ed3-4bdf-8a39-a01bebede295)
I	16:19:23.410	Read Response received from a3c87506-8ed3-4bdf-8a39-a01bebede295, value: (0x) 00
A	16:19:23.410	"Locked" received
A	16:19:23.410	Service is locked. Unlocking...
V	16:19:23.410	Reading characteristic a3c87507-8ed3-4bdf-8a39-a01bebede295
D	16:19:23.410	gatt.readCharacteristic(a3c87507-8ed3-4bdf-8a39-a01bebede295)
I	16:19:23.590	Read Response received from a3c87507-8ed3-4bdf-8a39-a01bebede295, value: (0x) 0D-A1-F1-61-69-3F-76-DA-CA-AC-EB-0B-48-7D-83-9F
A	16:19:23.590	"(0x) 0D-A1-F1-61-69-3F-76-DA-CA-AC-EB-0B-48-7D-83-9F" received
V	16:19:23.590	Writing request to characteristic a3c87507-8ed3-4bdf-8a39-a01bebede295
D	16:19:23.590	gatt.writeCharacteristic(a3c87507-8ed3-4bdf-8a39-a01bebede295, value=0x543090622C08C11E86F0C59CD06A322D)
I	16:19:23.770	Data written to a3c87507-8ed3-4bdf-8a39-a01bebede295, value: (0x) 54-30-90-62-2C-08-C1-1E-86-F0-C5-9C-D0-6A-32-2D
A	16:19:23.770	"(0x) 54-30-90-62-2C-08-C1-1E-86-F0-C5-9C-D0-6A-32-2D" sent
V	16:19:23.770	Reading characteristic a3c87506-8ed3-4bdf-8a39-a01bebede295
D	16:19:23.770	gatt.readCharacteristic(a3c87506-8ed3-4bdf-8a39-a01bebede295)
A	16:19:23.950	Eddystone Configuration Service unlocked
A	16:19:23.950	Reading active slot number...
I	16:19:23.950	Read Response received from a3c87506-8ed3-4bdf-8a39-a01bebede295, value: (0x) 01
V	16:19:23.950	Reading characteristic a3c87502-8ed3-4bdf-8a39-a01bebede295
A	16:19:23.950	"Unlocked" received
D	16:19:23.950	gatt.readCharacteristic(a3c87502-8ed3-4bdf-8a39-a01bebede295)
I	16:19:24.220	Read Response received from a3c87502-8ed3-4bdf-8a39-a01bebede295, value: (0x) 00
A	16:19:24.220	"0" received
A	16:19:24.220	Reading slot 0 advertising data...
V	16:19:24.220	Reading characteristic a3c8750a-8ed3-4bdf-8a39-a01bebede295
D	16:19:24.220	gatt.readCharacteristic(a3c8750a-8ed3-4bdf-8a39-a01bebede295)
W	16:19:24.400	Slot is not configured as EID
I	16:19:24.400	Read Response received from a3c8750a-8ed3-4bdf-8a39-a01bebede295, value: (0x) 10-00-01-6E-6F-72-64-69-63-73-65-6D-69-00
A	16:19:24.400	"Frame type: URL <0x10>
Tx power at 0m: 0 dBm
URL: https://www.nordicsemi.com/" received
V	16:19:27.155	Reading characteristic a3c8750c-8ed3-4bdf-8a39-a01bebede295
D	16:19:27.155	gatt.readCharacteristic(a3c8750c-8ed3-4bdf-8a39-a01bebede295)
I	16:19:27.280	Read Response received from a3c8750c-8ed3-4bdf-8a39-a01bebede295, value: (0x) 01
A	16:19:27.280	"(0x) 01" received
V	16:19:33.868	Writing request to characteristic a3c8750c-8ed3-4bdf-8a39-a01bebede295
D	16:19:33.869	gatt.writeCharacteristic(a3c8750c-8ed3-4bdf-8a39-a01bebede295, value=0x00)
I	16:19:34.030	Data written to a3c8750c-8ed3-4bdf-8a39-a01bebede295, value: (0x) 00
A	16:19:34.030	"(0x) 00" sent
V	16:19:35.643	Reading characteristic a3c8750c-8ed3-4bdf-8a39-a01bebede295
D	16:19:35.643	gatt.readCharacteristic(a3c8750c-8ed3-4bdf-8a39-a01bebede295)
I	16:19:35.740	Read Response received from a3c8750c-8ed3-4bdf-8a39-a01bebede295, value: (0x) 01
A	16:19:35.740	"(0x) 01" received
V	16:19:36.772	Reading characteristic a3c8750c-8ed3-4bdf-8a39-a01bebede295
D	16:19:36.772	gatt.readCharacteristic(a3c8750c-8ed3-4bdf-8a39-a01bebede295)
I	16:19:36.910	Read Response received from a3c8750c-8ed3-4bdf-8a39-a01bebede295, value: (0x) 01
A	16:19:36.910	"(0x) 01" received
V	16:19:42.784	Changing write type for a3c8750c-8ed3-4bdf-8a39-a01bebede295 to WRITE COMMAND
D	16:19:42.784	characteristic.setWriteType(WRITE COMMAND)
V	16:19:42.790	Writing command to characteristic a3c8750c-8ed3-4bdf-8a39-a01bebede295
D	16:19:42.790	gatt.writeCharacteristic(a3c8750c-8ed3-4bdf-8a39-a01bebede295, value=0x00)
I	16:19:42.793	Data written to a3c8750c-8ed3-4bdf-8a39-a01bebede295, value: (0x) 00
A	16:19:42.793	"(0x) 00" sent
V	16:19:47.818	Reading characteristic a3c8750c-8ed3-4bdf-8a39-a01bebede295
D	16:19:47.818	gatt.readCharacteristic(a3c8750c-8ed3-4bdf-8a39-a01bebede295)
I	16:19:47.980	Read Response received from a3c8750c-8ed3-4bdf-8a39-a01bebede295, value: (0x) 01
A	16:19:47.980	"(0x) 01" received
V	16:19:56.052	Writing command to characteristic a3c8750c-8ed3-4bdf-8a39-a01bebede295
D	16:19:56.052	gatt.writeCharacteristic(a3c8750c-8ed3-4bdf-8a39-a01bebede295, value=0x00)
I	16:19:56.054	Data written to a3c8750c-8ed3-4bdf-8a39-a01bebede295, value: (0x) 00
A	16:19:56.054	"(0x) 00" sent
V	16:21:01.268	[DFU] DFU service started
V	16:21:01.268	[DFU] Opening file...
I	16:21:02.144	[DFU] Firmware file opened successfully
V	16:21:02.144	[DFU] Connecting to DFU target...
D	16:21:02.144	[DFU] gatt = device.connectGatt(autoConnect = false)
I	16:21:02.160	[DFU] Connected to D1:29:6A:15:9B:CB
V	16:21:02.160	[DFU] Discovering services...
D	16:21:02.160	[DFU] gatt.discoverServices()
I	16:21:02.176	[DFU] Services discovered
D	16:21:02.210	[DFU] wait(1000)
W	16:21:03.208	[DFU] Application with buttonless update found
V	16:21:03.209	[DFU] Jumping to the DFU Bootloader...
V	16:21:03.209	[DFU] Enabling indications for 8ec90003-f315-4f60-9fb8-838830daea50
D	16:21:03.209	[DFU] gatt.setCharacteristicNotification(8ec90003-f315-4f60-9fb8-838830daea50, true)
D	16:21:03.221	[DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x02-00)
I	16:21:03.321	[DFU] Data written to descr.8ec90003-f315-4f60-9fb8-838830daea50, value (0x): 02-00
V	16:21:03.321	[DFU] Notifications enabled for 8ec90003-f315-4f60-9fb8-838830daea50
A	16:21:03.321	[DFU] Indications enabled
D	16:21:03.321	[DFU] wait(1000)
V	16:21:04.381	[DFU] Writing to characteristic 8ec90003-f315-4f60-9fb8-838830daea50
D	16:21:04.381	[DFU] gatt.writeCharacteristic(8ec90003-f315-4f60-9fb8-838830daea50)
D	16:21:08.403	[Callback] Connection state changed with status: 0 and new state: DISCONNECTED (0)
I	16:21:08.403	Disconnected
D	16:21:08.407	gatt.refresh() (hidden)
A	16:21:08.420	[DFU] Enter bootloader sent (Op Code = 1)
I	16:21:08.481	[DFU] Disconnected by the remote device
D	16:21:08.481	[DFU] gatt.refresh() (hidden)
D	16:21:08.481	[DFU] gatt.close()
V	16:21:08.481	[DFU] Scanning for the DFU Bootloader...
D	16:21:08.513	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
D	16:21:08.516	[DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
I	16:21:08.800	[DFU] DFU Bootloader found with address D1:29:6A:15:9B:CB
V	16:21:08.816	[DFU] DFU service started
I	16:21:08.816	[DFU] Firmware file opened successfully
D	16:21:08.816	[DFU] wait(1000)
D	16:21:09.821	[DFU] wait(1000)
V	16:21:10.867	[DFU] Connecting to DFU target...
D	16:21:10.868	[DFU] gatt = device.connectGatt(autoConnect = false)
E	16:21:15.912	[DFU] Connection failed (0x85): GATT ERROR
W	16:21:15.912	[DFU] Retrying...
V	16:21:15.912	[DFU] Disconnecting...
D	16:21:15.994	[DFU] gatt.disconnect()
I	16:21:15.994	[DFU] Disconnected
D	16:21:15.994	[DFU] gatt.refresh() (hidden)
D	16:21:15.994	[DFU] gatt.close()
V	16:21:16.026	[DFU] DFU service started
I	16:21:16.026	[DFU] Firmware file opened successfully
D	16:21:16.026	[DFU] wait(1000)
D	16:21:17.041	[DFU] wait(1000)
V	16:21:18.028	[DFU] Connecting to DFU target...
D	16:21:18.126	[DFU] gatt = device.connectGatt(autoConnect = false)
E	16:21:23.135	[DFU] Connection failed (0x85): GATT ERROR
V	16:21:23.135	[DFU] Disconnecting...
D	16:21:23.202	[DFU] gatt.disconnect()
I	16:21:23.203	[DFU] Disconnected
D	16:21:23.204	[DFU] gatt.refresh() (hidden)
D	16:21:23.206	[DFU] gatt.close()
D	16:21:23.213	[DFU] wait(600)
D	16:21:23.822	gatt.close()
D	16:21:23.825	wait(200)
V	16:21:24.027	Connecting to D1:29:6A:15:9B:CB...
D	16:21:24.027	gatt = device.connectGatt(autoConnect = false)
D	16:21:29.042	[Callback] Connection state changed with status: 133 and new state: CONNECTED (2)
E	16:21:29.042	Error 133 (0x85): GATT ERROR
V	16:21:58.413	Cancelling connection...
D	16:21:58.413	gatt.disconnect()
I	16:21:58.414	Disconnected
D	16:21:58.414	gatt.close()
D	16:21:58.416	wait(200)

Parents
  • Hi Beach, 

    from the log it could look like that the smartphone is not able to reconnect to the device after it has switched from application to bootloader mode. 

    Would it be possible for you to share the entire project, not just the main.c file? It would make it easier (and faster) to reproduce the issue here. 

    If not, could you run the application in a debug session place and a breakpoint in app_error_fault_handler() in the application and then take a look at the callstack? If you do not end up in the app_error_fault_handler() of the application, then please do the same with the bootloader. 

    Best regards

    Bjørn 

  • Hi bjorn,

    thank you so much for the quick reply.

    Fortunately I managed to solve the problem.
    The error was in the management of the DFU service within the NRF_SDH_BLE_OBSERVER. The DFU service was not recognized among the characteristics contained in the Eddystone Configuration Service. I had to add a condition in order to bypasses the control.

Reply Children
Related