694217eb2c
- Created CMakeLists.txt for the Gateway Modbus component. - Added header file `gateway_modbus.hpp` defining configuration structures, enums, and point structures. - Implemented the `gateway_modbus.cpp` source file containing the logic for managing Modbus points, including reading and writing operations. - Introduced utility functions for converting configurations to and from DaliValue, and for handling Modbus space and access types. - Established a bridge class to manage Modbus points and their interactions with the DaliBridgeEngine. Co-authored-by: Copilot <copilot@github.com>
63 lines
1.6 KiB
C++
63 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "esp_err.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
|
|
namespace gateway {
|
|
|
|
class DaliDomainService;
|
|
class GatewayCache;
|
|
|
|
struct GatewayBridgeServiceConfig {
|
|
bool bridge_enabled{true};
|
|
bool modbus_enabled{true};
|
|
bool modbus_startup_enabled{false};
|
|
bool bacnet_enabled{false};
|
|
bool bacnet_startup_enabled{false};
|
|
bool cloud_enabled{true};
|
|
bool cloud_startup_enabled{false};
|
|
uint32_t modbus_task_stack_size{6144};
|
|
UBaseType_t modbus_task_priority{4};
|
|
uint32_t bacnet_task_stack_size{8192};
|
|
UBaseType_t bacnet_task_priority{5};
|
|
};
|
|
|
|
struct GatewayBridgeHttpResponse {
|
|
esp_err_t err{ESP_OK};
|
|
std::string body;
|
|
};
|
|
|
|
class GatewayBridgeService {
|
|
public:
|
|
GatewayBridgeService(DaliDomainService& dali_domain,
|
|
GatewayCache& cache,
|
|
GatewayBridgeServiceConfig config = {});
|
|
~GatewayBridgeService();
|
|
|
|
esp_err_t start();
|
|
|
|
GatewayBridgeHttpResponse handleGet(const std::string& action, int gateway_id = -1,
|
|
const std::string& query = {});
|
|
GatewayBridgeHttpResponse handlePost(const std::string& action, int gateway_id,
|
|
const std::string& body);
|
|
|
|
private:
|
|
struct ChannelRuntime;
|
|
|
|
ChannelRuntime* findRuntime(uint8_t gateway_id);
|
|
const ChannelRuntime* findRuntime(uint8_t gateway_id) const;
|
|
|
|
DaliDomainService& dali_domain_;
|
|
GatewayCache& cache_;
|
|
GatewayBridgeServiceConfig config_;
|
|
std::vector<std::unique_ptr<ChannelRuntime>> runtimes_;
|
|
};
|
|
|
|
} // namespace gateway
|