feat(gateway): enhance GatewayNetworkService with HTTP and UDP support, add status LED control
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -80,6 +80,18 @@ void AppendPaddedName(std::vector<uint8_t>& out, std::string_view name) {
|
||||
}
|
||||
}
|
||||
|
||||
const char* PhyKindToString(DaliPhyKind phy_kind) {
|
||||
switch (phy_kind) {
|
||||
case DaliPhyKind::kNativeHardware:
|
||||
return "native";
|
||||
case DaliPhyKind::kSerialUart:
|
||||
return "serial";
|
||||
case DaliPhyKind::kCustom:
|
||||
default:
|
||||
return "custom";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
GatewayController::GatewayController(GatewayRuntime& runtime, DaliDomainService& dali_domain,
|
||||
@@ -157,6 +169,12 @@ void GatewayController::addBleStateSink(BleStateSink sink) {
|
||||
}
|
||||
}
|
||||
|
||||
void GatewayController::addWifiStateSink(WifiStateSink sink) {
|
||||
if (sink) {
|
||||
wifi_state_sinks_.push_back(std::move(sink));
|
||||
}
|
||||
}
|
||||
|
||||
void GatewayController::addGatewayNameSink(GatewayNameSink sink) {
|
||||
if (sink) {
|
||||
gateway_name_sinks_.push_back(std::move(sink));
|
||||
@@ -179,6 +197,36 @@ bool GatewayController::ipRouterEnabled() const {
|
||||
return ip_router_enabled_;
|
||||
}
|
||||
|
||||
GatewayControllerSnapshot GatewayController::snapshot() {
|
||||
GatewayControllerSnapshot out;
|
||||
out.setup_mode = setup_mode_;
|
||||
out.ble_enabled = ble_enabled_;
|
||||
out.wifi_enabled = wifi_enabled_;
|
||||
out.ip_router_enabled = ip_router_enabled_;
|
||||
out.internal_scene_supported = config_.internal_scene_supported;
|
||||
out.internal_group_supported = config_.internal_group_supported;
|
||||
|
||||
const auto channels = dali_domain_.channelInfo();
|
||||
out.channels.reserve(channels.size());
|
||||
for (const auto& channel : channels) {
|
||||
const auto [scene_low, scene_high] = sceneMask(channel.gateway_id);
|
||||
const auto [group_low, group_high] = groupMask(channel.gateway_id);
|
||||
GatewayChannelSnapshot channel_snapshot;
|
||||
channel_snapshot.channel_index = channel.channel_index;
|
||||
channel_snapshot.gateway_id = channel.gateway_id;
|
||||
channel_snapshot.name = channel.name;
|
||||
channel_snapshot.phy = PhyKindToString(channel.phy_kind);
|
||||
channel_snapshot.scene_mask_low = scene_low;
|
||||
channel_snapshot.scene_mask_high = scene_high;
|
||||
channel_snapshot.group_mask_low = group_low;
|
||||
channel_snapshot.group_mask_high = group_high;
|
||||
channel_snapshot.allocating = dali_domain_.isAllocAddr(channel.gateway_id);
|
||||
channel_snapshot.last_alloc_addr = dali_domain_.lastAllocAddr(channel.gateway_id);
|
||||
out.channels.push_back(std::move(channel_snapshot));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void GatewayController::TaskEntry(void* arg) {
|
||||
static_cast<GatewayController*>(arg)->taskLoop();
|
||||
}
|
||||
@@ -257,6 +305,9 @@ void GatewayController::dispatchCommand(const std::vector<uint8_t>& command) {
|
||||
} else if (addr == 1 || addr == 101) {
|
||||
wifi_enabled_ = true;
|
||||
}
|
||||
for (const auto& sink : wifi_state_sinks_) {
|
||||
sink(addr);
|
||||
}
|
||||
break;
|
||||
case 0x05:
|
||||
handleGatewayNameCommand(gateway_id, command);
|
||||
|
||||
Reference in New Issue
Block a user