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