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"
23 #include <lib/support/Span.h>
27 // Cluster Init Functions
28 void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
32 case ZCL_BASIC_CLUSTER_ID:
33 emberAfBasicClusterInitCallback(endpoint);
35 case ZCL_LEVEL_CONTROL_CLUSTER_ID:
36 emberAfLevelControlClusterInitCallback(endpoint);
38 case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID:
39 emberAfNetworkCommissioningClusterInitCallback(endpoint);
41 case ZCL_ON_OFF_CLUSTER_ID:
42 emberAfOnOffClusterInitCallback(endpoint);
45 // Unrecognized cluster ID
50 void __attribute__((weak)) emberAfBasicClusterInitCallback(EndpointId endpoint)
55 void __attribute__((weak)) emberAfLevelControlClusterInitCallback(EndpointId endpoint)
60 void __attribute__((weak)) emberAfNetworkCommissioningClusterInitCallback(EndpointId endpoint)
65 void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint)
72 // Non-Cluster Related Callbacks
75 /** @brief Add To Current App Tasks
77 * This function is only useful to sleepy end devices. This function will note
78 * the passed item as part of a set of tasks the application has outstanding
79 * (e.g. message sent requiring APS acknwoledgement). This will affect how the
80 * application behaves with regard to sleeping and polling. Until the
81 * outstanding task is completed, the device may poll more frequently and sleep
84 * @param tasks Ver.: always
86 void __attribute__((weak)) emberAfAddToCurrentAppTasksCallback(EmberAfApplicationTask tasks) {}
88 /** @brief Remove From Current App Tasks
90 * This function is only useful to sleepy end devices. This function will
91 * remove the passed item from the set of tasks the application has outstanding
92 * (e.g. message sent requiring APS acknwoledgement). This will affect how the
93 * application behaves with regard to sleeping and polling. Removing the item
94 * from the list of outstanding tasks may allow the device to sleep longer and
95 * poll less frequently. If there are other outstanding tasks the system may
96 * still have to stay away and poll more often.
98 * @param tasks Ver.: always
100 void __attribute__((weak)) emberAfRemoveFromCurrentAppTasksCallback(EmberAfApplicationTask tasks) {}
102 /** @brief Allow Network Write Attribute
104 * This function is called by the application framework before it writes an
105 * attribute in response to a write attribute request from an external device.
106 * The value passed into this callback is the value to which the attribute is to
107 * be set by the framework.
108 Example: In mirroring simple metering data
109 * on an Energy Services Interface (ESI) (formerly called Energy Service Portal
110 * (ESP) in SE 1.0).), a mirrored simple meter needs to write read-only
111 * attributes on its mirror. The-meter-mirror sample application, located in
112 * app/framework/sample-apps, uses this callback to allow the mirrored device to
113 * write simple metering attributes on the mirror regardless of the fact that
114 * most simple metering attributes are defined as read-only by the ZigBee
116 Note: The ZCL specification does not (as of this
117 * writing) specify any permission-level security for writing writeable
118 * attributes. As far as the ZCL specification is concerned, if an attribute is
119 * writeable, any device that has a link key for the device should be able to
120 * write that attribute. Furthermore if an attribute is read only, it should not
121 * be written over the air. Thus, if you implement permissions for writing
122 * attributes as a feature, you MAY be operating outside the specification. This
123 * is unlikely to be a problem for writing read-only attributes, but it may be a
124 * problem for attributes that are writeable according to the specification but
125 * restricted by the application implementing this callback.
127 * @param endpoint Ver.: always
128 * @param clusterId Ver.: always
129 * @param attributeId Ver.: always
130 * @param mask Ver.: always
131 * @param manufacturerCode Ver.: always
132 * @param value Ver.: always
133 * @param type Ver.: always
135 EmberAfAttributeWritePermission __attribute__((weak))
136 emberAfAllowNetworkWriteAttributeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
137 uint16_t manufacturerCode, uint8_t * value, uint8_t type)
139 return EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL; // Default
142 /** @brief Attribute Read Access
144 * This function is called whenever the Application Framework needs to check
145 * access permission for an attribute read.
147 * @param endpoint Ver.: always
148 * @param clusterId Ver.: always
149 * @param manufacturerCode Ver.: always
150 * @param attributeId Ver.: always
152 bool __attribute__((weak))
153 emberAfAttributeReadAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode, AttributeId attributeId)
158 /** @brief Attribute Write Access
160 * This function is called whenever the Application Framework needs to check
161 * access permission for an attribute write.
163 * @param endpoint Ver.: always
164 * @param clusterId Ver.: always
165 * @param manufacturerCode Ver.: always
166 * @param attributeId Ver.: always
168 bool __attribute__((weak))
169 emberAfAttributeWriteAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode, AttributeId attributeId)
174 /** @brief Default Response
176 * This function is called by the application framework when a Default Response
177 * command is received from an external device. The application should return
178 * true if the message was processed or false if it was not.
180 * @param clusterId The cluster identifier of this response. Ver.: always
181 * @param commandId The command identifier to which this is a response. Ver.:
183 * @param status Specifies either SUCCESS or the nature of the error that was
184 * detected in the received command. Ver.: always
186 bool __attribute__((weak)) emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, EmberAfStatus status)
191 /** @brief Configure Reporting Response
193 * This function is called by the application framework when a Configure
194 * Reporting Response command is received from an external device. The
195 * application should return true if the message was processed or false if it
198 * @param clusterId The cluster identifier of this response. Ver.: always
199 * @param buffer Buffer containing the list of attribute status records. Ver.:
201 * @param bufLen The length in bytes of the list. Ver.: always
203 bool __attribute__((weak)) emberAfConfigureReportingResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
208 /** @brief Read Reporting Configuration Response
210 * This function is called by the application framework when a Read Reporting
211 * Configuration Response command is received from an external device. The
212 * application should return true if the message was processed or false if it
215 * @param clusterId The cluster identifier of this response. Ver.: always
216 * @param buffer Buffer containing the list of attribute reporting configuration
217 * records. Ver.: always
218 * @param bufLen The length in bytes of the list. Ver.: always
220 bool __attribute__((weak)) emberAfReadReportingConfigurationResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
225 /** @brief Discover Attributes Response
227 * This function is called by the application framework when a Discover
228 * Attributes Response or Discover Attributes Extended Response command is
229 * received from an external device. The Discover Attributes Response command
230 * contains a bool indicating if discovery is complete and a list of zero or
231 * more attribute identifier/type records. The final argument indicates whether
232 * the response is in the extended format or not. The application should return
233 * true if the message was processed or false if it was not.
235 * @param clusterId The cluster identifier of this response. Ver.: always
236 * @param discoveryComplete Indicates whether there are more attributes to be
237 * discovered. true if there are no more attributes to be discovered. Ver.:
239 * @param buffer Buffer containing the list of attribute identifier/type
240 * records. Ver.: always
241 * @param bufLen The length in bytes of the list. Ver.: always
242 * @param extended Indicates whether the response is in the extended format or
245 bool __attribute__((weak)) emberAfDiscoverAttributesResponseCallback(ClusterId clusterId, bool discoveryComplete, uint8_t * buffer,
246 uint16_t bufLen, bool extended)
251 /** @brief Discover Commands Generated Response
253 * This function is called by the framework when Discover Commands Generated
254 * Response is received.
256 * @param clusterId The cluster identifier of this response. Ver.: always
257 * @param manufacturerCode Manufacturer code Ver.: always
258 * @param discoveryComplete Indicates whether there are more commands to be
259 * discovered. Ver.: always
260 * @param commandIds Buffer containing the list of command identifiers. Ver.:
262 * @param commandIdCount The length of bytes of the list, whish is the same as
263 * the number of identifiers. Ver.: always
265 bool __attribute__((weak))
266 emberAfDiscoverCommandsGeneratedResponseCallback(ClusterId clusterId, uint16_t manufacturerCode, bool discoveryComplete,
267 CommandId * commandIds, uint16_t commandIdCount)
272 /** @brief Discover Commands Received Response
274 * This function is called by the framework when Discover Commands Received
275 * Response is received.
277 * @param clusterId The cluster identifier of this response. Ver.: always
278 * @param manufacturerCode Manufacturer code Ver.: always
279 * @param discoveryComplete Indicates whether there are more commands to be
280 * discovered. Ver.: always
281 * @param commandIds Buffer containing the list of command identifiers. Ver.:
283 * @param commandIdCount The length of bytes of the list, whish is the same as
284 * the number of identifiers. Ver.: always
286 bool __attribute__((weak))
287 emberAfDiscoverCommandsReceivedResponseCallback(ClusterId clusterId, uint16_t manufacturerCode, bool discoveryComplete,
288 CommandId * commandIds, uint16_t commandIdCount)
293 /** @brief Pre Command Received
295 * This callback is the second in the Application Framework's message processing
296 * chain. At this point in the processing of incoming over-the-air messages, the
297 * application has determined that the incoming message is a ZCL command. It
298 * parses enough of the message to populate an EmberAfClusterCommand struct. The
299 * Application Framework defines this struct value in a local scope to the
300 * command processing but also makes it available through a global pointer
301 * called emberAfCurrentCommand, in app/framework/util/util.c. When command
302 * processing is complete, this pointer is cleared.
304 * @param cmd Ver.: always
306 bool __attribute__((weak)) emberAfPreCommandReceivedCallback(EmberAfClusterCommand * cmd)
311 /** @brief Pre Message Send
313 * This function is called by the framework when it is about to pass a message
314 * to the stack primitives for sending. This message may or may not be ZCL,
315 * ZDO, or some other protocol. This is called prior to
317 * fragmentation that may be done. If the function returns true it is assumed
318 * the callback has consumed and processed the message. The callback must also
319 * set the EmberStatus status code to be passed back to the caller. The
320 * framework will do no further processing on the message.
322 * function returns false then it is assumed that the callback has not processed
323 * the mesasge and the framework will continue to process accordingly.
325 * @param messageStruct The structure containing the parameters of the APS
326 * message to be sent. Ver.: always
327 * @param status A pointer to the status code value that will be returned to the
328 * caller. Ver.: always
330 bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberStatus * status)
335 /** @brief Message Sent
337 * This function is called by the application framework from the message sent
338 * handler, when it is informed by the stack regarding the message sent status.
339 * All of the values passed to the emberMessageSentHandler are passed on to this
340 * callback. This provides an opportunity for the application to verify that its
341 * message has been sent successfully and take the appropriate action. This
342 * callback should return a bool value of true or false. A value of true
343 * indicates that the message sent notification has been handled and should not
344 * be handled by the application framework.
346 * @param type Ver.: always
347 * @param indexOrDestination Ver.: always
348 * @param apsFrame Ver.: always
349 * @param msgLen Ver.: always
350 * @param message Ver.: always
351 * @param status Ver.: always
353 bool __attribute__((weak))
354 emberAfMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, EmberApsFrame * apsFrame, uint16_t msgLen,
355 uint8_t * message, EmberStatus status)
360 /** @brief Pre Attribute Change
362 * This function is called by the application framework before it changes an
363 * attribute value. The value passed into this callback is the value to which
364 * the attribute is to be set by the framework. The application should return
365 * ::EMBER_ZCL_STATUS_SUCCESS to permit the change or any other ::EmberAfStatus
368 * @param endpoint Ver.: always
369 * @param clusterId Ver.: always
370 * @param attributeId Ver.: always
371 * @param mask Ver.: always
372 * @param manufacturerCode Ver.: always
373 * @param type Ver.: always
374 * @param size Ver.: always
375 * @param value Ver.: always
377 EmberAfStatus __attribute__((weak))
378 emberAfPreAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
379 uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value)
381 return EMBER_ZCL_STATUS_SUCCESS;
384 /** @brief Post Attribute Change
386 * This function is called by the application framework after it changes an
387 * attribute value. The value passed into this callback is the value to which
388 * the attribute was set by the framework.
390 * @param endpoint Ver.: always
391 * @param clusterId Ver.: always
392 * @param attributeId Ver.: always
393 * @param mask Ver.: always
394 * @param manufacturerCode Ver.: always
395 * @param type Ver.: always
396 * @param size Ver.: always
397 * @param value Ver.: always
399 void __attribute__((weak))
400 emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
401 uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value)
404 /** @brief Read Attributes Response
406 * This function is called by the application framework when a Read Attributes
407 * Response command is received from an external device. The application should
408 * return true if the message was processed or false if it was not.
410 * @param clusterId The cluster identifier of this response. Ver.: always
411 * @param buffer Buffer containing the list of read attribute status records.
413 * @param bufLen The length in bytes of the list. Ver.: always
415 bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
420 /** @brief External Attribute Read
422 * Like emberAfExternalAttributeWriteCallback above, this function is called
423 * when the framework needs to read an attribute that is not stored within the
424 * Application Framework's data structures.
426 * information about the attribute itself is passed as a pointer to an
427 * EmberAfAttributeMetadata struct, which is stored within the application and
428 * used to manage the attribute. A complete description of the
429 * EmberAfAttributeMetadata struct is provided in
430 * app/framework/include/af-types.h
431 This function assumes that the
432 * application is able to read the attribute, write it into the passed buffer,
433 * and return immediately. Any attributes that require a state machine for
434 * reading and writing are not really candidates for externalization at the
435 * present time. The Application Framework does not currently include a state
436 * machine for reading or writing attributes that must take place across a
437 * series of application ticks. Attributes that cannot be read in a timely
438 * manner should be stored within the Application Framework and updated
439 * occasionally by the application code from within the
440 * emberAfMainTickCallback.
441 If the application was successfully able to
442 * read the attribute and write it into the passed buffer, it should return a
443 * value of EMBER_ZCL_STATUS_SUCCESS. Ensure that the size of the externally
444 * managed attribute value is smaller than what the buffer can hold. In the case
445 * of a buffer overflow throw an appropriate error such as
446 * EMBER_ZCL_STATUS_INSUFFICIENT_SPACE. Any other return value indicates the
447 * application was not able to read the attribute.
449 * @param endpoint Ver.: always
450 * @param clusterId Ver.: always
451 * @param attributeMetadata Ver.: always
452 * @param manufacturerCode Ver.: always
453 * @param buffer Ver.: always
454 * @param maxReadLength Ver.: always
456 EmberAfStatus __attribute__((weak))
457 emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata,
458 uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength)
460 return EMBER_ZCL_STATUS_FAILURE;
463 /** @brief Write Attributes Response
465 * This function is called by the application framework when a Write Attributes
466 * Response command is received from an external device. The application should
467 * return true if the message was processed or false if it was not.
469 * @param clusterId The cluster identifier of this response. Ver.: always
470 * @param buffer Buffer containing the list of write attribute status records.
472 * @param bufLen The length in bytes of the list. Ver.: always
474 bool __attribute__((weak)) emberAfWriteAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
479 /** @brief External Attribute Write
481 * This function is called whenever the Application Framework needs to write an
482 * attribute which is not stored within the data structures of the Application
483 * Framework itself. One of the new features in Version 2 is the ability to
484 * store attributes outside the Framework. This is particularly useful for
485 * attributes that do not need to be stored because they can be read off the
486 * hardware when they are needed, or are stored in some central location used by
487 * many modules within the system. In this case, you can indicate that the
488 * attribute is stored externally. When the framework needs to write an external
489 * attribute, it makes a call to this callback.
490 This callback is very
491 * useful for host micros which need to store attributes in persistent memory.
492 * Because each host micro (used with an Ember NCP) has its own type of
493 * persistent memory storage, the Application Framework does not include the
494 * ability to mark attributes as stored in flash the way that it does for Ember
495 * SoCs like the EM35x. On a host micro, any attributes that need to be stored
496 * in persistent memory should be marked as external and accessed through the
497 * external read and write callbacks. Any host code associated with the
498 * persistent storage should be implemented within this callback.
500 * the important information about the attribute itself is passed as a pointer
501 * to an EmberAfAttributeMetadata struct, which is stored within the application
502 * and used to manage the attribute. A complete description of the
503 * EmberAfAttributeMetadata struct is provided in
504 * app/framework/include/af-types.h.
505 This function assumes that the
506 * application is able to write the attribute and return immediately. Any
507 * attributes that require a state machine for reading and writing are not
508 * candidates for externalization at the present time. The Application Framework
509 * does not currently include a state machine for reading or writing attributes
510 * that must take place across a series of application ticks. Attributes that
511 * cannot be written immediately should be stored within the Application
512 * Framework and updated occasionally by the application code from within the
513 * emberAfMainTickCallback.
514 If the application was successfully able to
515 * write the attribute, it returns a value of EMBER_ZCL_STATUS_SUCCESS. Any
516 * other return value indicates the application was not able to write the
519 * @param endpoint Ver.: always
520 * @param clusterId Ver.: always
521 * @param attributeMetadata Ver.: always
522 * @param manufacturerCode Ver.: always
523 * @param buffer Ver.: always
525 EmberAfStatus __attribute__((weak))
526 emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata,
527 uint16_t manufacturerCode, uint8_t * buffer)
529 return EMBER_ZCL_STATUS_FAILURE;
532 /** @brief Report Attributes
534 * This function is called by the application framework when a Report Attributes
535 * command is received from an external device. The application should return
536 * true if the message was processed or false if it was not.
538 * @param clusterId The cluster identifier of this command. Ver.: always
539 * @param buffer Buffer containing the list of attribute report records. Ver.:
541 * @param bufLen The length in bytes of the list. Ver.: always
543 bool __attribute__((weak)) emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
548 /** @brief Get Current Time
550 * This callback is called when device attempts to get current time from the
551 * hardware. If this device has means to retrieve exact time, then this method
552 * should implement it. If the callback can't provide the exact time it should
553 * return 0 to indicate failure. Default action is to return 0, which indicates
554 * that device does not have access to real time.
557 uint32_t __attribute__((weak)) emberAfGetCurrentTimeCallback()
562 /** @brief Get Endpoint Info
564 * This function is a callback to an application implemented endpoint that
565 * operates outside the normal application framework. When the framework wishes
566 * to perform operations with that endpoint it uses this callback to retrieve
567 * the endpoint's information. If the endpoint exists and the application can
568 * provide data then true shall be returned. Otherwise the callback must return
571 * @param endpoint The endpoint to retrieve data for. Ver.: always
572 * @param returnNetworkIndex The index corresponding to the ZigBee network the
573 * endpoint belongs to. If not using a multi-network device, 0 must be
574 * returned. Otherwise on a multi-network device the stack will switch to this
575 * network before sending the message. Ver.: always
576 * @param returnEndpointInfo A pointer to a data struct that will be written
577 * with information about the endpoint. Ver.: always
579 bool __attribute__((weak))
580 emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex, EmberAfEndpointInfoStruct * returnEndpointInfo)
585 /** @brief Get Source Route Overhead
587 * This function is called by the framework to determine the overhead required
588 * in the network frame for source routing to a particular destination.
590 * @param destination The node id of the destination Ver.: always
592 uint8_t __attribute__((weak)) emberAfGetSourceRouteOverheadCallback(chip::NodeId destination)
597 /** @brief Registration Abort
599 * This callback is called when the device should abort the registration
603 void __attribute__((weak)) emberAfRegistrationAbortCallback() {}
605 /** @brief Interpan Send Message
607 * This function will send a raw MAC message with interpan frame format using
608 * the passed parameters.
610 * @param header Interpan header info Ver.: always
611 * @param messageLength The length of the message received or to send Ver.:
613 * @param message The message data received or to send. Ver.: always
615 EmberStatus __attribute__((weak))
616 emberAfInterpanSendMessageCallback(EmberAfInterpanHeader * header, uint16_t messageLength, uint8_t * message)
618 return EMBER_LIBRARY_NOT_PRESENT;
621 /** @brief Start Move
623 * This function is called to initiate the process for a device to move (rejoin)
627 bool __attribute__((weak)) emberAfStartMoveCallback()