I have seen this question answered for the old Nordic SDK but have not been able to find a solution in Zephyr & NCS. I'm following this post on how to develop a custom BLE service in NCS. I see on step 5 they start the BLE advertising using the sd[] and ad[] arrays defined for compile time. However, I am generating my device's name during runtime using the onboard chip ID. I am using the following to set my name:
hwinfo_get_device_id(dev_uuid, sizeof(dev_uuid)); name_holder[0] = 'h'; name_holder[1] = '2'; name_holder[2] = 'o'; name_holder[3] = convertLowerNibleToChar( dev_uuid[3]); name_holder[4] = convertUpperNibleToChar( dev_uuid[4]); name_holder[5] = convertLowerNibleToChar( dev_uuid[4]); name_holder[6] = convertUpperNibleToChar( dev_uuid[5]); name_holder[7] = convertLowerNibleToChar( dev_uuid[5]); name_holder[8] = '\0'; settings_runtime_set("bt/dis/serial", name_holder, sizeof(name_holder)); bt_set_name(name_holder);
I want to include the device name in my advertising data and scan data arrays, but those properties are defined during compile time. How would update this information during the device's runtime?