diff --git a/.idea/firmware.iml b/.idea/firmware.iml
new file mode 100644
index 0000000..f08604b
--- /dev/null
+++ b/.idea/firmware.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..cb860b6
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/rpc/CMakeLists.txt b/components/rpc/CMakeLists.txt
index c749993..7705066 100644
--- a/components/rpc/CMakeLists.txt
+++ b/components/rpc/CMakeLists.txt
@@ -1,3 +1,3 @@
-idf_component_register(SRCS "rpc.cpp" "TCPServer.cpp" "WifiManager.cpp"
+idf_component_register(SRCS "rpc.cpp" "WifiManager.cpp"
PRIV_REQUIRES driver esp_event nvs_flash esp_netif esp_wifi
INCLUDE_DIRS "include")
diff --git a/components/rpc/RPCFactory.cpp b/components/rpc/RPCFactory.cpp
deleted file mode 100644
index 129175e..0000000
--- a/components/rpc/RPCFactory.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-//
-// Created by Johnathon Slightham on 2025-05-25.
-//
diff --git a/components/rpc/WifiManager.cpp b/components/rpc/WifiManager.cpp
index 467913b..fa736bc 100644
--- a/components/rpc/WifiManager.cpp
+++ b/components/rpc/WifiManager.cpp
@@ -8,26 +8,17 @@
#include "freertos/semphr.h"
#include "esp_wifi.h"
-int WifiManager::init() {
+WifiManager::WifiManager() {
esp_netif_init();
esp_event_loop_create_default();
esp_netif_create_default_wifi_sta();
- printf("finished esp init");
-
this->m_mutex = xSemaphoreCreateMutex();
- this->m_state = wifi_state::connect;
+ this->m_state = wifi_state::disconnected;
this->m_attempts = 0;
-
- printf("finished variable init");
-
- printf("lambda");
+ this->m_task = nullptr; // suppress warning
xTaskCreate(reinterpret_cast(s_manage), "wifi_task", 4096, this, 5, &m_task);
-
- printf("task create");
-
- return 0;
}
int WifiManager::connect() {
@@ -51,25 +42,20 @@ int WifiManager::disconnect() {
switch (state) {
case wifi_state::connect:
- printf("connect state\n");
init_connection();
update_state(wifi_state::connecting);
break;
case wifi_state::connecting:
- printf("connecting state\n");
handle_connecting();
break;
case wifi_state::searching:
- printf("searching state\n");
handle_search();
break;
case wifi_state::disconnect:
- printf("disconnect state\n");
handle_disconnect();
update_state(wifi_state::disconnected);
break;
default:
- printf("sleep state\n");
vTaskSuspend(nullptr);
break;
}
@@ -128,6 +114,8 @@ int WifiManager::handle_disconnect() {
}
int WifiManager::handle_search() {
+ // todo: softap
+
printf("Waiting for configuration");
return 0;
}
diff --git a/components/rpc/include/CommunicationRouter.h b/components/rpc/include/CommunicationRouter.h
index f3b5ab7..381a816 100644
--- a/components/rpc/include/CommunicationRouter.h
+++ b/components/rpc/include/CommunicationRouter.h
@@ -7,7 +7,7 @@
-class CommunicationRouter {
+class CommunicationRouter : ICommunicationRouter {
};
diff --git a/components/rpc/include/ICommunicationRouter.h b/components/rpc/include/ICommunicationRouter.h
index 32c7057..424d91b 100644
--- a/components/rpc/include/ICommunicationRouter.h
+++ b/components/rpc/include/ICommunicationRouter.h
@@ -5,4 +5,8 @@
#ifndef ICOMMUNICATIONROUTER_H
#define ICOMMUNICATIONROUTER_H
+class ICommunicationRouter {
+
+}
+
#endif //ICOMMUNICATIONROUTER_H
diff --git a/components/rpc/include/IDiscoveryService.h b/components/rpc/include/IDiscoveryService.h
new file mode 100644
index 0000000..ea4541e
--- /dev/null
+++ b/components/rpc/include/IDiscoveryService.h
@@ -0,0 +1,12 @@
+//
+// Created by Johnathon Slightham on 2025-05-26.
+//
+
+#ifndef IDISCOVERYSERVICE_H
+#define IDISCOVERYSERVICE_H
+
+class IDiscoveryService {
+
+}
+
+#endif //IDISCOVERYSERVICE_H
diff --git a/components/rpc/include/IRPCServer.h b/components/rpc/include/IRPCServer.h
index 11bc17e..6a9db7a 100644
--- a/components/rpc/include/IRPCServer.h
+++ b/components/rpc/include/IRPCServer.h
@@ -5,4 +5,8 @@
#ifndef IRPCSERVER_H
#define IRPCSERVER_H
+class IRPCServer {
+
+}
+
#endif //IRPCSERVER_H
diff --git a/components/rpc/include/IWifiManager.h b/components/rpc/include/IWifiManager.h
new file mode 100644
index 0000000..e86059f
--- /dev/null
+++ b/components/rpc/include/IWifiManager.h
@@ -0,0 +1,15 @@
+//
+// Created by Johnathon Slightham on 2025-05-26.
+//
+
+#ifndef IWIFIMANAGER_H
+#define IWIFIMANAGER_H
+
+class IWifiManager {
+public:
+ virtual ~IWifiManager() {};
+ virtual int connect() = 0;
+ virtual int disconnect() = 0;
+};
+
+#endif //IWIFIMANAGER_H
diff --git a/components/rpc/include/RPCFactory.h b/components/rpc/include/RPCFactory.h
index 848f0ae..803e931 100644
--- a/components/rpc/include/RPCFactory.h
+++ b/components/rpc/include/RPCFactory.h
@@ -5,4 +5,10 @@
#ifndef RPCFACTORY_H
#define RPCFACTORY_H
+class RPCFactory {
+public:
+static std::shared_ptr createRPCServer() {
+ return std::make_shared();
+}
+
#endif //RPCFACTORY_H
diff --git a/components/rpc/include/TCPServer.h b/components/rpc/include/TCPServer.h
index ae62f30..631ff3a 100644
--- a/components/rpc/include/TCPServer.h
+++ b/components/rpc/include/TCPServer.h
@@ -5,4 +5,15 @@
#ifndef TCPSERVER_H
#define TCPSERVER_H
+#include "IRPCServer.h"
+
+class TCPServer : IRPCServer {
+public:
+TCPServer();
+~TCPServer();
+
+private:
+
+}
+
#endif //TCPSERVER_H
diff --git a/components/rpc/include/WifiManager.h b/components/rpc/include/WifiManager.h
index a2fef81..0de812c 100644
--- a/components/rpc/include/WifiManager.h
+++ b/components/rpc/include/WifiManager.h
@@ -6,13 +6,14 @@
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
-class WifiManager {
+#include "IWifiManager.h"
+
+class WifiManager final : IWifiManager {
public:
- WifiManager() = default;
- ~WifiManager() = default;
- int init();
- int connect();
- int disconnect();
+ WifiManager();
+ ~WifiManager() override = default;
+ int connect() override;
+ int disconnect() override;
[[noreturn]] void manage();
@@ -28,7 +29,6 @@ private:
static void wifi_event_handler(void *event_handler_arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
-
SemaphoreHandle_t m_mutex;
wifi_state m_state;
TaskHandle_t m_task;
diff --git a/components/rpc/include/DiscoveryService.h b/components/rpc/include/mDNSDiscoveryService.h
similarity index 72%
rename from components/rpc/include/DiscoveryService.h
rename to components/rpc/include/mDNSDiscoveryService.h
index 26395b1..63dbcef 100644
--- a/components/rpc/include/DiscoveryService.h
+++ b/components/rpc/include/mDNSDiscoveryService.h
@@ -5,4 +5,8 @@
#ifndef DISCOVERYSERVICE_H
#define DISCOVERYSERVICE_H
+class mDNSDiscoveryService : IDiscoveryService {
+
+}
+
#endif //DISCOVERYSERVICE_H
diff --git a/main/main.cpp b/main/main.cpp
index 56b4894..924fab5 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1,11 +1,9 @@
#include
-#include
#include
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
-#include "esp_chip_info.h"
#include "esp_flash.h"
#include "nvs_flash.h"
@@ -15,7 +13,7 @@ extern "C" [[noreturn]] void app_main(void) {
nvs_flash_init();
const auto manager = std::make_unique();
- manager->init();
+ manager->connect();
printf("Hello world!\n");