Coverage Report

Created: 2026-03-27 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/connectedhomeip/examples/all-clusters-app/all-clusters-common/include/rvc-operational-state-delegate-impl.h
Line
Count
Source
1
/*
2
 *
3
 *    Copyright (c) 2023 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-common/zap-generated/cluster-objects.h>
22
#include <app/clusters/operational-state-server/operational-state-server.h>
23
24
#include <protocols/interaction_model/StatusCode.h>
25
26
namespace chip {
27
namespace app {
28
namespace Clusters {
29
30
namespace RvcOperationalState {
31
32
// This is an application level delegate to handle operational state commands according to the specific business logic.
33
class RvcOperationalStateDelegate : public Delegate
34
{
35
private:
36
    const Clusters::OperationalState::GenericOperationalState rvcOpStateList[7] = {
37
        OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kStopped)),
38
        OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning)),
39
        OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kPaused)),
40
        OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kError)),
41
        OperationalState::GenericOperationalState(
42
            to_underlying(Clusters::RvcOperationalState::OperationalStateEnum::kSeekingCharger)),
43
        OperationalState::GenericOperationalState(to_underlying(Clusters::RvcOperationalState::OperationalStateEnum::kCharging)),
44
        OperationalState::GenericOperationalState(to_underlying(Clusters::RvcOperationalState::OperationalStateEnum::kDocked)),
45
    };
46
47
    Span<const OperationalState::GenericOperationalState> mOperationalStateList =
48
        Span<const OperationalState::GenericOperationalState>(rvcOpStateList);
49
    Span<const CharSpan> mOperationalPhaseList;
50
51
public:
52
0
    RvcOperationalStateDelegate() {}
53
54
    /**
55
     * Get the countdown time. This attribute is not used in this application.
56
     * @return The current countdown time.
57
     */
58
0
    app::DataModel::Nullable<uint32_t> GetCountdownTime() override { return {}; };
59
60
    /**
61
     * Fills in the provided GenericOperationalState with the state at index `index` if there is one,
62
     * or returns CHIP_ERROR_NOT_FOUND if the index is out of range for the list of states.
63
     * Note: This is used by the SDK to populate the operational state list attribute. If the contents of this list changes,
64
     * the device SHALL call the Instance's ReportOperationalStateListChange method to report that this attribute has changed.
65
     * @param index The index of the state, with 0 representing the first state.
66
     * @param operationalState  The GenericOperationalState is filled.
67
     */
68
    CHIP_ERROR GetOperationalStateAtIndex(size_t index, OperationalState::GenericOperationalState & operationalState) override;
69
70
    /**
71
     * Fills in the provided GenericOperationalPhase with the phase at index `index` if there is one,
72
     * or returns CHIP_ERROR_NOT_FOUND if the index is out of range for the list of phases.
73
     * Note: This is used by the SDK to populate the phase list attribute. If the contents of this list changes, the
74
     * device SHALL call the Instance's ReportPhaseListChange method to report that this attribute has changed.
75
     * @param index The index of the phase, with 0 representing the first phase.
76
     * @param operationalPhase  The GenericOperationalPhase is filled.
77
     */
78
    CHIP_ERROR GetOperationalPhaseAtIndex(size_t index, MutableCharSpan & operationalPhase) override;
79
80
    // command callback
81
    /**
82
     * Handle Command Callback in application: Pause
83
     * @param[out] get operational error after callback.
84
     */
85
    void HandlePauseStateCallback(OperationalState::GenericOperationalError & err) override;
86
87
    /**
88
     * Handle Command Callback in application: Resume
89
     * @param[out] get operational error after callback.
90
     */
91
    void HandleResumeStateCallback(OperationalState::GenericOperationalError & err) override;
92
93
    /**
94
     * Handle the GoHome command.
95
     * @param err
96
     */
97
    void HandleGoHomeCommandCallback(OperationalState::GenericOperationalError & err) override;
98
};
99
100
void Shutdown();
101
102
Instance * GetRvcOperationalStateInstance();
103
104
} // namespace RvcOperationalState
105
} // namespace Clusters
106
} // namespace app
107
} // namespace chip