|
26 | 26 |
|
27 | 27 | #include <type_traits>
|
28 | 28 |
|
| 29 | +#include "CommandSenderLegacyCallback.h" |
| 30 | + |
29 | 31 | #include <app/CommandPathParams.h>
|
30 | 32 | #include <app/MessageDef/InvokeRequestMessage.h>
|
31 | 33 | #include <app/MessageDef/InvokeResponseMessage.h>
|
@@ -53,77 +55,6 @@ namespace app {
|
53 | 55 | class CommandSender final : public Messaging::ExchangeDelegate
|
54 | 56 | {
|
55 | 57 | public:
|
56 |
| - // TODO(#30453) Reorder CommandSender::Callback and CommandSender::ExtendableCallback. To keep follow up |
57 |
| - // review simple, this was not done initially, and is expected to be completed within day of PR |
58 |
| - // introducing CommandSender::ExtendableCallback getting merged. |
59 |
| - /** |
60 |
| - * @brief Legacy callbacks for CommandSender |
61 |
| - */ |
62 |
| - class Callback |
63 |
| - { |
64 |
| - public: |
65 |
| - virtual ~Callback() = default; |
66 |
| - |
67 |
| - /** |
68 |
| - * OnResponse will be called when a successful response from server has been received and processed. |
69 |
| - * Specifically: |
70 |
| - * - When a status code is received and it is IM::Success, aData will be nullptr. |
71 |
| - * - When a data response is received, aData will point to a valid TLVReader initialized to point at the struct container |
72 |
| - * that contains the data payload (callee will still need to open and process the container). |
73 |
| - * |
74 |
| - * The CommandSender object MUST continue to exist after this call is completed. The application shall wait until it |
75 |
| - * receives an OnDone call to destroy the object. |
76 |
| - * |
77 |
| - * @param[in] apCommandSender The command sender object that initiated the command transaction. |
78 |
| - * @param[in] aPath The command path field in invoke command response. |
79 |
| - * @param[in] aStatusIB It will always have a success status. If apData is null, it can be any success status, |
80 |
| - * including possibly a cluster-specific one. If apData is not null it aStatusIB will always |
81 |
| - * be a generic SUCCESS status with no-cluster specific information. |
82 |
| - * @param[in] apData The command data, will be nullptr if the server returns a StatusIB. |
83 |
| - */ |
84 |
| - virtual void OnResponse(CommandSender * apCommandSender, const ConcreteCommandPath & aPath, const StatusIB & aStatusIB, |
85 |
| - TLV::TLVReader * apData) |
86 |
| - {} |
87 |
| - |
88 |
| - /** |
89 |
| - * OnError will be called when an error occurs *after* a successful call to SendCommandRequest(). The following |
90 |
| - * errors will be delivered through this call in the aError field: |
91 |
| - * |
92 |
| - * - CHIP_ERROR_TIMEOUT: A response was not received within the expected response timeout. |
93 |
| - * - CHIP_ERROR_*TLV*: A malformed, non-compliant response was received from the server. |
94 |
| - * - CHIP_ERROR encapsulating a StatusIB: If we got a non-path-specific or path-specific |
95 |
| - * status response from the server. In that case, |
96 |
| - * StatusIB::InitFromChipError can be used to extract the status. |
97 |
| - * - Note: a CommandSender using `CommandSender::Callback` only supports sending |
98 |
| - * a single InvokeRequest. As a result, only one path-specific error is expected |
99 |
| - * to ever be sent to the OnError callback. |
100 |
| - * - CHIP_ERROR*: All other cases. |
101 |
| - * |
102 |
| - * The CommandSender object MUST continue to exist after this call is completed. The application shall wait until it |
103 |
| - * receives an OnDone call to destroy and free the object. |
104 |
| - * |
105 |
| - * @param[in] apCommandSender The command sender object that initiated the command transaction. |
106 |
| - * @param[in] aError A system error code that conveys the overall error code. |
107 |
| - */ |
108 |
| - virtual void OnError(const CommandSender * apCommandSender, CHIP_ERROR aError) {} |
109 |
| - |
110 |
| - /** |
111 |
| - * OnDone will be called when CommandSender has finished all work and it is safe to destroy and free the |
112 |
| - * allocated CommandSender object. |
113 |
| - * |
114 |
| - * This function will: |
115 |
| - * - Always be called exactly *once* for a given CommandSender instance. |
116 |
| - * - Be called even in error circumstances. |
117 |
| - * - Only be called after a successful call to SendCommandRequest returns, if SendCommandRequest is used. |
118 |
| - * - Always be called before a successful return from SendGroupCommandRequest, if SendGroupCommandRequest is used. |
119 |
| - * |
120 |
| - * This function must be implemented to destroy the CommandSender object. |
121 |
| - * |
122 |
| - * @param[in] apCommandSender The command sender object of the terminated invoke command transaction. |
123 |
| - */ |
124 |
| - virtual void OnDone(CommandSender * apCommandSender) = 0; |
125 |
| - }; |
126 |
| - |
127 | 58 | // CommandSender::ExtendableCallback::OnResponse is public SDK API, so we cannot break
|
128 | 59 | // source compatibility for it. To allow for additional values to be added at a future
|
129 | 60 | // time without constantly changing the function's declaration parameter list, we are
|
@@ -229,6 +160,10 @@ class CommandSender final : public Messaging::ExchangeDelegate
|
229 | 160 | virtual void OnDone(CommandSender * apCommandSender) = 0;
|
230 | 161 | };
|
231 | 162 |
|
| 163 | + // `Callback` exists for legacy purposes. If you are developing a new callback implementation, |
| 164 | + // please use `ExtendableCallback`. |
| 165 | + using Callback = CommandSenderLegacyCallback; |
| 166 | + |
232 | 167 | // SetCommandSenderConfig is a public SDK API, so we cannot break source compatibility
|
233 | 168 | // for it. By having parameters to that API use this struct instead of individual
|
234 | 169 | // function arguments, we centralize required changes to one file when adding new
|
|
0 commit comments