Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bluetooth: mesh: Use bt_get_name to get device name #81901

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PavelVPV
Copy link
Collaborator

By default if CONFIG_BT_MESH_PROXY_USE_DEVICE_NAME or CONFIG_BT_MESH_PB_GATT_USE_DEVICE_NAME is enabled, the mesh stack will add BT_DATA_NAME_COMPLETE AD Type along with the Mesh Proxy Service or Mesh Provisioning Service advertisements accordingly.

When BT_LE_ADV_OPT_USE_NAME was present and
CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled, the advertised name was automatically updated by the host. This turned out to be a side-effect rather than expected behavior and after #71700 this behavior waa changed.

But customers use dynamic name feature.

This commit makes the mesh stack use bt_get_name to get the device name, which returns runtime name if CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled.

By default if CONFIG_BT_MESH_PROXY_USE_DEVICE_NAME
or CONFIG_BT_MESH_PB_GATT_USE_DEVICE_NAME is enabled, the mesh stack
will add BT_DATA_NAME_COMPLETE AD Type along with the Mesh Proxy Service
or Mesh Provisioning Service advertisements accordingly.

When BT_LE_ADV_OPT_USE_NAME was present and
CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled, the advertised name was
automatically updated by the host. This turned out to be a side-effect
rather than expected behavior and after zephyrproject-rtos#71700 this behavior waa
changed.

But customers use dynamic name feature.

This commit makes the mesh stack use bt_get_name to get the device name,
which returns runtime name if CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled.

Signed-off-by: Pavel Vasilyev <[email protected]>
Comment on lines +41 to +45
#if defined(CONFIG_BT_DEVICE_NAME_DYNAMIC)
#define BT_DEVICE_NAME_LEN strlen(bt_get_name())
#else
#define BT_DEVICE_NAME_LEN (sizeof(CONFIG_BT_DEVICE_NAME) - 1)
#endif
Copy link
Member

@jhedberg jhedberg Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider putting variants of a #define BT_DEVICE_NAME into the conditional branches too, so that in the static case you don't end up resolving to a function call but just a string literal? I suspect the compiler will likely optimize this anyway since it should know that bt_get_name() just returns the string literal, but since you have these conditional branches anyway you could remove some doubt by just having that extra define.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants