From fcfc99a21d25b38aad036937f6aabef244390644 Mon Sep 17 00:00:00 2001 From: Pavel Vasilyev Date: Mon, 22 Jan 2024 14:49:19 +0100 Subject: [PATCH] Bluetooth: Mesh: Add error code for bt_mesh_adv_terminate Return error code to let an implementation know if the adv was actually stopped (was scheduled) or not. Signed-off-by: Pavel Vasilyev --- subsys/bluetooth/mesh/adv.h | 2 +- subsys/bluetooth/mesh/adv_ext.c | 10 ++++++---- subsys/bluetooth/mesh/adv_legacy.c | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/subsys/bluetooth/mesh/adv.h b/subsys/bluetooth/mesh/adv.h index e79d082862a..6595badc9f9 100644 --- a/subsys/bluetooth/mesh/adv.h +++ b/subsys/bluetooth/mesh/adv.h @@ -101,7 +101,7 @@ void bt_mesh_adv_local_ready(void); void bt_mesh_adv_relay_ready(void); -void bt_mesh_adv_terminate(struct bt_mesh_adv *adv); +int bt_mesh_adv_terminate(struct bt_mesh_adv *adv); void bt_mesh_adv_friend_ready(void); diff --git a/subsys/bluetooth/mesh/adv_ext.c b/subsys/bluetooth/mesh/adv_ext.c index c19eb2cc00d..592081f2773 100644 --- a/subsys/bluetooth/mesh/adv_ext.c +++ b/subsys/bluetooth/mesh/adv_ext.c @@ -370,7 +370,7 @@ void bt_mesh_adv_friend_ready(void) } } -void bt_mesh_adv_terminate(struct bt_mesh_adv *adv) +int bt_mesh_adv_terminate(struct bt_mesh_adv *adv) { int err; @@ -382,13 +382,13 @@ void bt_mesh_adv_terminate(struct bt_mesh_adv *adv) } if (!atomic_test_bit(ext_adv->flags, ADV_FLAG_ACTIVE)) { - return; + return 0; } err = bt_le_ext_adv_stop(ext_adv->instance); if (err) { LOG_ERR("Failed to stop adv %d", err); - return; + return err; } /* Do not call `cb:end`, since this user action */ @@ -398,8 +398,10 @@ void bt_mesh_adv_terminate(struct bt_mesh_adv *adv) k_work_submit(&ext_adv->work); - return; + return 0; } + + return -EINVAL; } void bt_mesh_adv_init(void) diff --git a/subsys/bluetooth/mesh/adv_legacy.c b/subsys/bluetooth/mesh/adv_legacy.c index 135f444b9b4..867c91bbf8e 100644 --- a/subsys/bluetooth/mesh/adv_legacy.c +++ b/subsys/bluetooth/mesh/adv_legacy.c @@ -214,9 +214,11 @@ void bt_mesh_adv_gatt_update(void) bt_mesh_adv_get_cancel(); } -void bt_mesh_adv_terminate(struct bt_mesh_adv *adv) +int bt_mesh_adv_terminate(struct bt_mesh_adv *adv) { ARG_UNUSED(adv); + + return 0; } void bt_mesh_adv_init(void)