msh: Permit model walk from any model
Fixes bug where applications that disable model extensions end up in an
infinite loop, and adds support for walking model subtrees, as opposed
to forcing root to be unextended.
this is port of
@@ -803,7 +803,7 @@ void bt_mesh_model_tree_walk(struct bt_mesh_model *root,
void *user_data)
{
struct bt_mesh_model *m = root;
- uint32_t depth = 0;
+ int depth = 0;
/* 'skip' is set to true when we ascend from child to parent node.
* In that case, we want to skip calling the callback on the parent
* node and we don't want to descend onto a child node as those
@@ -812,7 +812,8 @@ void bt_mesh_model_tree_walk(struct bt_mesh_model *root,
bool skip = false;
do {
- if (!skip && cb(m, depth, user_data) == BT_MESH_WALK_STOP) {
+ if (!skip &&
+ cb(m, (uint32_t)depth, user_data) == BT_MESH_WALK_STOP) {
return;
}
#if MYNEWT_VAL(BLE_MESH_MODEL_EXTENSIONS)
@@ -828,7 +829,7 @@ void bt_mesh_model_tree_walk(struct bt_mesh_model *root,
skip = false;
}
#endif
- } while (m);
+ } while (m && depth > 0);
}
#if MYNEWT_VAL(BLE_MESH_MODEL_EXTENSIONS)
