mesh: Move model functionality out of node.c to model.c
PATCH v2 1/1 mesh: Move model functionality out of node.c to model.c
This moves the model related code out of node.c to model.c providing for better functional separation of modules.
--- mesh/cfgmod.h | 4 +- mesh/mesh-config-json.c | 5 +- mesh/model.c | 548 +++++++++++++++++++++++++++++----------- mesh/model.h | 37 +-- mesh/node.c | 304 +++------------------- mesh/node.h | 4 +- 6 files changed, 454 insertions(+), 448 deletions(-)
mesh/cfgmod.h +2 -2
@@ -17,8 +17,8 @@* */ -#define CONFIG_SRV_MODEL (VENDOR_ID_MASK | 0x0000) -#define CONFIG_CLI_MODEL (VENDOR_ID_MASK | 0x0001) +#define CONFIG_SRV_MODEL 0x0000 +#define CONFIG_CLI_MODEL 0x0001/* New List */ #define OP_APPKEY_ADD 0x00
mesh/mesh-config-json.c +1 -4
@@ -1126,18 +1126,15 @@ static bool parse_models(json_object *jmodels, struct mesh_config_element *ele)if (sscanf (str,"%04x" , &id) !=1 ) goto fail; - id |=VENDOR_ID_MASK ; }else if (len ==8 ) {if (sscanf (str,"%08x" , &id) !=1 ) goto fail; + mod->vendor = true; }else goto fail; mod->id = id; -if (len ==8 ) - mod->vendor = true; -if (json_object_object_get_ex (jmodel,"bind" , &jarray)) {if (json_object_get_type (jarray) != json_type_array || !parse_bindings (jarray, mod))
mesh/model.c +395 -153
912 lines not on this page · raw message
mesh/model.h +21 -16
@@ -60,14 +60,19 @@ struct mesh_model_ops {mesh_model_sub_cb sub; }; -struct mesh_model *mesh_model_new (uint8_t ele_idx,uint32_t mod_id); +bool mesh_model_add (struct mesh_node *node,struct l_queue *mods, +uint16_t mod_id,struct l_dbus_message_iter *opts); +bool mesh_model_vendor_add (struct mesh_node *node,struct l_queue *mods, +uint16_t vendor_id,uint16_t mod_id, +struct l_dbus_message_iter *opts);void mesh_model_free (void *data); -uint32_t mesh_model_get_model_id (const struct mesh_model *model);bool mesh_model_register (struct mesh_node *node,uint8_t ele_idx, -uint32_t mod_id,const struct mesh_model_ops *cbs, +uint16_t mod_id,const struct mesh_model_ops *cbs,void *user_data); -struct mesh_model *mesh_model_setup (struct mesh_node *node,uint8_t ele_idx, -void *data); +bool mesh_model_add_from_storage (struct mesh_node *node,uint8_t ele_idx, +struct l_queue *mods,struct l_queue *db_mods); +void mesh_model_convert_to_storage (struct l_queue *db_mods, +struct l_queue *mods);struct mesh_model_pub *mesh_model_pub_get (struct mesh_node *node,uint16_t addr,uint32_t mod_id,int *status); int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id,
@@ -95,26 +100,26 @@ bool mesh_model_send(struct mesh_node *node, uint16_t src, uint16_t dst, uint16_t app_idx, uint16_t net_idx, uint8_t ttl, bool segmented, const void *msg, uint16_t msg_len); -int mesh_model_publish (struct mesh_node *node,uint32_t mod_id,uint16_t src, +int mesh_model_publish (struct mesh_node *node,uint16_t mod_id,uint16_t src,uint8_t ttl,const void *msg,uint16_t msg_len); +int mesh_model_vendor_publish (struct mesh_node *node,uint16_t vendor_id, +uint16_t mod_id,uint16_t src,uint8_t ttl, +const void *msg,uint16_t msg_len);bool mesh_model_rx (struct mesh_node *node,bool szmict,uint32_t seq0,uint32_t seq,uint32_t iv_index,uint16_t net_idx,uint16_t src,uint16_t dst,uint8_t key_aid,const uint8_t *data,uint16_t size);void mesh_model_app_key_generate_new (struct mesh_node *node,uint16_t net_idx); -void mesh_model_app_key_delete (struct mesh_node *node,struct l_queue *models, -uint16_t idx); +void mesh_model_app_key_delete (struct mesh_node *node,uint16_t ele_idx, +struct l_queue *models,uint16_t app_idx);struct l_queue *mesh_model_get_appkeys (struct mesh_node *node);uint16_t mesh_model_opcode_set (uint32_t opcode,uint8_t *buf);bool mesh_model_opcode_get (const uint8_t *buf,uint16_t size,uint32_t *opcode,uint16_t *n); -void model_build_config (void *model,void *msg_builder); - -void mesh_model_enable_pub (struct mesh_model *mod,bool enable); -bool mesh_model_is_pub_enabled (struct mesh_model *mod); -void mesh_model_enable_sub (struct mesh_node *node,struct mesh_model *mod, -bool enable); -bool mesh_model_is_sub_enabled (struct mesh_model *mod); - +void mesh_model_build_config (void *model,void *msg_builder); +void mesh_model_update_opts (struct mesh_node *node,uint8_t ele_idx, +struct l_queue *curr,struct l_queue *updated); +uint16_t mesh_model_generate_composition (struct l_queue *mods,uint16_t buf_sz, +uint8_t *buf);void mesh_model_init (void );void mesh_model_cleanup (void );
mesh/node.c +33 -271
467 lines not on this page · raw message
mesh/node.h +2 -2
@@ -58,8 +58,8 @@ bool node_default_ttl_set(struct mesh_node *node, uint8_t ttl);bool node_set_sequence_number (struct mesh_node *node,uint32_t seq);uint32_t node_get_sequence_number (struct mesh_node *node);int node_get_element_idx (struct mesh_node *node,uint16_t ele_addr); -struct l_queue *node_get_element_models (struct mesh_node *node,uint8_t ele_idx, -int *status); +struct l_queue *node_get_element_models (struct mesh_node *node, +uint8_t ele_idx);uint16_t node_get_crpl (struct mesh_node *node);bool node_init_from_storage (struct mesh_node *node,const uint8_t uuid[16 ],struct mesh_config_node *db_node);
Signature · 1 line
2.26.2