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:
@@ -1,9 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "base.hpp"
|
||||
#include "addr.hpp"
|
||||
#include "bridge_model.hpp"
|
||||
#include "dali_comm.hpp"
|
||||
#include "dt1.hpp"
|
||||
#include "dt4.hpp"
|
||||
#include "dt5.hpp"
|
||||
#include "dt6.hpp"
|
||||
#include "dt8.hpp"
|
||||
|
||||
#include <map>
|
||||
@@ -30,6 +34,7 @@ struct DaliBridgeResult {
|
||||
std::optional<int> data;
|
||||
std::string error;
|
||||
DaliValue::Object metadata;
|
||||
DaliValue::Array results;
|
||||
|
||||
DaliValue::Object toJson() const;
|
||||
};
|
||||
@@ -49,7 +54,11 @@ class DaliBridgeEngine {
|
||||
DaliComm& comm_;
|
||||
DaliBase base_;
|
||||
DaliDT1 dt1_;
|
||||
DaliDT4 dt4_;
|
||||
DaliDT5 dt5_;
|
||||
DaliDT6 dt6_;
|
||||
DaliDT8 dt8_;
|
||||
DaliAddr addr_;
|
||||
std::map<std::string, BridgeModel> models_;
|
||||
|
||||
DaliBridgeResult executeResolved(const DaliBridgeRequest& request,
|
||||
|
||||
@@ -57,6 +57,36 @@ enum class BridgeOperation {
|
||||
startEmergencyFunctionTest = 18,
|
||||
stopEmergencyTest = 19,
|
||||
startEmergencyDurationTest = 20,
|
||||
setColorTemperatureRaw = 21,
|
||||
setColourXY = 22,
|
||||
setColourRGB = 23,
|
||||
setTemporaryColourTemperature = 24,
|
||||
setTemporaryColourXY = 25,
|
||||
setTemporaryRGBDimLevels = 26,
|
||||
setTemporaryColourMask = 27,
|
||||
activateTemporaryColour = 28,
|
||||
copyReportToTemporary = 29,
|
||||
storeDt8SceneSnapshot = 30,
|
||||
storeDt8PowerOnLevelSnapshot = 31,
|
||||
storeDt8SystemFailureLevelSnapshot = 32,
|
||||
getDt1Snapshot = 33,
|
||||
getDt4Snapshot = 34,
|
||||
getDt5Snapshot = 35,
|
||||
getDt6Snapshot = 36,
|
||||
getDt8StatusSnapshot = 37,
|
||||
getGroupMask = 38,
|
||||
setGroupMask = 39,
|
||||
getSceneLevel = 40,
|
||||
setSceneLevel = 41,
|
||||
removeSceneLevel = 42,
|
||||
getSceneMap = 43,
|
||||
getAddressSettings = 44,
|
||||
setAddressSettings = 45,
|
||||
searchAddressRange = 46,
|
||||
allocateAllShortAddresses = 47,
|
||||
resetAndAllocateShortAddresses = 48,
|
||||
stopAddressAllocation = 49,
|
||||
batch = 50,
|
||||
};
|
||||
|
||||
enum class BridgeValueEncoding {
|
||||
|
||||
Reference in New Issue
Block a user