diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-01-07 13:55:00 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-01-07 13:55:00 +0100 |
commit | d5288693e86db33ab6743c902440825e5eec1314 (patch) | |
tree | f57db60f98128f043e41db03dd98e8aa4bf1d2aa /confui | |
parent | 847b4a5d588ec504865398c21c3bcb73a6fc1fab (diff) |
mesh network message publishing commands all fully implemented
Diffstat (limited to 'confui')
-rw-r--r-- | confui/mesh_connector.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/confui/mesh_connector.cpp b/confui/mesh_connector.cpp index c77c159..7ef0f02 100644 --- a/confui/mesh_connector.cpp +++ b/confui/mesh_connector.cpp @@ -160,9 +160,11 @@ void CDMeshConnector::remove_link(cd_link_t link_handle, bool publish) { if (_links.count(link_handle) == 0) return; // invalid handle if (_links[link_handle] == nullptr) return; // already removed link - cd_s_bin* msg = cd_cmd_gen_post_link_rm(_links[link_handle]->button->uuid, _links[link_handle]->light->uuid); - cd_pclient_send(msg); - free(msg); + if (publish) { + cd_s_bin* msg = cd_cmd_gen_post_link_rm(_links[link_handle]->button->uuid, _links[link_handle]->light->uuid); + cd_pclient_send(msg); + free(msg); + } free(_links[link_handle]); _links[link_handle] = nullptr; @@ -177,19 +179,30 @@ void CDMeshConnector::remove_node(cd_uid_t node_handle) { void CDMeshConnector::update_node(cd_s_node *node_ptr, bool publish) { printf("turning %.*s %s\n", (int)node_ptr->name_len, node_ptr->name, node_ptr->light_on ? "on" : "off"); - return; + + if (!publish) return; + + cd_s_bin* msg = cd_cmd_gen_post_led(node_ptr->light_on, node_ptr->uuid); + cd_pclient_send(msg); + free(msg); } void CDMeshConnector::network_join_node(cd_s_node *node_ptr) { - node_ptr->provisioned = true; + node_ptr->provisioned = true; //TODO: await success printf("join %.*s into network\n", (int)node_ptr->name_len, node_ptr->name); - return; + + cd_s_bin* msg = cd_cmd_gen_post_net_add(node_ptr->uuid); + cd_pclient_send(msg); + free(msg); } void CDMeshConnector::network_remove_node(cd_s_node *node_ptr) { - node_ptr->provisioned = false; + node_ptr->provisioned = false; //TODO: await success printf("remove %.*s from network\n", (int)node_ptr->name_len, node_ptr->name); - return; + + cd_s_bin* msg = cd_cmd_gen_post_net_rm(node_ptr->uuid); + cd_pclient_send(msg); + free(msg); } string CDMeshConnector::cd_mac_to_string(cd_mac_addr_t mac) { |