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!

Parents
  • Hello,

    Have you seen the Services tutorial?
    It is a great place to start when jumping into adding services and characteristics to your project, I highly recommend it!
    It goes through the basic theory and practice of adding a new service to your project.

    If you should encounter any issues or questions, please do not hesitate to ask!

    Best regards,
    Karl

  • Hi @Karl YIvisaker

    I am already working on the following link to add service.
    https://github.com/bjornspockeli/nRF52-Bluetooth-Course

    Device Information Service is a very common service. So is there a link that can help me to add.

    I have the following links:
    https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.0.0%2Fgroup__ble__dis.html

    But I am getting confused form where to start. Can you please help?

    Thanks!

  • 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

  • Yes I mean how can I change the order of services?
    I am trying to change here but it is not working.



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

Reply
  • Yes I mean how can I change the order of services?
    I am trying to change here but it is not working.



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

Children
Related