Enhance bridge operation handling and improve JSON conversion

- Added new bridge operations to the bridgeOperationToString and bridgeOperationFromString functions for better command recognition.
- Implemented a fromCjson function to convert cJSON objects to DaliValue, supporting various data types including arrays and objects.
- Introduced isKnownBridgeRequestKey function to filter out unknown keys in bridge requests.
- Refactored handleDownlink to utilize the new fromCjson function for value and metadata extraction, improving code clarity and maintainability.
- Updated response creation to use a more structured approach with DaliValue's toJson method.

Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
Tony
2026-05-04 09:45:15 +08:00
parent fa4acef881
commit 1550ab15d6
6 changed files with 1062 additions and 276 deletions
+4 -4
View File
@@ -255,13 +255,13 @@ std::optional<std::pair<int, int>> DaliBase::getGradualChange(int a) {
std::optional<int> DaliBase::getGradualChangeRate(int a) {
const auto rs = getGradualChange(a);
if (!rs.has_value()) return std::nullopt;
return rs->second;
return rs->first;
}
std::optional<int> DaliBase::getGradualChangeSpeed(int a) {
const auto rs = getGradualChange(a);
if (!rs.has_value()) return std::nullopt;
return rs->first;
return rs->second;
}
bool DaliBase::setPowerOnLevel(int a, int value) { return setDTR(value) && storeDTRAsPoweredBright(a); }
@@ -291,7 +291,7 @@ bool DaliBase::setFadeTime(int a, int value) {
std::optional<int> DaliBase::getFadeTime(int a) {
const auto rs = getGradualChange(a);
if (!rs.has_value()) return std::nullopt;
return rs->first;
return rs->second;
}
bool DaliBase::setFadeRate(int a, int value) { return setDTR(value) && storeDTRAsFadeRate(a); }
@@ -299,7 +299,7 @@ bool DaliBase::setFadeRate(int a, int value) { return setDTR(value) && storeDTRA
std::optional<int> DaliBase::getFadeRate(int a) {
const auto rs = getGradualChange(a);
if (!rs.has_value()) return std::nullopt;
return rs->second;
return rs->first;
}
std::optional<int> DaliBase::getNextDeviceType(int a) { return query(a, DALI_CMD_QUERY_NEXT_DEVICE_TYPE); }