feat(gateway_network): integrate GatewayBridgeService and add bridge handling

- Updated CMakeLists.txt to require gateway_bridge component.
- Modified GatewayNetworkService to include a pointer to GatewayBridgeService.
- Added new HTTP handlers for bridge GET and POST requests.
- Implemented query utility functions for handling request parameters.
- Enhanced response handling for bridge actions with JSON responses.

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Tony
2026-05-01 03:54:02 +08:00
parent 2c1aa28d4f
commit d16c289626
19 changed files with 3186 additions and 10 deletions
+18
View File
@@ -0,0 +1,18 @@
set(GATEWAY_BRIDGE_REQUIRES
dali_domain
dali_cpp
espressif__cjson
freertos
log
lwip
nvs_flash
)
idf_component_register(
SRCS "src/gateway_bridge.cpp"
INCLUDE_DIRS "include"
REQUIRES ${GATEWAY_BRIDGE_REQUIRES}
PRIV_REQUIRES gateway_bacnet
)
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
@@ -0,0 +1,59 @@
#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;
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,
GatewayBridgeServiceConfig config = {});
~GatewayBridgeService();
esp_err_t start();
GatewayBridgeHttpResponse handleGet(const std::string& action, int gateway_id = -1,
const std::string& query = {}) const;
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_;
GatewayBridgeServiceConfig config_;
std::vector<std::unique_ptr<ChannelRuntime>> runtimes_;
};
} // namespace gateway
File diff suppressed because it is too large Load Diff