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!

  • 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},
    };
    

  • Hi Karl,
    I have successfully added all info in Device Info Service but getting issues in the device MAC address.

    Can you please check what I am making mistake?

    Thanks! 

    ble_gap_addr_t ble_addr;
    sd_ble_gap_addr_get(&ble_addr);
    
    
        ble_srv_ascii_to_utf8(&dis_init.p_sys_id, &ble_addr);
        ble_srv_ascii_to_utf8(&dis_init.model_num_str, (char *)MODEL_NUMBER);
        ble_srv_ascii_to_utf8(&dis_init.serial_num_str, (char *)SERIAL_NUMBER);
        ble_srv_ascii_to_utf8(&dis_init.fw_rev_str, (char *)FIRMWARE_NUMBER);
        ble_srv_ascii_to_utf8(&dis_init.hw_rev_str, (char *)HARDWARE_NUMBER);
        ble_srv_ascii_to_utf8(&dis_init.manufact_name_str, (char *)MANUFACTURER_NAME);
    
    

Reply
  • Hi Karl,
    I have successfully added all info in Device Info Service but getting issues in the device MAC address.

    Can you please check what I am making mistake?

    Thanks! 

    ble_gap_addr_t ble_addr;
    sd_ble_gap_addr_get(&ble_addr);
    
    
        ble_srv_ascii_to_utf8(&dis_init.p_sys_id, &ble_addr);
        ble_srv_ascii_to_utf8(&dis_init.model_num_str, (char *)MODEL_NUMBER);
        ble_srv_ascii_to_utf8(&dis_init.serial_num_str, (char *)SERIAL_NUMBER);
        ble_srv_ascii_to_utf8(&dis_init.fw_rev_str, (char *)FIRMWARE_NUMBER);
        ble_srv_ascii_to_utf8(&dis_init.hw_rev_str, (char *)HARDWARE_NUMBER);
        ble_srv_ascii_to_utf8(&dis_init.manufact_name_str, (char *)MANUFACTURER_NAME);
    
    

Children
No Data
Related