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);

}

Parents
  • 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

Reply
  • 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

Children
  • 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 

Related