Bluetooth: shell: fix bt init sync command
Shell command "bt init sync" now correctly enables Bluetooth synchronously, and "bt init" enables Bluetooth asynchronously. Fixes #47860. Signed-off-by: Andreas Rudolf <andreas.rudolf@husqvarnagroup.com>
This commit is contained in:
parent
577caf774e
commit
422f98182c
1 changed files with 6 additions and 7 deletions
|
@ -660,7 +660,7 @@ static void bt_ready(int err)
|
|||
static int cmd_init(const struct shell *sh, size_t argc, char *argv[])
|
||||
{
|
||||
int err;
|
||||
bool no_ready_cb = false;
|
||||
bool sync = false;
|
||||
|
||||
ctx_shell = sh;
|
||||
|
||||
|
@ -670,23 +670,22 @@ static int cmd_init(const struct shell *sh, size_t argc, char *argv[])
|
|||
if (!strcmp(arg, "no-settings-load")) {
|
||||
no_settings_load = true;
|
||||
} else if (!strcmp(arg, "sync")) {
|
||||
no_ready_cb = true;
|
||||
sync = true;
|
||||
} else {
|
||||
shell_help(sh);
|
||||
return SHELL_CMD_HELP_PRINTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (no_ready_cb) {
|
||||
if (sync) {
|
||||
err = bt_enable(NULL);
|
||||
bt_ready(err);
|
||||
} else {
|
||||
err = bt_enable(bt_ready);
|
||||
if (err) {
|
||||
shell_error(sh, "Bluetooth init failed (err %d)",
|
||||
err);
|
||||
}
|
||||
|
||||
} else {
|
||||
err = bt_enable(NULL);
|
||||
bt_ready(err);
|
||||
}
|
||||
|
||||
return err;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue