-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Bluetooth: Classic: add local name #96621
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have CONFIG_BT_DEVICE_NAME
and bt_set_name()
APIs. I don't think it makes sense to do BR/EDR-specific APIs for this.
updated |
err = bt_br_write_local_name(CONFIG_BT_DEVICE_NAME); | ||
if (err) { | ||
return err; | ||
} | ||
|
||
strncpy(bt_dev.name, CONFIG_BT_DEVICE_NAME, CONFIG_BT_DEVICE_NAME_MAX); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The device name storing feature will be broken by this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO, It would not storing CONFIG_BT_DEVICE_NAME , which would be load when stack init.
otherwise local name would be to twice, when bt_enable, it would try to store user name, and check (bt_dev.name[0] == '\0') , then set local name again
int bt_enable(bt_ready_cb_t cb)
{
......
} else if (IS_ENABLED(CONFIG_BT_DEVICE_NAME_DYNAMIC)) {
err = bt_set_name(CONFIG_BT_DEVICE_NAME);
if (err) {
LOG_WRN("Failed to set device name (%d)", err);
}
}
......
}
static int commit_settings(void)
{
......
#if defined(CONFIG_BT_DEVICE_NAME_DYNAMIC)
if (bt_dev.name[0] == '\0') {
bt_set_name(CONFIG_BT_DEVICE_NAME);
}
#endif
......
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think so.
int bt_enable(bt_ready_cb_t cb) { ...... } else if (IS_ENABLED(CONFIG_BT_DEVICE_NAME_DYNAMIC)) { err = bt_set_name(CONFIG_BT_DEVICE_NAME); if (err) { LOG_WRN("Failed to set device name (%d)", err); } } ...... }
If the settings is not enabled and CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled, the name is stored into bt_dev.name
. The default value is CONFIG_BT_DEVICE_NAME since the settings is not enabled.
static int commit_settings(void) { ...... #if defined(CONFIG_BT_DEVICE_NAME_DYNAMIC) if (bt_dev.name[0] == '\0') { bt_set_name(CONFIG_BT_DEVICE_NAME); } #endif ......
Or if the settings is enabled and CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled, the bt_dev.name
is loaded from settings. If the name is not stored, the default value CONFIG_BT_DEVICE_NAME will be used and store it to settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the settings is not enabled and CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled,that commit would meet the need. bt_dev.name would save last changed device name
and if the settings is enabled and CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled, if controller name has been changed, we need to cache name to bt_dev.name and store to settings
these cases would be handled well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the settings is not enabled and CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled,that commit would meet the need. bt_dev.name would save last changed device name
So, do you mean the change of the line 866 is used to fix the issue that the device name is incorrect when calling bt_get_name()
if the settings is not enabled but CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled and function bt_set_name()
is not called?
move bt local name commom hci to bt_br_write_local_name Signed-off-by: Kai Cheng <[email protected]>
add BR/EDR local name dynamic Signed-off-by: Kai Cheng <[email protected]>
|
add BR/EDR local name