Skip to content

Commit e58e16e

Browse files
Service Area: Remove nullable qualities to match the latest spec (project-chip#34732)
* Updated the golabl data type's XMLs, removing the cluster entries. * Zap generated after XML update. * Fixed namespaces used of global structs. * Restyled by clang-format * Renamed LocationInfoStruct to AreaInfoStruct. * Zap generated after XML update. * Renamed LocationStruct to AreaStruct and its LocationID and LocationDesc fields. * Zap generated after XML update. * Updated SDK and example code to match the new naming. * Updated the ProgressStruct's LocationID name to AreaID. * Zap generated after XML update. * Updated the SDK code following name changes. * Updated the SelectLocationsStatus and SkipLocationStatus enum names and some of their enums. * Zap generated after XML update. * Updated the SelectLocationsStatus and SkipCurrentLocationStatus names and their enum names. * Updated the names of the SupportedLocations, SelectedLocations and CurrentLocation attributes. * Zap generated after XML update. * Updated the changed names in the SDK. * Updated the service area command names in XML. * Zap generated after XML update. * Updated the service area command names in the SDK. * Updated the rvc-example zap file. * Refactored LocationStructureWrapper to AreaStructureWrapper. * Restyled by clang-format * Regenerated zap files due to changes upsteram. * Removed unused generated file. * Updated the Service Area XML marking previously nullabel attributes as not-nullable. * Zap generated after XML update. * Updated the attribute encoding and some server logic following the romoval of the nullable quality for some attributes. * spacing changes form zap regen. * Fixed minor mistake during merge. --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent c06221b commit e58e16e

File tree

16 files changed

+337
-423
lines changed

16 files changed

+337
-423
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/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/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 {

src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -39073,16 +39073,16 @@ public long initWithDevice(long devicePtr, int endpointId) {
3907339073
return 0L;
3907439074
}
3907539075

39076-
public void selectAreas(SelectAreasResponseCallback callback, @Nullable ArrayList<Long> newAreas) {
39076+
public void selectAreas(SelectAreasResponseCallback callback, ArrayList<Long> newAreas) {
3907739077
selectAreas(callback, newAreas, 0);
3907839078
}
3907939079

39080-
public void selectAreas(SelectAreasResponseCallback callback, @Nullable ArrayList<Long> newAreas, int timedInvokeTimeoutMs) {
39080+
public void selectAreas(SelectAreasResponseCallback callback, ArrayList<Long> newAreas, int timedInvokeTimeoutMs) {
3908139081
final long commandId = 0L;
3908239082

3908339083
ArrayList<StructElement> elements = new ArrayList<>();
3908439084
final long newAreasFieldID = 0L;
39085-
BaseTLVType newAreastlvValue = newAreas != null ? ArrayType.generateArrayType(newAreas, (elementnewAreas) -> new UIntType(elementnewAreas)) : new NullType();
39085+
BaseTLVType newAreastlvValue = ArrayType.generateArrayType(newAreas, (elementnewAreas) -> new UIntType(elementnewAreas));
3908639086
elements.add(new StructElement(newAreasFieldID, newAreastlvValue));
3908739087

3908839088
StructType commandArgs = new StructType(elements);
@@ -39156,11 +39156,11 @@ public interface SupportedAreasAttributeCallback extends BaseAttributeCallback {
3915639156
}
3915739157

3915839158
public interface SupportedMapsAttributeCallback extends BaseAttributeCallback {
39159-
void onSuccess(@Nullable List<ChipStructs.ServiceAreaClusterMapStruct> value);
39159+
void onSuccess(List<ChipStructs.ServiceAreaClusterMapStruct> value);
3916039160
}
3916139161

3916239162
public interface SelectedAreasAttributeCallback extends BaseAttributeCallback {
39163-
void onSuccess(@Nullable List<Long> value);
39163+
void onSuccess(List<Long> value);
3916439164
}
3916539165

3916639166
public interface CurrentAreaAttributeCallback extends BaseAttributeCallback {
@@ -39172,7 +39172,7 @@ public interface EstimatedEndTimeAttributeCallback extends BaseAttributeCallback
3917239172
}
3917339173

3917439174
public interface ProgressAttributeCallback extends BaseAttributeCallback {
39175-
void onSuccess(@Nullable List<ChipStructs.ServiceAreaClusterProgressStruct> value);
39175+
void onSuccess(List<ChipStructs.ServiceAreaClusterProgressStruct> value);
3917639176
}
3917739177

3917839178
public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback {
@@ -39224,7 +39224,7 @@ public void readSupportedMapsAttribute(
3922439224
readAttribute(new ReportCallbackImpl(callback, path) {
3922539225
@Override
3922639226
public void onSuccess(byte[] tlv) {
39227-
@Nullable List<ChipStructs.ServiceAreaClusterMapStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
39227+
List<ChipStructs.ServiceAreaClusterMapStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
3922839228
callback.onSuccess(value);
3922939229
}
3923039230
}, SUPPORTED_MAPS_ATTRIBUTE_ID, true);
@@ -39237,7 +39237,7 @@ public void subscribeSupportedMapsAttribute(
3923739237
subscribeAttribute(new ReportCallbackImpl(callback, path) {
3923839238
@Override
3923939239
public void onSuccess(byte[] tlv) {
39240-
@Nullable List<ChipStructs.ServiceAreaClusterMapStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
39240+
List<ChipStructs.ServiceAreaClusterMapStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
3924139241
callback.onSuccess(value);
3924239242
}
3924339243
}, SUPPORTED_MAPS_ATTRIBUTE_ID, minInterval, maxInterval);
@@ -39250,7 +39250,7 @@ public void readSelectedAreasAttribute(
3925039250
readAttribute(new ReportCallbackImpl(callback, path) {
3925139251
@Override
3925239252
public void onSuccess(byte[] tlv) {
39253-
@Nullable List<Long> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
39253+
List<Long> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
3925439254
callback.onSuccess(value);
3925539255
}
3925639256
}, SELECTED_AREAS_ATTRIBUTE_ID, true);
@@ -39263,7 +39263,7 @@ public void subscribeSelectedAreasAttribute(
3926339263
subscribeAttribute(new ReportCallbackImpl(callback, path) {
3926439264
@Override
3926539265
public void onSuccess(byte[] tlv) {
39266-
@Nullable List<Long> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
39266+
List<Long> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
3926739267
callback.onSuccess(value);
3926839268
}
3926939269
}, SELECTED_AREAS_ATTRIBUTE_ID, minInterval, maxInterval);
@@ -39328,7 +39328,7 @@ public void readProgressAttribute(
3932839328
readAttribute(new ReportCallbackImpl(callback, path) {
3932939329
@Override
3933039330
public void onSuccess(byte[] tlv) {
39331-
@Nullable List<ChipStructs.ServiceAreaClusterProgressStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
39331+
List<ChipStructs.ServiceAreaClusterProgressStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
3933239332
callback.onSuccess(value);
3933339333
}
3933439334
}, PROGRESS_ATTRIBUTE_ID, true);
@@ -39341,7 +39341,7 @@ public void subscribeProgressAttribute(
3934139341
subscribeAttribute(new ReportCallbackImpl(callback, path) {
3934239342
@Override
3934339343
public void onSuccess(byte[] tlv) {
39344-
@Nullable List<ChipStructs.ServiceAreaClusterProgressStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
39344+
List<ChipStructs.ServiceAreaClusterProgressStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
3934539345
callback.onSuccess(value);
3934639346
}
3934739347
}, PROGRESS_ATTRIBUTE_ID, minInterval, maxInterval);

src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -13193,7 +13193,7 @@ public void setCallbackDelegate(ClusterCommandCallback callback) {
1319313193
}
1319413194

1319513195
@Override
13196-
public void onSuccess(@Nullable List<ChipStructs.ServiceAreaClusterMapStruct> valueList) {
13196+
public void onSuccess(List<ChipStructs.ServiceAreaClusterMapStruct> valueList) {
1319713197
Map<CommandResponseInfo, Object> responseValues = new LinkedHashMap<>();
1319813198
CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List<ChipStructs.ServiceAreaClusterMapStruct>");
1319913199
responseValues.put(commandResponseInfo, valueList);
@@ -13214,7 +13214,7 @@ public void setCallbackDelegate(ClusterCommandCallback callback) {
1321413214
}
1321513215

1321613216
@Override
13217-
public void onSuccess(@Nullable List<Long> valueList) {
13217+
public void onSuccess(List<Long> valueList) {
1321813218
Map<CommandResponseInfo, Object> responseValues = new LinkedHashMap<>();
1321913219
CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List<Long>");
1322013220
responseValues.put(commandResponseInfo, valueList);
@@ -13277,7 +13277,7 @@ public void setCallbackDelegate(ClusterCommandCallback callback) {
1327713277
}
1327813278

1327913279
@Override
13280-
public void onSuccess(@Nullable List<ChipStructs.ServiceAreaClusterProgressStruct> valueList) {
13280+
public void onSuccess(List<ChipStructs.ServiceAreaClusterProgressStruct> valueList) {
1328113281
Map<CommandResponseInfo, Object> responseValues = new LinkedHashMap<>();
1328213282
CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List<ChipStructs.ServiceAreaClusterProgressStruct>");
1328313283
responseValues.put(commandResponseInfo, valueList);

0 commit comments

Comments
 (0)