Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c2a7b5a

Browse files
committedJul 1, 2024·
Fix build problem: init matter plugin
1 parent 938d307 commit c2a7b5a

File tree

2 files changed

+66
-17
lines changed

2 files changed

+66
-17
lines changed
 

‎examples/energy-management-app/energy-management-common/src/MeterIdentificationDelegate.cpp

+61-17
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,77 @@ void MeterIdentificationInstance::Shutdown()
4646
CHIP_ERROR MeterIdentificationDelegate::LoadJson(Json::Value & root)
4747
{
4848
Json::Value value = root.get("MeterType", Json::Value());
49-
#if 0
50-
if (!value.empty() && value.isInt())
49+
if (!value.empty())
5150
{
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+
}
5359
}
5460

55-
value = root.get("Name", Json::Value());
56-
if (!mName.IsNull())
61+
value = root.get("UtilityName", Json::Value());
62+
if (!value.empty())
5763
{
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+
}
6076
}
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())
6297
{
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+
}
68106
}
69107

70-
value = root.get("ProviderID", Json::Value());
71-
if (!value.empty() && value.isInt())
108+
value = root.get("PowerThresholdSource", Json::Value());
109+
if (!value.empty())
72110
{
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+
}
74119
}
75-
#endif
76120

77121
return CHIP_NO_ERROR;
78122
}

‎src/app/clusters/meter-identification-server/meter-identification-server.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,8 @@ CHIP_ERROR Instance::Write(const ConcreteDataAttributePath & aPath, AttributeVal
110110
} // namespace Clusters
111111
} // namespace app
112112
} // namespace chip
113+
114+
// -----------------------------------------------------------------------------
115+
// Plugin initialization
116+
117+
void MatterMeterIdentificationPluginServerInitCallback() {}

0 commit comments

Comments
 (0)
Please sign in to comment.