aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-12-02 14:52:55 +0100
committerlonkaars <loek@pipeframe.xyz>2022-12-02 14:56:06 +0100
commitbb7ec2144fecd1c7a41d14cc42f144c9923d70dc (patch)
treefb54a2dd582be7c0b84fcb1d9e88a2e405de7f9c
parent2f5d58c7eae101c3803a63ca11315aec5cd6e1f0 (diff)
dummy mesh_connector implemented
-rw-r--r--.clang-tidy10
-rw-r--r--confui/.gitignore1
-rw-r--r--confui/confui.pro6
-rw-r--r--confui/main.cpp2
-rw-r--r--confui/mainwindow.cpp6
-rw-r--r--confui/mainwindow.h12
-rw-r--r--confui/mesh_connector.cpp58
-rw-r--r--confui/mesh_connector.h51
8 files changed, 135 insertions, 11 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 2cca939..8fe126e 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -2,8 +2,14 @@ Checks: '-*,readability-identifier-naming'
CheckOptions:
- { key: readability-identifier-naming.EnumCase, value: lower_case }
- { key: readability-identifier-naming.EnumPrefix, value: cd_e_ }
- - { key: readability-identifier-naming.FunctionCase, value: lower_case }
- - { key: readability-identifier-naming.FunctionPrefix, value: cd_ }
+ - { key: readability-identifier-naming.GlobalFunctionCase, value: lower_case }
+ - { key: readability-identifier-naming.GlobalFunctionPrefix, value: cd_ }
+ - { key: readability-identifier-naming.ClassCase, value: CamelCase }
+ - { key: readability-identifier-naming.ClassPrefix, value: CD }
+ - { key: readability-identifier-naming.ClassMethodCase, value: lower_case }
+ - { key: readability-identifier-naming.ClassMethodPrefix, value: '' }
+ - { key: readability-identifier-naming.ClassMemberCase, value: lower_case }
+ - { key: readability-identifier-naming.ClassMemberPrefix, value: '' }
- { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.GlobalConstantIgnoredRegexp, value: _.* }
- { key: readability-identifier-naming.GlobalConstantPrefix, value: CD_ }
diff --git a/confui/.gitignore b/confui/.gitignore
index 73a7ada..383d0c8 100644
--- a/confui/.gitignore
+++ b/confui/.gitignore
@@ -69,3 +69,4 @@ Thumbs.db
*.exe
confui.mk
+moc_*
diff --git a/confui/confui.pro b/confui/confui.pro
index 1d2ed4d..8c38727 100644
--- a/confui/confui.pro
+++ b/confui/confui.pro
@@ -2,10 +2,12 @@ QT += core gui widgets
SOURCES += \
main.cpp \
- mainwindow.cpp
+ mainwindow.cpp \
+ mesh_connector.cpp
HEADERS += \
- mainwindow.h
+ mainwindow.h \
+ mesh_connector.h
CONFIG += c++17
diff --git a/confui/main.cpp b/confui/main.cpp
index ab8ae38..6c3ab56 100644
--- a/confui/main.cpp
+++ b/confui/main.cpp
@@ -4,7 +4,7 @@
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
- MainWindow w;
+ CDMainWindow w;
w.show();
return a.exec();
}
diff --git a/confui/mainwindow.cpp b/confui/mainwindow.cpp
index 3bc79b5..93ca8d7 100644
--- a/confui/mainwindow.cpp
+++ b/confui/mainwindow.cpp
@@ -1,8 +1,10 @@
#include "mainwindow.h"
-MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
+CDMainWindow::CDMainWindow(QWidget *parent) : QMainWindow(parent) {
+ this->mesh_connector = new CDMeshConnector();
}
-MainWindow::~MainWindow() {
+CDMainWindow::~CDMainWindow() {
+ delete this->mesh_connector;
}
diff --git a/confui/mainwindow.h b/confui/mainwindow.h
index 61402fc..da98cb4 100644
--- a/confui/mainwindow.h
+++ b/confui/mainwindow.h
@@ -5,14 +5,18 @@
#include <QDebug>
+#include "mesh_connector.h"
+
QT_BEGIN_NAMESPACE
-namespace Ui { class MainWindow; }
+namespace Ui { class CDMainWindow; }
QT_END_NAMESPACE
-class MainWindow : public QMainWindow {
+class CDMainWindow : public QMainWindow {
Q_OBJECT
public:
- MainWindow(QWidget *parent = nullptr);
- ~MainWindow();
+ CDMeshConnector *mesh_connector = nullptr;
+
+ CDMainWindow(QWidget *parent = nullptr);
+ ~CDMainWindow();
};
diff --git a/confui/mesh_connector.cpp b/confui/mesh_connector.cpp
new file mode 100644
index 0000000..004ee6c
--- /dev/null
+++ b/confui/mesh_connector.cpp
@@ -0,0 +1,58 @@
+#include "mesh_connector.h"
+
+CDMeshConnector::CDMeshConnector() {
+ return;
+}
+
+CDMeshConnector::~CDMeshConnector() {
+ return;
+}
+
+void CDMeshConnector::refresh_config_sync() {
+ return;
+}
+
+void CDMeshConnector::refresh_nodes_sync() {
+ return;
+}
+
+vector<cd_s_node> CDMeshConnector::get_nodes() {
+ return {};
+}
+
+vector<cd_s_automation> CDMeshConnector::get_config() {
+ return {};
+}
+
+cd_link_t CDMeshConnector::set_link(cd_mac_addr_t button, cd_mac_addr_t light) {
+ (void) button;
+ (void) light;
+ return 0;
+}
+
+void CDMeshConnector::remove_link(cd_link_t link_handle) {
+ (void) link_handle;
+ return;
+}
+
+cd_s_node* CDMeshConnector::get_node_by_id(cd_mac_addr_t address) {
+ (void) address;
+ return nullptr;
+}
+
+void CDMeshConnector::set_node(cd_s_node* node_ptr, bool light_status) {
+ (void) node_ptr;
+ (void) light_status;
+ return;
+}
+
+void CDMeshConnector::node_join_network(cd_s_node* node_ptr) {
+ (void) node_ptr;
+ return;
+}
+
+void CDMeshConnector::node_remove_network(cd_s_node* node_ptr) {
+ (void) node_ptr;
+ return;
+}
+
diff --git a/confui/mesh_connector.h b/confui/mesh_connector.h
new file mode 100644
index 0000000..070a83c
--- /dev/null
+++ b/confui/mesh_connector.h
@@ -0,0 +1,51 @@
+#pragma once
+
+#include <stdint.h>
+#include <vector>
+#include <map>
+
+typedef uint32_t cd_link_t;
+typedef uint8_t cd_mac_addr_t[6];
+
+using std::size_t;
+using std::vector;
+using std::map;
+
+enum cd_e_automation_type {
+ CD_AUTOMATION_TYPE_TOGGLE,
+ CD_AUTOMATION_TYPE_TURN_ON,
+ CD_AUTOMATION_TYPE_TURN_OFF,
+};
+
+typedef struct {
+ cd_mac_addr_t address;
+ size_t name_len;
+ char* name;
+ bool light_on;
+ bool provisioned;
+} cd_s_node;
+
+typedef struct {
+ cd_e_automation_type type;
+ cd_s_node button;
+ cd_s_node light;
+} cd_s_automation;
+
+class CDMeshConnector {
+private:
+ vector<cd_s_node> _nodes;
+ map<cd_link_t, cd_s_automation> _links;
+public:
+ CDMeshConnector();
+ virtual ~CDMeshConnector();
+ virtual void refresh_nodes_sync();
+ virtual void refresh_config_sync();
+ virtual vector<cd_s_node> get_nodes();
+ virtual vector<cd_s_automation> get_config();
+ virtual cd_link_t set_link(cd_mac_addr_t button, cd_mac_addr_t light);
+ 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 node_join_network(cd_s_node* node_ptr);
+ virtual void node_remove_network(cd_s_node* node_ptr);
+};