Coverage Report

Created: 2025-08-28 06:31

/src/connectedhomeip/examples/all-clusters-app/linux/AllClustersCommandDelegate.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 *
3
 *    Copyright (c) 2022 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 "NamedPipeCommands.h"
22
23
#include <json/json.h>
24
#include <platform/DiagnosticDataProvider.h>
25
26
#include <string>
27
28
class AllClustersAppCommandHandler
29
{
30
public:
31
    static AllClustersAppCommandHandler * FromJSON(const char * json);
32
33
    static void HandleCommand(intptr_t context);
34
35
0
    AllClustersAppCommandHandler(Json::Value && jasonValue) : mJsonValue(std::move(jasonValue)) {}
36
37
private:
38
    Json::Value mJsonValue;
39
40
    bool IsClusterPresentOnAnyEndpoint(chip::ClusterId clusterId);
41
42
    /**
43
     * Should be called when a reason that caused the device to start-up has been set.
44
     */
45
    void OnRebootSignalHandler(chip::DeviceLayer::BootReasonType bootReason);
46
47
    /**
48
     * Should be called when a general fault takes place on the Node.
49
     */
50
    void OnGeneralFaultEventHandler(uint32_t eventId);
51
52
    /**
53
     * Should be called when a software fault takes place on the Node.
54
     */
55
    void OnSoftwareFaultEventHandler(uint32_t eventId);
56
57
    /**
58
     * Should be called when the latching switch is moved to a new position.
59
     */
60
    void OnSwitchLatchedHandler(uint8_t newPosition);
61
62
    /**
63
     * Should be called when the momentary switch starts to be pressed.
64
     */
65
    void OnSwitchInitialPressedHandler(uint8_t newPosition);
66
67
    /**
68
     * Should be called when the momentary switch has been pressed for a "long" time.
69
     */
70
    void OnSwitchLongPressedHandler(uint8_t newPosition);
71
72
    /**
73
     * Should be called when the momentary switch has been released.
74
     */
75
    void OnSwitchShortReleasedHandler(uint8_t previousPosition);
76
77
    /**
78
     * Should be called when the momentary switch has been released after having been pressed for a long time.
79
     */
80
    void OnSwitchLongReleasedHandler(uint8_t previousPosition);
81
82
    /**
83
     * Should be called to indicate how many times the momentary switch has been pressed in a multi-press
84
     * sequence, during that sequence.
85
     */
86
    void OnSwitchMultiPressOngoingHandler(uint8_t newPosition, uint8_t count);
87
88
    /**
89
     * Should be called to indicate how many times the momentary switch has been pressed in a multi-press
90
     * sequence, after it has been detected that the sequence has ended.
91
     */
92
    void OnSwitchMultiPressCompleteHandler(uint8_t previousPosition, uint8_t count);
93
94
    /**
95
     * Should be called when it is necessary to change the mode to manual operation.
96
     */
97
    void OnModeChangeHandler(std::string device, std::string type, chip::app::DataModel::Nullable<uint8_t> mode);
98
99
    /**
100
     * Should be called when it is necessary to change the air quality attribute.
101
     */
102
    void OnAirQualityChange(uint32_t aEnum);
103
104
    /**
105
     * Should be called when it is necessary to change the measured moisture value.
106
     */
107
    void OnSoilMoistureChange(chip::EndpointId endpointId, chip::app::DataModel::Nullable<chip::Percent> soilMoisture);
108
109
    /**
110
     * Should be called when it is necessary to change the operational state as a manual operation.
111
     */
112
    void OnOperationalStateChange(std::string device, std::string operation, Json::Value param);
113
114
    /**
115
     * Should be called when it is necessary to change the operational state as a manual operation.
116
     */
117
    void OnGenericOperationalStateChange(std::string device, std::string operation, Json::Value param);
118
119
    /**
120
     * Should be called when it is necessary to change the operational state as a manual operation.
121
     */
122
    void OnOvenOperationalStateChange(std::string device, std::string operation, Json::Value param);
123
124
    /**
125
     * Should be called when it is necessary to change one or some attributes.
126
     */
127
    void OnMeterIdentificationHandler(const Json::Value & param);
128
129
    /**
130
     * Should be called when it is necessary to change the Occupancy attribute.
131
     */
132
    void HandleSetOccupancyChange(chip::EndpointId endpointId, uint8_t occupancyValue);
133
    static void OccupancyPresentTimerHandler(chip::System::Layer * systemLayer, void * appState);
134
};
135
136
class AllClustersCommandDelegate : public NamedPipeCommandDelegate
137
{
138
public:
139
    void OnEventCommandReceived(const char * json) override;
140
};