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

Handle the RvcOperationalState GoHome command #31289

Merged
merged 30 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0976e3b
Added the RvcOpearationalState specific command GoHome to the XML.
hicklin Jan 4, 2024
8cff269
Regenerated files from XMLs.
hicklin Jan 4, 2024
973c150
Added a virtual method to the base operational state class that allow…
hicklin Jan 4, 2024
cfcf293
Added a mechanism by which the OperationalState cluster can call deri…
hicklin Jan 5, 2024
3caa3a4
Implemented a default implementation of the RvcOperationalState::Dele…
hicklin Jan 5, 2024
9a4a9ed
Restyled by clang-format
restyled-commits Jan 8, 2024
9e49ea3
Merge branch 'master' into RvcOpState_add_GoHome_command
hicklin Jan 8, 2024
a9bc90d
Regenerated files from XMLs after merging changes in master.
hicklin Jan 8, 2024
255c976
Merge branch 'RvcOpState_add_GoHome_command' into Handle_RvcOpState_G…
hicklin Jan 8, 2024
feed0db
Separated the RVC OpState delegate implementation in the all-clusters…
hicklin Jan 8, 2024
472aff7
Enabled the GoHome command in the all-clusters-app zap file.
hicklin Jan 8, 2024
c524379
Enabled the GoHome command in the rvc-pp zap file.
hicklin Jan 8, 2024
f4e2f2d
Restyled by clang-format
restyled-commits Jan 8, 2024
db51705
Restyled by gn
restyled-commits Jan 8, 2024
9faf98c
Merge remote-tracking branch 'origin' into RvcOpState_add_GoHome_command
mhazley Jan 9, 2024
9e95efb
Java file regen
mhazley Jan 9, 2024
35ae888
Merge branch 'RvcOpState_add_GoHome_command' into Handle_RvcOpState_G…
hicklin Jan 12, 2024
8b29518
Removed definition of the RvcOperationalState class as it was mistake…
hicklin Jan 12, 2024
e4749da
Fixed the RvcOpState delegate in the all-clusters-app since the Gener…
hicklin Jan 12, 2024
7e4048d
Added functions to get the OpratioalState and RvcOperationalState ins…
hicklin Jan 12, 2024
657348f
Merge branch 'master' into Handle_RvcOpState_GoHome_command
hicklin Jan 12, 2024
cfde2d5
Restyled by clang-format
restyled-commits Jan 12, 2024
2029c1a
Merge branch 'Handle_RvcOpState_GoHome_command' of github.com:dysonlt…
hicklin Jan 12, 2024
4e62a80
Merge branch 'master' into RvcOpState_add_GoHome_command accepting th…
hicklin Jan 17, 2024
c362f4d
Regenerated zap files.
hicklin Jan 17, 2024
08561d0
Added missing license to an all-clusters-app src file.
hicklin Jan 17, 2024
c3b929a
Restyled by clang-format
restyled-commits Jan 17, 2024
1fb5f9a
Merge branch 'RvcOpState_add_GoHome_command' into Handle_RvcOpState_G…
hicklin Jan 17, 2024
cbce399
Removed question comment.
hicklin Jan 18, 2024
e6d687d
Merge branch 'master' into Handle_RvcOpState_GoHome_command
hicklin Jan 18, 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
Original file line number Diff line number Diff line change
Expand Up @@ -3556,6 +3556,8 @@ cluster RvcOperationalState = 97 {
command Start(): OperationalCommandResponse = 2;
/** Upon receipt, the device SHALL resume its operation from the point it was at when it received the Pause command, or from the point when it was paused by means outside of this cluster (for example by manual button press). */
command Resume(): OperationalCommandResponse = 3;
/** On receipt of this command, the device SHALL start seeking the charging dock, if possible in the current state of the device. */
command GoHome(): OperationalCommandResponse = 128;
}

/** Attributes and commands for monitoring HEPA filters in a device */
Expand Down Expand Up @@ -7305,6 +7307,7 @@ endpoint 1 {
handle command Pause;
handle command Resume;
handle command OperationalCommandResponse;
handle command GoHome;
}

server cluster HepaFilterMonitoring {
Expand Down
21 changes: 14 additions & 7 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -8426,7 +8426,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -8458,7 +8458,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -8474,7 +8474,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -8490,7 +8490,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -8506,7 +8506,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -11075,6 +11075,14 @@
"source": "server",
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "GoHome",
"code": 128,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
}
],
"attributes": [
Expand Down Expand Up @@ -22660,5 +22668,4 @@
}
],
"log": []
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -116,42 +116,6 @@ class OperationalStateDelegate : public GenericOperationalStateDelegateImpl
void Shutdown();

} // namespace OperationalState

namespace RvcOperationalState {

// This is an application level delegate to handle operational state commands according to the specific business logic.
class RvcOperationalStateDelegate : public OperationalState::GenericOperationalStateDelegateImpl
{
private:
const OperationalState::GenericOperationalState rvcOpStateList[7] = {
OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kStopped)),
OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning)),
OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kPaused)),
OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kError)),
OperationalState::GenericOperationalState(
to_underlying(Clusters::RvcOperationalState::OperationalStateEnum::kSeekingCharger)),
OperationalState::GenericOperationalState(to_underlying(Clusters::RvcOperationalState::OperationalStateEnum::kCharging)),
OperationalState::GenericOperationalState(to_underlying(Clusters::RvcOperationalState::OperationalStateEnum::kDocked)),
};

const OperationalState::GenericOperationalPhase rvcOpPhaseList[1] = {
// Phase List is null
OperationalState::GenericOperationalPhase(DataModel::Nullable<CharSpan>()),
};

public:
RvcOperationalStateDelegate()
{
GenericOperationalStateDelegateImpl::mOperationalStateList =
Span<const OperationalState::GenericOperationalState>(rvcOpStateList);
GenericOperationalStateDelegateImpl::mOperationalPhaseList =
Span<const OperationalState::GenericOperationalPhase>(rvcOpPhaseList);
}
};

void Shutdown();

} // namespace RvcOperationalState
} // namespace Clusters
} // namespace app
} // namespace chip
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
*
* Copyright (c) 2023 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-common/zap-generated/cluster-objects.h>
#include <app/clusters/operational-state-server/operational-state-server.h>
#include <app/util/af-enums.h>
#include <protocols/interaction_model/StatusCode.h>

namespace chip {
namespace app {
namespace Clusters {

namespace RvcOperationalState {

// This is an application level delegate to handle operational state commands according to the specific business logic.
class RvcOperationalStateDelegate : public Delegate
{
private:
const Clusters::OperationalState::GenericOperationalState rvcOpStateList[7] = {
OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kStopped)),
OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning)),
OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kPaused)),
OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kError)),
OperationalState::GenericOperationalState(
to_underlying(Clusters::RvcOperationalState::OperationalStateEnum::kSeekingCharger)),
OperationalState::GenericOperationalState(to_underlying(Clusters::RvcOperationalState::OperationalStateEnum::kCharging)),
OperationalState::GenericOperationalState(to_underlying(Clusters::RvcOperationalState::OperationalStateEnum::kDocked)),
};

const OperationalState::GenericOperationalPhase rvcOpPhaseList[1] = {
// Phase List is null
OperationalState::GenericOperationalPhase(DataModel::Nullable<CharSpan>()),
};

Span<const OperationalState::GenericOperationalState> mOperationalStateList =
Span<const OperationalState::GenericOperationalState>(rvcOpStateList);
Span<const OperationalState::GenericOperationalPhase> mOperationalPhaseList =
Span<const OperationalState::GenericOperationalPhase>(rvcOpPhaseList);

public:
RvcOperationalStateDelegate() {}

/**
* Get the countdown time. This attribute is not used in this application.
* @return The current countdown time.
*/
app::DataModel::Nullable<uint32_t> GetCountdownTime() override { return {}; };

/**
* Fills in the provided GenericOperationalState with the state at index `index` if there is one,
* or returns CHIP_ERROR_NOT_FOUND if the index is out of range for the list of states.
* Note: This is used by the SDK to populate the operational state list attribute. If the contents of this list changes,
* the device SHALL call the Instance's ReportOperationalStateListChange method to report that this attribute has changed.
* @param index The index of the state, with 0 representing the first state.
* @param operationalState The GenericOperationalState is filled.
*/
CHIP_ERROR GetOperationalStateAtIndex(size_t index, OperationalState::GenericOperationalState & operationalState) override;

/**
* Fills in the provided GenericOperationalPhase with the phase at index `index` if there is one,
* or returns CHIP_ERROR_NOT_FOUND if the index is out of range for the list of phases.
* Note: This is used by the SDK to populate the phase list attribute. If the contents of this list changes, the
* device SHALL call the Instance's ReportPhaseListChange method to report that this attribute has changed.
* @param index The index of the phase, with 0 representing the first phase.
* @param operationalPhase The GenericOperationalPhase is filled.
*/
CHIP_ERROR GetOperationalPhaseAtIndex(size_t index, OperationalState::GenericOperationalPhase & operationalPhase) override;

// command callback
/**
* Handle Command Callback in application: Pause
* @param[out] get operational error after callback.
*/
void HandlePauseStateCallback(OperationalState::GenericOperationalError & err) override;

/**
* Handle Command Callback in application: Resume
* @param[out] get operational error after callback.
*/
void HandleResumeStateCallback(OperationalState::GenericOperationalError & err) override;

/**
* Handle Command Callback in application: Start
* @param[out] get operational error after callback.
*/
void HandleStartStateCallback(OperationalState::GenericOperationalError & err) override;

/**
* Handle Command Callback in application: Stop
* @param[out] get operational error after callback.
*/
void HandleStopStateCallback(OperationalState::GenericOperationalError & err) override;

/**
* Handle the GoHome command.
* @param err
*/
void HandleGoHomeCommandCallback(OperationalState::GenericOperationalError & err) override;
};

void Shutdown();

} // namespace RvcOperationalState
} // namespace Clusters
} // namespace app
} // namespace chip
Original file line number Diff line number Diff line change
Expand Up @@ -131,36 +131,3 @@ void emberAfOperationalStateClusterInitCallback(chip::EndpointId endpointId)

gOperationalStateInstance->Init();
}

// Init RVC Operational State cluster

static OperationalState::Instance * gRvcOperationalStateInstance = nullptr;
static RvcOperationalStateDelegate * gRvcOperationalStateDelegate = nullptr;

void RvcOperationalState::Shutdown()
{
if (gRvcOperationalStateInstance != nullptr)
{
delete gRvcOperationalStateInstance;
gRvcOperationalStateInstance = nullptr;
}
if (gRvcOperationalStateDelegate != nullptr)
{
delete gRvcOperationalStateDelegate;
gRvcOperationalStateDelegate = nullptr;
}
}

void emberAfRvcOperationalStateClusterInitCallback(chip::EndpointId endpointId)
{
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1.
VerifyOrDie(gRvcOperationalStateInstance == nullptr && gRvcOperationalStateDelegate == nullptr);

gRvcOperationalStateDelegate = new RvcOperationalStateDelegate;
EndpointId operationalStateEndpoint = 0x01;
gRvcOperationalStateInstance = new RvcOperationalState::Instance(gRvcOperationalStateDelegate, operationalStateEndpoint);

gRvcOperationalStateInstance->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kStopped));

gRvcOperationalStateInstance->Init();
}
Loading
Loading