aboutsummaryrefslogtreecommitdiff
path: root/confui
diff options
context:
space:
mode:
Diffstat (limited to 'confui')
-rw-r--r--confui/mesh_connector.cpp3
-rw-r--r--confui/mesh_connector.h2
-rw-r--r--confui/ui_node.cpp18
-rw-r--r--confui/ui_node.h2
4 files changed, 22 insertions, 3 deletions
diff --git a/confui/mesh_connector.cpp b/confui/mesh_connector.cpp
index c6c3988..19f899e 100644
--- a/confui/mesh_connector.cpp
+++ b/confui/mesh_connector.cpp
@@ -124,8 +124,7 @@ cd_s_node* CDMeshConnector::get_node_by_id(cd_mac_addr_t address) {
return node;
}
-void CDMeshConnector::set_node(cd_s_node* node_ptr, bool light_status) {
- node_ptr->light_on = light_status;
+void CDMeshConnector::update_node(cd_s_node* node_ptr) {
printf("turning %.*s %s\n", (int) node_ptr->name_len, node_ptr->name, node_ptr->light_on ? "on" : "off");
return;
}
diff --git a/confui/mesh_connector.h b/confui/mesh_connector.h
index 3b13b3c..2d9931e 100644
--- a/confui/mesh_connector.h
+++ b/confui/mesh_connector.h
@@ -53,7 +53,7 @@ public:
virtual cd_link_t set_link(cd_s_node* button, cd_s_node* light, enum cd_e_automation_type action);
virtual void remove_link(cd_link_t link_handle);
virtual cd_s_node* get_node_by_id(cd_mac_addr_t address);
- virtual void set_node(cd_s_node* node_ptr, bool light_status);
+ virtual void update_node(cd_s_node* node_ptr);
virtual void node_join_network(cd_s_node* node_ptr);
virtual void node_remove_network(cd_s_node* node_ptr);
};
diff --git a/confui/ui_node.cpp b/confui/ui_node.cpp
index 94768f9..c810c29 100644
--- a/confui/ui_node.cpp
+++ b/confui/ui_node.cpp
@@ -16,6 +16,9 @@ CDNodeWidget::CDNodeWidget(cd_s_node* node, QWidget *parent) : QWidget(parent) {
main_layout->addWidget(switch_on_off);
main_layout->addWidget(button_add_remove);
+ connect(button_add_remove, &QPushButton::clicked, this, &CDNodeWidget::toggle_provision);
+ connect(switch_on_off, &QCheckBox::toggled, this, &CDNodeWidget::update_led);
+
update();
setLayout(main_layout);
}
@@ -40,3 +43,18 @@ void CDNodeWidget::update() {
button_add_remove->setText(_node->provisioned ? "Remove from network" : "Join network");
}
+
+void CDNodeWidget::toggle_provision() {
+ if (_node->provisioned) g_cd_mesh_connector->node_remove_network(_node);
+ else g_cd_mesh_connector->node_join_network(_node);
+
+ update();
+}
+
+void CDNodeWidget::update_led(bool on) {
+ _node->light_on = on;
+ g_cd_mesh_connector->update_node(_node);
+
+ update();
+}
+
diff --git a/confui/ui_node.h b/confui/ui_node.h
index 0b7049c..93fc296 100644
--- a/confui/ui_node.h
+++ b/confui/ui_node.h
@@ -26,4 +26,6 @@ public:
virtual ~CDNodeWidget();
virtual void update();
virtual void set_node(cd_s_node* node);
+ virtual void toggle_provision();
+ virtual void update_led(bool on);
};