Setting DIS info dynamically in Zephyr

SDK v3.0.2 Toolchain 3.01

Is it possible to set the DIS name, (and possibly others) dynamically at runtime? I need to provide some level of configuration to my  end users.

I've done this before at boot time using ble_dis_init() under SDK17 but under NCS/Zephyr it's buried in kconfig

Parents
  • Hello,

    Yes, it's possible to set the device name attribute value, etc at runtime. Please have a look at this thread:  Setting DIS serial number at runtime  

    Best regards,

    Vidar

  • Sorry I know I closed this ticket, but..

    With logging enabled I notice I get an error "<err> bt_gatt: Failed to save Database Hash (err -2)". Running the Zephyr peripheral_dis example I get the same.

    It doesn't appear to have affected operation. What are the consequences of the error?

    *** Booting nRF Connect SDK v3.0.2-89ba1294ac9b ***
    *** Using Zephyr OS v4.0.99-f791c49f492c ***
    [00:00:00.000,382] <inf> bt_sdc_hci_driver: SoftDevice Controller build revision:
                                                89 9a 50 8a 95 01 9c 58  fc 39 d2 c1 10 04 ee 02 |..P....X .9......
                                                64 ce 25 be                                      |d.%.
    [00:00:00.001,366] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    [00:00:00.001,379] <inf> bt_hci_core: HW Variant: nRF54Lx (0x0005)
    [00:00:00.001,392] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 137.20634 Build 2617349514
    [00:00:00.001,512] <inf> bt_hci_core: No ID address. App must call settings_load()
    [00:00:00.001,733] <inf> bt_hci_core: Identity: E7:B8:43:94:B6:B4 (random)
    [00:00:00.001,748] <inf> bt_hci_core: HCI: version 6.0 (0x0e) revision 0x30f3, manufacturer 0x0059
    [00:00:00.001,761] <inf> bt_hci_core: LMP: version 6.0 (0x0e) subver 0x30f3
    [00:00:00.002,523] <err> bt_gatt: Failed to save Database Hash (err -2)
    Bluetooth initialized
    Advertising successfully started

  • No problem. I'm not sure why the the DIS sample tries to save the database hash to settings, I was not able to reproduce this here with SDK v3.0.2. However, this may be required in your actual app, and the reason it fails is that Settings is likely not enabled with a NV storage backend (CONFIG_SETTINGS_NONE=y).

    Please check if the generated .config file includes the correct configuration. nRF54L requires the ZMS backend while all others use NVS.

  • I was not able to reproduce this here with SDK v3.0.2.

    You're using a different app; I'm testing using the peripheral_DIS example. Using 3.0.2 on a 54L15DK.

    nRF54L requires the ZMS backend while all others use NVS.

    My app currently uses NVS to save a structure which contains a mix of integer & string values, about 16 values plus maybe 40 bytes in strings (including the custom DIS name). I suppose I should be able to move that to ZMS assuming it's compatible with nRF52832 which I also need to support.

     Anyway back to the DIS example, it doesn't build now:

    C:/ncs/v3.0.2/zephyr/subsys/settings/src/settings_zms.c:708: undefined reference to `flash_area_get_sectors'

    which I guess is just a missing include file?

    [Edit: Builds OK now, was missing config  CONFIG_FLASH=CONFIG_FLASH_MAP=y]

  • Screenshots were taken from the peripheral_uart sample, but I was testing the peripheral_dis sample from the Zephyr repo.

    Nick_RA said:
    My app currently uses NVS to save a structure which contains a mix of integer & string values, about 16 values plus maybe 40 bytes in strings (including the custom DIS name). I suppose I should be able to move that to ZMS assuming it's compatible with nRF52832 which I also need to support.

    The sample is not configured to support any NV storage by default.

    ZMS is optimized for RRAM/MMRAM and NVS for FLASH. If you have a project for both nRF52 and nRF54L. you can create a Kconfig file in your project root that selectes the appropriate filesystem based on the NV memory the chip has. Same as we do in some of ourr SDK samplse. For example, in  the peripheral_uart sample here: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/bluetooth/peripheral_uart/Kconfig#L39-L43 

Reply
  • Screenshots were taken from the peripheral_uart sample, but I was testing the peripheral_dis sample from the Zephyr repo.

    Nick_RA said:
    My app currently uses NVS to save a structure which contains a mix of integer & string values, about 16 values plus maybe 40 bytes in strings (including the custom DIS name). I suppose I should be able to move that to ZMS assuming it's compatible with nRF52832 which I also need to support.

    The sample is not configured to support any NV storage by default.

    ZMS is optimized for RRAM/MMRAM and NVS for FLASH. If you have a project for both nRF52 and nRF54L. you can create a Kconfig file in your project root that selectes the appropriate filesystem based on the NV memory the chip has. Same as we do in some of ourr SDK samplse. For example, in  the peripheral_uart sample here: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/bluetooth/peripheral_uart/Kconfig#L39-L43 

Children
No Data
Related