Enhance DaliComm: refactor checkGatewayType to use checksum for newProbe and handle legacy tail

Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
Tony
2026-06-08 19:23:52 +08:00
parent 440dbd1757
commit e11a0f646c
+6 -2
View File
@@ -169,7 +169,9 @@ int DaliComm::checkGatewayType(int gateway) const {
const std::vector<uint8_t> usbProbe{0x01, 0x00, 0x00}; const std::vector<uint8_t> usbProbe{0x01, 0x00, 0x00};
const std::vector<uint8_t> legacyProbe{0x28, 0x01, static_cast<uint8_t>(gateway), 0x11, 0x00, 0x00, const std::vector<uint8_t> legacyProbe{0x28, 0x01, static_cast<uint8_t>(gateway), 0x11, 0x00, 0x00,
0xFF}; 0xFF};
const std::vector<uint8_t> newProbe{0x28, 0x01, static_cast<uint8_t>(gateway), 0x11, 0x00, const auto newProbe = checksum({0x28, 0x01, static_cast<uint8_t>(gateway), 0x11, 0x00,
0x00, 0x00, 0x00, 0x00});
const std::vector<uint8_t> newProbeLegacyTail{0x28, 0x01, static_cast<uint8_t>(gateway), 0x11, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF}; 0x00, 0x00, 0x00, 0x00, 0xFF};
prepareForQuery(); prepareForQuery();
@@ -180,9 +182,11 @@ int DaliComm::checkGatewayType(int gateway) const {
const auto legacyResp = transact_(legacyProbe.data(), legacyProbe.size()); const auto legacyResp = transact_(legacyProbe.data(), legacyProbe.size());
if (legacyResp.size() >= 2 && legacyResp[0] == gateway) return 2; if (legacyResp.size() >= 2 && legacyResp[0] == gateway) return 2;
for (const auto& probe : {newProbe, newProbeLegacyTail}) {
prepareForQuery(); prepareForQuery();
const auto newResp = transact_(newProbe.data(), newProbe.size()); const auto newResp = transact_(probe.data(), probe.size());
if (newResp.size() >= 2 && newResp[0] == gateway) return 3; if (newResp.size() >= 2 && newResp[0] == gateway) return 3;
}
return 0; return 0;
} }