-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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?
Changes from all commits
a9b13e4
736895f
0824491
e50f9c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ | |
|
|
||
| #include "addr_internal.h" | ||
| #include "adv.h" | ||
| #include "classic/br.h" | ||
| #include "common/hci_common_internal.h" | ||
| #include "common/bt_str.h" | ||
| #include "common/rpa.h" | ||
|
|
@@ -67,10 +68,6 @@ | |
| #include "settings.h" | ||
| #include "smp.h" | ||
|
|
||
| #if defined(CONFIG_BT_CLASSIC) | ||
| #include "classic/br.h" | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_BT_DF) | ||
| #include "direction_internal.h" | ||
| #endif /* CONFIG_BT_DF */ | ||
|
|
@@ -3975,10 +3972,9 @@ static int le_init(void) | |
| return le_set_event_mask(); | ||
| } | ||
|
|
||
| #if !defined(CONFIG_BT_CLASSIC) | ||
| static int bt_br_init(void) | ||
| static int br_hci_init(void) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you just rename this to |
||
| { | ||
| #if defined(CONFIG_BT_CONN) | ||
| #if !defined(CONFIG_BT_CLASSIC) && defined(CONFIG_BT_CONN) | ||
| struct net_buf *rsp; | ||
| int err; | ||
|
|
||
|
|
@@ -3994,11 +3990,10 @@ static int bt_br_init(void) | |
|
|
||
| read_buffer_size_complete(rsp); | ||
| net_buf_unref(rsp); | ||
| #endif /* CONFIG_BT_CONN */ | ||
| #endif /* !CONFIG_BT_CLASSIC && CONFIG_BT_CONN */ | ||
|
|
||
| return 0; | ||
| } | ||
| #endif /* !defined(CONFIG_BT_CLASSIC) */ | ||
|
|
||
| static int set_event_mask(void) | ||
| { | ||
|
|
@@ -4314,7 +4309,11 @@ static int hci_init(void) | |
| } | ||
|
|
||
| if (BT_FEAT_BREDR(bt_dev.features)) { | ||
| err = bt_br_init(); | ||
| if (IS_ENABLED(CONFIG_BT_CLASSIC)) { | ||
| err = bt_br_init(); | ||
| } else { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppse |
||
| err = br_hci_init(); | ||
| } | ||
| if (err) { | ||
| return err; | ||
| } | ||
|
|
@@ -4893,6 +4892,14 @@ int bt_set_name(const char *name) | |
| } | ||
| } | ||
|
|
||
| if (IS_ENABLED(CONFIG_BT_CLASSIC)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Until now if (IS_ENABLED(CONFIG_BT_CLASSIC) &&
atomic_test_bit(bt_dev.flags, BT_DEV_READY)) { |
||
| err = bt_br_write_local_name(bt_dev.name); | ||
| if (err) { | ||
| LOG_WRN("Unable to set local name"); | ||
| return err; | ||
| } | ||
| } | ||
|
|
||
| return 0; | ||
| #else | ||
| return -ENOMEM; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -320,7 +320,15 @@ 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); | ||
| /* No name in flash — just populate bt_dev.name with the default. | ||
| * Skip bt_set_name() to avoid an unnecessary flash write; | ||
| * the controller already has the default name from init. | ||
| */ | ||
| strncpy(bt_dev.name, CONFIG_BT_DEVICE_NAME, | ||
| CONFIG_BT_DEVICE_NAME_MAX); | ||
| bt_dev.name[CONFIG_BT_DEVICE_NAME_MAX] = '\0'; | ||
| } else { | ||
| bt_set_name(bt_dev.name); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a potential issue that the life of Flash will be reduced. Since there is not any change of device name, I think it is better to write device name to controller directly.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is to fix board reboot scenario. When I initiate the do you means that if the name has been set before, and the same name would set again?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The
Uh-huh, that is what your change is doing.
In theory I think this can be done. But currently, the new name is not checked in function
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hi @lylezhu2012 @jhedberg please help review I have verified last changes with qemu_x86 platform that the relevant functions and hci seem working normally, but this platform seems to be a pure memory simulation, and all data is lost after rebooting.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't look correct since the purpose of if (bt_dev.name[0] == '\0') {
bt_set_name(CONFIG_BT_DEVICE_NAME);
}
if (IS_ENABLED(CONFIG_BT_CLASSIC) {
bt_br_write_local_name(bt_dev.name);
} |
||
| } | ||
| #endif | ||
| if (!bt_dev.id_count) { | ||
|
|
||
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
CONFIG_BT_DEVICE_NAME_DYNAMIC=ycase should be handled in the settings commit callback, so you're missing a condition here: