mesh: Add Composition page storage to node.json
PATCH 1/1 mesh: Add Composition page storage to node.json
--- mesh/cfgmod-server.c | 42 ++++++++++--- mesh/mesh-config-json.c | 131 +++++++++++++++++++++++++++++++++++++++ mesh/mesh-config.h | 12 ++++ mesh/node.c | 132 +++++++++++++++++++++++++++++++++------- mesh/node.h | 6 +- 5 files changed, 291 insertions(+), 32 deletions(-)
mesh/cfgmod-server.c +34 -8
@@ -34,6 +34,12 @@#define CFG_MAX_MSG_LEN 380 +/* Supported composition pages, sorted high to low */ +/* Only page 0 is currently supported */ +static const uint8_t supported_pages[] = { +0 +}; + static void send_pub_status(struct mesh_node *node, uint16_t net_idx, uint16_t src, uint16_t dst, uint8_t status, uint16_t ele_addr, uint32_t mod_id,
@@ -701,6 +707,33 @@ static void node_reset(void *user_data)node_remove (node); } +static uint16_t get_composition (struct mesh_node *node,uint8_t page, +uint8_t *buf) +{ +const uint8_t *comp; +uint16_t len =0 ; +size_t i; + +for (i =0 ; i <sizeof (supported_pages); i++) { +if (page < supported_pages[i]) +continue ; + + page = supported_pages[i]; + comp =node_get_comp (node, page, &len); + +if (!page || len) +break ; + } + +if (!len) +return 0 ; + + *buf++ = page; +memcpy (buf, comp, len); + +return len +1 ; +} +static bool cfg_srv_pkt (uint16_t src,uint16_t dst,uint16_t app_idx,uint16_t net_idx,const uint8_t *data,uint16_t size,const void *user_data)
@@ -746,16 +779,9 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx,if (size !=1 )return false; -/* Only page 0 is currently supported */ -if (pkt[0 ] !=0 ) { -l_debug ("Unsupported page number %d" , pkt[0 ]); -l_debug ("Returning page number 0" ); - } long_msg =l_malloc (CFG_MAX_MSG_LEN ); n =mesh_model_opcode_set (OP_DEV_COMP_STATUS , long_msg); - long_msg[n++] =0 ; - n +=node_generate_comp (node, long_msg + n, -CFG_MAX_MSG_LEN - n); + n +=get_composition (node, pkt[0 ], long_msg + n);break ;
mesh/mesh-config-json.c +131 -0
161 lines not on this page · raw message
mesh/mesh-config.h +12 -0
@@ -17,6 +17,8 @@* */ +#define MIN_COMP_SIZE 14 +struct mesh_config ;struct mesh_config_sub {
@@ -88,10 +90,17 @@ struct mesh_config_transmit {uint8_t count; }; +struct mesh_config_comp_page { +uint16_t len; +uint8_t page_num; +uint8_t data[]; +}; +struct mesh_config_node {struct l_queue *elements;struct l_queue *netkeys;struct l_queue *appkeys; +struct l_queue *pages;uint32_t seq_number;uint32_t iv_index;bool iv_update;
@@ -139,6 +148,9 @@ bool mesh_config_write_relay_mode(struct mesh_config *cfg, uint8_t mode,bool mesh_config_write_ttl (struct mesh_config *cfg,uint8_t ttl);bool mesh_config_write_mode (struct mesh_config *cfg,const char *keyword,int value); +bool mesh_config_comp_page_add (struct mesh_config *cfg,uint8_t page, +uint8_t *data,uint16_t size); +bool mesh_config_comp_page_del (struct mesh_config *cfg,uint8_t page);bool mesh_config_model_binding_add (struct mesh_config *cfg,uint16_t ele_addr,bool vendor,uint32_t mod_id,uint16_t app_idx);
mesh/node.c +109 -23
183 lines not on this page · raw message
mesh/node.h +5 -1
@@ -63,7 +63,11 @@ 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); -uint16_t node_generate_comp (struct mesh_node *node,uint8_t *buf,uint16_t sz); +const uint8_t *node_get_comp (struct mesh_node *node,uint8_t page_num, +uint16_t *len); +bool node_set_comp (struct mesh_node *node,uint8_t page_num, +const uint8_t *data,uint16_t len); +bool node_replace_comp (struct mesh_node *node,uint8_t retire,uint8_t with);uint8_t node_lpn_mode_get (struct mesh_node *node);bool node_relay_mode_set (struct mesh_node *node,bool enable,uint8_t cnt,uint16_t interval);
Signature · 1 line
2.25.4
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. While we are preparing for reviewing the patches, we found the following issue/warning.
Test Result:
checkgitlint Failed
Outputs:
3: B6 Body message is missing
---
Regards,
Linux Bluetooth