From bb7ec2144fecd1c7a41d14cc42f144c9923d70dc Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 2 Dec 2022 14:52:55 +0100 Subject: dummy mesh_connector implemented --- .clang-tidy | 10 ++++++-- confui/.gitignore | 1 + confui/confui.pro | 6 +++-- confui/main.cpp | 2 +- confui/mainwindow.cpp | 6 +++-- confui/mainwindow.h | 12 ++++++---- confui/mesh_connector.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++ confui/mesh_connector.h | 51 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 135 insertions(+), 11 deletions(-) create mode 100644 confui/mesh_connector.cpp create mode 100644 confui/mesh_connector.h 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 +#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 CDMeshConnector::get_nodes() { + return {}; +} + +vector 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 +#include +#include + +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 _nodes; + map _links; +public: + CDMeshConnector(); + virtual ~CDMeshConnector(); + virtual void refresh_nodes_sync(); + virtual void refresh_config_sync(); + virtual vector get_nodes(); + virtual vector 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); +}; -- cgit v1.2.3