From 4a8a1577efbe3976d143c19415be57735697036d Mon Sep 17 00:00:00 2001 From: Lingao Meng Date: Fri, 13 Aug 2021 14:10:45 +0800 Subject: [PATCH] Bluetooth: Mesh: Redefine callback registration There is a problem with the previous method, that is, we use the same label(bt_mesh_subnet_cb_subnet_evt) and put it in the same section, which is not friendly for debugging. Signed-off-by: Lingao Meng --- subsys/bluetooth/mesh/app_keys.c | 4 +++- subsys/bluetooth/mesh/beacon.c | 4 +++- subsys/bluetooth/mesh/friend.c | 4 +++- subsys/bluetooth/mesh/gatt_services.c | 4 +++- subsys/bluetooth/mesh/lpn.c | 4 +++- subsys/bluetooth/mesh/subnet.h | 10 ++++------ 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/subsys/bluetooth/mesh/app_keys.c b/subsys/bluetooth/mesh/app_keys.c index 2762672175b..b47f122c7b2 100644 --- a/subsys/bluetooth/mesh/app_keys.c +++ b/subsys/bluetooth/mesh/app_keys.c @@ -602,7 +602,9 @@ static void subnet_evt(struct bt_mesh_subnet *sub, enum bt_mesh_key_evt evt) } } -BT_MESH_SUBNET_CB_DEFINE(subnet_evt); +BT_MESH_SUBNET_CB_DEFINE(app_keys) = { + .evt_handler = subnet_evt, +}; void bt_mesh_app_keys_reset(void) { diff --git a/subsys/bluetooth/mesh/beacon.c b/subsys/bluetooth/mesh/beacon.c index 179f65ee4d2..2c09389c943 100644 --- a/subsys/bluetooth/mesh/beacon.c +++ b/subsys/bluetooth/mesh/beacon.c @@ -423,7 +423,9 @@ static void subnet_evt(struct bt_mesh_subnet *sub, enum bt_mesh_key_evt evt) } } -BT_MESH_SUBNET_CB_DEFINE(subnet_evt); +BT_MESH_SUBNET_CB_DEFINE(beacon) = { + .evt_handler = subnet_evt, +}; void bt_mesh_beacon_init(void) { diff --git a/subsys/bluetooth/mesh/friend.c b/subsys/bluetooth/mesh/friend.c index 568d455d974..1876b30baa7 100644 --- a/subsys/bluetooth/mesh/friend.c +++ b/subsys/bluetooth/mesh/friend.c @@ -1305,7 +1305,9 @@ static void subnet_evt(struct bt_mesh_subnet *sub, enum bt_mesh_key_evt evt) } } -BT_MESH_SUBNET_CB_DEFINE(subnet_evt); +BT_MESH_SUBNET_CB_DEFINE(friend) = { + .evt_handler = subnet_evt, +}; int bt_mesh_friend_init(void) { diff --git a/subsys/bluetooth/mesh/gatt_services.c b/subsys/bluetooth/mesh/gatt_services.c index 07339b8ad2a..0a03ba8b39c 100644 --- a/subsys/bluetooth/mesh/gatt_services.c +++ b/subsys/bluetooth/mesh/gatt_services.c @@ -640,7 +640,9 @@ static void subnet_evt(struct bt_mesh_subnet *sub, enum bt_mesh_key_evt evt) } } -BT_MESH_SUBNET_CB_DEFINE(subnet_evt); +BT_MESH_SUBNET_CB_DEFINE(gatt_services) = { + .evt_handler = subnet_evt, +}; static void proxy_ccc_changed(const struct bt_gatt_attr *attr, uint16_t value) { diff --git a/subsys/bluetooth/mesh/lpn.c b/subsys/bluetooth/mesh/lpn.c index 786b03e8dbf..ab41d26e369 100644 --- a/subsys/bluetooth/mesh/lpn.c +++ b/subsys/bluetooth/mesh/lpn.c @@ -1075,7 +1075,9 @@ static void subnet_evt(struct bt_mesh_subnet *sub, enum bt_mesh_key_evt evt) } } -BT_MESH_SUBNET_CB_DEFINE(subnet_evt); +BT_MESH_SUBNET_CB_DEFINE(lpn) = { + .evt_handler = subnet_evt, +}; int bt_mesh_lpn_init(void) { diff --git a/subsys/bluetooth/mesh/subnet.h b/subsys/bluetooth/mesh/subnet.h index ee61dc50182..9565016c84c 100644 --- a/subsys/bluetooth/mesh/subnet.h +++ b/subsys/bluetooth/mesh/subnet.h @@ -76,13 +76,11 @@ struct bt_mesh_subnet_cb { * * @brief Register a subnet event callback. * - * @param _handler Handler function, see @ref bt_mesh_subnet_cb::evt_handler. + * @param _name Handler name. */ -#define BT_MESH_SUBNET_CB_DEFINE(_handler) \ - static const STRUCT_SECTION_ITERABLE( \ - bt_mesh_subnet_cb, _CONCAT(bt_mesh_subnet_cb_, _handler)) = { \ - .evt_handler = (_handler), \ - } +#define BT_MESH_SUBNET_CB_DEFINE(_name) \ + static const STRUCT_SECTION_ITERABLE( \ + bt_mesh_subnet_cb, _CONCAT(bt_mesh_subnet_cb_, _name)) /** @brief Reset all Network keys. */ void bt_mesh_net_keys_reset(void);