feat(gateway): enhance DALI and KNX handling with broadcast management support and configurable task stack size
Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
@@ -22,6 +22,21 @@ bool IsUsableIndividualAddress(uint16_t address) {
|
||||
return address != 0 && address != kInvalidIndividualAddress;
|
||||
}
|
||||
|
||||
bool IsBroadcastManagementRequest(CemiFrame& frame) {
|
||||
if (frame.addressType() != GroupAddress || frame.destinationAddress() != 0x0000) {
|
||||
return false;
|
||||
}
|
||||
switch (frame.apdu().type()) {
|
||||
case IndividualAddressWrite:
|
||||
case IndividualAddressRead:
|
||||
case IndividualAddressSerialNumberRead:
|
||||
case IndividualAddressSerialNumberWrite:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t OamBauNumberFromBaseMac() {
|
||||
uint8_t mac[6]{};
|
||||
if (esp_efuse_mac_get_default(mac) != ESP_OK && esp_read_mac(mac, ESP_MAC_WIFI_STA) != ESP_OK) {
|
||||
@@ -218,6 +233,33 @@ bool OamRouterRuntime::handleTunnelFrame(const uint8_t* data, size_t len,
|
||||
#endif
|
||||
}
|
||||
|
||||
bool OamRouterRuntime::handleLocalBroadcastManagementFrame(const uint8_t* data, size_t len,
|
||||
CemiFrameSender sender) {
|
||||
#if defined(ENABLE_BAU091A_PERSONA)
|
||||
if (data == nullptr || len < 2) {
|
||||
return false;
|
||||
}
|
||||
std::vector<uint8_t> frame_data(data, data + len);
|
||||
CemiFrame frame(frame_data.data(), static_cast<uint16_t>(frame_data.size()));
|
||||
if (!frame.valid() || !IsBroadcastManagementRequest(frame)) {
|
||||
return false;
|
||||
}
|
||||
const HopCountType hop_type =
|
||||
frame.npdu().hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
|
||||
sender_ = std::move(sender);
|
||||
device_.injectDataBroadcastIndication(hop_type, frame.priority(), frame.sourceAddress(),
|
||||
frame.apdu());
|
||||
loop();
|
||||
sender_ = nullptr;
|
||||
return true;
|
||||
#else
|
||||
(void)data;
|
||||
(void)len;
|
||||
(void)sender;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void OamRouterRuntime::loop() {
|
||||
#if defined(ENABLE_BAU091A_PERSONA)
|
||||
device_.loop();
|
||||
@@ -268,6 +310,9 @@ bool OamRouterRuntime::shouldConsumeTunnelFrame(CemiFrame& frame) const {
|
||||
return dest == individualAddress() || dest == tunnelClientAddress() ||
|
||||
(commissioning && dest == kKnxUnconfiguredBroadcastAddress);
|
||||
}
|
||||
if (IsBroadcastManagementRequest(frame)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user