NCS BLE Device information service set characteristics contents at run time.

Hi There, 

Currently using the DIS service in my application, however I am facing a couple of issues at the moment. 

# Enable DIS service
CONFIG_BT_DIS=y
CONFIG_BT_DIS_SERIAL_NUMBER=y
CONFIG_BT_DIS_FW_REV=y
CONFIG_BT_DIS_HW_REV=y
CONFIG_BT_DIS_SW_REV=y
CONFIG_BT_DIS_PNP=n
CONFIG_BT_DIS_SERIAL_NUMBER_STR="ShouldBeSetAtRunTime"
CONFIG_BT_DIS_FW_REV_STR="************"
CONFIG_BT_DIS_HW_REV_STR="*********"
CONFIG_BT_DIS_MANUF="##########"
CONFIG_BT_DIS_MODEL="##########"

1. How to set the serial number characteristic at run time instead of being populated from the configuration file, As in my case the serial number will be sent to the device during production. 

CONFIG_BT_DIS_SERIAL_NUMBER_STR

2. How to exclude the model characteristics from the service ? 

CONFIG_BT_DIS_MODEL

Environment description:

-  NCS v2.2.0

-  BLE Application. 

-  NRF52840 Using internal RC low frequency clock. (Raytac Module).


Cheers, 

  • Hi,

    1. How to set the serial number characteristic at run time instead of being populated from the configuration file, As in my case the serial number will be sent to the device during production. 

    You can set it runtime using settings_runtime_set(). This is actually what is called when CONFIG_BT_DIS_SERIAL_NUMBER_STR is set as well, but in this case make sure that CONFIG_BT_DIS_SERIAL_NUMBER_STR is not set, and call settings_runtime_set() yourself runtime with "bt/dis/serial" as the first parameter.

    2. How to exclude the model characteristics from the service ? 

    There is no support for excluding the model from the DIS service in Zephyr, so if you want to do that you will have to change the implementation in zephyr/subsys/bluetooth/services/dis.c.

Related