Bluetooth: Mesh: suspend/resume advertising
Disables Mesh advertising when suspending, and enables advertising when resuming Mesh. Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
This commit is contained in:
parent
3be26c4cb9
commit
897a1d0d1c
1 changed files with 18 additions and 0 deletions
|
@ -460,6 +460,13 @@ int bt_mesh_suspend(void)
|
|||
|
||||
bt_mesh_model_foreach(model_suspend, NULL);
|
||||
|
||||
err = bt_mesh_adv_disable();
|
||||
if (err) {
|
||||
atomic_clear_bit(bt_mesh.flags, BT_MESH_SUSPENDED);
|
||||
LOG_WRN("Disabling advertisers failed (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -488,6 +495,17 @@ int bt_mesh_resume(void)
|
|||
return -EALREADY;
|
||||
}
|
||||
|
||||
if (!IS_ENABLED(CONFIG_BT_EXT_ADV)) {
|
||||
bt_mesh_adv_init();
|
||||
}
|
||||
|
||||
err = bt_mesh_adv_enable();
|
||||
if (err) {
|
||||
atomic_set_bit(bt_mesh.flags, BT_MESH_SUSPENDED);
|
||||
LOG_WRN("Re-enabling advertisers failed (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = bt_mesh_scan_enable();
|
||||
if (err) {
|
||||
LOG_WRN("Re-enabling scanning failed (err %d)", err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue