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

DFU SERVICE ERROR WHILE ACTIVATING BLE UART SERVICE

Hi,

I’m running the  SDK 17, S132 and I do have the PC10040 board.

My embedded bluetooth application will work as a BLE UART, I will send and receive small blocks of data to configure my application.

I tested the example  SDK_17 / examples /ble_peripheral\ble_app_uart with success.

I intend to add  the SECURE DFU with bluetooth,

I tested examples\dfu\secure_bootloader\pca10040_s132_ble with examples\ble_peripheral\ble_app_buttonless_dfu. Everything works fine.

When I try to have DFU + BLE UART services active I’ve got errors while I’m starting advertising_init() 

SETUP

#define NUS_SERVICE_UUID_TYPE           BLE_UUID_TYPE_VENDOR_BEGIN                 

BLE_NUS_DEF(m_nus, NRF_SDH_BLE_TOTAL_LINK_COUNT);                                  

NRF_BLE_GATT_DEF(m_gatt);                                               

NRF_BLE_QWR_DEF(m_qwr);                                                

BLE_ADVERTISING_DEF(m_advertising);                              

static ble_uuid_t m_adv_uuids[] = { {BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE }, {BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE}};



static void advertising_init(void)

{

    uint32_t                       err_code;

    ble_advertising_init_t           init;

    

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

    init.advdata.name_type               = BLE_ADVDATA_FULL_NAME;

    init.advdata.include_appearance      = true;

    init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

    char n = 0;

       init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids2) / sizeof(m_adv_uuids2[0]);

       init.advdata.uuids_complete.p_uuids  = m_adv_uuids2;

        

    advertising_config_get(&init.config);

    init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&m_advertising, &init);   <====== I DO HAVE ERROR HERE !!!!

    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);

}

  • Hi 

    Most likely you are running out of room in the advertise packet, since it is limited to 31 bytes in total. Adding a 16-bit UUID requires an additional 4 bytes (2 for the header and 2 for the UUID). 

    Can you check how much of the packet you are using before you add the DFU service UUID?

    As a side note, if you are planning to use the NUS service for a product it is recommended to change the UUID, otherwise you have no way of differentiating your product from all the devices running the standard NUS example. 

    Best regards
    Torbjørn

  • Hi Torbjon,

    Thank you fo your prompt reply

    1) How can I check how much packet I'm using before I add DFU service?

    2) I do copy paste the examples with UUID setup,  I do not know what would be the correct UUID setup, do you have a DOC that explains that,

    Best regards,

    Carlos

  • Hi Carlos

    1) After calling ble_advertising_init you can access the raw data for the advertise packet and the scan response packet through the m_advertising struct. 

    The code snippet below shows how you can output this to the log:

    err_code = ble_advertising_init(&m_advertising, &init);
    APP_ERROR_CHECK(err_code);
    
    uint32_t adv_len, sr_len;
    adv_len = m_advertising.adv_data.adv_data.len;
    sr_len = m_advertising.adv_data.scan_rsp_data.len;
    NRF_LOG_INFO("adv_len: %i, sr_len: %i", adv_len, sr_len);

    2) You mean you want a guide on how to create your own UUID?

    This is actually as easy as creating a random one, using a UUID generator such as this one.

    Because of the huge number of possible 128-bit numbers there is no need to register your UUID anywhere.

    Best regards
    Torbjørn 

  • Hi Torbjon,


    I changed the ble_uuid_t definition, I used the same UUID_TYPE and after that I did not have more errors:

    static ble_uuid_t m_adv_uuids[] = { {BLE_UUID_NUS_SERVICE, BLE_UUID_TYPE_BLE }, {BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE}};


    I loaded  dfu/secure_bootloader and ble_peripheral\ble_app_buttonless_dfu, I noticed that the aplication goes to BootLoader during the start and I'm not able to run ble_app_buttonless_dfu.

    I had to create the ZIP file with ble_app_buttonless_dfu an send thru nRF connect aplication.

    Is there a way to set up the boot enviroment to run ble_app_buttonless_dfu after uploading it?

    Thanks in advance,

  • Hi 

    carloscoelho said:
    I changed the ble_uuid_t definition, I used the same UUID_TYPE and after that I did not have more errors:

    This might build and run OK, but the problem with this method is that you will advertise the wrong NUS service UUID. 

    The BLE_UUID_NUS_SERVICE has to go together with the NUS_SERVICE_UUID_TYPE, otherwise the UUID will not be correct. 

    I would recommend either removing the BLE_UUID_DEVICE_INFORMATION_SERVICE from the list, or add the UUID's to the scan response packet and not the advertise packet.  

    carloscoelho said:
    I loaded  dfu/secure_bootloader and ble_peripheral\ble_app_buttonless_dfu, I noticed that the aplication goes to BootLoader during the start and I'm not able to run ble_app_buttonless_dfu.

    Yes, this is a common issue if you don't use the bootloader to load the application, but load everything using nrfjprog or SES. 

    Please refer to this article for some pointers on how to handle this. 

    Also, if you have more detailed questions on DFU I recommend opening a new ticket, since I have limited experience with this ;)

    Best regards
    Torbjørn

Related