Zigbee Protocol Controller 1.6.0
dotdot_mqtt_translators.h
Go to the documentation of this file.
1/******************************************************************************
2 * # License
3 * <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
4 ******************************************************************************
5 * The licensor of this software is Silicon Laboratories Inc. Your use of this
6 * software is governed by the terms of Silicon Labs Master Software License
7 * Agreement (MSLA) available at
8 * www.silabs.com/about-us/legal/master-software-license-agreement. This
9 * software is distributed to you in Source Code format and is governed by the
10 * sections of the MSLA applicable to Source Code.
11 *
12 *****************************************************************************/
13
14#ifndef DOTDOT_MQTT_TRANSLATORS_H
15#define DOTDOT_MQTT_TRANSLATORS_H
16#include <sstream>
17#include <string>
18#include <vector>
19#include <map>
20
21#include <nlohmann/json.hpp>
22
23#include <zap-types.h>
24
25
32inline void from_json(const nlohmann::json& jsn, NM_StateParameters& field)
33{
34 field.ProvisioningMode = jsn.at("ProvisioningMode").get_ptr<const std::string*>()->c_str();
35 jsn.at("UserAccept").get_to(field.UserAccept);
36 field.SecurityCode = jsn.at("SecurityCode").get_ptr<const std::string*>()->c_str();
37 field.Unid = jsn.at("Unid").get_ptr<const std::string*>()->c_str();
38 jsn.at("AllowMultipleInclusions").get_to(field.AllowMultipleInclusions);
39}
40
41
48inline void to_json(nlohmann::json& jsn, const NM_StateParameters& field)
49{
50 jsn["ProvisioningMode"] = field.ProvisioningMode;
51 jsn["UserAccept"] = field.UserAccept;
52 jsn["SecurityCode"] = field.SecurityCode;
53 jsn["Unid"] = field.Unid;
54 jsn["AllowMultipleInclusions"] = field.AllowMultipleInclusions;
55}
56
57
64inline void from_json(const nlohmann::json& jsn, NetworkManagementState& field)
65{
66 jsn.at("State").get_to(field.State);
67 field.SupportedStateList = jsn.at("SupportedStateList").get_ptr<const std::string*>()->c_str();
68 jsn.at("StateParameters").get_to(field.StateParameters);
69 field.RequestedStateParameters = jsn.at("RequestedStateParameters").get_ptr<const std::string*>()->c_str();
70}
71
72
79inline void to_json(nlohmann::json& jsn, const NetworkManagementState& field)
80{
81 jsn["State"] = field.State;
82 jsn["SupportedStateList"] = field.SupportedStateList;
83 jsn["StateParameters"] = field.StateParameters;
84 jsn["RequestedStateParameters"] = field.RequestedStateParameters;
85}
86
87
94inline void from_json(const nlohmann::json& jsn, BindingObject& field)
95{
96 field.ClusterName = jsn.at("ClusterName").get_ptr<const std::string*>()->c_str();
97 field.DestinationUnid = jsn.at("DestinationUnid").get_ptr<const std::string*>()->c_str();
98 jsn.at("DestinationEp").get_to(field.DestinationEp);
99}
100
101
108inline void to_json(nlohmann::json& jsn, const BindingObject& field)
109{
110 jsn["ClusterName"] = field.ClusterName;
111 jsn["DestinationUnid"] = field.DestinationUnid;
112 jsn["DestinationEp"] = field.DestinationEp;
113}
114
115
122inline void from_json(const nlohmann::json& jsn, ConfigurationParameter& field)
123{
124 jsn.at("ParameterId").get_to(field.ParameterId);
125 jsn.at("Value").get_to(field.Value);
126 field.Name = jsn.at("Name").get_ptr<const std::string*>()->c_str();
127 field.Info = jsn.at("Info").get_ptr<const std::string*>()->c_str();
128 jsn.at("MinimumValue").get_to(field.MinimumValue);
129 jsn.at("MaximumValue").get_to(field.MaximumValue);
130 jsn.at("DefaultValue").get_to(field.DefaultValue);
131 jsn.at("DisplayFormat").get_to(field.DisplayFormat);
132 jsn.at("ReadOnly").get_to(field.ReadOnly);
133 jsn.at("Advanced").get_to(field.Advanced);
134 jsn.at("AlteringCapabilities").get_to(field.AlteringCapabilities);
135}
136
137
144inline void to_json(nlohmann::json& jsn, const ConfigurationParameter& field)
145{
146 jsn["ParameterId"] = field.ParameterId;
147 jsn["Value"] = field.Value;
148 jsn["Name"] = field.Name;
149 jsn["Info"] = field.Info;
150 jsn["MinimumValue"] = field.MinimumValue;
151 jsn["MaximumValue"] = field.MaximumValue;
152 jsn["DefaultValue"] = field.DefaultValue;
153 jsn["DisplayFormat"] = field.DisplayFormat;
154 jsn["ReadOnly"] = field.ReadOnly;
155 jsn["Advanced"] = field.Advanced;
156 jsn["AlteringCapabilities"] = field.AlteringCapabilities;
157}
158
159
166inline void from_json(const nlohmann::json& jsn, CoordinateAndOrientation& field)
167{
168 jsn.at("CoordinateX").get_to(field.CoordinateX);
169 jsn.at("CoordinateY").get_to(field.CoordinateY);
170 jsn.at("CoordinateZ").get_to(field.CoordinateZ);
171 jsn.at("OrientationX").get_to(field.OrientationX);
172 jsn.at("OrientationY").get_to(field.OrientationY);
173 jsn.at("OrientationZ").get_to(field.OrientationZ);
174}
175
176
183inline void to_json(nlohmann::json& jsn, const CoordinateAndOrientation& field)
184{
185 jsn["CoordinateX"] = field.CoordinateX;
186 jsn["CoordinateY"] = field.CoordinateY;
187 jsn["CoordinateZ"] = field.CoordinateZ;
188 jsn["OrientationX"] = field.OrientationX;
189 jsn["OrientationY"] = field.OrientationY;
190 jsn["OrientationZ"] = field.OrientationZ;
191}
192
193
200inline void from_json(const nlohmann::json& jsn, CredentialStruct& field)
201{
202 jsn.at("CredentialType").get_to(field.CredentialType);
203 jsn.at("CredentialIndex").get_to(field.CredentialIndex);
204}
205
206
213inline void to_json(nlohmann::json& jsn, const CredentialStruct& field)
214{
215 jsn["CredentialType"] = field.CredentialType;
216 jsn["CredentialIndex"] = field.CredentialIndex;
217}
218
219
226inline void from_json(const nlohmann::json& jsn, DeviceTypeStruct& field)
227{
228 jsn.at("DeviceType").get_to(field.DeviceType);
229 jsn.at("Revision").get_to(field.Revision);
230}
231
232
239inline void to_json(nlohmann::json& jsn, const DeviceTypeStruct& field)
240{
241 jsn["DeviceType"] = field.DeviceType;
242 jsn["Revision"] = field.Revision;
243}
244
245
252inline void from_json(const nlohmann::json& jsn, DiskIOCounters& field)
253{
254 field.UUID = jsn.at("UUID").get_ptr<const std::string*>()->c_str();
255 jsn.at("ReadCount").get_to(field.ReadCount);
256 jsn.at("WriteCount").get_to(field.WriteCount);
257 jsn.at("ReadBytes").get_to(field.ReadBytes);
258 jsn.at("WriteBytes").get_to(field.WriteBytes);
259}
260
261
268inline void to_json(nlohmann::json& jsn, const DiskIOCounters& field)
269{
270 jsn["UUID"] = field.UUID;
271 jsn["ReadCount"] = field.ReadCount;
272 jsn["WriteCount"] = field.WriteCount;
273 jsn["ReadBytes"] = field.ReadBytes;
274 jsn["WriteBytes"] = field.WriteBytes;
275}
276
277
284inline void from_json(const nlohmann::json& jsn, DiskUsageData& field)
285{
286 field.UUID = jsn.at("UUID").get_ptr<const std::string*>()->c_str();
287 jsn.at("UsagePercent").get_to(field.UsagePercent);
288 jsn.at("FreeSpaceMB").get_to(field.FreeSpaceMB);
289}
290
291
298inline void to_json(nlohmann::json& jsn, const DiskUsageData& field)
299{
300 jsn["UUID"] = field.UUID;
301 jsn["UsagePercent"] = field.UsagePercent;
302 jsn["FreeSpaceMB"] = field.FreeSpaceMB;
303}
304
305
312inline void from_json(const nlohmann::json& jsn, EstimatedPosition& field)
313{
314 field.ApplicationId = jsn.at("ApplicationId").get_ptr<const std::string*>()->c_str();
315 jsn.at("X").get_to(field.X);
316 jsn.at("Y").get_to(field.Y);
317 jsn.at("Z").get_to(field.Z);
318 jsn.at("DeviationX").get_to(field.DeviationX);
319 jsn.at("DeviationY").get_to(field.DeviationY);
320 jsn.at("DeviationZ").get_to(field.DeviationZ);
321 jsn.at("Sequence").get_to(field.Sequence);
322}
323
324
331inline void to_json(nlohmann::json& jsn, const EstimatedPosition& field)
332{
333 jsn["ApplicationId"] = field.ApplicationId;
334 jsn["X"] = field.X;
335 jsn["Y"] = field.Y;
336 jsn["Z"] = field.Z;
337 jsn["DeviationX"] = field.DeviationX;
338 jsn["DeviationY"] = field.DeviationY;
339 jsn["DeviationZ"] = field.DeviationZ;
340 jsn["Sequence"] = field.Sequence;
341}
342
343
350inline void from_json(const nlohmann::json& jsn, IasaceZoneStatusRecord& field)
351{
352 jsn.at("ZoneID").get_to(field.ZoneID);
353 jsn.at("ZoneStatus").get_to(field.ZoneStatus);
354}
355
356
363inline void to_json(nlohmann::json& jsn, const IasaceZoneStatusRecord& field)
364{
365 jsn["ZoneID"] = field.ZoneID;
366 jsn["ZoneStatus"] = field.ZoneStatus;
367}
368
369
376inline void from_json(const nlohmann::json& jsn, MinMaxPair& field)
377{
378 jsn.at("Min").get_to(field.Min);
379 jsn.at("Max").get_to(field.Max);
380}
381
382
389inline void to_json(nlohmann::json& jsn, const MinMaxPair& field)
390{
391 jsn["Min"] = field.Min;
392 jsn["Max"] = field.Max;
393}
394
395
402inline void from_json(const nlohmann::json& jsn, NetworkInterfaceData& field)
403{
404 field.InterfaceName = jsn.at("InterfaceName").get_ptr<const std::string*>()->c_str();
405 jsn.at("BytesSent").get_to(field.BytesSent);
406 jsn.at("BytesReceived").get_to(field.BytesReceived);
407 jsn.at("PacketsSent").get_to(field.PacketsSent);
408 jsn.at("PacketsReceived").get_to(field.PacketsReceived);
409 jsn.at("ErrorsIn").get_to(field.ErrorsIn);
410 jsn.at("ErrorsOut").get_to(field.ErrorsOut);
411 jsn.at("DropIn").get_to(field.DropIn);
412 jsn.at("DropOut").get_to(field.DropOut);
413}
414
415
422inline void to_json(nlohmann::json& jsn, const NetworkInterfaceData& field)
423{
424 jsn["InterfaceName"] = field.InterfaceName;
425 jsn["BytesSent"] = field.BytesSent;
426 jsn["BytesReceived"] = field.BytesReceived;
427 jsn["PacketsSent"] = field.PacketsSent;
428 jsn["PacketsReceived"] = field.PacketsReceived;
429 jsn["ErrorsIn"] = field.ErrorsIn;
430 jsn["ErrorsOut"] = field.ErrorsOut;
431 jsn["DropIn"] = field.DropIn;
432 jsn["DropOut"] = field.DropOut;
433}
434
435
442inline void from_json(const nlohmann::json& jsn, SExtensionFieldSetList& field)
443{
444 jsn.at("ClusterId").get_to(field.ClusterId);
445 field.ExtensionFieldSet = jsn.at("ExtensionFieldSet").get_ptr<const std::string*>()->c_str();
446}
447
448
455inline void to_json(nlohmann::json& jsn, const SExtensionFieldSetList& field)
456{
457 jsn["ClusterId"] = field.ClusterId;
458 jsn["ExtensionFieldSet"] = field.ExtensionFieldSet;
459}
460
461
468inline void from_json(const nlohmann::json& jsn, SSceneTable& field)
469{
470 jsn.at("SceneID").get_to(field.SceneID);
471 jsn.at("GroupID").get_to(field.GroupID);
472 field.SceneName = jsn.at("SceneName").get_ptr<const std::string*>()->c_str();
473 jsn.at("TransitionTime").get_to(field.TransitionTime);
474 jsn.at("TransitionTime100ms").get_to(field.TransitionTime100ms);
475 field.SceneTableExtensions = jsn.at("SceneTableExtensions").get_ptr<const std::string*>()->c_str();
476}
477
478
485inline void to_json(nlohmann::json& jsn, const SSceneTable& field)
486{
487 jsn["SceneID"] = field.SceneID;
488 jsn["GroupID"] = field.GroupID;
489 jsn["SceneName"] = field.SceneName;
490 jsn["TransitionTime"] = field.TransitionTime;
491 jsn["TransitionTime100ms"] = field.TransitionTime100ms;
492 jsn["SceneTableExtensions"] = field.SceneTableExtensions;
493}
494
495
502inline void from_json(const nlohmann::json& jsn, SphericalCoordinates& field)
503{
504 jsn.at("Azimuth").get_to(field.Azimuth);
505 jsn.at("Elevation").get_to(field.Elevation);
506 jsn.at("Distance").get_to(field.Distance);
507}
508
509
516inline void to_json(nlohmann::json& jsn, const SphericalCoordinates& field)
517{
518 jsn["Azimuth"] = field.Azimuth;
519 jsn["Elevation"] = field.Elevation;
520 jsn["Distance"] = field.Distance;
521}
522
523
530inline void from_json(const nlohmann::json& jsn, TransitionType& field)
531{
532 jsn.at("TransitionTime").get_to(field.TransitionTime);
533 jsn.at("HeatSetPoint").get_to(field.HeatSetPoint);
534 jsn.at("CoolSetPoint").get_to(field.CoolSetPoint);
535}
536
537
544inline void to_json(nlohmann::json& jsn, const TransitionType& field)
545{
546 jsn["TransitionTime"] = field.TransitionTime;
547 jsn["HeatSetPoint"] = field.HeatSetPoint;
548 jsn["CoolSetPoint"] = field.CoolSetPoint;
549}
550
551
558inline void from_json(const nlohmann::json& jsn, WirelessNetworkInterfaceData& field)
559{
560 field.InterfaceName = jsn.at("InterfaceName").get_ptr<const std::string*>()->c_str();
561 jsn.at("SignalStrengthdBm").get_to(field.SignalStrengthdBm);
562}
563
564
571inline void to_json(nlohmann::json& jsn, const WirelessNetworkInterfaceData& field)
572{
573 jsn["InterfaceName"] = field.InterfaceName;
574 jsn["SignalStrengthdBm"] = field.SignalStrengthdBm;
575}
576
577
578// END OF nlohmann parsers
579
580#endif
void from_json(const nlohmann::json &jsn, NM_StateParameters &field)
Definition: dotdot_mqtt_translators.h:32
void to_json(nlohmann::json &jsn, const NM_StateParameters &field)
Definition: dotdot_mqtt_translators.h:48
Definition: zap-types.h:2167
uint8_t DestinationEp
Definition: zap-types.h:2170
const char * ClusterName
Definition: zap-types.h:2168
const char * DestinationUnid
Definition: zap-types.h:2169
Definition: zap-types.h:2174
int64_t MaximumValue
Definition: zap-types.h:2180
int64_t MinimumValue
Definition: zap-types.h:2179
bool Advanced
Definition: zap-types.h:2184
bool AlteringCapabilities
Definition: zap-types.h:2185
int64_t DefaultValue
Definition: zap-types.h:2181
uint16_t ParameterId
Definition: zap-types.h:2175
int64_t Value
Definition: zap-types.h:2176
bool ReadOnly
Definition: zap-types.h:2183
const char * Info
Definition: zap-types.h:2178
uint8_t DisplayFormat
Definition: zap-types.h:2182
const char * Name
Definition: zap-types.h:2177
Definition: zap-types.h:2189
double CoordinateX
Definition: zap-types.h:2190
double OrientationZ
Definition: zap-types.h:2195
double OrientationX
Definition: zap-types.h:2193
double OrientationY
Definition: zap-types.h:2194
double CoordinateZ
Definition: zap-types.h:2192
double CoordinateY
Definition: zap-types.h:2191
Definition: zap-types.h:2199
CredentialTypeEnum CredentialType
Definition: zap-types.h:2200
uint16_t CredentialIndex
Definition: zap-types.h:2201
Definition: zap-types.h:2205
uint16_t Revision
Definition: zap-types.h:2207
DevTypeId DeviceType
Definition: zap-types.h:2206
Definition: zap-types.h:2211
uint64_t ReadCount
Definition: zap-types.h:2213
uint64_t WriteCount
Definition: zap-types.h:2214
uint64_t ReadBytes
Definition: zap-types.h:2215
uint64_t WriteBytes
Definition: zap-types.h:2216
const char * UUID
Definition: zap-types.h:2212
Definition: zap-types.h:2220
double FreeSpaceMB
Definition: zap-types.h:2223
double UsagePercent
Definition: zap-types.h:2222
const char * UUID
Definition: zap-types.h:2221
Definition: zap-types.h:2227
double DeviationY
Definition: zap-types.h:2233
double Z
Definition: zap-types.h:2231
double Y
Definition: zap-types.h:2230
double X
Definition: zap-types.h:2229
const char * ApplicationId
Definition: zap-types.h:2228
double DeviationZ
Definition: zap-types.h:2234
int32_t Sequence
Definition: zap-types.h:2235
double DeviationX
Definition: zap-types.h:2232
Definition: zap-types.h:2239
uint8_t ZoneID
Definition: zap-types.h:2240
uint16_t ZoneStatus
Definition: zap-types.h:2241
Definition: zap-types.h:2245
double Min
Definition: zap-types.h:2246
double Max
Definition: zap-types.h:2247
Definition: zap-types.h:2150
bool UserAccept
Definition: zap-types.h:2152
const char * SecurityCode
Definition: zap-types.h:2153
const char * ProvisioningMode
Definition: zap-types.h:2151
bool AllowMultipleInclusions
Definition: zap-types.h:2155
const char * Unid
Definition: zap-types.h:2154
Definition: zap-types.h:2251
uint64_t ErrorsIn
Definition: zap-types.h:2257
uint64_t ErrorsOut
Definition: zap-types.h:2258
uint64_t PacketsSent
Definition: zap-types.h:2255
uint64_t DropOut
Definition: zap-types.h:2260
uint64_t PacketsReceived
Definition: zap-types.h:2256
uint64_t BytesReceived
Definition: zap-types.h:2254
uint64_t BytesSent
Definition: zap-types.h:2253
const char * InterfaceName
Definition: zap-types.h:2252
uint64_t DropIn
Definition: zap-types.h:2259
Definition: zap-types.h:2159
NM_State State
Definition: zap-types.h:2160
const char * RequestedStateParameters
Definition: zap-types.h:2163
NM_StateParameters StateParameters
Definition: zap-types.h:2162
const char * SupportedStateList
Definition: zap-types.h:2161
Definition: zap-types.h:2264
uint16_t ClusterId
Definition: zap-types.h:2265
const char * ExtensionFieldSet
Definition: zap-types.h:2266
Definition: zap-types.h:2270
uint16_t TransitionTime
Definition: zap-types.h:2274
const char * SceneTableExtensions
Definition: zap-types.h:2276
const char * SceneName
Definition: zap-types.h:2273
uint8_t TransitionTime100ms
Definition: zap-types.h:2275
uint16_t GroupID
Definition: zap-types.h:2272
uint16_t SceneID
Definition: zap-types.h:2271
Definition: zap-types.h:2280
double Distance
Definition: zap-types.h:2283
double Elevation
Definition: zap-types.h:2282
double Azimuth
Definition: zap-types.h:2281
Definition: zap-types.h:2287
int16_t HeatSetPoint
Definition: zap-types.h:2289
uint16_t TransitionTime
Definition: zap-types.h:2288
int16_t CoolSetPoint
Definition: zap-types.h:2290
Definition: zap-types.h:2294
const char * InterfaceName
Definition: zap-types.h:2295
double SignalStrengthdBm
Definition: zap-types.h:2296