@@ -46,33 +46,77 @@ void MeterIdentificationInstance::Shutdown()
46
46
CHIP_ERROR MeterIdentificationDelegate::LoadJson (Json::Value & root)
47
47
{
48
48
Json::Value value = root.get (" MeterType" , Json::Value ());
49
- #if 0
50
- if (!value.empty() && value.isInt())
49
+ if (!value.empty ())
51
50
{
52
- mMeterType.SetNonNull(value.asInt());
51
+ if (value.isInt ())
52
+ {
53
+ mMeterType .SetNonNull (static_cast <MeterTypeEnum>(value.asInt ()));
54
+ }
55
+ else
56
+ {
57
+ mMeterType .SetNull ();
58
+ }
53
59
}
54
60
55
- value = root.get("Name ", Json::Value());
56
- if (!mName.IsNull ())
61
+ value = root.get (" UtilityName " , Json::Value ());
62
+ if (!value. empty ())
57
63
{
58
- chip::Platform::MemoryFree((void*)mName.Value().data());
59
- mName.SetNull();
64
+ chip::Platform::MemoryFree ((void *)mUtilityName .data ());
65
+ if (value.isString ())
66
+ {
67
+ size_t len = value.asString ().size ()+1 ;
68
+ char *str = (char *)chip::Platform::MemoryAlloc (len);
69
+ memcpy (str, value.asCString (), len);
70
+ mUtilityName = CharSpan (str, len);
71
+ }
72
+ else
73
+ {
74
+ mUtilityName = CharSpan ();
75
+ }
60
76
}
61
- if (!value.empty() && value.isString())
77
+
78
+ value = root.get (" PointOfDelivery" , Json::Value ());
79
+ if (!value.empty ())
80
+ {
81
+ chip::Platform::MemoryFree ((void *)mPointOfDelivery .data ());
82
+ if (value.isString ())
83
+ {
84
+ size_t len = value.asString ().size ()+1 ;
85
+ char *str = (char *)chip::Platform::MemoryAlloc (len);
86
+ memcpy (str, value.asCString (), len);
87
+ mPointOfDelivery = CharSpan (str, len);
88
+ }
89
+ else
90
+ {
91
+ mPointOfDelivery = CharSpan ();
92
+ }
93
+ }
94
+
95
+ value = root.get (" PowerThreshold" , Json::Value ());
96
+ if (!value.empty ())
62
97
{
63
- size_t len = value.asString().size()+1;
64
- char *str = (char*)chip::Platform::MemoryAlloc(len);
65
- memcpy(str, value.asCString(), len);
66
- CharSpan nameString(str, len);
67
- mName = MakeNullable(static_cast<CharSpan>(nameString));
98
+ if (value.isInt ())
99
+ {
100
+ mPowerThreshold .SetNonNull (value.asInt ());
101
+ }
102
+ else
103
+ {
104
+ mPowerThreshold .SetNull ();
105
+ }
68
106
}
69
107
70
- value = root.get("ProviderID ", Json::Value());
71
- if (!value.empty() && value.isInt() )
108
+ value = root.get (" PowerThresholdSource " , Json::Value ());
109
+ if (!value.empty ())
72
110
{
73
- providerID.SetNonNull(value.asInt());
111
+ if (value.isInt ())
112
+ {
113
+ mPowerThresholdSource .SetNonNull (static_cast <PowerThresholdSourceEnum>(value.asInt ()));
114
+ }
115
+ else
116
+ {
117
+ mPowerThresholdSource .SetNull ();
118
+ }
74
119
}
75
- #endif
76
120
77
121
return CHIP_NO_ERROR;
78
122
}
0 commit comments