Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / app / InteractionModelDelegate.h
1 /*
2  *
3  *    Copyright (c) 2021 Project CHIP Authors
4  *
5  *    Licensed under the Apache License, Version 2.0 (the "License");
6  *    you may not use this file except in compliance with the License.
7  *    You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *    Unless required by applicable law or agreed to in writing, software
12  *    distributed under the License is distributed on an "AS IS" BASIS,
13  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *    See the License for the specific language governing permissions and
15  *    limitations under the License.
16  */
17
18 /**
19  *    @file
20  *      This file defines the delegate the SDK consumer needs to implement to receive notifications from the interaction model.
21  *
22  */
23
24 #pragma once
25
26 #include <core/CHIPCore.h>
27 #include <messaging/ExchangeContext.h>
28 #include <system/SystemPacketBuffer.h>
29
30 namespace chip {
31 namespace app {
32 class ReadClient;
33 class CommandSender;
34 struct EventPathParams;
35
36 /**
37  * @brief
38  *   This class defines the API for a delegate that an SDK consumer can use to interface with the interaction model.
39  */
40 class InteractionModelDelegate
41 {
42 public:
43     /**
44      * Notification that the interaction model has received a list of events in response to a Read request and that list
45      * of events needs to be processed.
46      * @param[in]  apExchangeContext   An exchange context that represents the exchange the Report Data came in on.
47      *                                 This can be used to recover the NodeId of the node that sent the Report Data.
48      *                                 It is managed externally and should not be closed by the SDK consumer.
49      * @param[in]  apEventListReader  TLV reader positioned at the list that contains the events.  The
50      *                                implementation of EventStreamReceived is expected to call Next() on the reader to
51      *                                advance it to the first element of the list, then process the elements from beginning to the
52      *                                end. The callee is expected to consume all events.
53      *
54      * @retval  # CHIP_ERROR_NOT_IMPLEMENTED if not implemented
55      */
56     virtual CHIP_ERROR EventStreamReceived(const Messaging::ExchangeContext * apExchangeContext, TLV::TLVReader * apEventListReader)
57     {
58         return CHIP_ERROR_NOT_IMPLEMENTED;
59     }
60
61     /**
62      * Notification that the last message for a Report Data action for the given ReadClient has been received and processed.
63      * @param[in]  apReadClient   A current readClient which can identify the read to the consumer, particularly during
64      *                            multiple read interactions
65      * @retval # CHIP_ERROR_NOT_IMPLEMENTED if not implemented
66      */
67     virtual CHIP_ERROR ReportProcessed(const ReadClient * apReadClient) { return CHIP_ERROR_NOT_IMPLEMENTED; }
68
69     /**
70      * Notification that a read attempt encountered an asynchronous failure.
71      * @param[in]  apReadClient   A current readClient which can identify the read to the consumer, particularly during
72      *                            multiple read interactions
73      * @param[in]  aError         A error that could be CHIP_ERROR_TIMEOUT when read client fails to receive, or other error when
74      *                            fail to process report data.
75      * @retval # CHIP_ERROR_NOT_IMPLEMENTED if not implemented
76      */
77     virtual CHIP_ERROR ReportError(const ReadClient * apReadClient, CHIP_ERROR aError) { return CHIP_ERROR_NOT_IMPLEMENTED; }
78
79     /**
80      * Notification that a Command Send has received an Invoke Command Response containing a status code.
81      * @param[in]  apCommandSender A current command sender which can identify the command sender to the consumer, particularly
82      * during multiple command interactions
83      * @param[in]  aGeneralCode   Status code defined by the standard
84      * @param[in]  aProtocolId    Protocol Id
85      * @param[in]  aProtocolCode  Detailed error information, protocol-specific.
86      * @param[in]  aEndpointId    Endpoint identifier
87      * @param[in]  aClusterId     Cluster identifier
88      * @param[in]  aCommandId     Command identifier
89      * @param[in]  aCommandIndex  Current processing command index which can identify command if there exists multiple commands with
90      * same command Id
91      * @retval # CHIP_ERROR_NOT_IMPLEMENTED if not implemented
92      */
93     virtual CHIP_ERROR CommandResponseStatus(const CommandSender * apCommandSender,
94                                              const Protocols::SecureChannel::GeneralStatusCode aGeneralCode,
95                                              const uint32_t aProtocolId, const uint16_t aProtocolCode, chip::EndpointId aEndpointId,
96                                              const chip::ClusterId aClusterId, chip::CommandId aCommandId, uint8_t aCommandIndex)
97     {
98         return CHIP_ERROR_NOT_IMPLEMENTED;
99     }
100
101     /**
102      * Notification that a Command Send has received an Invoke Command Response and fails to process a command data element in that
103      * command response
104      * @param[in]  apCommandSender A current command sender which can identify the command sender to the consumer, particularly
105      * during multiple command interactions
106      * @param[in]  aCommandIndex  Current processing command index which can identify failed command
107      * @retval # CHIP_ERROR_NOT_IMPLEMENTED if not implemented
108      */
109     virtual CHIP_ERROR CommandResponseProtocolError(const CommandSender * apCommandSender, uint8_t aCommandIndex)
110     {
111         return CHIP_ERROR_NOT_IMPLEMENTED;
112     }
113
114     /**
115      * Notification that a command sender encountered an asynchronous failure.
116      * @param[in]  apCommandSender A current command sender which can identify the command sender to the consumer, particularly
117      * during multiple command interactions
118      * @retval # CHIP_ERROR_NOT_IMPLEMENTED if not implemented
119      */
120     virtual CHIP_ERROR CommandResponseTimeout(const CommandSender * apCommandSender) { return CHIP_ERROR_NOT_IMPLEMENTED; }
121
122     virtual ~InteractionModelDelegate() = default;
123 };
124
125 } // namespace app
126 } // namespace chip