Skip to content

Commit 98e8e2c

Browse files
authored
Merge branch 'master' into granbery/preset_atomic_write_fabric_index
2 parents 2a84acb + e58e16e commit 98e8e2c

File tree

21 files changed

+388
-473
lines changed

21 files changed

+388
-473
lines changed

examples/rvc-app/rvc-common/rvc-app.matter

+4-4
Original file line numberDiff line numberDiff line change
@@ -1480,11 +1480,11 @@ provisional cluster ServiceArea = 336 {
14801480
}
14811481

14821482
readonly attribute AreaStruct supportedAreas[] = 0;
1483-
readonly attribute nullable MapStruct supportedMaps[] = 1;
1484-
readonly attribute nullable int32u selectedAreas[] = 2;
1483+
readonly attribute MapStruct supportedMaps[] = 1;
1484+
readonly attribute int32u selectedAreas[] = 2;
14851485
readonly attribute optional nullable int32u currentArea = 3;
14861486
readonly attribute optional nullable epoch_s estimatedEndTime = 4;
1487-
readonly attribute optional nullable ProgressStruct progress[] = 5;
1487+
readonly attribute optional ProgressStruct progress[] = 5;
14881488
readonly attribute command_id generatedCommandList[] = 65528;
14891489
readonly attribute command_id acceptedCommandList[] = 65529;
14901490
readonly attribute event_id eventList[] = 65530;
@@ -1493,7 +1493,7 @@ provisional cluster ServiceArea = 336 {
14931493
readonly attribute int16u clusterRevision = 65533;
14941494

14951495
request struct SelectAreasRequest {
1496-
nullable int32u newAreas[] = 0;
1496+
int32u newAreas[] = 0;
14971497
}
14981498

14991499
response struct SelectAreasResponse = 1 {

src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp

+28-12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ namespace Clusters {
2626
namespace EcosystemInformation {
2727
namespace {
2828

29+
#define ZCL_ECOSYSTEM_INFORMATION_CLUSTER_REVISION (1u)
30+
#define ZCL_ECOSYSTEM_INFORMATION_FEATURE_MAP (0u)
31+
2932
constexpr size_t kDeviceNameMaxSize = 64;
3033
constexpr size_t kUniqueLocationIdMaxSize = 64;
3134
constexpr size_t kUniqueLocationIdsListMaxSize = 64;
@@ -46,18 +49,7 @@ class AttrAccess : public AttributeAccessInterface
4649
CHIP_ERROR AttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
4750
{
4851
VerifyOrDie(aPath.mClusterId == Clusters::EcosystemInformation::Id);
49-
switch (aPath.mAttributeId)
50-
{
51-
case Attributes::RemovedOn::Id:
52-
return EcosystemInformationServer::Instance().EncodeRemovedOnAttribute(aPath.mEndpointId, aEncoder);
53-
case Attributes::DeviceDirectory ::Id:
54-
return EcosystemInformationServer::Instance().EncodeDeviceDirectoryAttribute(aPath.mEndpointId, aEncoder);
55-
case Attributes::LocationDirectory ::Id:
56-
return EcosystemInformationServer::Instance().EncodeLocationStructAttribute(aPath.mEndpointId, aEncoder);
57-
default:
58-
break;
59-
}
60-
return CHIP_NO_ERROR;
52+
return EcosystemInformationServer::Instance().ReadAttribute(aPath, aEncoder);
6153
}
6254

6355
// WARNING: caller is expected to use the returned LocationDescriptorStruct::Type immediately. Caller must
@@ -285,6 +277,30 @@ CHIP_ERROR EcosystemInformationServer::RemoveDevice(EndpointId aEndpoint, uint64
285277
return CHIP_NO_ERROR;
286278
}
287279

280+
CHIP_ERROR EcosystemInformationServer::ReadAttribute(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
281+
{
282+
switch (aPath.mAttributeId)
283+
{
284+
case Attributes::RemovedOn::Id:
285+
return EcosystemInformationServer::Instance().EncodeRemovedOnAttribute(aPath.mEndpointId, aEncoder);
286+
case Attributes::DeviceDirectory::Id:
287+
return EcosystemInformationServer::Instance().EncodeDeviceDirectoryAttribute(aPath.mEndpointId, aEncoder);
288+
case Attributes::LocationDirectory::Id:
289+
return EcosystemInformationServer::Instance().EncodeLocationStructAttribute(aPath.mEndpointId, aEncoder);
290+
case Attributes::ClusterRevision::Id: {
291+
uint16_t rev = ZCL_ECOSYSTEM_INFORMATION_CLUSTER_REVISION;
292+
return aEncoder.Encode(rev);
293+
}
294+
case Attributes::FeatureMap::Id: {
295+
uint32_t featureMap = ZCL_ECOSYSTEM_INFORMATION_FEATURE_MAP;
296+
return aEncoder.Encode(featureMap);
297+
}
298+
default:
299+
break;
300+
}
301+
return CHIP_NO_ERROR;
302+
}
303+
288304
CHIP_ERROR EcosystemInformationServer::EncodeRemovedOnAttribute(EndpointId aEndpoint, AttributeValueEncoder & aEncoder)
289305
{
290306
auto it = mDevicesMap.find(aEndpoint);

src/app/clusters/ecosystem-information-server/ecosystem-information-server.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,7 @@ class EcosystemInformationServer
182182
CHIP_ERROR RemoveDevice(EndpointId aEndpoint, uint64_t aEpochUs);
183183
// TODO(#33223) Add removal and update counterparts to AddDeviceInfo and AddLocationInfo.
184184

185-
CHIP_ERROR EncodeRemovedOnAttribute(EndpointId aEndpoint, AttributeValueEncoder & aEncoder);
186-
CHIP_ERROR EncodeDeviceDirectoryAttribute(EndpointId aEndpoint, AttributeValueEncoder & aEncoder);
187-
CHIP_ERROR EncodeLocationStructAttribute(EndpointId aEndpoint, AttributeValueEncoder & aEncoder);
185+
CHIP_ERROR ReadAttribute(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder);
188186

189187
private:
190188
struct DeviceInfo
@@ -194,6 +192,11 @@ class EcosystemInformationServer
194192
// Map key is using the UniqueLocationId
195193
std::map<std::string, std::unique_ptr<EcosystemLocationStruct>> mLocationDirectory;
196194
};
195+
196+
CHIP_ERROR EncodeRemovedOnAttribute(EndpointId aEndpoint, AttributeValueEncoder & aEncoder);
197+
CHIP_ERROR EncodeDeviceDirectoryAttribute(EndpointId aEndpoint, AttributeValueEncoder & aEncoder);
198+
CHIP_ERROR EncodeLocationStructAttribute(EndpointId aEndpoint, AttributeValueEncoder & aEncoder);
199+
197200
std::map<EndpointId, DeviceInfo> mDevicesMap;
198201

199202
static EcosystemInformationServer mInstance;

src/app/clusters/service-area-server/service-area-server.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ CHIP_ERROR Instance::ReadSupportedAreas(AttributeValueEncoder & aEncoder)
134134
{
135135
if (mDelegate->GetNumberOfSupportedAreas() == 0)
136136
{
137-
return aEncoder.EncodeNull();
137+
return aEncoder.EncodeEmptyList();
138138
}
139139

140140
return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR {
@@ -153,7 +153,7 @@ CHIP_ERROR Instance::ReadSupportedMaps(AttributeValueEncoder & aEncoder)
153153
{
154154
if (mDelegate->GetNumberOfSupportedMaps() == 0)
155155
{
156-
return aEncoder.EncodeNull();
156+
return aEncoder.EncodeEmptyList();
157157
}
158158

159159
return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR {
@@ -172,7 +172,7 @@ CHIP_ERROR Instance::ReadSelectedAreas(AttributeValueEncoder & aEncoder)
172172
{
173173
if (mDelegate->GetNumberOfSelectedAreas() == 0)
174174
{
175-
return aEncoder.EncodeNull();
175+
return aEncoder.EncodeEmptyList();
176176
}
177177

178178
return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR {
@@ -191,7 +191,7 @@ CHIP_ERROR Instance::ReadProgress(AttributeValueEncoder & aEncoder)
191191
{
192192
if (mDelegate->GetNumberOfProgressElements() == 0)
193193
{
194-
return aEncoder.EncodeNull();
194+
return aEncoder.EncodeEmptyList();
195195
}
196196

197197
return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR {
@@ -224,9 +224,8 @@ void Instance::HandleSelectAreasCmd(HandlerContext & ctx, const Commands::Select
224224

225225
size_t numberOfLocations = 0;
226226
// Get the number of Selected Locations in the command parameter and check that it is valid.
227-
if (!req.newAreas.IsNull())
228227
{
229-
if (CHIP_NO_ERROR != req.newAreas.Value().ComputeSize(&numberOfLocations))
228+
if (CHIP_NO_ERROR != req.newAreas.ComputeSize(&numberOfLocations))
230229
{
231230
ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::InvalidCommand);
232231
return;
@@ -244,14 +243,14 @@ void Instance::HandleSelectAreasCmd(HandlerContext & ctx, const Commands::Select
244243
// if number of selected locations in parameter matches number in attribute - the locations *might* be the same
245244
bool matchesCurrentSelectedAreas = (numberOfLocations == mDelegate->GetNumberOfSelectedAreas());
246245

247-
if (!req.newAreas.IsNull())
246+
if (numberOfLocations != 0)
248247
{
249248
// do as much parameter validation as we can
250249
{
251250
uint32_t ignoredIndex = 0;
252251
uint32_t oldSelectedLocation;
253252
uint32_t i = 0;
254-
auto iLocationIter = req.newAreas.Value().begin();
253+
auto iLocationIter = req.newAreas.begin();
255254
while (iLocationIter.Next())
256255
{
257256
uint32_t aSelectedLocation = iLocationIter.GetValue();
@@ -266,7 +265,7 @@ void Instance::HandleSelectAreasCmd(HandlerContext & ctx, const Commands::Select
266265

267266
// Checking for duplicate locations.
268267
uint32_t j = 0;
269-
auto jLocationIter = req.newAreas.Value().begin();
268+
auto jLocationIter = req.newAreas.begin();
270269
while (j < i)
271270
{
272271
jLocationIter
@@ -343,9 +342,9 @@ void Instance::HandleSelectAreasCmd(HandlerContext & ctx, const Commands::Select
343342
// and the SelectedAreas attribute SHALL be set to the value of the newAreas field.
344343
mDelegate->ClearSelectedAreas();
345344

346-
if (!req.newAreas.IsNull())
345+
if (numberOfLocations != 0)
347346
{
348-
auto locationIter = req.newAreas.Value().begin();
347+
auto locationIter = req.newAreas.begin();
349348
uint32_t ignored;
350349
while (locationIter.Next())
351350
{

src/app/clusters/thermostat-server/thermostat-server.cpp

+8-35
Original file line numberDiff line numberDiff line change
@@ -321,46 +321,21 @@ bool IsPresetHandlePresentInPresets(Delegate * delegate, const ByteSpan & preset
321321
}
322322

323323
/**
324-
* @brief Returns the length of the list of presets if the pending presets were to be applied. The calculation is done by
325-
* adding the number of presets in Presets attribute list to the number of pending presets in the pending
326-
* presets list and subtracting the number of duplicate presets. This is called before changes are actually applied.
324+
* @brief Returns the length of the list of presets if the pending presets were to be applied. The size of the pending presets list
325+
* calculated, after all the constraint checks are done, is the new size of the updated Presets attribute since the pending
326+
* preset list is expected to have all existing presets with or without edits plus new presets.
327+
* This is called before changes are actually applied.
327328
*
328329
* @param[in] delegate The delegate to use.
329330
*
330331
* @return count of the updated Presets attribute if the pending presets were applied to it. Return 0 for error cases.
331332
*/
332-
uint8_t CountUpdatedPresetsAfterApplyingPendingPresets(Delegate * delegate)
333+
uint8_t CountNumberOfPendingPresets(Delegate * delegate)
333334
{
334-
uint8_t numberOfPresets = 0;
335-
uint8_t numberOfMatches = 0;
336335
uint8_t numberOfPendingPresets = 0;
337336

338337
VerifyOrReturnValue(delegate != nullptr, 0);
339338

340-
for (uint8_t i = 0; true; i++)
341-
{
342-
PresetStructWithOwnedMembers preset;
343-
CHIP_ERROR err = delegate->GetPresetAtIndex(i, preset);
344-
345-
if (err == CHIP_ERROR_PROVIDER_LIST_EXHAUSTED)
346-
{
347-
break;
348-
}
349-
if (err != CHIP_NO_ERROR)
350-
{
351-
ChipLogError(Zcl, "GetUpdatedPresetsCount: GetPresetAtIndex failed with error %" CHIP_ERROR_FORMAT, err.Format());
352-
return 0;
353-
}
354-
numberOfPresets++;
355-
356-
bool found = MatchingPendingPresetExists(delegate, preset);
357-
358-
if (found)
359-
{
360-
numberOfMatches++;
361-
}
362-
}
363-
364339
for (uint8_t i = 0; true; i++)
365340
{
366341
PresetStructWithOwnedMembers pendingPreset;
@@ -372,16 +347,14 @@ uint8_t CountUpdatedPresetsAfterApplyingPendingPresets(Delegate * delegate)
372347
}
373348
if (err != CHIP_NO_ERROR)
374349
{
375-
ChipLogError(Zcl, "GetUpdatedPresetsCount: GetPendingPresetAtIndex failed with error %" CHIP_ERROR_FORMAT,
350+
ChipLogError(Zcl, "CountNumberOfPendingPresets: GetPendingPresetAtIndex failed with error %" CHIP_ERROR_FORMAT,
376351
err.Format());
377352
return 0;
378353
}
379354
numberOfPendingPresets++;
380355
}
381356

382-
// TODO: #34546 - Need to support deletion of presets that are removed from Presets.
383-
// This API needs to modify its logic for the deletion case.
384-
return static_cast<uint8_t>(numberOfPresets + numberOfPendingPresets - numberOfMatches);
357+
return numberOfPendingPresets;
385358
}
386359

387360
/**
@@ -1545,7 +1518,7 @@ imcode commitPresets(Delegate * delegate, EndpointId endpoint)
15451518
}
15461519
}
15471520

1548-
uint8_t totalCount = CountUpdatedPresetsAfterApplyingPendingPresets(delegate);
1521+
uint8_t totalCount = CountNumberOfPendingPresets(delegate);
15491522

15501523
uint8_t numberOfPresetsSupported = delegate->GetNumberOfPresets();
15511524

src/app/zap-templates/zcl/data-model/chip/service-area-cluster.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,18 @@ limitations under the License.
8989

9090
<!-- Attributes -->
9191
<attribute side="server" code="0x0000" define="SupportedAreas" type="array" entryType="AreaStruct" writable="false" isNullable="false" optional="false">SupportedAreas</attribute>
92-
<attribute side="server" code="0x0001" define="SupportedMaps" type="array" entryType="MapStruct" writable="false" isNullable="true" optional="false">SupportedMaps</attribute>
93-
<attribute side="server" code="0x0002" define="SelectedAreas" type="array" entryType="int32u" writable="false" isNullable="true" optional="false">SelectedAreas</attribute>
92+
<attribute side="server" code="0x0001" define="SupportedMaps" type="array" entryType="MapStruct" writable="false" isNullable="false" optional="false">SupportedMaps</attribute>
93+
<attribute side="server" code="0x0002" define="SelectedAreas" type="array" entryType="int32u" writable="false" isNullable="false" optional="false">SelectedAreas</attribute>
9494
<attribute side="server" code="0x0003" define="CurrentArea" type="int32u" writable="false" isNullable="true" optional="true" >CurrentArea</attribute>
9595
<attribute side="server" code="0x0004" define="EstimatedEndTime" type="epoch_s" writable="false" isNullable="true" optional="true" >EstimatedEndTime</attribute>
96-
<attribute side="server" code="0x0005" define="Progress" type="array" entryType="ProgressStruct" writable="false" isNullable="true" optional="true" >Progress</attribute>
96+
<attribute side="server" code="0x0005" define="Progress" type="array" entryType="ProgressStruct" writable="false" isNullable="false" optional="true" >Progress</attribute>
9797

9898
<!-- Commands -->
9999
<command source="client" code="0x00" name="SelectAreas" response="SelectAreasResponse" optional="false">
100100
<description>
101101
Command used to select a set of device areas, where the device is to operate.
102102
</description>
103-
<arg name="NewAreas" type="int32u" array="true" isNullable="true"/>
103+
<arg name="NewAreas" type="int32u" array="true"/>
104104
</command>
105105

106106
<command source="server" code="0x01" name="SelectAreasResponse" disableDefaultResponse="true" optional="false">

src/controller/data_model/controller-clusters.matter

+4-4
Original file line numberDiff line numberDiff line change
@@ -6502,11 +6502,11 @@ provisional cluster ServiceArea = 336 {
65026502
}
65036503

65046504
readonly attribute AreaStruct supportedAreas[] = 0;
6505-
readonly attribute nullable MapStruct supportedMaps[] = 1;
6506-
readonly attribute nullable int32u selectedAreas[] = 2;
6505+
readonly attribute MapStruct supportedMaps[] = 1;
6506+
readonly attribute int32u selectedAreas[] = 2;
65076507
readonly attribute optional nullable int32u currentArea = 3;
65086508
readonly attribute optional nullable epoch_s estimatedEndTime = 4;
6509-
readonly attribute optional nullable ProgressStruct progress[] = 5;
6509+
readonly attribute optional ProgressStruct progress[] = 5;
65106510
readonly attribute command_id generatedCommandList[] = 65528;
65116511
readonly attribute command_id acceptedCommandList[] = 65529;
65126512
readonly attribute event_id eventList[] = 65530;
@@ -6515,7 +6515,7 @@ provisional cluster ServiceArea = 336 {
65156515
readonly attribute int16u clusterRevision = 65533;
65166516

65176517
request struct SelectAreasRequest {
6518-
nullable int32u newAreas[] = 0;
6518+
int32u newAreas[] = 0;
65196519
}
65206520

65216521
response struct SelectAreasResponse = 1 {

0 commit comments

Comments
 (0)