Skip to content

Commit

Permalink
Service Area: Remove nullable qualities to match the latest spec (#34732
Browse files Browse the repository at this point in the history
)

* 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>
  • Loading branch information
2 people authored and pull[bot] committed Sep 4, 2024
1 parent 66e1dc3 commit 2528656
Show file tree
Hide file tree
Showing 16 changed files with 337 additions and 423 deletions.
8 changes: 4 additions & 4 deletions examples/rvc-app/rvc-common/rvc-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1480,11 +1480,11 @@ provisional cluster ServiceArea = 336 {
}

readonly attribute AreaStruct supportedAreas[] = 0;
readonly attribute nullable MapStruct supportedMaps[] = 1;
readonly attribute nullable int32u selectedAreas[] = 2;
readonly attribute MapStruct supportedMaps[] = 1;
readonly attribute int32u selectedAreas[] = 2;
readonly attribute optional nullable int32u currentArea = 3;
readonly attribute optional nullable epoch_s estimatedEndTime = 4;
readonly attribute optional nullable ProgressStruct progress[] = 5;
readonly attribute optional ProgressStruct progress[] = 5;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand All @@ -1493,7 +1493,7 @@ provisional cluster ServiceArea = 336 {
readonly attribute int16u clusterRevision = 65533;

request struct SelectAreasRequest {
nullable int32u newAreas[] = 0;
int32u newAreas[] = 0;
}

response struct SelectAreasResponse = 1 {
Expand Down
21 changes: 10 additions & 11 deletions src/app/clusters/service-area-server/service-area-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ CHIP_ERROR Instance::ReadSupportedAreas(AttributeValueEncoder & aEncoder)
{
if (mDelegate->GetNumberOfSupportedAreas() == 0)
{
return aEncoder.EncodeNull();
return aEncoder.EncodeEmptyList();
}

return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR {
Expand All @@ -153,7 +153,7 @@ CHIP_ERROR Instance::ReadSupportedMaps(AttributeValueEncoder & aEncoder)
{
if (mDelegate->GetNumberOfSupportedMaps() == 0)
{
return aEncoder.EncodeNull();
return aEncoder.EncodeEmptyList();
}

return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR {
Expand All @@ -172,7 +172,7 @@ CHIP_ERROR Instance::ReadSelectedAreas(AttributeValueEncoder & aEncoder)
{
if (mDelegate->GetNumberOfSelectedAreas() == 0)
{
return aEncoder.EncodeNull();
return aEncoder.EncodeEmptyList();
}

return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR {
Expand All @@ -191,7 +191,7 @@ CHIP_ERROR Instance::ReadProgress(AttributeValueEncoder & aEncoder)
{
if (mDelegate->GetNumberOfProgressElements() == 0)
{
return aEncoder.EncodeNull();
return aEncoder.EncodeEmptyList();
}

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

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

if (!req.newAreas.IsNull())
if (numberOfLocations != 0)
{
// do as much parameter validation as we can
{
uint32_t ignoredIndex = 0;
uint32_t oldSelectedLocation;
uint32_t i = 0;
auto iLocationIter = req.newAreas.Value().begin();
auto iLocationIter = req.newAreas.begin();
while (iLocationIter.Next())
{
uint32_t aSelectedLocation = iLocationIter.GetValue();
Expand All @@ -266,7 +265,7 @@ void Instance::HandleSelectAreasCmd(HandlerContext & ctx, const Commands::Select

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

if (!req.newAreas.IsNull())
if (numberOfLocations != 0)
{
auto locationIter = req.newAreas.Value().begin();
auto locationIter = req.newAreas.begin();
uint32_t ignored;
while (locationIter.Next())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,18 @@ limitations under the License.

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

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

<command source="server" code="0x01" name="SelectAreasResponse" disableDefaultResponse="true" optional="false">
Expand Down
8 changes: 4 additions & 4 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -6502,11 +6502,11 @@ provisional cluster ServiceArea = 336 {
}

readonly attribute AreaStruct supportedAreas[] = 0;
readonly attribute nullable MapStruct supportedMaps[] = 1;
readonly attribute nullable int32u selectedAreas[] = 2;
readonly attribute MapStruct supportedMaps[] = 1;
readonly attribute int32u selectedAreas[] = 2;
readonly attribute optional nullable int32u currentArea = 3;
readonly attribute optional nullable epoch_s estimatedEndTime = 4;
readonly attribute optional nullable ProgressStruct progress[] = 5;
readonly attribute optional ProgressStruct progress[] = 5;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand All @@ -6515,7 +6515,7 @@ provisional cluster ServiceArea = 336 {
readonly attribute int16u clusterRevision = 65533;

request struct SelectAreasRequest {
nullable int32u newAreas[] = 0;
int32u newAreas[] = 0;
}

response struct SelectAreasResponse = 1 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39073,16 +39073,16 @@ public long initWithDevice(long devicePtr, int endpointId) {
return 0L;
}

public void selectAreas(SelectAreasResponseCallback callback, @Nullable ArrayList<Long> newAreas) {
public void selectAreas(SelectAreasResponseCallback callback, ArrayList<Long> newAreas) {
selectAreas(callback, newAreas, 0);
}

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

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

StructType commandArgs = new StructType(elements);
Expand Down Expand Up @@ -39156,11 +39156,11 @@ public interface SupportedAreasAttributeCallback extends BaseAttributeCallback {
}

public interface SupportedMapsAttributeCallback extends BaseAttributeCallback {
void onSuccess(@Nullable List<ChipStructs.ServiceAreaClusterMapStruct> value);
void onSuccess(List<ChipStructs.ServiceAreaClusterMapStruct> value);
}

public interface SelectedAreasAttributeCallback extends BaseAttributeCallback {
void onSuccess(@Nullable List<Long> value);
void onSuccess(List<Long> value);
}

public interface CurrentAreaAttributeCallback extends BaseAttributeCallback {
Expand All @@ -39172,7 +39172,7 @@ public interface EstimatedEndTimeAttributeCallback extends BaseAttributeCallback
}

public interface ProgressAttributeCallback extends BaseAttributeCallback {
void onSuccess(@Nullable List<ChipStructs.ServiceAreaClusterProgressStruct> value);
void onSuccess(List<ChipStructs.ServiceAreaClusterProgressStruct> value);
}

public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback {
Expand Down Expand Up @@ -39224,7 +39224,7 @@ public void readSupportedMapsAttribute(
readAttribute(new ReportCallbackImpl(callback, path) {
@Override
public void onSuccess(byte[] tlv) {
@Nullable List<ChipStructs.ServiceAreaClusterMapStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
List<ChipStructs.ServiceAreaClusterMapStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, SUPPORTED_MAPS_ATTRIBUTE_ID, true);
Expand All @@ -39237,7 +39237,7 @@ public void subscribeSupportedMapsAttribute(
subscribeAttribute(new ReportCallbackImpl(callback, path) {
@Override
public void onSuccess(byte[] tlv) {
@Nullable List<ChipStructs.ServiceAreaClusterMapStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
List<ChipStructs.ServiceAreaClusterMapStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, SUPPORTED_MAPS_ATTRIBUTE_ID, minInterval, maxInterval);
Expand All @@ -39250,7 +39250,7 @@ public void readSelectedAreasAttribute(
readAttribute(new ReportCallbackImpl(callback, path) {
@Override
public void onSuccess(byte[] tlv) {
@Nullable List<Long> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
List<Long> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, SELECTED_AREAS_ATTRIBUTE_ID, true);
Expand All @@ -39263,7 +39263,7 @@ public void subscribeSelectedAreasAttribute(
subscribeAttribute(new ReportCallbackImpl(callback, path) {
@Override
public void onSuccess(byte[] tlv) {
@Nullable List<Long> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
List<Long> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, SELECTED_AREAS_ATTRIBUTE_ID, minInterval, maxInterval);
Expand Down Expand Up @@ -39328,7 +39328,7 @@ public void readProgressAttribute(
readAttribute(new ReportCallbackImpl(callback, path) {
@Override
public void onSuccess(byte[] tlv) {
@Nullable List<ChipStructs.ServiceAreaClusterProgressStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
List<ChipStructs.ServiceAreaClusterProgressStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, PROGRESS_ATTRIBUTE_ID, true);
Expand All @@ -39341,7 +39341,7 @@ public void subscribeProgressAttribute(
subscribeAttribute(new ReportCallbackImpl(callback, path) {
@Override
public void onSuccess(byte[] tlv) {
@Nullable List<ChipStructs.ServiceAreaClusterProgressStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
List<ChipStructs.ServiceAreaClusterProgressStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, PROGRESS_ATTRIBUTE_ID, minInterval, maxInterval);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13193,7 +13193,7 @@ public void setCallbackDelegate(ClusterCommandCallback callback) {
}

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

@Override
public void onSuccess(@Nullable List<Long> valueList) {
public void onSuccess(List<Long> valueList) {
Map<CommandResponseInfo, Object> responseValues = new LinkedHashMap<>();
CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List<Long>");
responseValues.put(commandResponseInfo, valueList);
Expand Down Expand Up @@ -13277,7 +13277,7 @@ public void setCallbackDelegate(ClusterCommandCallback callback) {
}

@Override
public void onSuccess(@Nullable List<ChipStructs.ServiceAreaClusterProgressStruct> valueList) {
public void onSuccess(List<ChipStructs.ServiceAreaClusterProgressStruct> valueList) {
Map<CommandResponseInfo, Object> responseValues = new LinkedHashMap<>();
CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List<ChipStructs.ServiceAreaClusterProgressStruct>");
responseValues.put(commandResponseInfo, valueList);
Expand Down
Loading

0 comments on commit 2528656

Please sign in to comment.