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_LEVEL_CONTROL_CLUSTER_ID:
34 emberAfLevelControlClusterInitCallback(endpoint);
36 case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID:
37 emberAfNetworkCommissioningClusterInitCallback(endpoint);
39 case ZCL_ON_OFF_CLUSTER_ID:
40 emberAfOnOffClusterInitCallback(endpoint);
43 // Unrecognized cluster ID
48 void __attribute__((weak)) emberAfBasicClusterInitCallback(EndpointId endpoint)
53 void __attribute__((weak)) emberAfLevelControlClusterInitCallback(EndpointId endpoint)
58 void __attribute__((weak)) emberAfNetworkCommissioningClusterInitCallback(EndpointId endpoint)
63 void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint)
70 // Non-Cluster Related Callbacks
73 /** @brief Add To Current App Tasks
75 * This function is only useful to sleepy end devices. This function will note
76 * the passed item as part of a set of tasks the application has outstanding
77 * (e.g. message sent requiring APS acknwoledgement). This will affect how the
78 * application behaves with regard to sleeping and polling. Until the
79 * outstanding task is completed, the device may poll more frequently and sleep
82 * @param tasks Ver.: always
84 void __attribute__((weak)) emberAfAddToCurrentAppTasksCallback(EmberAfApplicationTask tasks) {}
86 /** @brief Remove From Current App Tasks
88 * This function is only useful to sleepy end devices. This function will
89 * remove the passed item from the set of tasks the application has outstanding
90 * (e.g. message sent requiring APS acknwoledgement). This will affect how the
91 * application behaves with regard to sleeping and polling. Removing the item
92 * from the list of outstanding tasks may allow the device to sleep longer and
93 * poll less frequently. If there are other outstanding tasks the system may
94 * still have to stay away and poll more often.
96 * @param tasks Ver.: always
98 void __attribute__((weak)) emberAfRemoveFromCurrentAppTasksCallback(EmberAfApplicationTask tasks) {}
100 /** @brief Allow Network Write Attribute
102 * This function is called by the application framework before it writes an
103 * attribute in response to a write attribute request from an external device.
104 * The value passed into this callback is the value to which the attribute is to
105 * be set by the framework.
106 Example: In mirroring simple metering data
107 * on an Energy Services Interface (ESI) (formerly called Energy Service Portal
108 * (ESP) in SE 1.0).), a mirrored simple meter needs to write read-only
109 * attributes on its mirror. The-meter-mirror sample application, located in
110 * app/framework/sample-apps, uses this callback to allow the mirrored device to
111 * write simple metering attributes on the mirror regardless of the fact that
112 * most simple metering attributes are defined as read-only by the ZigBee
114 Note: The ZCL specification does not (as of this
115 * writing) specify any permission-level security for writing writeable
116 * attributes. As far as the ZCL specification is concerned, if an attribute is
117 * writeable, any device that has a link key for the device should be able to
118 * write that attribute. Furthermore if an attribute is read only, it should not
119 * be written over the air. Thus, if you implement permissions for writing
120 * attributes as a feature, you MAY be operating outside the specification. This
121 * is unlikely to be a problem for writing read-only attributes, but it may be a
122 * problem for attributes that are writeable according to the specification but
123 * restricted by the application implementing this callback.
125 * @param endpoint Ver.: always
126 * @param clusterId Ver.: always
127 * @param attributeId Ver.: always
128 * @param mask Ver.: always
129 * @param manufacturerCode Ver.: always
130 * @param value Ver.: always
131 * @param type Ver.: always
133 EmberAfAttributeWritePermission __attribute__((weak))
134 emberAfAllowNetworkWriteAttributeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
135 uint16_t manufacturerCode, uint8_t * value, uint8_t type)
137 return EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL; // Default
140 /** @brief Attribute Read Access
142 * This function is called whenever the Application Framework needs to check
143 * access permission for an attribute read.
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 emberAfAttributeReadAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode, AttributeId attributeId)
156 /** @brief Attribute Write Access
158 * This function is called whenever the Application Framework needs to check
159 * access permission for an attribute write.
161 * @param endpoint Ver.: always
162 * @param clusterId Ver.: always
163 * @param manufacturerCode Ver.: always
164 * @param attributeId Ver.: always
166 bool __attribute__((weak))
167 emberAfAttributeWriteAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode, AttributeId attributeId)
172 /** @brief Default Response
174 * This function is called by the application framework when a Default Response
175 * command is received from an external device. The application should return
176 * true if the message was processed or false if it was not.
178 * @param clusterId The cluster identifier of this response. Ver.: always
179 * @param commandId The command identifier to which this is a response. Ver.:
181 * @param status Specifies either SUCCESS or the nature of the error that was
182 * detected in the received command. Ver.: always
184 bool __attribute__((weak)) emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, EmberAfStatus status)
189 /** @brief Configure Reporting Response
191 * This function is called by the application framework when a Configure
192 * Reporting Response command is received from an external device. The
193 * application should return true if the message was processed or false if it
196 * @param clusterId The cluster identifier of this response. Ver.: always
197 * @param buffer Buffer containing the list of attribute status records. Ver.:
199 * @param bufLen The length in bytes of the list. Ver.: always
201 bool __attribute__((weak)) emberAfConfigureReportingResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
206 /** @brief Read Reporting Configuration Response
208 * This function is called by the application framework when a Read Reporting
209 * Configuration Response command is received from an external device. The
210 * application should return true if the message was processed or false if it
213 * @param clusterId The cluster identifier of this response. Ver.: always
214 * @param buffer Buffer containing the list of attribute reporting configuration
215 * records. Ver.: always
216 * @param bufLen The length in bytes of the list. Ver.: always
218 bool __attribute__((weak)) emberAfReadReportingConfigurationResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
223 /** @brief Discover Attributes Response
225 * This function is called by the application framework when a Discover
226 * Attributes Response or Discover Attributes Extended Response command is
227 * received from an external device. The Discover Attributes Response command
228 * contains a bool indicating if discovery is complete and a list of zero or
229 * more attribute identifier/type records. The final argument indicates whether
230 * the response is in the extended format or not. The application should return
231 * true if the message was processed or false if it was not.
233 * @param clusterId The cluster identifier of this response. Ver.: always
234 * @param discoveryComplete Indicates whether there are more attributes to be
235 * discovered. true if there are no more attributes to be discovered. Ver.:
237 * @param buffer Buffer containing the list of attribute identifier/type
238 * records. Ver.: always
239 * @param bufLen The length in bytes of the list. Ver.: always
240 * @param extended Indicates whether the response is in the extended format or
243 bool __attribute__((weak)) emberAfDiscoverAttributesResponseCallback(ClusterId clusterId, bool discoveryComplete, uint8_t * buffer,
244 uint16_t bufLen, bool extended)
249 /** @brief Discover Commands Generated Response
251 * This function is called by the framework when Discover Commands Generated
252 * Response is received.
254 * @param clusterId The cluster identifier of this response. Ver.: always
255 * @param manufacturerCode Manufacturer code Ver.: always
256 * @param discoveryComplete Indicates whether there are more commands to be
257 * discovered. Ver.: always
258 * @param commandIds Buffer containing the list of command identifiers. Ver.:
260 * @param commandIdCount The length of bytes of the list, whish is the same as
261 * the number of identifiers. Ver.: always
263 bool __attribute__((weak))
264 emberAfDiscoverCommandsGeneratedResponseCallback(ClusterId clusterId, uint16_t manufacturerCode, bool discoveryComplete,
265 CommandId * commandIds, uint16_t commandIdCount)
270 /** @brief Discover Commands Received Response
272 * This function is called by the framework when Discover Commands Received
273 * Response is received.
275 * @param clusterId The cluster identifier of this response. Ver.: always
276 * @param manufacturerCode Manufacturer code Ver.: always
277 * @param discoveryComplete Indicates whether there are more commands to be
278 * discovered. Ver.: always
279 * @param commandIds Buffer containing the list of command identifiers. Ver.:
281 * @param commandIdCount The length of bytes of the list, whish is the same as
282 * the number of identifiers. Ver.: always
284 bool __attribute__((weak))
285 emberAfDiscoverCommandsReceivedResponseCallback(ClusterId clusterId, uint16_t manufacturerCode, bool discoveryComplete,
286 CommandId * commandIds, uint16_t commandIdCount)
291 /** @brief Pre Command Received
293 * This callback is the second in the Application Framework's message processing
294 * chain. At this point in the processing of incoming over-the-air messages, the
295 * application has determined that the incoming message is a ZCL command. It
296 * parses enough of the message to populate an EmberAfClusterCommand struct. The
297 * Application Framework defines this struct value in a local scope to the
298 * command processing but also makes it available through a global pointer
299 * called emberAfCurrentCommand, in app/framework/util/util.c. When command
300 * processing is complete, this pointer is cleared.
302 * @param cmd Ver.: always
304 bool __attribute__((weak)) emberAfPreCommandReceivedCallback(EmberAfClusterCommand * cmd)
309 /** @brief Pre Message Send
311 * This function is called by the framework when it is about to pass a message
312 * to the stack primitives for sending. This message may or may not be ZCL,
313 * ZDO, or some other protocol. This is called prior to
315 * fragmentation that may be done. If the function returns true it is assumed
316 * the callback has consumed and processed the message. The callback must also
317 * set the EmberStatus status code to be passed back to the caller. The
318 * framework will do no further processing on the message.
320 * function returns false then it is assumed that the callback has not processed
321 * the mesasge and the framework will continue to process accordingly.
323 * @param messageStruct The structure containing the parameters of the APS
324 * message to be sent. Ver.: always
325 * @param status A pointer to the status code value that will be returned to the
326 * caller. Ver.: always
328 bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberStatus * status)
333 /** @brief Message Sent
335 * This function is called by the application framework from the message sent
336 * handler, when it is informed by the stack regarding the message sent status.
337 * All of the values passed to the emberMessageSentHandler are passed on to this
338 * callback. This provides an opportunity for the application to verify that its
339 * message has been sent successfully and take the appropriate action. This
340 * callback should return a bool value of true or false. A value of true
341 * indicates that the message sent notification has been handled and should not
342 * be handled by the application framework.
344 * @param type Ver.: always
345 * @param indexOrDestination Ver.: always
346 * @param apsFrame Ver.: always
347 * @param msgLen Ver.: always
348 * @param message Ver.: always
349 * @param status Ver.: always
351 bool __attribute__((weak))
352 emberAfMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, EmberApsFrame * apsFrame, uint16_t msgLen,
353 uint8_t * message, EmberStatus status)
358 /** @brief Pre Attribute Change
360 * This function is called by the application framework before it changes an
361 * attribute value. The value passed into this callback is the value to which
362 * the attribute is to be set by the framework. The application should return
363 * ::EMBER_ZCL_STATUS_SUCCESS to permit the change or any other ::EmberAfStatus
366 * @param endpoint Ver.: always
367 * @param clusterId Ver.: always
368 * @param attributeId Ver.: always
369 * @param mask Ver.: always
370 * @param manufacturerCode Ver.: always
371 * @param type Ver.: always
372 * @param size Ver.: always
373 * @param value Ver.: always
375 EmberAfStatus __attribute__((weak))
376 emberAfPreAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
377 uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value)
379 return EMBER_ZCL_STATUS_SUCCESS;
382 /** @brief Post Attribute Change
384 * This function is called by the application framework after it changes an
385 * attribute value. The value passed into this callback is the value to which
386 * the attribute was set by the framework.
388 * @param endpoint Ver.: always
389 * @param clusterId Ver.: always
390 * @param attributeId Ver.: always
391 * @param mask Ver.: always
392 * @param manufacturerCode Ver.: always
393 * @param type Ver.: always
394 * @param size Ver.: always
395 * @param value Ver.: always
397 void __attribute__((weak))
398 emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
399 uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value)
402 /** @brief Read Attributes Response
404 * This function is called by the application framework when a Read Attributes
405 * Response command is received from an external device. The application should
406 * return true if the message was processed or false if it was not.
408 * @param clusterId The cluster identifier of this response. Ver.: always
409 * @param buffer Buffer containing the list of read attribute status records.
411 * @param bufLen The length in bytes of the list. Ver.: always
413 bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
418 /** @brief External Attribute Read
420 * Like emberAfExternalAttributeWriteCallback above, this function is called
421 * when the framework needs to read an attribute that is not stored within the
422 * Application Framework's data structures.
424 * information about the attribute itself is passed as a pointer to an
425 * EmberAfAttributeMetadata struct, which is stored within the application and
426 * used to manage the attribute. A complete description of the
427 * EmberAfAttributeMetadata struct is provided in
428 * app/framework/include/af-types.h
429 This function assumes that the
430 * application is able to read the attribute, write it into the passed buffer,
431 * and return immediately. Any attributes that require a state machine for
432 * reading and writing are not really candidates for externalization at the
433 * present time. The Application Framework does not currently include a state
434 * machine for reading or writing attributes that must take place across a
435 * series of application ticks. Attributes that cannot be read in a timely
436 * manner should be stored within the Application Framework and updated
437 * occasionally by the application code from within the
438 * emberAfMainTickCallback.
439 If the application was successfully able to
440 * read the attribute and write it into the passed buffer, it should return a
441 * value of EMBER_ZCL_STATUS_SUCCESS. Ensure that the size of the externally
442 * managed attribute value is smaller than what the buffer can hold. In the case
443 * of a buffer overflow throw an appropriate error such as
444 * EMBER_ZCL_STATUS_INSUFFICIENT_SPACE. Any other return value indicates the
445 * application was not able to read the attribute.
447 * @param endpoint Ver.: always
448 * @param clusterId Ver.: always
449 * @param attributeMetadata Ver.: always
450 * @param manufacturerCode Ver.: always
451 * @param buffer Ver.: always
452 * @param maxReadLength Ver.: always
454 EmberAfStatus __attribute__((weak))
455 emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata,
456 uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength)
458 return EMBER_ZCL_STATUS_FAILURE;
461 /** @brief Write Attributes Response
463 * This function is called by the application framework when a Write Attributes
464 * Response command is received from an external device. The application should
465 * return true if the message was processed or false if it was not.
467 * @param clusterId The cluster identifier of this response. Ver.: always
468 * @param buffer Buffer containing the list of write attribute status records.
470 * @param bufLen The length in bytes of the list. Ver.: always
472 bool __attribute__((weak)) emberAfWriteAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
477 /** @brief External Attribute Write
479 * This function is called whenever the Application Framework needs to write an
480 * attribute which is not stored within the data structures of the Application
481 * Framework itself. One of the new features in Version 2 is the ability to
482 * store attributes outside the Framework. This is particularly useful for
483 * attributes that do not need to be stored because they can be read off the
484 * hardware when they are needed, or are stored in some central location used by
485 * many modules within the system. In this case, you can indicate that the
486 * attribute is stored externally. When the framework needs to write an external
487 * attribute, it makes a call to this callback.
488 This callback is very
489 * useful for host micros which need to store attributes in persistent memory.
490 * Because each host micro (used with an Ember NCP) has its own type of
491 * persistent memory storage, the Application Framework does not include the
492 * ability to mark attributes as stored in flash the way that it does for Ember
493 * SoCs like the EM35x. On a host micro, any attributes that need to be stored
494 * in persistent memory should be marked as external and accessed through the
495 * external read and write callbacks. Any host code associated with the
496 * persistent storage should be implemented within this callback.
498 * the important information about the attribute itself is passed as a pointer
499 * to an EmberAfAttributeMetadata struct, which is stored within the application
500 * and used to manage the attribute. A complete description of the
501 * EmberAfAttributeMetadata struct is provided in
502 * app/framework/include/af-types.h.
503 This function assumes that the
504 * application is able to write the attribute and return immediately. Any
505 * attributes that require a state machine for reading and writing are not
506 * candidates for externalization at the present time. The Application Framework
507 * does not currently include a state machine for reading or writing attributes
508 * that must take place across a series of application ticks. Attributes that
509 * cannot be written immediately should be stored within the Application
510 * Framework and updated occasionally by the application code from within the
511 * emberAfMainTickCallback.
512 If the application was successfully able to
513 * write the attribute, it returns a value of EMBER_ZCL_STATUS_SUCCESS. Any
514 * other return value indicates the application was not able to write the
517 * @param endpoint Ver.: always
518 * @param clusterId Ver.: always
519 * @param attributeMetadata Ver.: always
520 * @param manufacturerCode Ver.: always
521 * @param buffer Ver.: always
523 EmberAfStatus __attribute__((weak))
524 emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata,
525 uint16_t manufacturerCode, uint8_t * buffer)
527 return EMBER_ZCL_STATUS_FAILURE;
530 /** @brief Report Attributes
532 * This function is called by the application framework when a Report Attributes
533 * command is received from an external device. The application should return
534 * true if the message was processed or false if it was not.
536 * @param clusterId The cluster identifier of this command. Ver.: always
537 * @param buffer Buffer containing the list of attribute report records. Ver.:
539 * @param bufLen The length in bytes of the list. Ver.: always
541 bool __attribute__((weak)) emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
546 /** @brief Get Current Time
548 * This callback is called when device attempts to get current time from the
549 * hardware. If this device has means to retrieve exact time, then this method
550 * should implement it. If the callback can't provide the exact time it should
551 * return 0 to indicate failure. Default action is to return 0, which indicates
552 * that device does not have access to real time.
555 uint32_t __attribute__((weak)) emberAfGetCurrentTimeCallback()
560 /** @brief Get Endpoint Info
562 * This function is a callback to an application implemented endpoint that
563 * operates outside the normal application framework. When the framework wishes
564 * to perform operations with that endpoint it uses this callback to retrieve
565 * the endpoint's information. If the endpoint exists and the application can
566 * provide data then true shall be returned. Otherwise the callback must return
569 * @param endpoint The endpoint to retrieve data for. Ver.: always
570 * @param returnNetworkIndex The index corresponding to the ZigBee network the
571 * endpoint belongs to. If not using a multi-network device, 0 must be
572 * returned. Otherwise on a multi-network device the stack will switch to this
573 * network before sending the message. Ver.: always
574 * @param returnEndpointInfo A pointer to a data struct that will be written
575 * with information about the endpoint. Ver.: always
577 bool __attribute__((weak))
578 emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex, EmberAfEndpointInfoStruct * returnEndpointInfo)
583 /** @brief Get Source Route Overhead
585 * This function is called by the framework to determine the overhead required
586 * in the network frame for source routing to a particular destination.
588 * @param destination The node id of the destination Ver.: always
590 uint8_t __attribute__((weak)) emberAfGetSourceRouteOverheadCallback(chip::NodeId destination)
595 /** @brief Registration Abort
597 * This callback is called when the device should abort the registration
601 void __attribute__((weak)) emberAfRegistrationAbortCallback() {}
603 /** @brief Interpan Send Message
605 * This function will send a raw MAC message with interpan frame format using
606 * the passed parameters.
608 * @param header Interpan header info Ver.: always
609 * @param messageLength The length of the message received or to send Ver.:
611 * @param message The message data received or to send. Ver.: always
613 EmberStatus __attribute__((weak))
614 emberAfInterpanSendMessageCallback(EmberAfInterpanHeader * header, uint16_t messageLength, uint8_t * message)
616 return EMBER_LIBRARY_NOT_PRESENT;
619 /** @brief Start Move
621 * This function is called to initiate the process for a device to move (rejoin)
625 bool __attribute__((weak)) emberAfStartMoveCallback()