diff options
author | Inga Stotland <inga.stotland@intel.com> | 2019-10-01 09:27:28 -0700 |
---|---|---|
committer | Brian Gix <brian.gix@intel.com> | 2019-10-01 09:51:54 -0700 |
commit | 550dc90dfca02370973e99b8e903576fa7e9d818 (patch) | |
tree | 89c9248506633cdb40d8c3aeaba693f6d7ab70c6 /mesh/mesh-config-json.c | |
parent | f82256202f73ab111e8586d75db1e0412f2120d6 (diff) | |
download | bluez-550dc90dfca02370973e99b8e903576fa7e9d818.tar.gz |
mesh: Make mesh-config API more consistent
This changes the prototypes for mesh_config_model_binding_add() and
mesh_config_model_binding_del() to take the element's address as input
parameter instead of the element's index. The change aligns the API
with other functions that handle storage of model states.
Diffstat (limited to 'mesh/mesh-config-json.c')
-rw-r--r-- | mesh/mesh-config-json.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index cafa2fdd7..198fef518 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -835,11 +835,12 @@ bool mesh_config_app_key_del(struct mesh_config *cfg, uint16_t net_idx, return save_config(jnode, cfg->node_dir_path); } -bool mesh_config_model_binding_add(struct mesh_config *cfg, uint8_t ele_idx, - bool vendor, uint32_t mod_id, +bool mesh_config_model_binding_add(struct mesh_config *cfg, uint16_t ele_addr, + bool vendor, uint32_t mod_id, uint16_t app_idx) { json_object *jnode, *jmodel, *jstring, *jarray = NULL; + int ele_idx; char buf[5]; if (!cfg) @@ -847,6 +848,10 @@ bool mesh_config_model_binding_add(struct mesh_config *cfg, uint8_t ele_idx, jnode = cfg->jnode; + ele_idx = get_element_index(jnode, ele_addr); + if (ele_idx < 0) + return false; + jmodel = get_element_model(jnode, ele_idx, mod_id, vendor); if (!jmodel) return false; @@ -875,11 +880,12 @@ bool mesh_config_model_binding_add(struct mesh_config *cfg, uint8_t ele_idx, return save_config(jnode, cfg->node_dir_path); } -bool mesh_config_model_binding_del(struct mesh_config *cfg, uint8_t ele_idx, - bool vendor, uint32_t mod_id, +bool mesh_config_model_binding_del(struct mesh_config *cfg, uint16_t ele_addr, + bool vendor, uint32_t mod_id, uint16_t app_idx) { json_object *jnode, *jmodel, *jarray, *jarray_new; + int ele_idx; char buf[5]; if (!cfg) @@ -887,6 +893,10 @@ bool mesh_config_model_binding_del(struct mesh_config *cfg, uint8_t ele_idx, jnode = cfg->jnode; + ele_idx = get_element_index(jnode, ele_addr); + if (ele_idx < 0) + return false; + jmodel = get_element_model(jnode, ele_idx, mod_id, vendor); if (!jmodel) return false; @@ -1818,7 +1828,7 @@ bool mesh_config_net_key_set_phase(struct mesh_config *cfg, uint16_t idx, return save_config(jnode, cfg->node_dir_path); } -bool mesh_config_model_pub_add(struct mesh_config *cfg, uint16_t addr, +bool mesh_config_model_pub_add(struct mesh_config *cfg, uint16_t ele_addr, uint32_t mod_id, bool vendor, struct mesh_config_pub *pub) { @@ -1831,7 +1841,7 @@ bool mesh_config_model_pub_add(struct mesh_config *cfg, uint16_t addr, jnode = cfg->jnode; - ele_idx = get_element_index(jnode, addr); + ele_idx = get_element_index(jnode, ele_addr); if (ele_idx < 0) return false; @@ -1886,13 +1896,13 @@ fail: return false; } -static bool delete_model_property(json_object *jnode, uint16_t addr, +static bool delete_model_property(json_object *jnode, uint16_t ele_addr, uint32_t mod_id, bool vendor, const char *keyword) { json_object *jmodel; int ele_idx; - ele_idx = get_element_index(jnode, addr); + ele_idx = get_element_index(jnode, ele_addr); if (ele_idx < 0) return false; @@ -1915,7 +1925,7 @@ bool mesh_config_model_pub_del(struct mesh_config *cfg, uint16_t addr, return save_config(cfg->jnode, cfg->node_dir_path); } -bool mesh_config_model_sub_add(struct mesh_config *cfg, uint16_t addr, +bool mesh_config_model_sub_add(struct mesh_config *cfg, uint16_t ele_addr, uint32_t mod_id, bool vendor, struct mesh_config_sub *sub) { @@ -1928,7 +1938,7 @@ bool mesh_config_model_sub_add(struct mesh_config *cfg, uint16_t addr, jnode = cfg->jnode; - ele_idx = get_element_index(jnode, addr); + ele_idx = get_element_index(jnode, ele_addr); if (ele_idx < 0) return false; @@ -1966,7 +1976,7 @@ bool mesh_config_model_sub_add(struct mesh_config *cfg, uint16_t addr, return save_config(jnode, cfg->node_dir_path); } -bool mesh_config_model_sub_del(struct mesh_config *cfg, uint16_t addr, +bool mesh_config_model_sub_del(struct mesh_config *cfg, uint16_t ele_addr, uint32_t mod_id, bool vendor, struct mesh_config_sub *sub) { @@ -1979,7 +1989,7 @@ bool mesh_config_model_sub_del(struct mesh_config *cfg, uint16_t addr, jnode = cfg->jnode; - ele_idx = get_element_index(jnode, addr); + ele_idx = get_element_index(jnode, ele_addr); if (ele_idx < 0) return false; |