Cleanup rpc interfaces

This commit is contained in:
2025-10-22 23:07:41 -04:00
parent c1512a1fa6
commit 6a1bf027b4
28 changed files with 224 additions and 97 deletions

View File

@@ -18,7 +18,7 @@
#define METADATA_PERIOD_MS 1000
[[noreturn]] void LoopManager::control_loop() const {
const auto actuator = ActuatorFactory::create_actuator(m_config_manager.get_module_type());
const auto actuator = ActuatorFactory::create_actuator(m_config_manager.get_module_type()); // todo: this needs to be moved higher up with one factory that returns shared ptr for both actuator and sensor.
uint8_t buffer[512];
while (true) {
@@ -27,6 +27,11 @@
}
}
[[noreturn]] void LoopManager::sensor_loop() const {
// todo: impl
}
[[noreturn]] void LoopManager::metadata_tx_loop(char * args) {
const auto that = reinterpret_cast<LoopManager *>(args);
const auto topology_message_builder = std::make_unique<Flatbuffers::TopologyMessageBuilder>();

View File

@@ -12,19 +12,15 @@
class LoopManager {
public:
LoopManager() : m_config_manager(ConfigManager::get_instance()),
m_messaging_interface(std::make_unique<MessagingInterface>(std::make_unique<WifiManager>())) {}
[[noreturn]] void control_loop() const;
[[noreturn]] static void metadata_tx_loop(char * args);
[[noreturn]] static void metadata_rx_loop(char * args);
m_messaging_interface(std::make_unique<MessagingInterface>()) {}
[[noreturn]] void control_loop() const; // gets control commands
[[noreturn]] void sensor_loop() const; // sends sensor data commands continually
[[noreturn]] static void metadata_tx_loop(char * args); // sends metadata continually (low duty cycle)
[[noreturn]] static void metadata_rx_loop(char * args); // gets other commands from PC (ie. f/w updates, nvs updates)
private:
ConfigManager& m_config_manager;
std::unique_ptr<MessagingInterface> m_messaging_interface;
private:
};
#endif //LOOPMANAGER_H

View File

@@ -0,0 +1,14 @@
//
// Created by Johnathon Slightham on 2025-10-16.
//
#ifndef ISENSOR_H
#define ISENSOR_H
class ISensor {
public:
virtual ~ISensor() {}
virtual void get_reading() = 0; // todo: return a flatbuffer object
};
#endif //ISENSOR_H

View File

@@ -0,0 +1,13 @@
//
// Created by Johnathon Slightham on 2025-10-16.
//
#ifndef SENSORFACTORY_H
#define SENSORFACTORY_H
class SensorFactory {
public:
static std::unique_ptr<ISensor> create_sensor(ModuleType type);
};
#endif //SENSORFACTORY_H

View File

@@ -9,6 +9,7 @@
#include <cstdint>
#include "IActuator.h"
#include "ISensor.h"
class Servo1Actuator final : public IActuator {
public:

View File

@@ -5,8 +5,6 @@
#include "sdkconfig.h"
#include "ConfigManager.h"
#include "LoopManager.h"
#include "TCPServer.h"
#include "WifiManager.h"
#include "esp_log.h"
extern "C" [[noreturn]] void app_main(void) {