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,
|
||||
|
||||
Reference in New Issue
Block a user