From 49e4f754b4db84def55fe4c8f93ca72e00be2ae1 Mon Sep 17 00:00:00 2001 From: Lingao Meng Date: Sat, 18 Apr 2020 00:20:30 -0700 Subject: [PATCH] Bluetooth: Mesh: Fix add model group address to sub list When low power node reset, should add group address to friend subscription list. Fixes: #24311 Signed-off-by: Lingao Meng --- subsys/bluetooth/mesh/cfg_srv.c | 3 +++ subsys/bluetooth/mesh/settings.c | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/subsys/bluetooth/mesh/cfg_srv.c b/subsys/bluetooth/mesh/cfg_srv.c index 3d66db784ce..347c8bac770 100644 --- a/subsys/bluetooth/mesh/cfg_srv.c +++ b/subsys/bluetooth/mesh/cfg_srv.c @@ -1262,6 +1262,9 @@ static size_t mod_sub_list_clear(struct bt_mesh_model *mod) /* Unref stored labels related to this model */ for (i = 0, clear_count = 0; i < ARRAY_SIZE(mod->groups); i++) { if (mod->groups[i] != BT_MESH_ADDR_UNASSIGNED) { + if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER)) { + bt_mesh_lpn_group_del(&mod->groups[i], 1); + } mod->groups[i] = BT_MESH_ADDR_UNASSIGNED; clear_count++; } diff --git a/subsys/bluetooth/mesh/settings.c b/subsys/bluetooth/mesh/settings.c index 35ab1a7ee86..d91f615224c 100644 --- a/subsys/bluetooth/mesh/settings.c +++ b/subsys/bluetooth/mesh/settings.c @@ -32,6 +32,7 @@ #include "foundation.h" #include "proxy.h" #include "settings.h" +#include "lpn.h" /* Tracking of what storage changes are pending for App and Net Keys. We * track this in a separate array here instead of within the respective @@ -1097,6 +1098,16 @@ static void commit_mod(struct bt_mesh_model *mod, struct bt_mesh_elem *elem, k_delayed_work_submit(&mod->pub->timer, ms); } } + + if (!IS_ENABLED(CONFIG_BT_MESH_LOW_POWER)) { + return; + } + + for (int i = 0; i < ARRAY_SIZE(mod->groups); i++) { + if (mod->groups[i] != BT_MESH_ADDR_UNASSIGNED) { + bt_mesh_lpn_group_add(mod->groups[i]); + } + } } static int mesh_commit(void)