3 * Copyright (c) 2021 Project CHIP Authors
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 * This file defines the delegate the SDK consumer needs to implement to receive notifications from the interaction model.
26 #include <core/CHIPCore.h>
27 #include <messaging/ExchangeContext.h>
28 #include <system/SystemPacketBuffer.h>
34 struct EventPathParams;
38 * This class defines the API for a delegate that an SDK consumer can use to interface with the interaction model.
40 class InteractionModelDelegate
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.
54 * @retval # CHIP_ERROR_NOT_IMPLEMENTED if not implemented
56 virtual CHIP_ERROR EventStreamReceived(const Messaging::ExchangeContext * apExchangeContext, TLV::TLVReader * apEventListReader)
58 return CHIP_ERROR_NOT_IMPLEMENTED;
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
67 virtual CHIP_ERROR ReportProcessed(const ReadClient * apReadClient) { return CHIP_ERROR_NOT_IMPLEMENTED; }
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
77 virtual CHIP_ERROR ReportError(const ReadClient * apReadClient, CHIP_ERROR aError) { return CHIP_ERROR_NOT_IMPLEMENTED; }
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
91 * @retval # CHIP_ERROR_NOT_IMPLEMENTED if not implemented
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)
98 return CHIP_ERROR_NOT_IMPLEMENTED;
102 * Notification that a Command Send has received an Invoke Command Response and fails to process a command data element in that
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
109 virtual CHIP_ERROR CommandResponseProtocolError(const CommandSender * apCommandSender, uint8_t aCommandIndex)
111 return CHIP_ERROR_NOT_IMPLEMENTED;
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
120 virtual CHIP_ERROR CommandResponseTimeout(const CommandSender * apCommandSender) { return CHIP_ERROR_NOT_IMPLEMENTED; }
122 virtual ~InteractionModelDelegate() = default;