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

Add Device Information Service in custom_ble_app_template

Hi,
I am working on nRF52840.
I want to add Device Information Service in ble_app_template. (as shown in the attached image its from another device)
How can I add?
Kindly suggest. 
Thanks!

  • Hello again,

    Looking at your included project files I would think you are exceeding the possible 31 byte length of an advertisement here - you are attempting to advertise with a 15 length name, full appearance and 2 service UUID's.
    An advertisement can at most be 31 bytes, and you will need to use some bytes for overhead ( type and length fields ).
    So, I would suggest that you try to shorten the device name length ( you are currently using 17 bytes on just the device name ), and moving one or both of your service UUID's to the scan response.

    Try this, and let me know if it resolves your issue.

    Best regards,
    Karl

  • Hi @Karl

    I have changed the name but still the same issue. Disappointed


    #define DEVICE_NAME                     "M"                       /**< Name of device. Will be included in the advertising data. */
    #define MANUFACTURER_NAME               "N"                   /**< Manufacturer. Will be passed to Device Information Service. */
    


    static void advertising_init(void)
    {
        ret_code_t             err_code;
        ble_advertising_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        init.advdata.name_type               = BLE_ADVDATA_SHORT_NAME;
        init.advdata.include_appearance      = true;
        init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
        init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.advdata.uuids_complete.p_uuids  = m_adv_uuids;
    
        init.config.ble_adv_fast_enabled  = true;
        init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
        init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
    
        init.evt_handler = on_adv_evt;
    
        err_code = ble_advertising_init(&m_advertising, &init);
     //   APP_ERROR_CHECK(err_code);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }
    

  • If you use BLE_ADVDATA_SHORT_NAME then it will short the name down for you, so you can keep your DEVICE_NAME "longer_name", and it will only include the first 6 characters.

    You do not need to shorten your manufacturer name, because it will not be advertised - only the device information service will provide the manufacturer name.

    Did you move your one of the UUID's to the scan response instead of the advertising?

    Best regards,
    Karl

  • Thank you so much, Karl (Y)
    Problem Solved.
    I have changed the following and I can see both services.

        init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.srdata.uuids_complete.p_uuids  = m_adv_uuids;
    



    One last thing now how can I add the following info in Device Info Service? and how can I bring up the Device information service above the unknow service?



    Thanks again.

  • Muqarrab said:
    Thank you so much, Karl (Y)
    Problem Solved.

    It is no problem at all Muqarrab, I am happy to help!
    Great, I am glad to hear that you were able to resolve the issue, and that the application is now working as intended! :)

    Muqarrab said:
    I have changed the following and I can see both services.

    Perfect. The scan response can be used as an extension of the advertising data - which is perfect for cases like this, where 31 bytes is not enough to convey all the information.

    Muqarrab said:
    One last thing now how can I add the following info in Device Info Service? and how can I bring up the Device information service above the unknow service?

    If you would like to add more information to your Device Information service, you need to do this during your services initialization. On line 311 of your main.c, you begin to do this - but you only add manufacturer name. Here you may add all the other information, like shown in the ble_dis_init_t structure documentation.

    I do not understand what you mean by that last part, "bring up the Device information service above the unknown service"?
    I suppose you are talking about the placement of the services in the list - this is determined by their placement on the GATT table. You can probably change this by changing the order of initialization - right now you are initializing your custom service ( unknown service ) before your DIS service, which I would assume assigns the lowest GATT index to the custom service.
    I have not tried this last part myself, but give it a try and let me know if it does not change your services order.

    Best regards,
    Karl

Related