feat(gateway): implement serial communication handling in DaliDomainService and GatewayController
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -114,6 +114,7 @@ esp_err_t GatewayController::start() {
|
||||
runtime_.setCommandAddressResolver([this](uint8_t gateway_id, uint8_t raw_addr) {
|
||||
return resolveInternalGroupRawAddress(gateway_id, raw_addr);
|
||||
});
|
||||
dali_domain_.addRawFrameSink([this](const DaliRawFrame& frame) { handleDaliRawFrame(frame); });
|
||||
|
||||
for (const auto& channel : dali_domain_.channelInfo()) {
|
||||
sceneStore(channel.gateway_id);
|
||||
@@ -508,6 +509,31 @@ void GatewayController::publishFrame(const std::vector<uint8_t>& frame) {
|
||||
}
|
||||
}
|
||||
|
||||
void GatewayController::handleDaliRawFrame(const DaliRawFrame& frame) {
|
||||
if (frame.data.size() != 2 && frame.data.size() != 3) {
|
||||
return;
|
||||
}
|
||||
if (setup_mode_ || dali_domain_.isAllocAddr(frame.gateway_id) ||
|
||||
runtime_.hasActiveQueryCommand(frame.gateway_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t addr = 0;
|
||||
uint8_t data = 0;
|
||||
if (frame.data.size() == 2) {
|
||||
addr = frame.data[0];
|
||||
data = frame.data[1];
|
||||
if (addr == 0xBE) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
addr = frame.data[1];
|
||||
data = frame.data[2];
|
||||
}
|
||||
|
||||
publishPayload(frame.gateway_id, {0x01, frame.gateway_id, addr, data});
|
||||
}
|
||||
|
||||
uint8_t GatewayController::resolveInternalGroupRawAddress(uint8_t gateway_id, uint8_t raw_addr) {
|
||||
if (raw_addr < 0x80 || raw_addr > 0x9f) {
|
||||
return raw_addr;
|
||||
|
||||
Reference in New Issue
Block a user