summaryrefslogtreecommitdiff
path: root/mesh/model.c
diff options
context:
space:
mode:
authorInga Stotland <inga.stotland@intel.com>2019-07-14 16:23:17 -0700
committerBrian Gix <brian.gix@intel.com>2019-07-15 14:48:04 -0700
commitd57524629036a4bbbe183b6a32afa02a87fe489d (patch)
tree4175d37a786eed74f108823dfc6ba1b068cc1d64 /mesh/model.c
parentc4bf0626fb621559ecaea7e1eadf22d386b7ee63 (diff)
downloadbluez-d57524629036a4bbbe183b6a32afa02a87fe489d.tar.gz
mesh: Use mesh_config APIs to store node configuration
This eliminates storage_set...() routines as an intermediate layer between mesh_config layer and the rest of the daemon when storing updated node configuration values. For the JSON based implementation, each call to mesh_config_write...() routines results in writing to the node configuration file.
Diffstat (limited to 'mesh/model.c')
-rw-r--r--mesh/model.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/mesh/model.c b/mesh/model.c
index 0f10727b4..ef62a223a 100644
--- a/mesh/model.c
+++ b/mesh/model.c
@@ -532,7 +532,8 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id,
{
int status;
struct mesh_model *mod;
- bool is_present;
+ bool is_present, is_vendor;
+ uint8_t ele_idx;
mod = find_model(node, addr, id, &status);
if (!mod) {
@@ -540,7 +541,8 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id,
return status;
}
- id = (id >= VENDOR_ID_MASK) ? (id & 0xffff) : id;
+ is_vendor = id < VENDOR_ID_MASK && id > 0xffff;
+ id = !is_vendor ? (id & 0xffff) : id;
if (id == CONFIG_SRV_MODEL || id == CONFIG_CLI_MODEL)
return MESH_STATUS_INVALID_MODEL;
@@ -556,10 +558,12 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id,
if (is_present && !unbind)
return MESH_STATUS_SUCCESS;
+ ele_idx = (uint8_t) node_get_element_idx(node, addr);
+
if (unbind) {
model_unbind_idx(node, mod, app_idx);
-
- if (!storage_model_bind(node, addr, id, app_idx, true))
+ if (!mesh_config_model_binding_del(node_config_get(node),
+ ele_idx, is_vendor, id, app_idx))
return MESH_STATUS_STORAGE_FAIL;
return MESH_STATUS_SUCCESS;
@@ -568,7 +572,8 @@ static int update_binding(struct mesh_node *node, uint16_t addr, uint32_t id,
if (l_queue_length(mod->bindings) >= MAX_BINDINGS)
return MESH_STATUS_INSUFF_RESOURCES;
- if (!storage_model_bind(node, addr, id, app_idx, false))
+ if (!mesh_config_model_binding_add(node_config_get(node),
+ ele_idx, is_vendor, id, app_idx))
return MESH_STATUS_STORAGE_FAIL;
model_bind_idx(node, mod, app_idx);