Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PositionTag and AreaDesc field names #35094

Merged
merged 8 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/rvc-app/linux/RvcAppCommandDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ void RvcAppCommandHandler::OnAddServiceAreaArea(Json::Value jsonValue)
if (jsonValue.isMember("LandmarkTag"))
{
DataModel::Nullable<Globals::RelativePositionTag> relativePositionTag = DataModel::NullNullable;
if (jsonValue.isMember("PositionTag"))
if (jsonValue.isMember("RelativePositionTag"))
{
relativePositionTag = Globals::RelativePositionTag(jsonValue["PositionTag"].asUInt());
relativePositionTag = Globals::RelativePositionTag(jsonValue["RelativePositionTag"].asUInt());
}

area.SetLandmarkInfo(Globals::LandmarkTag(jsonValue["LandmarkTag"].asUInt()), relativePositionTag);
Expand Down
4 changes: 2 additions & 2 deletions examples/rvc-app/rvc-common/rvc-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ provisional cluster ServiceArea = 336 {

struct LandmarkInfoStruct {
LandmarkTag landmarkTag = 0;
nullable RelativePositionTag positionTag = 1;
nullable RelativePositionTag relativePositionTag = 1;
}

struct AreaInfoStruct {
Expand All @@ -1469,7 +1469,7 @@ provisional cluster ServiceArea = 336 {
struct AreaStruct {
int32u areaID = 0;
nullable int32u mapID = 1;
AreaInfoStruct areaDesc = 2;
AreaInfoStruct areaInfo = 2;
}

struct MapStruct {
Expand Down
50 changes: 25 additions & 25 deletions src/app/clusters/service-area-server/service-area-cluster-objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ struct AreaStructureWrapper : public chip::app::Clusters::ServiceArea::Structs::
{
areaID = aOther.areaID;
mapID = aOther.mapID;
SetLocationInfo(aOther.areaDesc.locationInfo);
SetLandmarkInfo(aOther.areaDesc.landmarkInfo);
SetLocationInfo(aOther.areaInfo.locationInfo);
SetLandmarkInfo(aOther.areaInfo.landmarkInfo);

return *this;
}
Expand All @@ -95,7 +95,7 @@ struct AreaStructureWrapper : public chip::app::Clusters::ServiceArea::Structs::

AreaStructureWrapper & SetLocationInfoNull()
{
areaDesc.locationInfo.SetNull();
areaInfo.locationInfo.SetNull();
return *this;
}

Expand All @@ -108,15 +108,15 @@ struct AreaStructureWrapper : public chip::app::Clusters::ServiceArea::Structs::
AreaStructureWrapper & SetLocationInfo(const CharSpan & locationName, const DataModel::Nullable<int16_t> & floorNumber,
const DataModel::Nullable<Globals::AreaTypeTag> & areaType)
{
areaDesc.locationInfo.SetNonNull();
areaInfo.locationInfo.SetNonNull();

// Copy the name. If the name is larger than kAreaNameMaxSize, truncate it to fit.
auto sizeToCopy = std::min(kAreaNameMaxSize, locationName.size());
memcpy(mAreaNameBuffer, locationName.data(), sizeToCopy);
areaDesc.locationInfo.Value().locationName = CharSpan(mAreaNameBuffer, sizeToCopy);
areaInfo.locationInfo.Value().locationName = CharSpan(mAreaNameBuffer, sizeToCopy);

areaDesc.locationInfo.Value().floorNumber = floorNumber;
areaDesc.locationInfo.Value().areaType = areaType;
areaInfo.locationInfo.Value().floorNumber = floorNumber;
areaInfo.locationInfo.Value().areaType = areaType;

return *this;
}
Expand All @@ -138,7 +138,7 @@ struct AreaStructureWrapper : public chip::app::Clusters::ServiceArea::Structs::

AreaStructureWrapper & SetLandmarkInfoNull()
{
areaDesc.landmarkInfo.SetNull();
areaInfo.landmarkInfo.SetNull();
return *this;
}

Expand All @@ -150,9 +150,9 @@ struct AreaStructureWrapper : public chip::app::Clusters::ServiceArea::Structs::
AreaStructureWrapper & SetLandmarkInfo(const Globals::LandmarkTag & landmarkTag,
const DataModel::Nullable<Globals::RelativePositionTag> & relativePositionTag)
{
areaDesc.landmarkInfo.SetNonNull();
areaDesc.landmarkInfo.Value().landmarkTag = landmarkTag;
areaDesc.landmarkInfo.Value().positionTag = relativePositionTag;
areaInfo.landmarkInfo.SetNonNull();
areaInfo.landmarkInfo.Value().landmarkTag = landmarkTag;
areaInfo.landmarkInfo.Value().relativePositionTag = relativePositionTag;

return *this;
}
Expand All @@ -167,7 +167,7 @@ struct AreaStructureWrapper : public chip::app::Clusters::ServiceArea::Structs::
return SetLandmarkInfoNull();
}

return SetLandmarkInfo(landmarkInfo.Value().landmarkTag, landmarkInfo.Value().positionTag);
return SetLandmarkInfo(landmarkInfo.Value().landmarkTag, landmarkInfo.Value().relativePositionTag);
}

/**
Expand All @@ -178,9 +178,9 @@ struct AreaStructureWrapper : public chip::app::Clusters::ServiceArea::Structs::
*/
bool IsNameEqual(const CharSpan & aAreaName) const
{
if (!areaDesc.locationInfo.IsNull())
if (!areaInfo.locationInfo.IsNull())
{
return areaDesc.locationInfo.Value().locationName.data_equal(aAreaName);
return areaInfo.locationInfo.Value().locationName.data_equal(aAreaName);
}

return false;
Expand Down Expand Up @@ -215,43 +215,43 @@ struct AreaStructureWrapper : public chip::app::Clusters::ServiceArea::Structs::
return false;
}

if (areaDesc.locationInfo.IsNull() != aOther.areaDesc.locationInfo.IsNull())
if (areaInfo.locationInfo.IsNull() != aOther.areaInfo.locationInfo.IsNull())
{
return false;
}

if (!areaDesc.locationInfo.IsNull())
if (!areaInfo.locationInfo.IsNull())
{

if (!IsNameEqual(aOther.areaDesc.locationInfo.Value().locationName))
if (!IsNameEqual(aOther.areaInfo.locationInfo.Value().locationName))
{
return false;
}

if (areaDesc.locationInfo.Value().floorNumber != aOther.areaDesc.locationInfo.Value().floorNumber)
if (areaInfo.locationInfo.Value().floorNumber != aOther.areaInfo.locationInfo.Value().floorNumber)
{
return false;
}

if (areaDesc.locationInfo.Value().areaType != aOther.areaDesc.locationInfo.Value().areaType)
if (areaInfo.locationInfo.Value().areaType != aOther.areaInfo.locationInfo.Value().areaType)
{
return false;
}
}

if (areaDesc.landmarkInfo.IsNull() != aOther.areaDesc.landmarkInfo.IsNull())
if (areaInfo.landmarkInfo.IsNull() != aOther.areaInfo.landmarkInfo.IsNull())
{
return false;
}

if (!areaDesc.landmarkInfo.IsNull())
if (!areaInfo.landmarkInfo.IsNull())
{
if (areaDesc.landmarkInfo.Value().landmarkTag != aOther.areaDesc.landmarkInfo.Value().landmarkTag)
if (areaInfo.landmarkInfo.Value().landmarkTag != aOther.areaInfo.landmarkInfo.Value().landmarkTag)
{
return false;
}

if (areaDesc.landmarkInfo.Value().positionTag != aOther.areaDesc.landmarkInfo.Value().positionTag)
if (areaInfo.landmarkInfo.Value().relativePositionTag != aOther.areaInfo.landmarkInfo.Value().relativePositionTag)
{
return false;
}
Expand All @@ -265,12 +265,12 @@ struct AreaStructureWrapper : public chip::app::Clusters::ServiceArea::Structs::
*/
CharSpan GetName()
{
if (areaDesc.locationInfo.IsNull())
if (areaInfo.locationInfo.IsNull())
{
return { mAreaNameBuffer, 0 };
}

return areaDesc.locationInfo.Value().locationName;
return areaInfo.locationInfo.Value().locationName;
}

private:
Expand Down
8 changes: 4 additions & 4 deletions src/app/clusters/service-area-server/service-area-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,18 +442,18 @@ bool Instance::IsValidSupportedArea(const AreaStructureWrapper & aArea)
{
// If the LocationInfo field is null, the LandmarkInfo field SHALL NOT be null.
// If the LandmarkInfo field is null, the LocationInfo field SHALL NOT be null.
if (aArea.areaDesc.locationInfo.IsNull() && aArea.areaDesc.landmarkInfo.IsNull())
if (aArea.areaInfo.locationInfo.IsNull() && aArea.areaInfo.landmarkInfo.IsNull())
{
ChipLogDetail(Zcl, "IsValidAsSupportedArea %" PRIu32 " - must have locationInfo and/or LandmarkInfo", aArea.areaID);
return false;
}

// If LocationInfo is not null, and its LocationName field is an empty string, at least one of the following SHALL NOT
// be null: LocationInfo's FloorNumber field, LocationInfo's AreaType field, the LandmarkInfo
if (!aArea.areaDesc.locationInfo.IsNull())
if (!aArea.areaInfo.locationInfo.IsNull())
{
if (aArea.areaDesc.locationInfo.Value().locationName.empty() && aArea.areaDesc.locationInfo.Value().floorNumber.IsNull() &&
aArea.areaDesc.locationInfo.Value().areaType.IsNull() && aArea.areaDesc.landmarkInfo.IsNull())
if (aArea.areaInfo.locationInfo.Value().locationName.empty() && aArea.areaInfo.locationInfo.Value().floorNumber.IsNull() &&
aArea.areaInfo.locationInfo.Value().areaType.IsNull() && aArea.areaInfo.landmarkInfo.IsNull())
{
ChipLogDetail(
Zcl, "IsValidAsSupportedArea %" PRIu32 " - AreaName is empty string, FloorNumber, AreaType, LandmarkInfo are null",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ limitations under the License.
Data types
<struct name="LandmarkInfoStruct" apiMaturity="provisional">
<cluster code="0x0150"/>
<item name="LandmarkTag" type="LandmarkTag" optional="false" isNullable="false"/>
<item name="PositionTag" type="RelativePositionTag" optional="false" isNullable="true"/>
<item name="LandmarkTag" type="LandmarkTag" optional="false" isNullable="false"/>
<item name="RelativePositionTag" type="RelativePositionTag" optional="false" isNullable="true"/>
</struct>

<struct name="AreaInfoStruct" apiMaturity="provisional">
Expand All @@ -40,7 +40,7 @@ limitations under the License.
<cluster code="0x0150"/>
<item name="AreaID" type="int32u" optional="false" isNullable="false"/>
<item name="MapID" type="int32u" optional="false" isNullable="true"/>
<item name="AreaDesc" type="AreaInfoStruct" optional="false" isNullable="false"/>
<item name="AreaInfo" type="AreaInfoStruct" optional="false" isNullable="false"/>
</struct>

<struct name="ProgressStruct">
Expand Down
4 changes: 2 additions & 2 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -6483,7 +6483,7 @@ provisional cluster ServiceArea = 336 {

struct LandmarkInfoStruct {
LandmarkTag landmarkTag = 0;
nullable RelativePositionTag positionTag = 1;
nullable RelativePositionTag relativePositionTag = 1;
}

struct AreaInfoStruct {
Expand All @@ -6494,7 +6494,7 @@ provisional cluster ServiceArea = 336 {
struct AreaStruct {
int32u areaID = 0;
nullable int32u mapID = 1;
AreaInfoStruct areaDesc = 2;
AreaInfoStruct areaInfo = 2;
}

struct MapStruct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9294,22 +9294,22 @@ public String toString() {
}
public static class ServiceAreaClusterLandmarkInfoStruct {
public Integer landmarkTag;
public @Nullable Integer positionTag;
public @Nullable Integer relativePositionTag;
private static final long LANDMARK_TAG_ID = 0L;
private static final long POSITION_TAG_ID = 1L;
private static final long RELATIVE_POSITION_TAG_ID = 1L;

public ServiceAreaClusterLandmarkInfoStruct(
Integer landmarkTag,
@Nullable Integer positionTag
@Nullable Integer relativePositionTag
) {
this.landmarkTag = landmarkTag;
this.positionTag = positionTag;
this.relativePositionTag = relativePositionTag;
}

public StructType encodeTlv() {
ArrayList<StructElement> values = new ArrayList<>();
values.add(new StructElement(LANDMARK_TAG_ID, new UIntType(landmarkTag)));
values.add(new StructElement(POSITION_TAG_ID, positionTag != null ? new UIntType(positionTag) : new NullType()));
values.add(new StructElement(RELATIVE_POSITION_TAG_ID, relativePositionTag != null ? new UIntType(relativePositionTag) : new NullType()));

return new StructType(values);
}
Expand All @@ -9319,23 +9319,23 @@ public static ServiceAreaClusterLandmarkInfoStruct decodeTlv(BaseTLVType tlvValu
return null;
}
Integer landmarkTag = null;
@Nullable Integer positionTag = null;
@Nullable Integer relativePositionTag = null;
for (StructElement element: ((StructType)tlvValue).value()) {
if (element.contextTagNum() == LANDMARK_TAG_ID) {
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
UIntType castingValue = element.value(UIntType.class);
landmarkTag = castingValue.value(Integer.class);
}
} else if (element.contextTagNum() == POSITION_TAG_ID) {
} else if (element.contextTagNum() == RELATIVE_POSITION_TAG_ID) {
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
UIntType castingValue = element.value(UIntType.class);
positionTag = castingValue.value(Integer.class);
relativePositionTag = castingValue.value(Integer.class);
}
}
}
return new ServiceAreaClusterLandmarkInfoStruct(
landmarkTag,
positionTag
relativePositionTag
);
}

Expand All @@ -9346,8 +9346,8 @@ public String toString() {
output.append("\tlandmarkTag: ");
output.append(landmarkTag);
output.append("\n");
output.append("\tpositionTag: ");
output.append(positionTag);
output.append("\trelativePositionTag: ");
output.append(relativePositionTag);
output.append("\n");
output.append("}\n");
return output.toString();
Expand Down Expand Up @@ -9417,26 +9417,26 @@ public String toString() {
public static class ServiceAreaClusterAreaStruct {
public Long areaID;
public @Nullable Long mapID;
public ChipStructs.ServiceAreaClusterAreaInfoStruct areaDesc;
public ChipStructs.ServiceAreaClusterAreaInfoStruct areaInfo;
private static final long AREA_ID_ID = 0L;
private static final long MAP_ID_ID = 1L;
private static final long AREA_DESC_ID = 2L;
private static final long AREA_INFO_ID = 2L;

public ServiceAreaClusterAreaStruct(
Long areaID,
@Nullable Long mapID,
ChipStructs.ServiceAreaClusterAreaInfoStruct areaDesc
ChipStructs.ServiceAreaClusterAreaInfoStruct areaInfo
) {
this.areaID = areaID;
this.mapID = mapID;
this.areaDesc = areaDesc;
this.areaInfo = areaInfo;
}

public StructType encodeTlv() {
ArrayList<StructElement> values = new ArrayList<>();
values.add(new StructElement(AREA_ID_ID, new UIntType(areaID)));
values.add(new StructElement(MAP_ID_ID, mapID != null ? new UIntType(mapID) : new NullType()));
values.add(new StructElement(AREA_DESC_ID, areaDesc.encodeTlv()));
values.add(new StructElement(AREA_INFO_ID, areaInfo.encodeTlv()));

return new StructType(values);
}
Expand All @@ -9447,7 +9447,7 @@ public static ServiceAreaClusterAreaStruct decodeTlv(BaseTLVType tlvValue) {
}
Long areaID = null;
@Nullable Long mapID = null;
ChipStructs.ServiceAreaClusterAreaInfoStruct areaDesc = null;
ChipStructs.ServiceAreaClusterAreaInfoStruct areaInfo = null;
for (StructElement element: ((StructType)tlvValue).value()) {
if (element.contextTagNum() == AREA_ID_ID) {
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
Expand All @@ -9459,17 +9459,17 @@ public static ServiceAreaClusterAreaStruct decodeTlv(BaseTLVType tlvValue) {
UIntType castingValue = element.value(UIntType.class);
mapID = castingValue.value(Long.class);
}
} else if (element.contextTagNum() == AREA_DESC_ID) {
} else if (element.contextTagNum() == AREA_INFO_ID) {
if (element.value(BaseTLVType.class).type() == TLVType.Struct) {
StructType castingValue = element.value(StructType.class);
areaDesc = ChipStructs.ServiceAreaClusterAreaInfoStruct.decodeTlv(castingValue);
areaInfo = ChipStructs.ServiceAreaClusterAreaInfoStruct.decodeTlv(castingValue);
}
}
}
return new ServiceAreaClusterAreaStruct(
areaID,
mapID,
areaDesc
areaInfo
);
}

Expand All @@ -9483,8 +9483,8 @@ public String toString() {
output.append("\tmapID: ");
output.append(mapID);
output.append("\n");
output.append("\tareaDesc: ");
output.append(areaDesc);
output.append("\tareaInfo: ");
output.append(areaInfo);
output.append("\n");
output.append("}\n");
return output.toString();
Expand Down
Loading
Loading