Skip to content

Commit

Permalink
Implementation of service area server (#33991)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
7 people authored Jul 31, 2024
1 parent 45196ac commit 161b256
Show file tree
Hide file tree
Showing 23 changed files with 3,432 additions and 269 deletions.
1 change: 1 addition & 0 deletions examples/rvc-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ executable("chip-rvc-app") {
"${chip_root}/examples/rvc-app/rvc-common/src/rvc-device.cpp",
"${chip_root}/examples/rvc-app/rvc-common/src/rvc-mode-delegates.cpp",
"${chip_root}/examples/rvc-app/rvc-common/src/rvc-operational-state-delegate.cpp",
"${chip_root}/examples/rvc-app/rvc-common/src/rvc-service-area-delegate.cpp",
"RvcAppCommandDelegate.cpp",
"include/CHIPProjectAppConfig.h",
"main.cpp",
Expand Down
9 changes: 8 additions & 1 deletion examples/rvc-app/rvc-common/include/rvc-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

#include "rvc-mode-delegates.h"
#include "rvc-operational-state-delegate.h"
#include "rvc-service-area-delegate.h"
#include <app/clusters/mode-base-server/mode-base-server.h>
#include <app/clusters/operational-state-server/operational-state-server.h>
#include <app/clusters/service-area-server/service-area-delegate.h>
#include <app/clusters/service-area-server/service-area-server.h>

#include <string>

Expand All @@ -23,6 +26,9 @@ class RvcDevice
RvcOperationalState::RvcOperationalStateDelegate mOperationalStateDelegate;
RvcOperationalState::Instance mOperationalStateInstance;

ServiceArea::RvcServiceAreaDelegate mServiceAreaDelegate;
ServiceArea::Instance mServiceAreaInstance;

bool mDocked = false;
bool mCharging = false;

Expand All @@ -37,7 +43,8 @@ class RvcDevice
explicit RvcDevice(EndpointId aRvcClustersEndpoint) :
mRunModeDelegate(), mRunModeInstance(&mRunModeDelegate, aRvcClustersEndpoint, RvcRunMode::Id, 0), mCleanModeDelegate(),
mCleanModeInstance(&mCleanModeDelegate, aRvcClustersEndpoint, RvcCleanMode::Id, 0), mOperationalStateDelegate(),
mOperationalStateInstance(&mOperationalStateDelegate, aRvcClustersEndpoint)
mOperationalStateInstance(&mOperationalStateDelegate, aRvcClustersEndpoint), mServiceAreaDelegate(),
mServiceAreaInstance(&mServiceAreaDelegate, aRvcClustersEndpoint, BitMask<ServiceArea::Feature>(0))
{
// set the current-mode at start-up
mRunModeInstance.UpdateCurrentMode(RvcRunMode::ModeIdle);
Expand Down
124 changes: 124 additions & 0 deletions examples/rvc-app/rvc-common/include/rvc-service-area-delegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <app/clusters/service-area-server/service-area-server.h>
#include <app/util/config.h>
#include <cstring>
#include <utility>

namespace chip {
namespace app {
namespace Clusters {

class RvcDevice;

namespace ServiceArea {

class RvcServiceAreaDelegate : public Delegate
{
private:
// containers for array attributes.
std::vector<ServiceArea::LocationStructureWrapper> mSupportedLocations;
std::vector<ServiceArea::MapStructureWrapper> mSupportedMaps;
std::vector<uint32_t> mSelectedLocations;
std::vector<ServiceArea::Structs::ProgressStruct::Type> mProgressList;

public:
CHIP_ERROR Init() override;

// command support
bool IsSetSelectedLocationsAllowed(MutableCharSpan statusText) override;

bool IsValidSelectLocationsSet(const ServiceArea::Commands::SelectLocations::DecodableType & req,
ServiceArea::SelectLocationsStatus & locationStatus, MutableCharSpan statusText) override;

bool HandleSkipCurrentLocation(MutableCharSpan skipStatusText) override;

//*************************************************************************
// Supported Locations accessors

bool IsSupportedLocationsChangeAllowed() override;

uint32_t GetNumberOfSupportedLocations() override;

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

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

bool AddSupportedLocation(const ServiceArea::LocationStructureWrapper & newLocation, uint32_t & listIndex) override;

bool ModifySupportedLocation(uint32_t listIndex, const ServiceArea::LocationStructureWrapper & modifiedLocation) override;

bool ClearSupportedLocations() override;

//*************************************************************************
// Supported Maps accessors

bool IsSupportedMapChangeAllowed() override;

uint32_t GetNumberOfSupportedMaps() override;

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

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

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

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

bool ClearSupportedMaps() override;

//*************************************************************************
// Selected Locations accessors

uint32_t GetNumberOfSelectedLocations() override;

bool GetSelectedLocationByIndex(uint32_t listIndex, uint32_t & selectedLocation) override;

// IsSelectedLocation() no override

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

bool ClearSelectedLocations() override;

//*************************************************************************
// Progress accessors

uint32_t GetNumberOfProgressElements() override;

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

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

bool AddProgressElement(const ServiceArea::Structs::ProgressStruct::Type & newProgressElement, uint32_t & listIndex) override;

bool ModifyProgressElement(uint32_t listIndex,
const ServiceArea::Structs::ProgressStruct::Type & modifiedProgressElement) override;

bool ClearProgress() override;
};

} // namespace ServiceArea

} // namespace Clusters
} // namespace app
} // namespace chip
Loading

0 comments on commit 161b256

Please sign in to comment.