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

Address comments from reviews #34884

Merged
merged 77 commits into from
Aug 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
e4087bd
Updated the golabl data type's XMLs, removing the cluster entries.
hicklin Jul 31, 2024
7342db3
Zap generated after XML update.
hicklin Jul 31, 2024
63edf2e
Fixed namespaces used of global structs.
hicklin Jul 31, 2024
1cab752
Restyled by clang-format
restyled-commits Jul 31, 2024
72de6c5
Renamed LocationInfoStruct to AreaInfoStruct.
hicklin Aug 1, 2024
f2add10
Zap generated after XML update.
hicklin Aug 1, 2024
c6134a6
Renamed LocationStruct to AreaStruct and its LocationID and LocationD…
hicklin Aug 1, 2024
af8b02c
Zap generated after XML update.
hicklin Aug 1, 2024
a20d803
Updated SDK and example code to match the new naming.
hicklin Aug 1, 2024
8bb0d34
Updated the ProgressStruct's LocationID name to AreaID.
hicklin Aug 1, 2024
5bd0285
Zap generated after XML update.
hicklin Aug 1, 2024
5dc5eb0
Updated the SDK code following name changes.
hicklin Aug 1, 2024
5429771
Updated the SelectLocationsStatus and SkipLocationStatus enum names a…
hicklin Aug 1, 2024
04e87b6
Zap generated after XML update.
hicklin Aug 1, 2024
91f4446
Updated the SelectLocationsStatus and SkipCurrentLocationStatus names…
hicklin Aug 1, 2024
31a3c1a
Updated the names of the SupportedLocations, SelectedLocations and Cu…
hicklin Aug 1, 2024
f7d6a54
Zap generated after XML update.
hicklin Aug 1, 2024
4c128e6
Updated the changed names in the SDK.
hicklin Aug 1, 2024
088f01d
Updated the service area command names in XML.
hicklin Aug 1, 2024
a6b8036
Zap generated after XML update.
hicklin Aug 1, 2024
69eb53f
Updated the service area command names in the SDK.
hicklin Aug 1, 2024
c6c3659
Updated the rvc-example zap file.
hicklin Aug 1, 2024
d378b4e
Refactored LocationStructureWrapper to AreaStructureWrapper.
hicklin Aug 1, 2024
75a3369
Merge branch 'master' into update_names
hicklin Aug 1, 2024
86c38ed
Restyled by clang-format
restyled-commits Aug 1, 2024
a611a5b
Regenerated zap files due to changes upsteram.
hicklin Aug 1, 2024
56d0184
Merge branch 'master' into update_names
hicklin Aug 2, 2024
b3abfbd
Removed unused generated file.
hicklin Aug 2, 2024
e82a96e
Updated the Service Area XML marking previously nullabel attributes a…
hicklin Aug 2, 2024
f48fb79
Zap generated after XML update.
hicklin Aug 2, 2024
499b42d
Updated the attribute encoding and some server logic following the ro…
hicklin Aug 2, 2024
1aa272e
Explicitly set the Service Area version.
hicklin Aug 2, 2024
3881db0
Zap generated after XML update.
hicklin Aug 2, 2024
9a9b3bc
Updated the service area features in the XML to match the current spec.
hicklin Aug 2, 2024
d57ec78
Zap generated after XML update.
hicklin Aug 2, 2024
15376cb
Updated the SupportedArea validation logic as if the MAPS feature is …
hicklin Aug 2, 2024
43dd764
Change the type of the MapID to uint32 to match the spec.
hicklin Aug 2, 2024
ad374f1
Added the SkippedArea arg to the SkipArea command.
hicklin Aug 2, 2024
5979878
Zap generated after XML update.
hicklin Aug 2, 2024
5b079da
Updated the Service Area server code to handle the new SkippedArea co…
hicklin Aug 2, 2024
e8dd79c
Updated the service area XML to match the current spec. This includes…
hicklin Aug 2, 2024
1eb0f17
Zap generated after XML update.
hicklin Aug 2, 2024
bf8d264
Updated SDK server code and rvc-example after changes to the XML.
hicklin Aug 2, 2024
54cbcc2
Restyled by whitespace
restyled-commits Aug 2, 2024
9548b69
added vector include.
hicklin Aug 2, 2024
afb1084
Merge branch 'master' into update_names
hicklin Aug 5, 2024
ba24897
spacing changes form zap regen.
hicklin Aug 5, 2024
4f61bf3
Fixed minor mistake during merge.
hicklin Aug 5, 2024
30b4118
Merge branch 'update_names' into remove_nullable_qualities
hicklin Aug 5, 2024
2325e2a
Merge branch 'remove_nullable_qualities' into update_service_area_xml…
hicklin Aug 5, 2024
21663d9
Restyled by clang-format
restyled-commits Aug 5, 2024
cd43089
Merge branch 'master' into remove_nullable_qualities. Fixed conflicts…
hicklin Aug 5, 2024
82396bc
Merge branch 'remove_nullable_qualities' into update_service_area_xml…
hicklin Aug 5, 2024
b730832
Applied suggestions from review.
hicklin Aug 5, 2024
b3140db
Restyled by whitespace
restyled-commits Aug 5, 2024
c7f248c
Merge branch 'master' into update_service_area_xml_from_07
hicklin Aug 6, 2024
22db496
Updated the LondmarkInfoSturct PositionTag type.
hicklin Aug 6, 2024
23b1c6b
Zap generated after XML update.
hicklin Aug 6, 2024
ec07b0e
Fixed SDK following update to the position type.
hicklin Aug 6, 2024
95c68f7
Restyled by clang-format
restyled-commits Aug 6, 2024
6fafcf9
Updated the AeraStructWrapper to not contain methods with a large num…
hicklin Aug 6, 2024
0a5ec9f
Restyled by whitespace
restyled-commits Aug 6, 2024
6f9efb1
Restyled by clang-format
restyled-commits Aug 6, 2024
40c8298
Merge branch 'master' into update_service_area_xml_from_07. Fixed XML…
hicklin Aug 7, 2024
0ec7d0b
Missed a submudule update.
hicklin Aug 7, 2024
ca10c9a
Merge branch 'update_service_area_xml_from_07' into improve_AreaStruc…
hicklin Aug 7, 2024
f3df11c
Made the setters reture a ref to the sturct to allow chaining.
hicklin Aug 7, 2024
ed743e4
simplified the = oporator and add the == operator.
hicklin Aug 7, 2024
931557e
Restyled by clang-format
restyled-commits Aug 7, 2024
10c7abb
Merge branch 'master' into improve_AreaStructWrapper
hicklin Aug 8, 2024
ccdc1e5
minor change to get restyler going.
hicklin Aug 8, 2024
35f5908
Restyled by clang-format
restyled-commits Aug 8, 2024
258e249
Fixed status text referance issue.
hicklin Aug 8, 2024
b7ae205
Fixed issue casued by a change in the way that registrations are made.
hicklin Aug 8, 2024
2ee994e
Merge branch 'improve_AreaStructWrapper' into address_comments_from_r…
hicklin Aug 8, 2024
61e357b
Fixed styling and minor bug in IsValidSupportedArea.
hicklin Aug 8, 2024
b0940e8
Merge branch 'master' into address_comments_from_reviews
hicklin Aug 9, 2024
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
Prev Previous commit
Next Next commit
Updated SDK and example code to match the new naming.
hicklin committed Aug 1, 2024
commit a20d8038aa06886889b21aced8bdd6c2914edb20
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ class RvcServiceAreaDelegate : public Delegate

bool GetSupportedLocationByIndex(uint32_t listIndex, ServiceArea::LocationStructureWrapper & supportedLocation) override;

bool GetSupportedLocationById(uint32_t aLocationId, uint32_t & listIndex,
bool GetSupportedLocationById(uint32_t aAreaId, uint32_t & listIndex,
ServiceArea::LocationStructureWrapper & supportedLocation) override;

bool AddSupportedLocation(const ServiceArea::LocationStructureWrapper & newLocation, uint32_t & listIndex) override;
@@ -95,7 +95,7 @@ class RvcServiceAreaDelegate : public Delegate

// IsSelectedLocation() no override

bool AddSelectedLocation(uint32_t aLocationId, uint32_t & listIndex) override;
bool AddSelectedLocation(uint32_t aAreaId, uint32_t & listIndex) override;

bool ClearSelectedLocations() override;

@@ -106,7 +106,7 @@ class RvcServiceAreaDelegate : public Delegate

bool GetProgressElementByIndex(uint32_t listIndex, ServiceArea::Structs::ProgressStruct::Type & aProgressElement) override;

bool GetProgressElementById(uint32_t aLocationId, uint32_t & listIndex,
bool GetProgressElementById(uint32_t aAreaId, uint32_t & listIndex,
ServiceArea::Structs::ProgressStruct::Type & aProgressElement) override;

bool AddProgressElement(const ServiceArea::Structs::ProgressStruct::Type & newProgressElement, uint32_t & listIndex) override;
54 changes: 27 additions & 27 deletions examples/rvc-app/rvc-common/src/rvc-service-area-delegate.cpp
Original file line number Diff line number Diff line change
@@ -32,40 +32,40 @@ CHIP_ERROR RvcServiceAreaDelegate::Init()
GetInstance()->AddSupportedMap(supportedMapId_YY, "My Map YY"_span);

// hardcoded fill of SUPPORTED LOCATIONS for prototyping
uint32_t supportedLocationId_A = 7;
uint32_t supportedLocationId_B = 1234567;
uint32_t supportedLocationId_C = 10050;
uint32_t supportedLocationId_D = 0x88888888;
uint32_t supportedAreaID_A = 7;
uint32_t supportedAreaID_B = 1234567;
uint32_t supportedAreaID_C = 10050;
uint32_t supportedAreaID_D = 0x88888888;

// Location A has name, floor number, uses map XX
GetInstance()->AddSupportedLocation(
supportedLocationId_A, DataModel::Nullable<uint_fast8_t>(supportedMapId_XX), "My Location A"_span,
supportedAreaID_A, DataModel::Nullable<uint_fast8_t>(supportedMapId_XX), "My Location A"_span,
DataModel::Nullable<int16_t>(4), DataModel::Nullable<Globals::AreaTypeTag>(), DataModel::Nullable<Globals::LandmarkTag>(),
DataModel::Nullable<Globals::PositionTag>(), DataModel::Nullable<Globals::FloorSurfaceTag>());

// Location B has name, uses map XX
GetInstance()->AddSupportedLocation(
supportedLocationId_B, DataModel::Nullable<uint_fast8_t>(supportedMapId_XX), "My Location B"_span,
supportedAreaID_B, DataModel::Nullable<uint_fast8_t>(supportedMapId_XX), "My Location B"_span,
DataModel::Nullable<int16_t>(), DataModel::Nullable<Globals::AreaTypeTag>(), DataModel::Nullable<Globals::LandmarkTag>(),
DataModel::Nullable<Globals::PositionTag>(), DataModel::Nullable<Globals::FloorSurfaceTag>());

// Location C has full SemData, no name, Map YY
GetInstance()->AddSupportedLocation(supportedLocationId_C, DataModel::Nullable<uint_fast8_t>(supportedMapId_YY), CharSpan(),
GetInstance()->AddSupportedLocation(supportedAreaID_C, DataModel::Nullable<uint_fast8_t>(supportedMapId_YY), CharSpan(),
DataModel::Nullable<int16_t>(-1),
DataModel::Nullable<Globals::AreaTypeTag>(Globals::AreaTypeTag::kPlayRoom),
DataModel::Nullable<Globals::LandmarkTag>(Globals::LandmarkTag::kBackDoor),
DataModel::Nullable<Globals::PositionTag>(Globals::PositionTag::kNextTo),
DataModel::Nullable<Globals::FloorSurfaceTag>(Globals::FloorSurfaceTag::kConcrete));

// Location D has null values for all HomeLocationStruct fields, Map YY
GetInstance()->AddSupportedLocation(supportedLocationId_D, DataModel::Nullable<uint_fast8_t>(supportedMapId_YY),
GetInstance()->AddSupportedLocation(supportedAreaID_D, DataModel::Nullable<uint_fast8_t>(supportedMapId_YY),
"My Location D"_span, DataModel::Nullable<int16_t>(),
DataModel::Nullable<Globals::AreaTypeTag>(),
DataModel::Nullable<Globals::LandmarkTag>(Globals::LandmarkTag::kCouch),
DataModel::Nullable<Globals::PositionTag>(Globals::PositionTag::kNextTo),
DataModel::Nullable<Globals::FloorSurfaceTag>(Globals::FloorSurfaceTag::kHardwood));

GetInstance()->SetCurrentLocation(supportedLocationId_C);
GetInstance()->SetCurrentLocation(supportedAreaID_C);

return CHIP_NO_ERROR;
}
@@ -117,7 +117,7 @@ bool RvcServiceAreaDelegate::GetSupportedLocationByIndex(uint32_t listIndex, Loc
return false;
};

bool RvcServiceAreaDelegate::GetSupportedLocationById(uint32_t aLocationId, uint32_t & listIndex,
bool RvcServiceAreaDelegate::GetSupportedLocationById(uint32_t aAreaID, uint32_t & listIndex,
LocationStructureWrapper & aSupportedLocation)
{
// We do not need to reimplement this method as it's already done by the SDK.
@@ -127,7 +127,7 @@ bool RvcServiceAreaDelegate::GetSupportedLocationById(uint32_t aLocationId, uint

while (listIndex < mSupportedLocations.size())
{
if (mSupportedLocations[listIndex].locationID == aLocationId)
if (mSupportedLocations[listIndex].areaID == aAreaID)
{
aSupportedLocation = mSupportedLocations[listIndex];
return true;
@@ -141,7 +141,7 @@ bool RvcServiceAreaDelegate::GetSupportedLocationById(uint32_t aLocationId, uint

bool RvcServiceAreaDelegate::AddSupportedLocation(const LocationStructureWrapper & newLocation, uint32_t & listIndex)
{
// The server instance (caller) is responsible for ensuring that there are no duplicate location IDs, list size not exceeded,
// The server instance (caller) is responsible for ensuring that there are no duplicate area IDs, list size not exceeded,
// etc.

// Double-check list size to ensure there no memory issues.
@@ -153,22 +153,22 @@ bool RvcServiceAreaDelegate::AddSupportedLocation(const LocationStructureWrapper
return true;
}

ChipLogError(Zcl, "AddSupportedLocation %u - supported locations list is already at maximum size %u", newLocation.locationID,
ChipLogError(Zcl, "AddSupportedLocation %u - supported locations list is already at maximum size %u", newLocation.areaID,
static_cast<uint32_t>(kMaxNumSupportedLocations));

return false;
}

bool RvcServiceAreaDelegate::ModifySupportedLocation(uint32_t listIndex, const LocationStructureWrapper & modifiedLocation)
{
// The server instance (caller) is responsible for ensuring that there are no duplicate location IDs, list size not exceeded,
// The server instance (caller) is responsible for ensuring that there are no duplicate area IDs, list size not exceeded,
// etc.

// Double-check that locationID's match.
if (modifiedLocation.locationID != mSupportedLocations[listIndex].locationID)
// Double-check that areaID's match.
if (modifiedLocation.areaID != mSupportedLocations[listIndex].areaID)
{
ChipLogError(Zcl, "ModifySupportedLocation - locationID's do not match, new locationID %u, existing locationID %u",
modifiedLocation.locationID, mSupportedLocations[listIndex].locationID);
ChipLogError(Zcl, "ModifySupportedLocation - areaID's do not match, new areaID %u, existing areaID %u",
modifiedLocation.areaID, mSupportedLocations[listIndex].areaID);
return false;
}

@@ -236,7 +236,7 @@ bool RvcServiceAreaDelegate::GetSupportedMapById(uint8_t aMapId, uint32_t & list

bool RvcServiceAreaDelegate::AddSupportedMap(const MapStructureWrapper & newMap, uint32_t & listIndex)
{
// The server instance (caller) is responsible for ensuring that there are no duplicate location IDs, list size not exceeded,
// The server instance (caller) is responsible for ensuring that there are no duplicate area IDs, list size not exceeded,
// etc.

// Double-check list size to ensure there no memory issues.
@@ -255,7 +255,7 @@ bool RvcServiceAreaDelegate::AddSupportedMap(const MapStructureWrapper & newMap,

bool RvcServiceAreaDelegate::ModifySupportedMap(uint32_t listIndex, const MapStructureWrapper & modifiedMap)
{
// The server instance (caller) is responsible for ensuring that there are no duplicate location IDs, list size not exceeded,
// The server instance (caller) is responsible for ensuring that there are no duplicate area IDs, list size not exceeded,
// etc.

// Double-check that mapID's match.
@@ -301,20 +301,20 @@ bool RvcServiceAreaDelegate::GetSelectedLocationByIndex(uint32_t listIndex, uint
return false;
};

bool RvcServiceAreaDelegate::AddSelectedLocation(uint32_t aLocationId, uint32_t & listIndex)
bool RvcServiceAreaDelegate::AddSelectedLocation(uint32_t aAreaID, uint32_t & listIndex)
{
// The server instance (caller) is responsible for ensuring that there are no duplicate location IDs, list size not exceeded,
// The server instance (caller) is responsible for ensuring that there are no duplicate area IDs, list size not exceeded,
// etc.

// Double-check list size to ensure there no memory issues.
if (mSelectedLocations.size() < kMaxNumSelectedLocations)
{
// not sorting list, number of locations normally expected to be small, max 255
mSelectedLocations.push_back(aLocationId);
mSelectedLocations.push_back(aAreaID);
listIndex = static_cast<uint32_t>(mSelectedLocations.size()) - 1; // new element is last in list
return true;
}
ChipLogError(Zcl, "AddSelectedLocation %u - selected locations list is already at maximum size %u", aLocationId,
ChipLogError(Zcl, "AddSelectedLocation %u - selected locations list is already at maximum size %u", aAreaID,
static_cast<uint32_t>(kMaxNumSelectedLocations));

return false;
@@ -350,7 +350,7 @@ bool RvcServiceAreaDelegate::GetProgressElementByIndex(uint32_t listIndex, Struc
return false;
};

bool RvcServiceAreaDelegate::GetProgressElementById(uint32_t aLocationId, uint32_t & listIndex,
bool RvcServiceAreaDelegate::GetProgressElementById(uint32_t aAreaID, uint32_t & listIndex,
Structs::ProgressStruct::Type & aProgressElement)
{
// We do not need to reimplement this method as it's already done by the SDK.
@@ -360,7 +360,7 @@ bool RvcServiceAreaDelegate::GetProgressElementById(uint32_t aLocationId, uint32

while (listIndex < mProgressList.size())
{
if (mProgressList[listIndex].locationID == aLocationId)
if (mProgressList[listIndex].locationID == aAreaID)
{
aProgressElement = mProgressList[listIndex];
return true;
@@ -374,7 +374,7 @@ bool RvcServiceAreaDelegate::GetProgressElementById(uint32_t aLocationId, uint32

bool RvcServiceAreaDelegate::AddProgressElement(const Structs::ProgressStruct::Type & newProgressElement, uint32_t & listIndex)
{
// The server instance (caller) is responsible for ensuring that there are no duplicate location IDs, list size not exceeded,
// The server instance (caller) is responsible for ensuring that there are no duplicate area IDs, list size not exceeded,
// etc.

// Double-check list size to ensure there no memory issues.
88 changes: 44 additions & 44 deletions src/app/clusters/service-area-server/service-area-cluster-objects.h
Original file line number Diff line number Diff line change
@@ -31,10 +31,10 @@ inline constexpr size_t kLocationNameMaxSize = 128u;
inline constexpr size_t kMapNameMaxSize = 64u;

/**
* This class is used to wrap the LocationStruct object and provide a more user-friendly interface for the data.
* This class is used to wrap the AreaStruct object and provide a more user-friendly interface for the data.
* It provides a way to store the location name in a buffer, and provides a way to compare the location name with a given string.
*/
struct LocationStructureWrapper : public chip::app::Clusters::ServiceArea::Structs::LocationStruct::Type
struct LocationStructureWrapper : public chip::app::Clusters::ServiceArea::Structs::AreaStruct::Type
{
LocationStructureWrapper()
{
@@ -45,7 +45,7 @@ struct LocationStructureWrapper : public chip::app::Clusters::ServiceArea::Struc

/**
* @brief This is a full constructor that initializes the location object with the given values. All values are deep copied.
* @param[in] aLocationId The unique identifier of this location.
* @param[in] aAreaID The unique identifier of this location.
* @param[in] aMapId The identifier of the supported map associated with this location.
* @param[in] aLocationName A human readable name for this location (empty string if not used).
* @param[in] aFloorNumber The floor level of this location - use negative values for below ground.
@@ -60,14 +60,14 @@ struct LocationStructureWrapper : public chip::app::Clusters::ServiceArea::Struc
* @note If aLocationName is larger than kLocationNameMaxSize, it will be truncated.
* @note If aLocationName is an empty string and aFloorNumber and aAreaTypeTag are null, locationInfo will be set to null.
*/
LocationStructureWrapper(uint32_t aLocationId, const DataModel::Nullable<uint8_t> & aMapId, const CharSpan & aLocationName,
LocationStructureWrapper(uint32_t aAreaID, const DataModel::Nullable<uint8_t> & aMapId, const CharSpan & aLocationName,
const DataModel::Nullable<int16_t> & aFloorNumber,
const DataModel::Nullable<Globals::AreaTypeTag> & aAreaTypeTag,
const DataModel::Nullable<Globals::LandmarkTag> & aLandmarkTag,
const DataModel::Nullable<Globals::PositionTag> & aPositionTag,
const DataModel::Nullable<Globals::FloorSurfaceTag> & aSurfaceTag)
{
Set(aLocationId, aMapId, aLocationName, aFloorNumber, aAreaTypeTag, aLandmarkTag, aPositionTag, aSurfaceTag);
Set(aAreaID, aMapId, aLocationName, aFloorNumber, aAreaTypeTag, aLandmarkTag, aPositionTag, aSurfaceTag);
}

/**
@@ -88,24 +88,24 @@ struct LocationStructureWrapper : public chip::app::Clusters::ServiceArea::Struc
*/
LocationStructureWrapper & operator=(const LocationStructureWrapper & aOther)
{
if (aOther.locationInfo.locationInfo.IsNull())
if (aOther.areaDesc.locationInfo.IsNull())
{
Set(aOther.locationID, aOther.mapID, CharSpan(), NullOptional, NullOptional, aOther.locationInfo.landmarkTag,
aOther.locationInfo.positionTag, aOther.locationInfo.surfaceTag);
Set(aOther.areaID, aOther.mapID, CharSpan(), NullOptional, NullOptional, aOther.areaDesc.landmarkTag,
aOther.areaDesc.positionTag, aOther.areaDesc.surfaceTag);
}
else
{
Set(aOther.locationID, aOther.mapID, aOther.locationInfo.locationInfo.Value().locationName,
aOther.locationInfo.locationInfo.Value().floorNumber, aOther.locationInfo.locationInfo.Value().areaType,
aOther.locationInfo.landmarkTag, aOther.locationInfo.positionTag, aOther.locationInfo.surfaceTag);
Set(aOther.areaID, aOther.mapID, aOther.areaDesc.locationInfo.Value().locationName,
aOther.areaDesc.locationInfo.Value().floorNumber, aOther.areaDesc.locationInfo.Value().areaType,
aOther.areaDesc.landmarkTag, aOther.areaDesc.positionTag, aOther.areaDesc.surfaceTag);
}

return *this;
}

/**
* @brief Set all fields of the location object. All values are deep copied.
* @param[in] aLocationId The unique identifier of this location.
* @param[in] aAreaID The unique identifier of this location.
* @param[in] aMapId The identifier of the supported map associated with this location.
* @param[in] aLocationName A human readable name for this location (empty string if not used).
* @param[in] aFloorNumber The floor level of this location - use negative values for below ground.
@@ -120,51 +120,51 @@ struct LocationStructureWrapper : public chip::app::Clusters::ServiceArea::Struc
* @note If aLocationName is larger than kLocationNameMaxSize, it will be truncated.
* @note If aLocationName is an empty string and aFloorNumber and aAreaTypeTag are null, locationInfo will be set to null.
*/
void Set(uint32_t aLocationId, const DataModel::Nullable<uint8_t> & aMapId, const CharSpan & aLocationName,
void Set(uint32_t aAreaID, const DataModel::Nullable<uint8_t> & aMapId, const CharSpan & aLocationName,
const DataModel::Nullable<int16_t> & aFloorNumber, const DataModel::Nullable<Globals::AreaTypeTag> & aAreaType,
const DataModel::Nullable<Globals::LandmarkTag> & aLandmarkTag,
const DataModel::Nullable<Globals::PositionTag> & aPositionTag,
const DataModel::Nullable<Globals::FloorSurfaceTag> & aSurfaceTag)
{
locationID = aLocationId;
mapID = aMapId;
areaID = aAreaID;
mapID = aMapId;

// If there is at least one non-null value for locationInfo, add it to the location structure.
if ((!aLocationName.empty()) || (!aFloorNumber.IsNull()) || (!aAreaType.IsNull()))
{
// Create a home location info structure and fill it in except for the location name. This is done below.
locationInfo.locationInfo.SetNonNull(Globals::Structs::LocationDescriptorStruct::Type());
// Create a home location desc structure and fill it in except for the location name. This is done below.
areaDesc.locationInfo.SetNonNull(Globals::Structs::LocationDescriptorStruct::Type());

locationInfo.locationInfo.Value().floorNumber = aFloorNumber;
locationInfo.locationInfo.Value().areaType = aAreaType;
areaDesc.locationInfo.Value().floorNumber = aFloorNumber;
areaDesc.locationInfo.Value().areaType = aAreaType;
}
else
{
locationInfo.locationInfo.SetNull();
areaDesc.locationInfo.SetNull();
}

locationInfo.landmarkTag = aLandmarkTag;
locationInfo.positionTag = aPositionTag;
locationInfo.surfaceTag = aSurfaceTag;
areaDesc.landmarkTag = aLandmarkTag;
areaDesc.positionTag = aPositionTag;
areaDesc.surfaceTag = aSurfaceTag;

// this assumes locationInfo structure was created above, if appropriate
if (!locationInfo.locationInfo.IsNull())
// this assumes areaDesc structure was created above, if appropriate
if (!areaDesc.locationInfo.IsNull())
{
if (aLocationName.empty())
{
locationInfo.locationInfo.Value().locationName = CharSpan(mLocationNameBuffer, 0);
areaDesc.locationInfo.Value().locationName = CharSpan(mLocationNameBuffer, 0);
}
else if (aLocationName.size() > sizeof(mLocationNameBuffer))
{
// Save the truncated name that fits into available size.
memcpy(mLocationNameBuffer, aLocationName.data(), sizeof(mLocationNameBuffer));
locationInfo.locationInfo.Value().locationName = CharSpan(mLocationNameBuffer, sizeof(mLocationNameBuffer));
areaDesc.locationInfo.Value().locationName = CharSpan(mLocationNameBuffer, sizeof(mLocationNameBuffer));
}
else
{
// Save full name.
memcpy(mLocationNameBuffer, aLocationName.data(), aLocationName.size());
locationInfo.locationInfo.Value().locationName = CharSpan(mLocationNameBuffer, aLocationName.size());
areaDesc.locationInfo.Value().locationName = CharSpan(mLocationNameBuffer, aLocationName.size());
}
}
}
@@ -177,34 +177,34 @@ struct LocationStructureWrapper : public chip::app::Clusters::ServiceArea::Struc
*/
bool IsNameEqual(const CharSpan & aLocationName) const
{
if (!locationInfo.locationInfo.IsNull())
if (!areaDesc.locationInfo.IsNull())
{
return locationInfo.locationInfo.Value().locationName.data_equal(aLocationName);
return areaDesc.locationInfo.Value().locationName.data_equal(aLocationName);
}

return false;
}

/**
* This is used for configuring the IsEqual method.
* If kIgnoreLocationId is set, the location IDs are ignored when checking for equality.
* If kIgnoreAreaID is set, the area IDs are ignored when checking for equality.
* If kIgnoreMapId is set, the map IDs are ignored when checking for equality.
*/
enum class IsEqualConfig : uint8_t
{
kIgnoreLocationId = 0x1,
kIgnoreAreaID = 0x1,
kIgnoreMapId = 0x2,
};

/**
* @brief Checks if the given LocationStructureWrapper is equal to this one.
* @param aOther The location to compare with.
* @param aConfig Set if the location IDs and/or the map IDs should be ignored when checking for equality.
* @param aConfig Set if the area IDs and/or the map IDs should be ignored when checking for equality.
* @return True if both locations are equal. False otherwise.
*/
bool IsEqual(const LocationStructureWrapper & aOther, BitMask<IsEqualConfig> aConfig) const
{
if (!aConfig.Has(IsEqualConfig::kIgnoreLocationId) && (locationID != aOther.locationID))
if (!aConfig.Has(IsEqualConfig::kIgnoreAreaID) && (areaID != aOther.areaID))
{
return false;
}
@@ -214,41 +214,41 @@ struct LocationStructureWrapper : public chip::app::Clusters::ServiceArea::Struc
return false;
}

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

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

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

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

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

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

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

if (locationInfo.surfaceTag != aOther.locationInfo.surfaceTag)
if (areaDesc.surfaceTag != aOther.areaDesc.surfaceTag)
{
return false;
}
@@ -261,12 +261,12 @@ struct LocationStructureWrapper : public chip::app::Clusters::ServiceArea::Struc
*/
CharSpan GetName()
{
if (locationInfo.locationInfo.IsNull())
if (areaDesc.locationInfo.IsNull())
{
return { mLocationNameBuffer, 0 };
}

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

private:
20 changes: 10 additions & 10 deletions src/app/clusters/service-area-server/service-area-delegate.cpp
Original file line number Diff line number Diff line change
@@ -3,14 +3,14 @@

using namespace chip::app::Clusters::ServiceArea;

bool Delegate::GetSupportedLocationById(uint32_t aLocationId, uint32_t & listIndex, LocationStructureWrapper & aSupportedLocation)
bool Delegate::GetSupportedLocationById(uint32_t aAreaId, uint32_t & listIndex, LocationStructureWrapper & aSupportedLocation)
{
listIndex = 0;

// simple linear iteration to find the location with the desired locationID.
// simple linear iteration to find the location with the desired areaId.
while (GetSupportedLocationByIndex(listIndex, aSupportedLocation))
{
if (aSupportedLocation.locationID == aLocationId)
if (aSupportedLocation.areaID == aAreaId)
{
return true;
}
@@ -45,14 +45,14 @@ bool Delegate::GetSupportedMapById(uint8_t aMapId, uint32_t & listIndex, MapStru
return false;
}

bool Delegate::IsSelectedLocation(uint32_t aLocationId)
bool Delegate::IsSelectedLocation(uint32_t aAreaId)
{
uint32_t listIndex = 0;
uint32_t selectedLocation;

while (GetSelectedLocationByIndex(listIndex, selectedLocation))
{
if (selectedLocation == aLocationId)
if (selectedLocation == aAreaId)
{
return true;
}
@@ -63,14 +63,14 @@ bool Delegate::IsSelectedLocation(uint32_t aLocationId)
return false;
}

bool Delegate::GetProgressElementById(uint32_t aLocationId, uint32_t & listIndex, Structs::ProgressStruct::Type & aProgressElement)
bool Delegate::GetProgressElementById(uint32_t aAreaId, uint32_t & listIndex, Structs::ProgressStruct::Type & aProgressElement)
{
listIndex = 0;

// simple linear iteration to find the progress element with the desired locationID.
// simple linear iteration to find the progress element with the desired areaID.
while (GetProgressElementByIndex(listIndex, aProgressElement))
{
if (aProgressElement.locationID == aLocationId)
if (aProgressElement.locationID == aAreaId)
{
return true;
}
@@ -81,10 +81,10 @@ bool Delegate::GetProgressElementById(uint32_t aLocationId, uint32_t & listIndex
return false;
}

bool Delegate::IsProgressElement(uint32_t aLocationId)
bool Delegate::IsProgressElement(uint32_t aAreaId)
{
uint32_t index;
Structs::ProgressStruct::Type progressElement;

return GetProgressElementById(aLocationId, index, progressElement);
return GetProgressElementById(aAreaId, index, progressElement);
}
32 changes: 16 additions & 16 deletions src/app/clusters/service-area-server/service-area-delegate.h
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ class Delegate
* @return true if the current device state allows the SupportedLocations attribute to be updated.
*
* @note The SupportedLocations attribute list changes (adding or deleting entries,
* changing their MapID fields, changing the LocationID fields, or nulling the entire list)
* changing their MapID fields, changing the AreaID fields, or nulling the entire list)
* SHOULD NOT be allowed while the device is operating, to reduce the impact on the clients,
* and the potential confusion for the users.
*
@@ -154,15 +154,15 @@ class Delegate
virtual bool GetSupportedLocationByIndex(uint32_t listIndex, LocationStructureWrapper & aSupportedLocation) = 0;

/**
* @brief Get a supported location that matches a locationID.
* @param[in] aLocationId the locationID to search for.
* @brief Get a supported location that matches a areaID.
* @param[in] aAreaId the areaID to search for.
* @param[out] listIndex the location's index in the list, if found.
* @param[out] aSupportedLocation copy of the location contents, if found.
* @return true if location found, false otherwise.
*
* @note may be overloaded in device implementation for optimization, if desired.
*/
virtual bool GetSupportedLocationById(uint32_t aLocationId, uint32_t & listIndex,
virtual bool GetSupportedLocationById(uint32_t aAreaId, uint32_t & listIndex,
LocationStructureWrapper & aSupportedLocation);

/**
@@ -183,7 +183,7 @@ class Delegate
* @param[in] modifiedLocation A location with the modified contents.
* @return true if successful, false otherwise.
*
* @note this function SHOULD double check that newLocation's locationID matches the object at listIndex.
* @note this function SHOULD double check that newLocation's areaID matches the object at listIndex.
*/
virtual bool ModifySupportedLocation(uint32_t listIndex, const LocationStructureWrapper & modifiedLocation) = 0;

@@ -288,23 +288,23 @@ class Delegate
virtual bool GetSelectedLocationByIndex(uint32_t listIndex, uint32_t & selectedLocation) = 0;

/**
* @return true if the aLocationId locationID is found in the SelectedLocations list, false otherwise.
* @return true if the aAreaId areaID is found in the SelectedLocations list, false otherwise.
*
* @note may be overloaded in device implementation for optimization, if desired.
*/
virtual bool IsSelectedLocation(uint32_t aLocationId);
virtual bool IsSelectedLocation(uint32_t aAreaId);

/**
* This method is called by the server instance to add a new selected location to the list.
* The server instance will ensure that the aLocationId references a SUPPORTED location, and is unique within selected
* The server instance will ensure that the aAreaId references a SUPPORTED location, and is unique within selected
* locations.
* @param[in] aLocationId The new locationID to add.
* @param[in] aAreaId The new areaID to add.
* @param[out] listIndex filled with the list index of the new location, if successful.
* @return true if successful, false otherwise.
*
* @note this function SHOULD double check that the added location won't exceed the maximum list size.
*/
virtual bool AddSelectedLocation(uint32_t aLocationId, uint32_t & listIndex) = 0;
virtual bool AddSelectedLocation(uint32_t aAreaId, uint32_t & listIndex) = 0;

/**
* @return true if selected locations was not already null, false otherwise.
@@ -325,23 +325,23 @@ class Delegate
virtual bool GetProgressElementByIndex(uint32_t listIndex, Structs::ProgressStruct::Type & aProgressElement) = 0;

/**
* @brief Get a progress element that matches a locationID.
* @param[in] aLocationId the locationID to search for.
* @brief Get a progress element that matches a areaID.
* @param[in] aAreaId the areaID to search for.
* @param[out] listIndex the location's index in the list, if found.
* @param[out] aProgressElement copy of the progress element contents, if found.
* @return true if a progress element is found, false otherwise.
*
* @note may be overloaded in device implementation for optimization, if desired.
*/
virtual bool GetProgressElementById(uint32_t aLocationId, uint32_t & listIndex,
virtual bool GetProgressElementById(uint32_t aAreaId, uint32_t & listIndex,
Structs::ProgressStruct::Type & aProgressElement);

/**
* @brief Is the progress element in the progress list?
* @param[in] aLocationId location id of the progress element.
* @param[in] aAreaId location id of the progress element.
* @return true if the progress element identified by Id is in the progress list.
*/
virtual bool IsProgressElement(uint32_t aLocationId);
virtual bool IsProgressElement(uint32_t aAreaId);

/**
* This method is called by the server instance to add a new progress element to the list.
@@ -361,7 +361,7 @@ class Delegate
* @param[in] modifiedProgressElement modified element's contents.
* @return true if successful, false otherwise.
*
* @note this function SHOULD double check that modifiedProgressElement's locationID matches the object at listIndex
* @note this function SHOULD double check that modifiedProgressElement's areaID matches the object at listIndex
*/
virtual bool ModifyProgressElement(uint32_t listIndex, const Structs::ProgressStruct::Type & modifiedProgressElement) = 0;

98 changes: 49 additions & 49 deletions src/app/clusters/service-area-server/service-area-server.cpp

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions src/app/clusters/service-area-server/service-area-server.h
Original file line number Diff line number Diff line change
@@ -139,9 +139,9 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface
// Supported Locations manipulators

/**
* @return true if a location with the aLocationId ID exists in the supported locations attribute. False otherwise.
* @return true if a location with the aAreaId ID exists in the supported locations attribute. False otherwise.
*/
bool IsSupportedLocation(uint32_t aLocationId);
bool IsSupportedLocation(uint32_t aAreaId);

/**
* @brief Check if the given location adheres to the restrictions required by the supported locations attribute.
@@ -152,12 +152,12 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface
/**
* @brief check if aLocation is unique with regard to supported locations.
* @param[in] aLocation the location to check.
* @param[out] ignoreLocationId if true, we do not check if the location ID is unique.
* @param[out] ignoreAreaId if true, we do not check if the area ID is unique.
* @return true if there isn't a location in supported locations that matches aLocation.
*
* @note This method may ignore checking the MapId uniqueness. This depends on whether the SupportedMaps attribute is null.
*/
bool IsUniqueSupportedLocation(const LocationStructureWrapper & aLocation, bool ignoreLocationId);
bool IsUniqueSupportedLocation(const LocationStructureWrapper & aLocation, bool ignoreAreaId);

/**
* @brief Check if changing the estimated end time attribute to aEstimatedEndTime requires the change to be reported.
@@ -169,7 +169,7 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface
public:
/**
* @brief Add new location to the supported locations list.
* @param[in] aLocationId unique identifier of this location.
* @param[in] aAreaId unique identifier of this location.
* @param[in] aMapId identifier of supported map.
* @param[in] aLocationName human readable name for this location (empty string if not used).
* @param[in] aFloorNumber represents floor level - negative values for below ground.
@@ -182,7 +182,7 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface
*
* @note if aLocationName is larger than kLocationNameMaxSize, it will be truncated.
*/
bool AddSupportedLocation(uint32_t aLocationId, const DataModel::Nullable<uint8_t> & aMapId, const CharSpan & aLocationName,
bool AddSupportedLocation(uint32_t aAreaId, const DataModel::Nullable<uint8_t> & aMapId, const CharSpan & aLocationName,
const DataModel::Nullable<int16_t> & aFloorNumber,
const DataModel::Nullable<Globals::AreaTypeTag> & aAreaType,
const DataModel::Nullable<Globals::LandmarkTag> & aLandmarkTag,
@@ -191,7 +191,7 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface

/**
* @brief Modify/replace an existing location in the supported locations list.
* @param[in] aLocationId unique identifier of this location.
* @param[in] aAreaId unique identifier of this location.
* @param[in] aMapId identifier of supported map (will not be modified).
* @param[in] aLocationName human readable name for this location (empty string if not used).
* @param[in] aFloorNumber represents floor level - negative values for below ground.
@@ -206,7 +206,7 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface
* @note if aLocationName is larger than kLocationNameMaxSize, it will be truncated.
* @note if mapID is changed, the delegate's HandleSupportedLocationsUpdated method is called.
*/
bool ModifySupportedLocation(uint32_t aLocationId, const DataModel::Nullable<uint8_t> & aMapId, const CharSpan & aLocationName,
bool ModifySupportedLocation(uint32_t aAreaId, const DataModel::Nullable<uint8_t> & aMapId, const CharSpan & aLocationName,
const DataModel::Nullable<int16_t> & aFloorNumber,
const DataModel::Nullable<Globals::AreaTypeTag> & aAreaType,
const DataModel::Nullable<Globals::LandmarkTag> & aLandmarkTag,
@@ -258,7 +258,7 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface

/**
* @brief Add a selected location.
* @param[in] aSelectedLocation The locationID to add.
* @param[in] aSelectedLocation The areaID to add.
* @bool true if successfully added.
*/
bool AddSelectedLocation(uint32_t & aSelectedLocation);
@@ -274,7 +274,7 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface
DataModel::Nullable<uint32_t> GetCurrentLocation();

/**
* @param[in] aCurrentLocation The location ID that the CurrentLocation attribute should be set to. Must be a supported location
* @param[in] aCurrentLocation The area ID that the CurrentLocation attribute should be set to. Must be a supported location
* or NULL.
* @return true if the current location is set, false otherwise.
*
@@ -303,36 +303,36 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface

/**
* @brief Add a progress element in a pending status to the progress list.
* @param[in] aLocationId location id of the progress element.
* @param[in] aAreaId location id of the progress element.
* @return true if the new progress element passed validation checks and was successfully added to the list, false otherwise.
*/
bool AddPendingProgressElement(uint32_t aLocationId);
bool AddPendingProgressElement(uint32_t aAreaId);

/**
* @brief Set the status of progress element identified by locationID.
* @param[in] aLocationId The locationID of the progress element to update.
* @brief Set the status of progress element identified by areaID.
* @param[in] aAreaId The areaID of the progress element to update.
* @param[in] status The location cluster operation status for this location.
* @return true if progress element is found and status is set, false otherwise.
*
* @note TotalOperationalTime is set to null if resulting opStatus is not equal to Completed or Skipped.
*/
bool SetProgressStatus(uint32_t aLocationId, OperationalStatusEnum opStatus);
bool SetProgressStatus(uint32_t aAreaId, OperationalStatusEnum opStatus);

/**
* @brief Set the total operational time for the progress element identified by locationID.
* @param[in] aLocationId The locationID of the progress element to update.
* @brief Set the total operational time for the progress element identified by areaID.
* @param[in] aAreaId The areaID of the progress element to update.
* @param[in] aTotalOperationalTime The total operational time for this location.
* @return true if progress element is found and operational time is set, false otherwise.
*/
bool SetProgressTotalOperationalTime(uint32_t aLocationId, const DataModel::Nullable<uint32_t> & aTotalOperationalTime);
bool SetProgressTotalOperationalTime(uint32_t aAreaId, const DataModel::Nullable<uint32_t> & aTotalOperationalTime);

/**
* @brief Set the estimated time for the progress element identified by locationID.
* @param[in] aLocationId The locationID of the progress element to update.
* @brief Set the estimated time for the progress element identified by areaID.
* @param[in] aAreaId The areaID of the progress element to update.
* @param[in] aEstimatedTime The estimated time for this location.
* @return true if progress element is found and estimated time is set, false otherwise.
*/
bool SetProgressEstimatedTime(uint32_t aLocationId, const DataModel::Nullable<uint32_t> & aEstimatedTime);
bool SetProgressEstimatedTime(uint32_t aAreaId, const DataModel::Nullable<uint32_t> & aEstimatedTime);

/**
* @return true if the progress list was not already null, false otherwise.