Skip to content

Commit

Permalink
Update service area xml from 07 (project-chip#34738)
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.

* Explicitly set the Service Area version.

* Zap generated after XML update.

* Updated the service area features in the XML to match the current spec.

* Zap generated after XML update.

* Updated the SupportedArea validation logic as if the MAPS feature is not supported, the Delegate may choose not to implement map related methods.

* Change the type of the MapID to uint32 to match the spec.

* Added the SkippedArea arg to the SkipArea command.

* Zap generated after XML update.

* Updated the Service Area server code to handle the new SkippedArea command arg.

* Updated the service area XML to match the current spec. This includes the addition of the LandmarkInfoStruct and updates of AreaInfoStruct, SelectAreasStatus.

* Zap generated after XML update.

* Updated SDK server code and rvc-example after changes to the XML.

* Restyled by whitespace

* added vector include.

* spacing changes form zap regen.

* Fixed minor mistake during merge.

* Restyled by clang-format

* Applied suggestions from review.

* Restyled by whitespace

* Updated the LondmarkInfoSturct PositionTag type.

* Zap generated after XML update.

* Fixed SDK following update to the position type.

* Restyled by clang-format

* Missed a submudule update.

---------

Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
hicklin and restyled-commits authored Aug 7, 2024
1 parent fa29225 commit 599fd16
Show file tree
Hide file tree
Showing 48 changed files with 911 additions and 555 deletions.
3 changes: 2 additions & 1 deletion examples/rvc-app/rvc-common/include/rvc-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class RvcDevice
mRunModeDelegate(), mRunModeInstance(&mRunModeDelegate, aRvcClustersEndpoint, RvcRunMode::Id, 0), mCleanModeDelegate(),
mCleanModeInstance(&mCleanModeDelegate, aRvcClustersEndpoint, RvcCleanMode::Id, 0), mOperationalStateDelegate(),
mOperationalStateInstance(&mOperationalStateDelegate, aRvcClustersEndpoint), mServiceAreaDelegate(),
mServiceAreaInstance(&mServiceAreaDelegate, aRvcClustersEndpoint, BitMask<ServiceArea::Feature>(0))
mServiceAreaInstance(&mServiceAreaDelegate, aRvcClustersEndpoint,
BitMask<ServiceArea::Feature>(ServiceArea::Feature::kMaps, ServiceArea::Feature::kProgressReporting))
{
// set the current-mode at start-up
mRunModeInstance.UpdateCurrentMode(RvcRunMode::ModeIdle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RvcServiceAreaDelegate : public Delegate
bool IsValidSelectAreasSet(const ServiceArea::Commands::SelectAreas::DecodableType & req,
ServiceArea::SelectAreasStatus & locationStatus, MutableCharSpan statusText) override;

bool HandleSkipCurrentArea(MutableCharSpan skipStatusText) override;
bool HandleSkipCurrentArea(uint32_t skippedArea, MutableCharSpan skipStatusText) override;

//*************************************************************************
// Supported Locations accessors
Expand Down Expand Up @@ -78,7 +78,7 @@ class RvcServiceAreaDelegate : public Delegate

bool GetSupportedMapByIndex(uint32_t listIndex, ServiceArea::MapStructureWrapper & supportedMap) override;

bool GetSupportedMapById(uint8_t aMapId, uint32_t & listIndex, ServiceArea::MapStructureWrapper & supportedMap) override;
bool GetSupportedMapById(uint32_t aMapId, uint32_t & listIndex, ServiceArea::MapStructureWrapper & supportedMap) override;

bool AddSupportedMap(const ServiceArea::MapStructureWrapper & newMap, uint32_t & listIndex) override;

Expand Down
35 changes: 22 additions & 13 deletions examples/rvc-app/rvc-common/rvc-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1424,9 +1424,9 @@ cluster RvcOperationalState = 97 {
command GoHome(): OperationalCommandResponse = 128;
}

/** The Service Area cluster provides an interface for controlling the locations where a device should operate, and for querying the current location. */
/** The Service Area cluster provides an interface for controlling the areas where a device should operate, and for querying the current area being serviced. */
provisional cluster ServiceArea = 336 {
revision 1; // NOTE: Default/not specifically set
revision 1;

enum OperationalStatusEnum : enum8 {
kPending = 0;
Expand All @@ -1447,28 +1447,33 @@ provisional cluster ServiceArea = 336 {
kSuccess = 0;
kInvalidAreaList = 1;
kInvalidInMode = 2;
kInvalidSkippedArea = 3;
}

bitmap Feature : bitmap32 {
kListOrder = 0x1;
kSelectWhileRunning = 0x2;
kSelectWhileRunning = 0x1;
kProgressReporting = 0x2;
kMaps = 0x4;
}

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

struct AreaInfoStruct {
nullable LocationDescriptorStruct locationInfo = 0;
nullable LandmarkTag landmarkTag = 1;
nullable PositionTag positionTag = 2;
nullable FloorSurfaceTag surfaceTag = 3;
nullable LandmarkInfoStruct landmarkInfo = 1;
}

struct AreaStruct {
int32u areaID = 0;
nullable int8u mapID = 1;
nullable int32u mapID = 1;
AreaInfoStruct areaDesc = 2;
}

struct MapStruct {
int8u mapID = 0;
int32u mapID = 0;
char_string<64> name = 1;
}

Expand All @@ -1480,7 +1485,7 @@ provisional cluster ServiceArea = 336 {
}

readonly attribute AreaStruct supportedAreas[] = 0;
readonly attribute MapStruct supportedMaps[] = 1;
readonly attribute optional MapStruct supportedMaps[] = 1;
readonly attribute int32u selectedAreas[] = 2;
readonly attribute optional nullable int32u currentArea = 3;
readonly attribute optional nullable epoch_s estimatedEndTime = 4;
Expand All @@ -1498,18 +1503,22 @@ provisional cluster ServiceArea = 336 {

response struct SelectAreasResponse = 1 {
SelectAreasStatus status = 0;
optional char_string<256> statusText = 1;
char_string<256> statusText = 1;
}

request struct SkipAreaRequest {
int32u skippedArea = 0;
}

response struct SkipAreaResponse = 3 {
SkipAreaStatus status = 0;
optional char_string<256> statusText = 1;
char_string<256> statusText = 1;
}

/** Command used to select a set of device areas, where the device is to operate. */
command SelectAreas(SelectAreasRequest): SelectAreasResponse = 0;
/** This command is used to skip an area where the device operates. */
command SkipArea(): SkipAreaResponse = 2;
command SkipArea(SkipAreaRequest): SkipAreaResponse = 2;
}

endpoint 0 {
Expand Down
38 changes: 18 additions & 20 deletions examples/rvc-app/rvc-common/src/rvc-service-area-delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
#include <app-common/zap-generated/attributes/Accessors.h>
#include <rvc-service-area-delegate.h>
#include <vector>

using namespace chip;
using namespace chip::app::Clusters;
Expand All @@ -25,8 +26,8 @@ using namespace chip::app::Clusters::ServiceArea;
CHIP_ERROR RvcServiceAreaDelegate::Init()
{
// hardcoded fill of SUPPORTED MAPS for prototyping
uint8_t supportedMapId_XX = 3;
uint8_t supportedMapId_YY = 245;
uint32_t supportedMapId_XX = 3;
uint32_t supportedMapId_YY = 245;

GetInstance()->AddSupportedMap(supportedMapId_XX, "My Map XX"_span);
GetInstance()->AddSupportedMap(supportedMapId_YY, "My Map YY"_span);
Expand All @@ -38,32 +39,29 @@ CHIP_ERROR RvcServiceAreaDelegate::Init()
uint32_t supportedAreaID_D = 0x88888888;

// Location A has name, floor number, uses map XX
GetInstance()->AddSupportedLocation(
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>());
GetInstance()->AddSupportedLocation(supportedAreaID_A, DataModel::Nullable<uint32_t>(supportedMapId_XX), "My Location A"_span,
DataModel::Nullable<int16_t>(4), DataModel::Nullable<Globals::AreaTypeTag>(),
DataModel::Nullable<Globals::LandmarkTag>(),
DataModel::Nullable<Globals::RelativePositionTag>());

// Location B has name, uses map XX
GetInstance()->AddSupportedLocation(
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>());
GetInstance()->AddSupportedLocation(supportedAreaID_B, DataModel::Nullable<uint32_t>(supportedMapId_XX), "My Location B"_span,
DataModel::Nullable<int16_t>(), DataModel::Nullable<Globals::AreaTypeTag>(),
DataModel::Nullable<Globals::LandmarkTag>(),
DataModel::Nullable<Globals::RelativePositionTag>());

// Location C has full SemData, no name, Map YY
GetInstance()->AddSupportedLocation(supportedAreaID_C, DataModel::Nullable<uint_fast8_t>(supportedMapId_YY), CharSpan(),
GetInstance()->AddSupportedLocation(supportedAreaID_C, DataModel::Nullable<uint32_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::kLeft),
DataModel::Nullable<Globals::FloorSurfaceTag>(Globals::FloorSurfaceTag::kConcrete));
DataModel::Nullable<Globals::RelativePositionTag>(Globals::RelativePositionTag::kNextTo));

// Location D has null values for all HomeLocationStruct fields, Map YY
GetInstance()->AddSupportedLocation(supportedAreaID_D, DataModel::Nullable<uint_fast8_t>(supportedMapId_YY),
"My Location D"_span, DataModel::Nullable<int16_t>(),
DataModel::Nullable<Globals::AreaTypeTag>(),
GetInstance()->AddSupportedLocation(supportedAreaID_D, DataModel::Nullable<uint32_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::kLeft),
DataModel::Nullable<Globals::FloorSurfaceTag>(Globals::FloorSurfaceTag::kHardwood));
DataModel::Nullable<Globals::RelativePositionTag>(Globals::RelativePositionTag::kNextTo));

GetInstance()->SetCurrentArea(supportedAreaID_C);

Expand All @@ -86,7 +84,7 @@ bool RvcServiceAreaDelegate::IsValidSelectAreasSet(const Commands::SelectAreas::
return true;
};

bool RvcServiceAreaDelegate::HandleSkipCurrentArea(MutableCharSpan skipStatusText)
bool RvcServiceAreaDelegate::HandleSkipCurrentArea(uint32_t skippedArea, MutableCharSpan skipStatusText)
{
// TODO IMPLEMENT
return true;
Expand Down Expand Up @@ -213,7 +211,7 @@ bool RvcServiceAreaDelegate::GetSupportedMapByIndex(uint32_t listIndex, MapStruc
return false;
};

bool RvcServiceAreaDelegate::GetSupportedMapById(uint8_t aMapId, uint32_t & listIndex, MapStructureWrapper & aSupportedMap)
bool RvcServiceAreaDelegate::GetSupportedMapById(uint32_t aMapId, uint32_t & listIndex, MapStructureWrapper & aSupportedMap)
{
// We do not need to reimplement this method as it's already done by the SDK.
// We are reimplementing this method, still using linear search, but with some optimization on the SDK implementation
Expand Down
Loading

0 comments on commit 599fd16

Please sign in to comment.