Skip to content

Commit 161b256

Browse files
hicklinjohnfierkekiel-appleplauricrestyled-commits
authored
Implementation of service area server (#33991)
* Add definitions for common HomeLocationStruct and types - see connectedhomeip-spec PR 8933 * Add definition for Service Area Cluster - see connectedhomeip-spec PR 8937 * Add semantic tag definitions needed for Service Area Cluster - see connectedhomeip-spec PR 8937 * Update Service Area Cluster definition of LocationInfoStruct - see connectedhomeip-spec PR 8937 * Rename SurfaceTag to FloorSurfaceTag - spec PR 8937 commit 431739b3e3996d0ef74a36b2a6b93ac0d3db9c45 * Fix Carport typo, remove IsGroundFloor field (spec change) * Update home location definitions per spec PR 8933 commit f04958166412d5b7eff4d3443273f47f12f22baf 2024-05-23 * update generated files * Update Service Area Cluster definitions per spec PR 8937 up to commit 6bf3762eb1ee733c642e79074744d1185b82a89c 2024-05-24 * update generated files * Initial implementations of service-area-cluster per spec PR 8937 up to commit 6bf3762eb1ee733c642e79074744d1185b82a89c 2024-05-24 * Regenerated zap files after merge. * Moved the AreaTypeTag namespace definition to namespaces.xml. * Moved the HomeLoc global struct into global-sturcts.xml. * Updated the AreaTypeTag namespace to match the latest spec definition. * Updated the AreaTypeTag namespace to match the latest spec definition. * Updated the matterlint rules with the changes in the xml files. * Reverted changes to the rvc zap file. * Addded global xml files to relevant lists of xmls. * Added the Position, Landmark and Floor Surface Namespaces. * Removed namespace tag definitions from the service area cluters XML. * Regenerated zap files. * Rewrite service-area-server and delegate to avoid disallowed c++ containers * Regenerated zap files. * Regenerated zap files. * Explicitly set the conformance. * Fixed typos in the service-area clusters XML from review. * Used a more feature rich method for defining the cluster's features. * Reordered data-type definitions to match the order in the spec. * Regenerated zap files. * Updated the service area type names following fixes to the XMLs. * Updated the rvc-example type names following fixes to the XMLs. * Simplified some of the logic in the service-area cluster objects. * Added an InEqual method to the LocationSturctureWrapper and simplified the Instance::IsUniqueSupportedLocation impl. * Removed the handle volotile methos as the delegate should be responsibel for updating these values as they change. * Apply editorial suggestions from code review. Includes a minor bug fix. Co-authored-by: Kiel Oleson <kielo@apple.com> Co-authored-by: Petru Lauric <81822411+plauric@users.noreply.github.com> * Replaced Location Location in the logging text with Service Area. * Implemented some renaming and editorial changes from review. Moved some service area methods from public to private. * Added the ServicArea to the controller init.py * Moved the HandleSupportedLocationsUpdated method form the instance to the server. * Moved delegate implementations to the .cpp * Removed calling the HandleSupportedLocationsUpdate when adding a new supported location as the restrictions imposed on the SelectedLocations, CurrentLocation and Progress attributs are maintained. * Removed calling the HandleSupportedLocationsUpdate when adding a new supported map as the restrictions imposed on the SupprotedLocations attribut are maintained. * Renamed a delegate method and updated it's documentation. * Reverted a change to the darwin file for apple engineers to make. * Removed the optional cluster id prameter from the service area Instance constructor. * Removed unneeded check. * Added a way to get the Service Area instance from the delegate. Added a virtual Init method to the Service area delegate. * Moved the rvc service area delegate impl out of the rvc device class and into it's own class. * Comment chages to the service area delegate in the rvc example app. * Added github issue to a comment. * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Restyled by isort * zap regen after pull. * Updated the Service Area code documentation following a review comment. Move the IsProgressElement to the delegate and added a default implementation. * Restyled by whitespace * Restyled by clang-format * Renamed DoseNameMatch to IsNameEqual. * Replaced the multiple bool inputs of the IsEqual method with a BitMask. * Removed the use of ret_value to improve readability. * Removed redundant ; * Removed redundant use of the namespaces. * Moved the empty impl of MatterServiceAreaPluginServerInitCallback to util. * Simplified some method returns. * Updated a log level. * Removed extra logs while reading attributes. * Removed else after if return. * Fixed sizeof-array-decay warning. * Cast all std::vector.size() returns in the RVC service area delegate to uint32_t. The service area server limits the size of these lists to 255. * Change the way the Delegate and Instance classes are stopped from being copyabel. * Fixed a bug that was causing the clang-tidy CI test to seg fault. * Restyled by clang-format * Renamed namespaces.xml to semantic-tag-namespace-enums.xml. * Missed some rename locations. * Regenerated zap files after sync with upstream. * Fixed typos from review. * Fixed the termination of the Location and Map structure wrappers' name buffers. * - Replaced the use of `char *` with `MutableCharSpan`. - Removed the use of the VerifyOrExit macro. - Removed `IsSupportedMapChangeAllowed` check in the `AddSupportedMap` method as adding maps does not compromise any of the other attributes. * Restyled by clang-format * Refactored out the use of ret_value. * Removed an unused method in the rvc-app * Refactored rvc-app to use static casts. * Fixed missing ; * Restyled by clang-format * Rplaced the use of fromCharSpan with _span in the rvc-app. * Removed unneeded casting. * Removed unnecessary null terminations in the service area struct wrappers. * Fixed an error in the docs. * Restyled by clang-format * Moved the responsibility of checking for duplicates in the selected locations command attribute to the server. * Restyled by clang-format * Removed unneccessary memset. * Updated some docs. * Removed unneeded Raw() call. * Added attribute ID to reading log. * Removed the use of __func__ * Fixed incorrect command handling statuses. * Fixed some code documentation. * Fixed bug in handling of errorStatusTexts from the delegate. * Rnamed dummy vars as ignored. * Fixed the printing of map name. * Replaced use of Nullable<type> with NullNullable. * Added a log that was commented out. * Added non-list service area attributes to the list of attributeAccessInterfaceAttributes. * Fixed bug relateing to getting a null value. * Improved the readability of the logic for determining if a change to the service area's estimated end time attribute should be reported. * Do not report CurrentLocation change if it does not change. * Simplified logic returns Co-authored-by: Andrei Litvin <andy314@gmail.com> * Restyled by whitespace * Restyled by clang-format * Restyled by prettier-json * Changed the way the Commond Handler Interface is registered following the merge. * Made all delegate methods public. Removed the Instance class from being a friend of the Delegated class. * Restyled by clang-format * Reduced the socope of variabels to improve readability. * Regenerated zap files after sync with upstream. * Fixed name change of LocationDescriptorStruct * Restyled by clang-format * Added FeatureMap to the list of attributeAccessInterfaceAttributes. * Do not consider list of 0 as error. * Fixed attribute ID printing. * Apply suggestions from code review Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Generated zap code after merge. * Fixed the logic of the ReportEstimatedEndTimeChange method. --------- Co-authored-by: jfierke@irobot.com <jfierke@irobot.com> Co-authored-by: Kiel Oleson <kielo@apple.com> Co-authored-by: Petru Lauric <81822411+plauric@users.noreply.github.com> Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Andrei Litvin <andy314@gmail.com> Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent 45196ac commit 161b256

23 files changed

+3432
-269
lines changed

examples/rvc-app/linux/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ executable("chip-rvc-app") {
2727
"${chip_root}/examples/rvc-app/rvc-common/src/rvc-device.cpp",
2828
"${chip_root}/examples/rvc-app/rvc-common/src/rvc-mode-delegates.cpp",
2929
"${chip_root}/examples/rvc-app/rvc-common/src/rvc-operational-state-delegate.cpp",
30+
"${chip_root}/examples/rvc-app/rvc-common/src/rvc-service-area-delegate.cpp",
3031
"RvcAppCommandDelegate.cpp",
3132
"include/CHIPProjectAppConfig.h",
3233
"main.cpp",

examples/rvc-app/rvc-common/include/rvc-device.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
#include "rvc-mode-delegates.h"
44
#include "rvc-operational-state-delegate.h"
5+
#include "rvc-service-area-delegate.h"
56
#include <app/clusters/mode-base-server/mode-base-server.h>
67
#include <app/clusters/operational-state-server/operational-state-server.h>
8+
#include <app/clusters/service-area-server/service-area-delegate.h>
9+
#include <app/clusters/service-area-server/service-area-server.h>
710

811
#include <string>
912

@@ -23,6 +26,9 @@ class RvcDevice
2326
RvcOperationalState::RvcOperationalStateDelegate mOperationalStateDelegate;
2427
RvcOperationalState::Instance mOperationalStateInstance;
2528

29+
ServiceArea::RvcServiceAreaDelegate mServiceAreaDelegate;
30+
ServiceArea::Instance mServiceAreaInstance;
31+
2632
bool mDocked = false;
2733
bool mCharging = false;
2834

@@ -37,7 +43,8 @@ class RvcDevice
3743
explicit RvcDevice(EndpointId aRvcClustersEndpoint) :
3844
mRunModeDelegate(), mRunModeInstance(&mRunModeDelegate, aRvcClustersEndpoint, RvcRunMode::Id, 0), mCleanModeDelegate(),
3945
mCleanModeInstance(&mCleanModeDelegate, aRvcClustersEndpoint, RvcCleanMode::Id, 0), mOperationalStateDelegate(),
40-
mOperationalStateInstance(&mOperationalStateDelegate, aRvcClustersEndpoint)
46+
mOperationalStateInstance(&mOperationalStateDelegate, aRvcClustersEndpoint), mServiceAreaDelegate(),
47+
mServiceAreaInstance(&mServiceAreaDelegate, aRvcClustersEndpoint, BitMask<ServiceArea::Feature>(0))
4148
{
4249
// set the current-mode at start-up
4350
mRunModeInstance.UpdateCurrentMode(RvcRunMode::ModeIdle);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#pragma once
20+
21+
#include <app/clusters/service-area-server/service-area-server.h>
22+
#include <app/util/config.h>
23+
#include <cstring>
24+
#include <utility>
25+
26+
namespace chip {
27+
namespace app {
28+
namespace Clusters {
29+
30+
class RvcDevice;
31+
32+
namespace ServiceArea {
33+
34+
class RvcServiceAreaDelegate : public Delegate
35+
{
36+
private:
37+
// containers for array attributes.
38+
std::vector<ServiceArea::LocationStructureWrapper> mSupportedLocations;
39+
std::vector<ServiceArea::MapStructureWrapper> mSupportedMaps;
40+
std::vector<uint32_t> mSelectedLocations;
41+
std::vector<ServiceArea::Structs::ProgressStruct::Type> mProgressList;
42+
43+
public:
44+
CHIP_ERROR Init() override;
45+
46+
// command support
47+
bool IsSetSelectedLocationsAllowed(MutableCharSpan statusText) override;
48+
49+
bool IsValidSelectLocationsSet(const ServiceArea::Commands::SelectLocations::DecodableType & req,
50+
ServiceArea::SelectLocationsStatus & locationStatus, MutableCharSpan statusText) override;
51+
52+
bool HandleSkipCurrentLocation(MutableCharSpan skipStatusText) override;
53+
54+
//*************************************************************************
55+
// Supported Locations accessors
56+
57+
bool IsSupportedLocationsChangeAllowed() override;
58+
59+
uint32_t GetNumberOfSupportedLocations() override;
60+
61+
bool GetSupportedLocationByIndex(uint32_t listIndex, ServiceArea::LocationStructureWrapper & supportedLocation) override;
62+
63+
bool GetSupportedLocationById(uint32_t aLocationId, uint32_t & listIndex,
64+
ServiceArea::LocationStructureWrapper & supportedLocation) override;
65+
66+
bool AddSupportedLocation(const ServiceArea::LocationStructureWrapper & newLocation, uint32_t & listIndex) override;
67+
68+
bool ModifySupportedLocation(uint32_t listIndex, const ServiceArea::LocationStructureWrapper & modifiedLocation) override;
69+
70+
bool ClearSupportedLocations() override;
71+
72+
//*************************************************************************
73+
// Supported Maps accessors
74+
75+
bool IsSupportedMapChangeAllowed() override;
76+
77+
uint32_t GetNumberOfSupportedMaps() override;
78+
79+
bool GetSupportedMapByIndex(uint32_t listIndex, ServiceArea::MapStructureWrapper & supportedMap) override;
80+
81+
bool GetSupportedMapById(uint8_t aMapId, uint32_t & listIndex, ServiceArea::MapStructureWrapper & supportedMap) override;
82+
83+
bool AddSupportedMap(const ServiceArea::MapStructureWrapper & newMap, uint32_t & listIndex) override;
84+
85+
bool ModifySupportedMap(uint32_t listIndex, const ServiceArea::MapStructureWrapper & newMap) override;
86+
87+
bool ClearSupportedMaps() override;
88+
89+
//*************************************************************************
90+
// Selected Locations accessors
91+
92+
uint32_t GetNumberOfSelectedLocations() override;
93+
94+
bool GetSelectedLocationByIndex(uint32_t listIndex, uint32_t & selectedLocation) override;
95+
96+
// IsSelectedLocation() no override
97+
98+
bool AddSelectedLocation(uint32_t aLocationId, uint32_t & listIndex) override;
99+
100+
bool ClearSelectedLocations() override;
101+
102+
//*************************************************************************
103+
// Progress accessors
104+
105+
uint32_t GetNumberOfProgressElements() override;
106+
107+
bool GetProgressElementByIndex(uint32_t listIndex, ServiceArea::Structs::ProgressStruct::Type & aProgressElement) override;
108+
109+
bool GetProgressElementById(uint32_t aLocationId, uint32_t & listIndex,
110+
ServiceArea::Structs::ProgressStruct::Type & aProgressElement) override;
111+
112+
bool AddProgressElement(const ServiceArea::Structs::ProgressStruct::Type & newProgressElement, uint32_t & listIndex) override;
113+
114+
bool ModifyProgressElement(uint32_t listIndex,
115+
const ServiceArea::Structs::ProgressStruct::Type & modifiedProgressElement) override;
116+
117+
bool ClearProgress() override;
118+
};
119+
120+
} // namespace ServiceArea
121+
122+
} // namespace Clusters
123+
} // namespace app
124+
} // namespace chip

0 commit comments

Comments
 (0)