7673db7643259b9398640c85b4667af3c26e843f
[platform/upstream/connectedhomeip.git] / examples / lock-app / lock-common / gen / callback-stub.cpp
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 // THIS FILE IS GENERATED BY ZAP
19
20 #include "callback.h"
21 #include "cluster-id.h"
22
23 using namespace chip;
24
25 // Cluster Init Functions
26 void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
27 {
28     switch (clusterId)
29     {
30     case ZCL_ON_OFF_CLUSTER_ID:
31         emberAfOnOffClusterInitCallback(endpoint);
32         break;
33     default:
34         // Unrecognized cluster ID
35         break;
36     }
37 }
38
39 void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint)
40 {
41     // To prevent warning
42     (void) endpoint;
43 }
44
45 //
46 // Non-Cluster Related Callbacks
47 //
48
49 /** @brief Add To Current App Tasks
50  *
51  * This function is only useful to sleepy end devices.  This function will note
52  * the passed item as part of a set of tasks the application has outstanding
53  * (e.g. message sent requiring APS acknwoledgement).  This will affect how the
54  * application behaves with regard to sleeping and polling.  Until the
55  * outstanding task is completed, the device may poll more frequently and sleep
56  * less often.
57  *
58  * @param tasks   Ver.: always
59  */
60 void __attribute__((weak)) emberAfAddToCurrentAppTasksCallback(EmberAfApplicationTask tasks) {}
61
62 /** @brief Remove From Current App Tasks
63  *
64  * This function is only useful to sleepy end devices.  This function will
65  * remove the passed item from the set of tasks the application has outstanding
66  * (e.g. message sent requiring APS acknwoledgement).  This will affect how the
67  * application behaves with regard to sleeping and polling.  Removing the item
68  * from the list of outstanding tasks may allow the device to sleep longer and
69  * poll less frequently.  If there are other outstanding tasks the system may
70  * still have to stay away and poll more often.
71  *
72  * @param tasks   Ver.: always
73  */
74 void __attribute__((weak)) emberAfRemoveFromCurrentAppTasksCallback(EmberAfApplicationTask tasks) {}
75
76 /** @brief Allow Network Write Attribute
77  *
78  * This function is called by the application framework before it writes an
79  * attribute in response to a write attribute request from an external device.
80  * The value passed into this callback is the value to which the attribute is to
81  * be set by the framework.
82         Example:        In mirroring simple metering data
83  * on an Energy Services Interface (ESI) (formerly called Energy Service Portal
84  * (ESP) in SE 1.0).), a mirrored simple meter needs to write read-only
85  * attributes on its mirror. The-meter-mirror sample application, located in
86  * app/framework/sample-apps, uses this callback to allow the mirrored device to
87  * write simple metering attributes on the mirror regardless of the fact that
88  * most simple metering attributes are defined as read-only by the ZigBee
89  * specification.
90         Note:   The ZCL specification does not (as of this
91  * writing) specify any permission-level security for writing writeable
92  * attributes. As far as the ZCL specification is concerned, if an attribute is
93  * writeable, any device that has a link key for the device should be able to
94  * write that attribute. Furthermore if an attribute is read only, it should not
95  * be written over the air. Thus, if you implement permissions for writing
96  * attributes as a feature, you MAY be operating outside the specification. This
97  * is unlikely to be a problem for writing read-only attributes, but it may be a
98  * problem for attributes that are writeable according to the specification but
99  * restricted by the application implementing this callback.
100  *
101  * @param endpoint   Ver.: always
102  * @param clusterId   Ver.: always
103  * @param attributeId   Ver.: always
104  * @param mask   Ver.: always
105  * @param manufacturerCode   Ver.: always
106  * @param value   Ver.: always
107  * @param type   Ver.: always
108  */
109 EmberAfAttributeWritePermission __attribute__((weak))
110 emberAfAllowNetworkWriteAttributeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
111                                           uint16_t manufacturerCode, uint8_t * value, uint8_t type)
112 {
113     return EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL; // Default
114 }
115
116 /** @brief Attribute Read Access
117  *
118  * This function is called whenever the Application Framework needs to check
119  * access permission for an attribute read.
120  *
121  * @param endpoint   Ver.: always
122  * @param clusterId   Ver.: always
123  * @param manufacturerCode   Ver.: always
124  * @param attributeId   Ver.: always
125  */
126 bool __attribute__((weak))
127 emberAfAttributeReadAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode, AttributeId attributeId)
128 {
129     return true;
130 }
131
132 /** @brief Attribute Write Access
133  *
134  * This function is called whenever the Application Framework needs to check
135  * access permission for an attribute write.
136  *
137  * @param endpoint   Ver.: always
138  * @param clusterId   Ver.: always
139  * @param manufacturerCode   Ver.: always
140  * @param attributeId   Ver.: always
141  */
142 bool __attribute__((weak))
143 emberAfAttributeWriteAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode, AttributeId attributeId)
144 {
145     return true;
146 }
147
148 /** @brief Default Response
149  *
150  * This function is called by the application framework when a Default Response
151  * command is received from an external device.  The application should return
152  * true if the message was processed or false if it was not.
153  *
154  * @param clusterId The cluster identifier of this response.  Ver.: always
155  * @param commandId The command identifier to which this is a response.  Ver.:
156  * always
157  * @param status Specifies either SUCCESS or the nature of the error that was
158  * detected in the received command.  Ver.: always
159  */
160 bool __attribute__((weak)) emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, EmberAfStatus status)
161 {
162     return false;
163 }
164
165 /** @brief Configure Reporting Response
166  *
167  * This function is called by the application framework when a Configure
168  * Reporting Response command is received from an external device.  The
169  * application should return true if the message was processed or false if it
170  * was not.
171  *
172  * @param clusterId The cluster identifier of this response.  Ver.: always
173  * @param buffer Buffer containing the list of attribute status records.  Ver.:
174  * always
175  * @param bufLen The length in bytes of the list.  Ver.: always
176  */
177 bool __attribute__((weak)) emberAfConfigureReportingResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
178 {
179     return false;
180 }
181
182 /** @brief Read Reporting Configuration Response
183  *
184  * This function is called by the application framework when a Read Reporting
185  * Configuration Response command is received from an external device.  The
186  * application should return true if the message was processed or false if it
187  * was not.
188  *
189  * @param clusterId The cluster identifier of this response.  Ver.: always
190  * @param buffer Buffer containing the list of attribute reporting configuration
191  * records.  Ver.: always
192  * @param bufLen The length in bytes of the list.  Ver.: always
193  */
194 bool __attribute__((weak)) emberAfReadReportingConfigurationResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
195 {
196     return false;
197 }
198
199 /** @brief Discover Attributes Response
200  *
201  * This function is called by the application framework when a Discover
202  * Attributes Response or Discover Attributes Extended Response command is
203  * received from an external device.  The Discover Attributes Response command
204  * contains a bool indicating if discovery is complete and a list of zero or
205  * more attribute identifier/type records. The final argument indicates whether
206  * the response is in the extended format or not.  The application should return
207  * true if the message was processed or false if it was not.
208  *
209  * @param clusterId The cluster identifier of this response.  Ver.: always
210  * @param discoveryComplete Indicates whether there are more attributes to be
211  * discovered.  true if there are no more attributes to be discovered.  Ver.:
212  * always
213  * @param buffer Buffer containing the list of attribute identifier/type
214  * records.  Ver.: always
215  * @param bufLen The length in bytes of the list.  Ver.: always
216  * @param extended Indicates whether the response is in the extended format or
217  * not.  Ver.: always
218  */
219 bool __attribute__((weak)) emberAfDiscoverAttributesResponseCallback(ClusterId clusterId, bool discoveryComplete, uint8_t * buffer,
220                                                                      uint16_t bufLen, bool extended)
221 {
222     return false;
223 }
224
225 /** @brief Discover Commands Generated Response
226  *
227  * This function is called by the framework when Discover Commands Generated
228  * Response is received.
229  *
230  * @param clusterId The cluster identifier of this response.  Ver.: always
231  * @param manufacturerCode Manufacturer code  Ver.: always
232  * @param discoveryComplete Indicates whether there are more commands to be
233  * discovered.  Ver.: always
234  * @param commandIds Buffer containing the list of command identifiers.  Ver.:
235  * always
236  * @param commandIdCount The length of bytes of the list, whish is the same as
237  * the number of identifiers.  Ver.: always
238  */
239 bool __attribute__((weak))
240 emberAfDiscoverCommandsGeneratedResponseCallback(ClusterId clusterId, uint16_t manufacturerCode, bool discoveryComplete,
241                                                  CommandId * commandIds, uint16_t commandIdCount)
242 {
243     return false;
244 }
245
246 /** @brief Discover Commands Received Response
247  *
248  * This function is called by the framework when Discover Commands Received
249  * Response is received.
250  *
251  * @param clusterId The cluster identifier of this response.  Ver.: always
252  * @param manufacturerCode Manufacturer code  Ver.: always
253  * @param discoveryComplete Indicates whether there are more commands to be
254  * discovered.  Ver.: always
255  * @param commandIds Buffer containing the list of command identifiers.  Ver.:
256  * always
257  * @param commandIdCount The length of bytes of the list, whish is the same as
258  * the number of identifiers.  Ver.: always
259  */
260 bool __attribute__((weak))
261 emberAfDiscoverCommandsReceivedResponseCallback(ClusterId clusterId, uint16_t manufacturerCode, bool discoveryComplete,
262                                                 CommandId * commandIds, uint16_t commandIdCount)
263 {
264     return false;
265 }
266
267 /** @brief Pre Command Received
268  *
269  * This callback is the second in the Application Framework's message processing
270  * chain. At this point in the processing of incoming over-the-air messages, the
271  * application has determined that the incoming message is a ZCL command. It
272  * parses enough of the message to populate an EmberAfClusterCommand struct. The
273  * Application Framework defines this struct value in a local scope to the
274  * command processing but also makes it available through a global pointer
275  * called emberAfCurrentCommand, in app/framework/util/util.c. When command
276  * processing is complete, this pointer is cleared.
277  *
278  * @param cmd   Ver.: always
279  */
280 bool __attribute__((weak)) emberAfPreCommandReceivedCallback(EmberAfClusterCommand * cmd)
281 {
282     return false;
283 }
284
285 /** @brief Pre Message Send
286  *
287  * This function is called by the framework when it is about to pass a message
288  * to the stack primitives for sending.   This message may or may not be ZCL,
289  * ZDO, or some other protocol.  This is called prior to
290         any ZigBee
291  * fragmentation that may be done.  If the function returns true it is assumed
292  * the callback has consumed and processed the message.  The callback must also
293  * set the EmberStatus status code to be passed back to the caller.  The
294  * framework will do no further processing on the message.
295         If the
296  * function returns false then it is assumed that the callback has not processed
297  * the mesasge and the framework will continue to process accordingly.
298  *
299  * @param messageStruct The structure containing the parameters of the APS
300  * message to be sent.  Ver.: always
301  * @param status A pointer to the status code value that will be returned to the
302  * caller.  Ver.: always
303  */
304 bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberStatus * status)
305 {
306     return false;
307 }
308
309 /** @brief Message Sent
310  *
311  * This function is called by the application framework from the message sent
312  * handler, when it is informed by the stack regarding the message sent status.
313  * All of the values passed to the emberMessageSentHandler are passed on to this
314  * callback. This provides an opportunity for the application to verify that its
315  * message has been sent successfully and take the appropriate action. This
316  * callback should return a bool value of true or false. A value of true
317  * indicates that the message sent notification has been handled and should not
318  * be handled by the application framework.
319  *
320  * @param type   Ver.: always
321  * @param indexOrDestination   Ver.: always
322  * @param apsFrame   Ver.: always
323  * @param msgLen   Ver.: always
324  * @param message   Ver.: always
325  * @param status   Ver.: always
326  */
327 bool __attribute__((weak))
328 emberAfMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, EmberApsFrame * apsFrame, uint16_t msgLen,
329                            uint8_t * message, EmberStatus status)
330 {
331     return false;
332 }
333
334 /** @brief Pre Attribute Change
335  *
336  * This function is called by the application framework before it changes an
337  * attribute value.  The value passed into this callback is the value to which
338  * the attribute is to be set by the framework.  The application should return
339  * ::EMBER_ZCL_STATUS_SUCCESS to permit the change or any other ::EmberAfStatus
340  * to reject it.
341  *
342  * @param endpoint   Ver.: always
343  * @param clusterId   Ver.: always
344  * @param attributeId   Ver.: always
345  * @param mask   Ver.: always
346  * @param manufacturerCode   Ver.: always
347  * @param type   Ver.: always
348  * @param size   Ver.: always
349  * @param value   Ver.: always
350  */
351 EmberAfStatus __attribute__((weak))
352 emberAfPreAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
353                                   uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value)
354 {
355     return EMBER_ZCL_STATUS_SUCCESS;
356 }
357
358 /** @brief Post Attribute Change
359  *
360  * This function is called by the application framework after it changes an
361  * attribute value. The value passed into this callback is the value to which
362  * the attribute was set by the framework.
363  *
364  * @param endpoint   Ver.: always
365  * @param clusterId   Ver.: always
366  * @param attributeId   Ver.: always
367  * @param mask   Ver.: always
368  * @param manufacturerCode   Ver.: always
369  * @param type   Ver.: always
370  * @param size   Ver.: always
371  * @param value   Ver.: always
372  */
373 void __attribute__((weak))
374 emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
375                                    uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value)
376 {}
377
378 /** @brief Read Attributes Response
379  *
380  * This function is called by the application framework when a Read Attributes
381  * Response command is received from an external device.  The application should
382  * return true if the message was processed or false if it was not.
383  *
384  * @param clusterId The cluster identifier of this response.  Ver.: always
385  * @param buffer Buffer containing the list of read attribute status records.
386  * Ver.: always
387  * @param bufLen The length in bytes of the list.  Ver.: always
388  */
389 bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
390 {
391     return false;
392 }
393
394 /** @brief External Attribute Read
395  *
396  * Like emberAfExternalAttributeWriteCallback above, this function is called
397  * when the framework needs to read an attribute that is not stored within the
398  * Application Framework's data structures.
399         All of the important
400  * information about the attribute itself is passed as a pointer to an
401  * EmberAfAttributeMetadata struct, which is stored within the application and
402  * used to manage the attribute. A complete description of the
403  * EmberAfAttributeMetadata struct is provided in
404  * app/framework/include/af-types.h
405         This function assumes that the
406  * application is able to read the attribute, write it into the passed buffer,
407  * and return immediately. Any attributes that require a state machine for
408  * reading and writing are not really candidates for externalization at the
409  * present time. The Application Framework does not currently include a state
410  * machine for reading or writing attributes that must take place across a
411  * series of application ticks. Attributes that cannot be read in a timely
412  * manner should be stored within the Application Framework and updated
413  * occasionally by the application code from within the
414  * emberAfMainTickCallback.
415         If the application was successfully able to
416  * read the attribute and write it into the passed buffer, it should return a
417  * value of EMBER_ZCL_STATUS_SUCCESS. Ensure that the size of the externally
418  * managed attribute value is smaller than what the buffer can hold. In the case
419  * of a buffer overflow throw an appropriate error such as
420  * EMBER_ZCL_STATUS_INSUFFICIENT_SPACE. Any other return value indicates the
421  * application was not able to read the attribute.
422  *
423  * @param endpoint   Ver.: always
424  * @param clusterId   Ver.: always
425  * @param attributeMetadata   Ver.: always
426  * @param manufacturerCode   Ver.: always
427  * @param buffer   Ver.: always
428  * @param maxReadLength   Ver.: always
429  */
430 EmberAfStatus __attribute__((weak))
431 emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata,
432                                      uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength)
433 {
434     return EMBER_ZCL_STATUS_FAILURE;
435 }
436
437 /** @brief Write Attributes Response
438  *
439  * This function is called by the application framework when a Write Attributes
440  * Response command is received from an external device.  The application should
441  * return true if the message was processed or false if it was not.
442  *
443  * @param clusterId The cluster identifier of this response.  Ver.: always
444  * @param buffer Buffer containing the list of write attribute status records.
445  * Ver.: always
446  * @param bufLen The length in bytes of the list.  Ver.: always
447  */
448 bool __attribute__((weak)) emberAfWriteAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
449 {
450     return false;
451 }
452
453 /** @brief External Attribute Write
454  *
455  * This function is called whenever the Application Framework needs to write an
456  * attribute which is not stored within the data structures of the Application
457  * Framework itself. One of the new features in Version 2 is the ability to
458  * store attributes outside the Framework. This is particularly useful for
459  * attributes that do not need to be stored because they can be read off the
460  * hardware when they are needed, or are stored in some central location used by
461  * many modules within the system. In this case, you can indicate that the
462  * attribute is stored externally. When the framework needs to write an external
463  * attribute, it makes a call to this callback.
464         This callback is very
465  * useful for host micros which need to store attributes in persistent memory.
466  * Because each host micro (used with an Ember NCP) has its own type of
467  * persistent memory storage, the Application Framework does not include the
468  * ability to mark attributes as stored in flash the way that it does for Ember
469  * SoCs like the EM35x. On a host micro, any attributes that need to be stored
470  * in persistent memory should be marked as external and accessed through the
471  * external read and write callbacks. Any host code associated with the
472  * persistent storage should be implemented within this callback.
473         All of
474  * the important information about the attribute itself is passed as a pointer
475  * to an EmberAfAttributeMetadata struct, which is stored within the application
476  * and used to manage the attribute. A complete description of the
477  * EmberAfAttributeMetadata struct is provided in
478  * app/framework/include/af-types.h.
479         This function assumes that the
480  * application is able to write the attribute and return immediately. Any
481  * attributes that require a state machine for reading and writing are not
482  * candidates for externalization at the present time. The Application Framework
483  * does not currently include a state machine for reading or writing attributes
484  * that must take place across a series of application ticks. Attributes that
485  * cannot be written immediately should be stored within the Application
486  * Framework and updated occasionally by the application code from within the
487  * emberAfMainTickCallback.
488         If the application was successfully able to
489  * write the attribute, it returns a value of EMBER_ZCL_STATUS_SUCCESS. Any
490  * other return value indicates the application was not able to write the
491  * attribute.
492  *
493  * @param endpoint   Ver.: always
494  * @param clusterId   Ver.: always
495  * @param attributeMetadata   Ver.: always
496  * @param manufacturerCode   Ver.: always
497  * @param buffer   Ver.: always
498  */
499 EmberAfStatus __attribute__((weak))
500 emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata,
501                                       uint16_t manufacturerCode, uint8_t * buffer)
502 {
503     return EMBER_ZCL_STATUS_FAILURE;
504 }
505
506 /** @brief Report Attributes
507  *
508  * This function is called by the application framework when a Report Attributes
509  * command is received from an external device.  The application should return
510  * true if the message was processed or false if it was not.
511  *
512  * @param clusterId The cluster identifier of this command.  Ver.: always
513  * @param buffer Buffer containing the list of attribute report records.  Ver.:
514  * always
515  * @param bufLen The length in bytes of the list.  Ver.: always
516  */
517 bool __attribute__((weak)) emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
518 {
519     return false;
520 }
521
522 /** @brief Get Current Time
523  *
524  * This callback is called when device attempts to get current time from the
525  * hardware. If this device has means to retrieve exact time, then this method
526  * should implement it. If the callback can't provide the exact time it should
527  * return 0 to indicate failure. Default action is to return 0, which indicates
528  * that device does not have access to real time.
529  *
530  */
531 uint32_t __attribute__((weak)) emberAfGetCurrentTimeCallback()
532 {
533     return 0;
534 }
535
536 /** @brief Get Endpoint Info
537  *
538  * This function is a callback to an application implemented endpoint that
539  * operates outside the normal application framework.  When the framework wishes
540  * to perform operations with that endpoint it uses this callback to retrieve
541  * the endpoint's information.  If the endpoint exists and the application can
542  * provide data then true shall be returned.  Otherwise the callback must return
543  * false.
544  *
545  * @param endpoint The endpoint to retrieve data for.  Ver.: always
546  * @param returnNetworkIndex The index corresponding to the ZigBee network the
547  * endpoint belongs to.  If not using a multi-network device, 0 must be
548  * returned.  Otherwise on a multi-network device the stack will switch to this
549  * network before sending the message.  Ver.: always
550  * @param returnEndpointInfo A pointer to a data struct that will be written
551  * with information about the endpoint.  Ver.: always
552  */
553 bool __attribute__((weak))
554 emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex, EmberAfEndpointInfoStruct * returnEndpointInfo)
555 {
556     return false;
557 }
558
559 /** @brief Get Source Route Overhead
560  *
561  * This function is called by the framework to determine the overhead required
562  * in the network frame for source routing to a particular destination.
563  *
564  * @param destination The node id of the destination  Ver.: always
565  */
566 uint8_t __attribute__((weak)) emberAfGetSourceRouteOverheadCallback(chip::NodeId destination)
567 {
568     return 0;
569 }
570
571 /** @brief Registration Abort
572  *
573  * This callback is called when the device should abort the registration
574  * process.
575  *
576  */
577 void __attribute__((weak)) emberAfRegistrationAbortCallback() {}
578
579 /** @brief Interpan Send Message
580  *
581  * This function will send a raw MAC message with interpan frame format using
582  * the passed parameters.
583  *
584  * @param header Interpan header info  Ver.: always
585  * @param messageLength The length of the message received or to send  Ver.:
586  * always
587  * @param message The message data received or to send.  Ver.: always
588  */
589 EmberStatus __attribute__((weak))
590 emberAfInterpanSendMessageCallback(EmberAfInterpanHeader * header, uint16_t messageLength, uint8_t * message)
591 {
592     return EMBER_LIBRARY_NOT_PRESENT;
593 }
594
595 /** @brief Start Move
596  *
597  * This function is called to initiate the process for a device to move (rejoin)
598  * to a new parent.
599  *
600  */
601 bool __attribute__((weak)) emberAfStartMoveCallback()
602 {
603     return false;
604 }