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_BARRIER_CONTROL_CLUSTER_ID:
31 emberAfBarrierControlClusterInitCallback(endpoint);
33 case ZCL_BASIC_CLUSTER_ID:
34 emberAfBasicClusterInitCallback(endpoint);
36 case ZCL_BINDING_CLUSTER_ID:
37 emberAfBindingClusterInitCallback(endpoint);
39 case ZCL_COLOR_CONTROL_CLUSTER_ID:
40 emberAfColorControlClusterInitCallback(endpoint);
42 case ZCL_DOOR_LOCK_CLUSTER_ID:
43 emberAfDoorLockClusterInitCallback(endpoint);
45 case ZCL_GROUPS_CLUSTER_ID:
46 emberAfGroupsClusterInitCallback(endpoint);
48 case ZCL_IDENTIFY_CLUSTER_ID:
49 emberAfIdentifyClusterInitCallback(endpoint);
51 case ZCL_LEVEL_CONTROL_CLUSTER_ID:
52 emberAfLevelControlClusterInitCallback(endpoint);
54 case ZCL_ON_OFF_CLUSTER_ID:
55 emberAfOnOffClusterInitCallback(endpoint);
57 case ZCL_SCENES_CLUSTER_ID:
58 emberAfScenesClusterInitCallback(endpoint);
60 case ZCL_TEMP_MEASUREMENT_CLUSTER_ID:
61 emberAfTemperatureMeasurementClusterInitCallback(endpoint);
64 // Unrecognized cluster ID
69 void __attribute__((weak)) emberAfBarrierControlClusterInitCallback(EndpointId endpoint)
74 void __attribute__((weak)) emberAfBasicClusterInitCallback(EndpointId endpoint)
79 void __attribute__((weak)) emberAfBindingClusterInitCallback(EndpointId endpoint)
84 void __attribute__((weak)) emberAfColorControlClusterInitCallback(EndpointId endpoint)
89 void __attribute__((weak)) emberAfDoorLockClusterInitCallback(EndpointId endpoint)
94 void __attribute__((weak)) emberAfGroupsClusterInitCallback(EndpointId endpoint)
99 void __attribute__((weak)) emberAfIdentifyClusterInitCallback(EndpointId endpoint)
101 // To prevent warning
104 void __attribute__((weak)) emberAfLevelControlClusterInitCallback(EndpointId endpoint)
106 // To prevent warning
109 void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint)
111 // To prevent warning
114 void __attribute__((weak)) emberAfScenesClusterInitCallback(EndpointId endpoint)
116 // To prevent warning
119 void __attribute__((weak)) emberAfTemperatureMeasurementClusterInitCallback(EndpointId endpoint)
121 // To prevent warning
126 // Non-Cluster Related Callbacks
129 /** @brief Add To Current App Tasks
131 * This function is only useful to sleepy end devices. This function will note
132 * the passed item as part of a set of tasks the application has outstanding
133 * (e.g. message sent requiring APS acknwoledgement). This will affect how the
134 * application behaves with regard to sleeping and polling. Until the
135 * outstanding task is completed, the device may poll more frequently and sleep
138 * @param tasks Ver.: always
140 void __attribute__((weak)) emberAfAddToCurrentAppTasksCallback(EmberAfApplicationTask tasks) {}
142 /** @brief Remove From Current App Tasks
144 * This function is only useful to sleepy end devices. This function will
145 * remove the passed item from the set of tasks the application has outstanding
146 * (e.g. message sent requiring APS acknwoledgement). This will affect how the
147 * application behaves with regard to sleeping and polling. Removing the item
148 * from the list of outstanding tasks may allow the device to sleep longer and
149 * poll less frequently. If there are other outstanding tasks the system may
150 * still have to stay away and poll more often.
152 * @param tasks Ver.: always
154 void __attribute__((weak)) emberAfRemoveFromCurrentAppTasksCallback(EmberAfApplicationTask tasks) {}
156 /** @brief Allow Network Write Attribute
158 * This function is called by the application framework before it writes an
159 * attribute in response to a write attribute request from an external device.
160 * The value passed into this callback is the value to which the attribute is to
161 * be set by the framework.
162 Example: In mirroring simple metering data
163 * on an Energy Services Interface (ESI) (formerly called Energy Service Portal
164 * (ESP) in SE 1.0).), a mirrored simple meter needs to write read-only
165 * attributes on its mirror. The-meter-mirror sample application, located in
166 * app/framework/sample-apps, uses this callback to allow the mirrored device to
167 * write simple metering attributes on the mirror regardless of the fact that
168 * most simple metering attributes are defined as read-only by the ZigBee
170 Note: The ZCL specification does not (as of this
171 * writing) specify any permission-level security for writing writeable
172 * attributes. As far as the ZCL specification is concerned, if an attribute is
173 * writeable, any device that has a link key for the device should be able to
174 * write that attribute. Furthermore if an attribute is read only, it should not
175 * be written over the air. Thus, if you implement permissions for writing
176 * attributes as a feature, you MAY be operating outside the specification. This
177 * is unlikely to be a problem for writing read-only attributes, but it may be a
178 * problem for attributes that are writeable according to the specification but
179 * restricted by the application implementing this callback.
181 * @param endpoint Ver.: always
182 * @param clusterId Ver.: always
183 * @param attributeId Ver.: always
184 * @param mask Ver.: always
185 * @param manufacturerCode Ver.: always
186 * @param value Ver.: always
187 * @param type Ver.: always
189 EmberAfAttributeWritePermission __attribute__((weak))
190 emberAfAllowNetworkWriteAttributeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
191 uint16_t manufacturerCode, uint8_t * value, uint8_t type)
193 return EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL; // Default
196 /** @brief Attribute Read Access
198 * This function is called whenever the Application Framework needs to check
199 * access permission for an attribute read.
201 * @param endpoint Ver.: always
202 * @param clusterId Ver.: always
203 * @param manufacturerCode Ver.: always
204 * @param attributeId Ver.: always
206 bool __attribute__((weak))
207 emberAfAttributeReadAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode, AttributeId attributeId)
212 /** @brief Attribute Write Access
214 * This function is called whenever the Application Framework needs to check
215 * access permission for an attribute write.
217 * @param endpoint Ver.: always
218 * @param clusterId Ver.: always
219 * @param manufacturerCode Ver.: always
220 * @param attributeId Ver.: always
222 bool __attribute__((weak))
223 emberAfAttributeWriteAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode, AttributeId attributeId)
228 /** @brief Default Response
230 * This function is called by the application framework when a Default Response
231 * command is received from an external device. The application should return
232 * true if the message was processed or false if it was not.
234 * @param clusterId The cluster identifier of this response. Ver.: always
235 * @param commandId The command identifier to which this is a response. Ver.:
237 * @param status Specifies either SUCCESS or the nature of the error that was
238 * detected in the received command. Ver.: always
240 bool __attribute__((weak)) emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, EmberAfStatus status)
245 /** @brief Configure Reporting Response
247 * This function is called by the application framework when a Configure
248 * Reporting Response command is received from an external device. The
249 * application should return true if the message was processed or false if it
252 * @param clusterId The cluster identifier of this response. Ver.: always
253 * @param buffer Buffer containing the list of attribute status records. Ver.:
255 * @param bufLen The length in bytes of the list. Ver.: always
257 bool __attribute__((weak)) emberAfConfigureReportingResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
262 /** @brief Read Reporting Configuration Response
264 * This function is called by the application framework when a Read Reporting
265 * Configuration Response command is received from an external device. The
266 * application should return true if the message was processed or false if it
269 * @param clusterId The cluster identifier of this response. Ver.: always
270 * @param buffer Buffer containing the list of attribute reporting configuration
271 * records. Ver.: always
272 * @param bufLen The length in bytes of the list. Ver.: always
274 bool __attribute__((weak)) emberAfReadReportingConfigurationResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
279 /** @brief Discover Attributes Response
281 * This function is called by the application framework when a Discover
282 * Attributes Response or Discover Attributes Extended Response command is
283 * received from an external device. The Discover Attributes Response command
284 * contains a bool indicating if discovery is complete and a list of zero or
285 * more attribute identifier/type records. The final argument indicates whether
286 * the response is in the extended format or not. The application should return
287 * true if the message was processed or false if it was not.
289 * @param clusterId The cluster identifier of this response. Ver.: always
290 * @param discoveryComplete Indicates whether there are more attributes to be
291 * discovered. true if there are no more attributes to be discovered. Ver.:
293 * @param buffer Buffer containing the list of attribute identifier/type
294 * records. Ver.: always
295 * @param bufLen The length in bytes of the list. Ver.: always
296 * @param extended Indicates whether the response is in the extended format or
299 bool __attribute__((weak)) emberAfDiscoverAttributesResponseCallback(ClusterId clusterId, bool discoveryComplete, uint8_t * buffer,
300 uint16_t bufLen, bool extended)
305 /** @brief Discover Commands Generated Response
307 * This function is called by the framework when Discover Commands Generated
308 * Response is received.
310 * @param clusterId The cluster identifier of this response. Ver.: always
311 * @param manufacturerCode Manufacturer code Ver.: always
312 * @param discoveryComplete Indicates whether there are more commands to be
313 * discovered. Ver.: always
314 * @param commandIds Buffer containing the list of command identifiers. Ver.:
316 * @param commandIdCount The length of bytes of the list, whish is the same as
317 * the number of identifiers. Ver.: always
319 bool __attribute__((weak))
320 emberAfDiscoverCommandsGeneratedResponseCallback(ClusterId clusterId, uint16_t manufacturerCode, bool discoveryComplete,
321 CommandId * commandIds, uint16_t commandIdCount)
326 /** @brief Discover Commands Received Response
328 * This function is called by the framework when Discover Commands Received
329 * Response is received.
331 * @param clusterId The cluster identifier of this response. Ver.: always
332 * @param manufacturerCode Manufacturer code Ver.: always
333 * @param discoveryComplete Indicates whether there are more commands to be
334 * discovered. Ver.: always
335 * @param commandIds Buffer containing the list of command identifiers. Ver.:
337 * @param commandIdCount The length of bytes of the list, whish is the same as
338 * the number of identifiers. Ver.: always
340 bool __attribute__((weak))
341 emberAfDiscoverCommandsReceivedResponseCallback(ClusterId clusterId, uint16_t manufacturerCode, bool discoveryComplete,
342 CommandId * commandIds, uint16_t commandIdCount)
347 /** @brief Pre Command Received
349 * This callback is the second in the Application Framework's message processing
350 * chain. At this point in the processing of incoming over-the-air messages, the
351 * application has determined that the incoming message is a ZCL command. It
352 * parses enough of the message to populate an EmberAfClusterCommand struct. The
353 * Application Framework defines this struct value in a local scope to the
354 * command processing but also makes it available through a global pointer
355 * called emberAfCurrentCommand, in app/framework/util/util.c. When command
356 * processing is complete, this pointer is cleared.
358 * @param cmd Ver.: always
360 bool __attribute__((weak)) emberAfPreCommandReceivedCallback(EmberAfClusterCommand * cmd)
365 /** @brief Pre Message Send
367 * This function is called by the framework when it is about to pass a message
368 * to the stack primitives for sending. This message may or may not be ZCL,
369 * ZDO, or some other protocol. This is called prior to
371 * fragmentation that may be done. If the function returns true it is assumed
372 * the callback has consumed and processed the message. The callback must also
373 * set the EmberStatus status code to be passed back to the caller. The
374 * framework will do no further processing on the message.
376 * function returns false then it is assumed that the callback has not processed
377 * the mesasge and the framework will continue to process accordingly.
379 * @param messageStruct The structure containing the parameters of the APS
380 * message to be sent. Ver.: always
381 * @param status A pointer to the status code value that will be returned to the
382 * caller. Ver.: always
384 bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberStatus * status)
389 /** @brief Message Sent
391 * This function is called by the application framework from the message sent
392 * handler, when it is informed by the stack regarding the message sent status.
393 * All of the values passed to the emberMessageSentHandler are passed on to this
394 * callback. This provides an opportunity for the application to verify that its
395 * message has been sent successfully and take the appropriate action. This
396 * callback should return a bool value of true or false. A value of true
397 * indicates that the message sent notification has been handled and should not
398 * be handled by the application framework.
400 * @param type Ver.: always
401 * @param indexOrDestination Ver.: always
402 * @param apsFrame Ver.: always
403 * @param msgLen Ver.: always
404 * @param message Ver.: always
405 * @param status Ver.: always
407 bool __attribute__((weak))
408 emberAfMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, EmberApsFrame * apsFrame, uint16_t msgLen,
409 uint8_t * message, EmberStatus status)
414 /** @brief Pre Attribute Change
416 * This function is called by the application framework before it changes an
417 * attribute value. The value passed into this callback is the value to which
418 * the attribute is to be set by the framework. The application should return
419 * ::EMBER_ZCL_STATUS_SUCCESS to permit the change or any other ::EmberAfStatus
422 * @param endpoint Ver.: always
423 * @param clusterId Ver.: always
424 * @param attributeId Ver.: always
425 * @param mask Ver.: always
426 * @param manufacturerCode Ver.: always
427 * @param type Ver.: always
428 * @param size Ver.: always
429 * @param value Ver.: always
431 EmberAfStatus __attribute__((weak))
432 emberAfPreAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
433 uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value)
435 return EMBER_ZCL_STATUS_SUCCESS;
438 /** @brief Post Attribute Change
440 * This function is called by the application framework after it changes an
441 * attribute value. The value passed into this callback is the value to which
442 * the attribute was set by the framework.
444 * @param endpoint Ver.: always
445 * @param clusterId Ver.: always
446 * @param attributeId Ver.: always
447 * @param mask Ver.: always
448 * @param manufacturerCode Ver.: always
449 * @param type Ver.: always
450 * @param size Ver.: always
451 * @param value Ver.: always
453 void __attribute__((weak))
454 emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
455 uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value)
458 /** @brief Read Attributes Response
460 * This function is called by the application framework when a Read Attributes
461 * Response command is received from an external device. The application should
462 * return true if the message was processed or false if it was not.
464 * @param clusterId The cluster identifier of this response. Ver.: always
465 * @param buffer Buffer containing the list of read attribute status records.
467 * @param bufLen The length in bytes of the list. Ver.: always
469 bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
474 /** @brief External Attribute Read
476 * Like emberAfExternalAttributeWriteCallback above, this function is called
477 * when the framework needs to read an attribute that is not stored within the
478 * Application Framework's data structures.
480 * information about the attribute itself is passed as a pointer to an
481 * EmberAfAttributeMetadata struct, which is stored within the application and
482 * used to manage the attribute. A complete description of the
483 * EmberAfAttributeMetadata struct is provided in
484 * app/framework/include/af-types.h
485 This function assumes that the
486 * application is able to read the attribute, write it into the passed buffer,
487 * and return immediately. Any attributes that require a state machine for
488 * reading and writing are not really candidates for externalization at the
489 * present time. The Application Framework does not currently include a state
490 * machine for reading or writing attributes that must take place across a
491 * series of application ticks. Attributes that cannot be read in a timely
492 * manner should be stored within the Application Framework and updated
493 * occasionally by the application code from within the
494 * emberAfMainTickCallback.
495 If the application was successfully able to
496 * read the attribute and write it into the passed buffer, it should return a
497 * value of EMBER_ZCL_STATUS_SUCCESS. Ensure that the size of the externally
498 * managed attribute value is smaller than what the buffer can hold. In the case
499 * of a buffer overflow throw an appropriate error such as
500 * EMBER_ZCL_STATUS_INSUFFICIENT_SPACE. Any other return value indicates the
501 * application was not able to read the attribute.
503 * @param endpoint Ver.: always
504 * @param clusterId Ver.: always
505 * @param attributeMetadata Ver.: always
506 * @param manufacturerCode Ver.: always
507 * @param buffer Ver.: always
508 * @param maxReadLength Ver.: always
510 EmberAfStatus __attribute__((weak))
511 emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata,
512 uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength)
514 return EMBER_ZCL_STATUS_FAILURE;
517 /** @brief Write Attributes Response
519 * This function is called by the application framework when a Write Attributes
520 * Response command is received from an external device. The application should
521 * return true if the message was processed or false if it was not.
523 * @param clusterId The cluster identifier of this response. Ver.: always
524 * @param buffer Buffer containing the list of write attribute status records.
526 * @param bufLen The length in bytes of the list. Ver.: always
528 bool __attribute__((weak)) emberAfWriteAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
533 /** @brief External Attribute Write
535 * This function is called whenever the Application Framework needs to write an
536 * attribute which is not stored within the data structures of the Application
537 * Framework itself. One of the new features in Version 2 is the ability to
538 * store attributes outside the Framework. This is particularly useful for
539 * attributes that do not need to be stored because they can be read off the
540 * hardware when they are needed, or are stored in some central location used by
541 * many modules within the system. In this case, you can indicate that the
542 * attribute is stored externally. When the framework needs to write an external
543 * attribute, it makes a call to this callback.
544 This callback is very
545 * useful for host micros which need to store attributes in persistent memory.
546 * Because each host micro (used with an Ember NCP) has its own type of
547 * persistent memory storage, the Application Framework does not include the
548 * ability to mark attributes as stored in flash the way that it does for Ember
549 * SoCs like the EM35x. On a host micro, any attributes that need to be stored
550 * in persistent memory should be marked as external and accessed through the
551 * external read and write callbacks. Any host code associated with the
552 * persistent storage should be implemented within this callback.
554 * the important information about the attribute itself is passed as a pointer
555 * to an EmberAfAttributeMetadata struct, which is stored within the application
556 * and used to manage the attribute. A complete description of the
557 * EmberAfAttributeMetadata struct is provided in
558 * app/framework/include/af-types.h.
559 This function assumes that the
560 * application is able to write the attribute and return immediately. Any
561 * attributes that require a state machine for reading and writing are not
562 * candidates for externalization at the present time. The Application Framework
563 * does not currently include a state machine for reading or writing attributes
564 * that must take place across a series of application ticks. Attributes that
565 * cannot be written immediately should be stored within the Application
566 * Framework and updated occasionally by the application code from within the
567 * emberAfMainTickCallback.
568 If the application was successfully able to
569 * write the attribute, it returns a value of EMBER_ZCL_STATUS_SUCCESS. Any
570 * other return value indicates the application was not able to write the
573 * @param endpoint Ver.: always
574 * @param clusterId Ver.: always
575 * @param attributeMetadata Ver.: always
576 * @param manufacturerCode Ver.: always
577 * @param buffer Ver.: always
579 EmberAfStatus __attribute__((weak))
580 emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata,
581 uint16_t manufacturerCode, uint8_t * buffer)
583 return EMBER_ZCL_STATUS_FAILURE;
586 /** @brief Report Attributes
588 * This function is called by the application framework when a Report Attributes
589 * command is received from an external device. The application should return
590 * true if the message was processed or false if it was not.
592 * @param clusterId The cluster identifier of this command. Ver.: always
593 * @param buffer Buffer containing the list of attribute report records. Ver.:
595 * @param bufLen The length in bytes of the list. Ver.: always
597 bool __attribute__((weak)) emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
602 /** @brief Get Current Time
604 * This callback is called when device attempts to get current time from the
605 * hardware. If this device has means to retrieve exact time, then this method
606 * should implement it. If the callback can't provide the exact time it should
607 * return 0 to indicate failure. Default action is to return 0, which indicates
608 * that device does not have access to real time.
611 uint32_t __attribute__((weak)) emberAfGetCurrentTimeCallback()
616 /** @brief Get Endpoint Info
618 * This function is a callback to an application implemented endpoint that
619 * operates outside the normal application framework. When the framework wishes
620 * to perform operations with that endpoint it uses this callback to retrieve
621 * the endpoint's information. If the endpoint exists and the application can
622 * provide data then true shall be returned. Otherwise the callback must return
625 * @param endpoint The endpoint to retrieve data for. Ver.: always
626 * @param returnNetworkIndex The index corresponding to the ZigBee network the
627 * endpoint belongs to. If not using a multi-network device, 0 must be
628 * returned. Otherwise on a multi-network device the stack will switch to this
629 * network before sending the message. Ver.: always
630 * @param returnEndpointInfo A pointer to a data struct that will be written
631 * with information about the endpoint. Ver.: always
633 bool __attribute__((weak))
634 emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex, EmberAfEndpointInfoStruct * returnEndpointInfo)
639 /** @brief Get Source Route Overhead
641 * This function is called by the framework to determine the overhead required
642 * in the network frame for source routing to a particular destination.
644 * @param destination The node id of the destination Ver.: always
646 uint8_t __attribute__((weak)) emberAfGetSourceRouteOverheadCallback(chip::NodeId destination)
651 /** @brief Registration Abort
653 * This callback is called when the device should abort the registration
657 void __attribute__((weak)) emberAfRegistrationAbortCallback() {}
659 /** @brief Interpan Send Message
661 * This function will send a raw MAC message with interpan frame format using
662 * the passed parameters.
664 * @param header Interpan header info Ver.: always
665 * @param messageLength The length of the message received or to send Ver.:
667 * @param message The message data received or to send. Ver.: always
669 EmberStatus __attribute__((weak))
670 emberAfInterpanSendMessageCallback(EmberAfInterpanHeader * header, uint16_t messageLength, uint8_t * message)
672 return EMBER_LIBRARY_NOT_PRESENT;
675 /** @brief Start Move
677 * This function is called to initiate the process for a device to move (rejoin)
681 bool __attribute__((weak)) emberAfStartMoveCallback()