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 <menglingao@xiaomi.com>
diff --git a/subsys/bluetooth/mesh/app_keys.c b/subsys/bluetooth/mesh/app_keys.c
index 2762672..b47f122 100644
--- a/subsys/bluetooth/mesh/app_keys.c
+++ b/subsys/bluetooth/mesh/app_keys.c
@@ -602,7 +602,9 @@
}
}
-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 179f65e..2c09389 100644
--- a/subsys/bluetooth/mesh/beacon.c
+++ b/subsys/bluetooth/mesh/beacon.c
@@ -423,7 +423,9 @@
}
}
-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 568d455..1876b30 100644
--- a/subsys/bluetooth/mesh/friend.c
+++ b/subsys/bluetooth/mesh/friend.c
@@ -1305,7 +1305,9 @@
}
}
-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 07339b8..0a03ba8 100644
--- a/subsys/bluetooth/mesh/gatt_services.c
+++ b/subsys/bluetooth/mesh/gatt_services.c
@@ -640,7 +640,9 @@
}
}
-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 786b03e..ab41d26 100644
--- a/subsys/bluetooth/mesh/lpn.c
+++ b/subsys/bluetooth/mesh/lpn.c
@@ -1075,7 +1075,9 @@
}
}
-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 ee61dc5..9565016 100644
--- a/subsys/bluetooth/mesh/subnet.h
+++ b/subsys/bluetooth/mesh/subnet.h
@@ -76,13 +76,11 @@
*
* @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);