diff options
author | Inga Stotland <inga.stotland@intel.com> | 2020-08-12 12:03:16 -0700 |
---|---|---|
committer | Brian Gix <brian.gix@intel.com> | 2020-08-13 15:04:03 -0700 |
commit | 8ea7d5842817bc339f482be3a53cadb7df7aa76d (patch) | |
tree | 6300e5f71464627d1025b763c077f90bf52f60f9 /mesh/model.c | |
parent | fd45d85ad9ff987d5f2d3d7f95ef95f757b0f514 (diff) | |
download | bluez-8ea7d5842817bc339f482be3a53cadb7df7aa76d.tar.gz |
mesh: Fix model ID prior to calling mesh config functions
Model IDs for SIG defined models need to be stripped off SIG_VENDOR
value used for internal housekeeping prior to calling functions
that save new model state in node configuration.
Also, remove duplicate statements for model lookup in node config.
Diffstat (limited to 'mesh/model.c')
-rw-r--r-- | mesh/model.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/mesh/model.c b/mesh/model.c index 23afb93a8..136edb194 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -628,6 +628,7 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, uint16_t app_idx, bool unbind) { struct mesh_model *mod; + bool vendor; int ele_idx = node_get_element_idx(node, addr); if (ele_idx < 0) @@ -651,11 +652,15 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, if (unbind ^ has_binding(mod->bindings, app_idx)) return MESH_STATUS_SUCCESS; + vendor = IS_VENDOR(id); + id = vendor ? id : MODEL_ID(id); + if (unbind) { model_unbind_idx(node, ele_idx, mod, app_idx); + if (!mesh_config_model_binding_del(node_config_get(node), - addr, IS_VENDOR(id), - id, app_idx)) + addr, vendor, id, + app_idx)) return MESH_STATUS_STORAGE_FAIL; l_debug("Unbind key %4.4x to model %8.8x", app_idx, mod->id); @@ -666,13 +671,12 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id, return MESH_STATUS_INSUFF_RESOURCES; if (!mesh_config_model_binding_add(node_config_get(node), addr, - IS_VENDOR(id), id, app_idx)) + vendor, id, app_idx)) return MESH_STATUS_STORAGE_FAIL; model_bind_idx(node, ele_idx, mod, app_idx); return MESH_STATUS_SUCCESS; - } static struct mesh_virtual *add_virtual(const uint8_t *v) |