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_NETWORK_COMMISSIONING_CLUSTER_ID:
36 emberAfNetworkCommissioningClusterInitCallback(endpoint);
38 case ZCL_ON_OFF_CLUSTER_ID:
39 emberAfOnOffClusterInitCallback(endpoint);
42 // Unrecognized cluster ID
47 void __attribute__((weak)) emberAfBasicClusterInitCallback(EndpointId endpoint)
52 void __attribute__((weak)) emberAfNetworkCommissioningClusterInitCallback(EndpointId endpoint)
57 void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint)
64 // Non-Cluster Related Callbacks
67 /** @brief Add To Current App Tasks
69 * This function is only useful to sleepy end devices. This function will note
70 * the passed item as part of a set of tasks the application has outstanding
71 * (e.g. message sent requiring APS acknwoledgement). This will affect how the
72 * application behaves with regard to sleeping and polling. Until the
73 * outstanding task is completed, the device may poll more frequently and sleep
76 * @param tasks Ver.: always
78 void __attribute__((weak)) emberAfAddToCurrentAppTasksCallback(EmberAfApplicationTask tasks) {}
80 /** @brief Remove From Current App Tasks
82 * This function is only useful to sleepy end devices. This function will
83 * remove the passed item from the set of tasks the application has outstanding
84 * (e.g. message sent requiring APS acknwoledgement). This will affect how the
85 * application behaves with regard to sleeping and polling. Removing the item
86 * from the list of outstanding tasks may allow the device to sleep longer and
87 * poll less frequently. If there are other outstanding tasks the system may
88 * still have to stay away and poll more often.
90 * @param tasks Ver.: always
92 void __attribute__((weak)) emberAfRemoveFromCurrentAppTasksCallback(EmberAfApplicationTask tasks) {}
94 /** @brief Allow Network Write Attribute
96 * This function is called by the application framework before it writes an
97 * attribute in response to a write attribute request from an external device.
98 * The value passed into this callback is the value to which the attribute is to
99 * be set by the framework.
100 Example: In mirroring simple metering data
101 * on an Energy Services Interface (ESI) (formerly called Energy Service Portal
102 * (ESP) in SE 1.0).), a mirrored simple meter needs to write read-only
103 * attributes on its mirror. The-meter-mirror sample application, located in
104 * app/framework/sample-apps, uses this callback to allow the mirrored device to
105 * write simple metering attributes on the mirror regardless of the fact that
106 * most simple metering attributes are defined as read-only by the ZigBee
108 Note: The ZCL specification does not (as of this
109 * writing) specify any permission-level security for writing writeable
110 * attributes. As far as the ZCL specification is concerned, if an attribute is
111 * writeable, any device that has a link key for the device should be able to
112 * write that attribute. Furthermore if an attribute is read only, it should not
113 * be written over the air. Thus, if you implement permissions for writing
114 * attributes as a feature, you MAY be operating outside the specification. This
115 * is unlikely to be a problem for writing read-only attributes, but it may be a
116 * problem for attributes that are writeable according to the specification but
117 * restricted by the application implementing this callback.
119 * @param endpoint Ver.: always
120 * @param clusterId Ver.: always
121 * @param attributeId Ver.: always
122 * @param mask Ver.: always
123 * @param manufacturerCode Ver.: always
124 * @param value Ver.: always
125 * @param type Ver.: always
127 EmberAfAttributeWritePermission __attribute__((weak))
128 emberAfAllowNetworkWriteAttributeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
129 uint16_t manufacturerCode, uint8_t * value, uint8_t type)
131 return EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL; // Default
134 /** @brief Attribute Read Access
136 * This function is called whenever the Application Framework needs to check
137 * access permission for an attribute read.
139 * @param endpoint Ver.: always
140 * @param clusterId Ver.: always
141 * @param manufacturerCode Ver.: always
142 * @param attributeId Ver.: always
144 bool __attribute__((weak))
145 emberAfAttributeReadAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode, AttributeId attributeId)
150 /** @brief Attribute Write Access
152 * This function is called whenever the Application Framework needs to check
153 * access permission for an attribute write.
155 * @param endpoint Ver.: always
156 * @param clusterId Ver.: always
157 * @param manufacturerCode Ver.: always
158 * @param attributeId Ver.: always
160 bool __attribute__((weak))
161 emberAfAttributeWriteAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode, AttributeId attributeId)
166 /** @brief Default Response
168 * This function is called by the application framework when a Default Response
169 * command is received from an external device. The application should return
170 * true if the message was processed or false if it was not.
172 * @param clusterId The cluster identifier of this response. Ver.: always
173 * @param commandId The command identifier to which this is a response. Ver.:
175 * @param status Specifies either SUCCESS or the nature of the error that was
176 * detected in the received command. Ver.: always
178 bool __attribute__((weak)) emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, EmberAfStatus status)
183 /** @brief Configure Reporting Response
185 * This function is called by the application framework when a Configure
186 * Reporting Response command is received from an external device. The
187 * application should return true if the message was processed or false if it
190 * @param clusterId The cluster identifier of this response. Ver.: always
191 * @param buffer Buffer containing the list of attribute status records. Ver.:
193 * @param bufLen The length in bytes of the list. Ver.: always
195 bool __attribute__((weak)) emberAfConfigureReportingResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
200 /** @brief Read Reporting Configuration Response
202 * This function is called by the application framework when a Read Reporting
203 * Configuration Response command is received from an external device. The
204 * application should return true if the message was processed or false if it
207 * @param clusterId The cluster identifier of this response. Ver.: always
208 * @param buffer Buffer containing the list of attribute reporting configuration
209 * records. Ver.: always
210 * @param bufLen The length in bytes of the list. Ver.: always
212 bool __attribute__((weak)) emberAfReadReportingConfigurationResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
217 /** @brief Discover Attributes Response
219 * This function is called by the application framework when a Discover
220 * Attributes Response or Discover Attributes Extended Response command is
221 * received from an external device. The Discover Attributes Response command
222 * contains a bool indicating if discovery is complete and a list of zero or
223 * more attribute identifier/type records. The final argument indicates whether
224 * the response is in the extended format or not. The application should return
225 * true if the message was processed or false if it was not.
227 * @param clusterId The cluster identifier of this response. Ver.: always
228 * @param discoveryComplete Indicates whether there are more attributes to be
229 * discovered. true if there are no more attributes to be discovered. Ver.:
231 * @param buffer Buffer containing the list of attribute identifier/type
232 * records. Ver.: always
233 * @param bufLen The length in bytes of the list. Ver.: always
234 * @param extended Indicates whether the response is in the extended format or
237 bool __attribute__((weak)) emberAfDiscoverAttributesResponseCallback(ClusterId clusterId, bool discoveryComplete, uint8_t * buffer,
238 uint16_t bufLen, bool extended)
243 /** @brief Discover Commands Generated Response
245 * This function is called by the framework when Discover Commands Generated
246 * Response is received.
248 * @param clusterId The cluster identifier of this response. Ver.: always
249 * @param manufacturerCode Manufacturer code Ver.: always
250 * @param discoveryComplete Indicates whether there are more commands to be
251 * discovered. Ver.: always
252 * @param commandIds Buffer containing the list of command identifiers. Ver.:
254 * @param commandIdCount The length of bytes of the list, whish is the same as
255 * the number of identifiers. Ver.: always
257 bool __attribute__((weak))
258 emberAfDiscoverCommandsGeneratedResponseCallback(ClusterId clusterId, uint16_t manufacturerCode, bool discoveryComplete,
259 CommandId * commandIds, uint16_t commandIdCount)
264 /** @brief Discover Commands Received Response
266 * This function is called by the framework when Discover Commands Received
267 * Response is received.
269 * @param clusterId The cluster identifier of this response. Ver.: always
270 * @param manufacturerCode Manufacturer code Ver.: always
271 * @param discoveryComplete Indicates whether there are more commands to be
272 * discovered. Ver.: always
273 * @param commandIds Buffer containing the list of command identifiers. Ver.:
275 * @param commandIdCount The length of bytes of the list, whish is the same as
276 * the number of identifiers. Ver.: always
278 bool __attribute__((weak))
279 emberAfDiscoverCommandsReceivedResponseCallback(ClusterId clusterId, uint16_t manufacturerCode, bool discoveryComplete,
280 CommandId * commandIds, uint16_t commandIdCount)
285 /** @brief Pre Command Received
287 * This callback is the second in the Application Framework's message processing
288 * chain. At this point in the processing of incoming over-the-air messages, the
289 * application has determined that the incoming message is a ZCL command. It
290 * parses enough of the message to populate an EmberAfClusterCommand struct. The
291 * Application Framework defines this struct value in a local scope to the
292 * command processing but also makes it available through a global pointer
293 * called emberAfCurrentCommand, in app/framework/util/util.c. When command
294 * processing is complete, this pointer is cleared.
296 * @param cmd Ver.: always
298 bool __attribute__((weak)) emberAfPreCommandReceivedCallback(EmberAfClusterCommand * cmd)
303 /** @brief Pre Message Send
305 * This function is called by the framework when it is about to pass a message
306 * to the stack primitives for sending. This message may or may not be ZCL,
307 * ZDO, or some other protocol. This is called prior to
309 * fragmentation that may be done. If the function returns true it is assumed
310 * the callback has consumed and processed the message. The callback must also
311 * set the EmberStatus status code to be passed back to the caller. The
312 * framework will do no further processing on the message.
314 * function returns false then it is assumed that the callback has not processed
315 * the mesasge and the framework will continue to process accordingly.
317 * @param messageStruct The structure containing the parameters of the APS
318 * message to be sent. Ver.: always
319 * @param status A pointer to the status code value that will be returned to the
320 * caller. Ver.: always
322 bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberStatus * status)
327 /** @brief Message Sent
329 * This function is called by the application framework from the message sent
330 * handler, when it is informed by the stack regarding the message sent status.
331 * All of the values passed to the emberMessageSentHandler are passed on to this
332 * callback. This provides an opportunity for the application to verify that its
333 * message has been sent successfully and take the appropriate action. This
334 * callback should return a bool value of true or false. A value of true
335 * indicates that the message sent notification has been handled and should not
336 * be handled by the application framework.
338 * @param type Ver.: always
339 * @param indexOrDestination Ver.: always
340 * @param apsFrame Ver.: always
341 * @param msgLen Ver.: always
342 * @param message Ver.: always
343 * @param status Ver.: always
345 bool __attribute__((weak))
346 emberAfMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, EmberApsFrame * apsFrame, uint16_t msgLen,
347 uint8_t * message, EmberStatus status)
352 /** @brief Pre Attribute Change
354 * This function is called by the application framework before it changes an
355 * attribute value. The value passed into this callback is the value to which
356 * the attribute is to be set by the framework. The application should return
357 * ::EMBER_ZCL_STATUS_SUCCESS to permit the change or any other ::EmberAfStatus
360 * @param endpoint Ver.: always
361 * @param clusterId Ver.: always
362 * @param attributeId Ver.: always
363 * @param mask Ver.: always
364 * @param manufacturerCode Ver.: always
365 * @param type Ver.: always
366 * @param size Ver.: always
367 * @param value Ver.: always
369 EmberAfStatus __attribute__((weak))
370 emberAfPreAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
371 uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value)
373 return EMBER_ZCL_STATUS_SUCCESS;
376 /** @brief Post Attribute Change
378 * This function is called by the application framework after it changes an
379 * attribute value. The value passed into this callback is the value to which
380 * the attribute was set by the framework.
382 * @param endpoint Ver.: always
383 * @param clusterId Ver.: always
384 * @param attributeId Ver.: always
385 * @param mask Ver.: always
386 * @param manufacturerCode Ver.: always
387 * @param type Ver.: always
388 * @param size Ver.: always
389 * @param value Ver.: always
391 void __attribute__((weak))
392 emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
393 uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value)
396 /** @brief Read Attributes Response
398 * This function is called by the application framework when a Read Attributes
399 * Response command is received from an external device. The application should
400 * return true if the message was processed or false if it was not.
402 * @param clusterId The cluster identifier of this response. Ver.: always
403 * @param buffer Buffer containing the list of read attribute status records.
405 * @param bufLen The length in bytes of the list. Ver.: always
407 bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
412 /** @brief External Attribute Read
414 * Like emberAfExternalAttributeWriteCallback above, this function is called
415 * when the framework needs to read an attribute that is not stored within the
416 * Application Framework's data structures.
418 * information about the attribute itself is passed as a pointer to an
419 * EmberAfAttributeMetadata struct, which is stored within the application and
420 * used to manage the attribute. A complete description of the
421 * EmberAfAttributeMetadata struct is provided in
422 * app/framework/include/af-types.h
423 This function assumes that the
424 * application is able to read the attribute, write it into the passed buffer,
425 * and return immediately. Any attributes that require a state machine for
426 * reading and writing are not really candidates for externalization at the
427 * present time. The Application Framework does not currently include a state
428 * machine for reading or writing attributes that must take place across a
429 * series of application ticks. Attributes that cannot be read in a timely
430 * manner should be stored within the Application Framework and updated
431 * occasionally by the application code from within the
432 * emberAfMainTickCallback.
433 If the application was successfully able to
434 * read the attribute and write it into the passed buffer, it should return a
435 * value of EMBER_ZCL_STATUS_SUCCESS. Ensure that the size of the externally
436 * managed attribute value is smaller than what the buffer can hold. In the case
437 * of a buffer overflow throw an appropriate error such as
438 * EMBER_ZCL_STATUS_INSUFFICIENT_SPACE. Any other return value indicates the
439 * application was not able to read the attribute.
441 * @param endpoint Ver.: always
442 * @param clusterId Ver.: always
443 * @param attributeMetadata Ver.: always
444 * @param manufacturerCode Ver.: always
445 * @param buffer Ver.: always
446 * @param maxReadLength Ver.: always
448 EmberAfStatus __attribute__((weak))
449 emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata,
450 uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength)
452 return EMBER_ZCL_STATUS_FAILURE;
455 /** @brief Write Attributes Response
457 * This function is called by the application framework when a Write Attributes
458 * Response command is received from an external device. The application should
459 * return true if the message was processed or false if it was not.
461 * @param clusterId The cluster identifier of this response. Ver.: always
462 * @param buffer Buffer containing the list of write attribute status records.
464 * @param bufLen The length in bytes of the list. Ver.: always
466 bool __attribute__((weak)) emberAfWriteAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
471 /** @brief External Attribute Write
473 * This function is called whenever the Application Framework needs to write an
474 * attribute which is not stored within the data structures of the Application
475 * Framework itself. One of the new features in Version 2 is the ability to
476 * store attributes outside the Framework. This is particularly useful for
477 * attributes that do not need to be stored because they can be read off the
478 * hardware when they are needed, or are stored in some central location used by
479 * many modules within the system. In this case, you can indicate that the
480 * attribute is stored externally. When the framework needs to write an external
481 * attribute, it makes a call to this callback.
482 This callback is very
483 * useful for host micros which need to store attributes in persistent memory.
484 * Because each host micro (used with an Ember NCP) has its own type of
485 * persistent memory storage, the Application Framework does not include the
486 * ability to mark attributes as stored in flash the way that it does for Ember
487 * SoCs like the EM35x. On a host micro, any attributes that need to be stored
488 * in persistent memory should be marked as external and accessed through the
489 * external read and write callbacks. Any host code associated with the
490 * persistent storage should be implemented within this callback.
492 * the important information about the attribute itself is passed as a pointer
493 * to an EmberAfAttributeMetadata struct, which is stored within the application
494 * and used to manage the attribute. A complete description of the
495 * EmberAfAttributeMetadata struct is provided in
496 * app/framework/include/af-types.h.
497 This function assumes that the
498 * application is able to write the attribute and return immediately. Any
499 * attributes that require a state machine for reading and writing are not
500 * candidates for externalization at the present time. The Application Framework
501 * does not currently include a state machine for reading or writing attributes
502 * that must take place across a series of application ticks. Attributes that
503 * cannot be written immediately should be stored within the Application
504 * Framework and updated occasionally by the application code from within the
505 * emberAfMainTickCallback.
506 If the application was successfully able to
507 * write the attribute, it returns a value of EMBER_ZCL_STATUS_SUCCESS. Any
508 * other return value indicates the application was not able to write the
511 * @param endpoint Ver.: always
512 * @param clusterId Ver.: always
513 * @param attributeMetadata Ver.: always
514 * @param manufacturerCode Ver.: always
515 * @param buffer Ver.: always
517 EmberAfStatus __attribute__((weak))
518 emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata,
519 uint16_t manufacturerCode, uint8_t * buffer)
521 return EMBER_ZCL_STATUS_FAILURE;
524 /** @brief Report Attributes
526 * This function is called by the application framework when a Report Attributes
527 * command is received from an external device. The application should return
528 * true if the message was processed or false if it was not.
530 * @param clusterId The cluster identifier of this command. Ver.: always
531 * @param buffer Buffer containing the list of attribute report records. Ver.:
533 * @param bufLen The length in bytes of the list. Ver.: always
535 bool __attribute__((weak)) emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
540 /** @brief Get Current Time
542 * This callback is called when device attempts to get current time from the
543 * hardware. If this device has means to retrieve exact time, then this method
544 * should implement it. If the callback can't provide the exact time it should
545 * return 0 to indicate failure. Default action is to return 0, which indicates
546 * that device does not have access to real time.
549 uint32_t __attribute__((weak)) emberAfGetCurrentTimeCallback()
554 /** @brief Get Endpoint Info
556 * This function is a callback to an application implemented endpoint that
557 * operates outside the normal application framework. When the framework wishes
558 * to perform operations with that endpoint it uses this callback to retrieve
559 * the endpoint's information. If the endpoint exists and the application can
560 * provide data then true shall be returned. Otherwise the callback must return
563 * @param endpoint The endpoint to retrieve data for. Ver.: always
564 * @param returnNetworkIndex The index corresponding to the ZigBee network the
565 * endpoint belongs to. If not using a multi-network device, 0 must be
566 * returned. Otherwise on a multi-network device the stack will switch to this
567 * network before sending the message. Ver.: always
568 * @param returnEndpointInfo A pointer to a data struct that will be written
569 * with information about the endpoint. Ver.: always
571 bool __attribute__((weak))
572 emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex, EmberAfEndpointInfoStruct * returnEndpointInfo)
577 /** @brief Get Source Route Overhead
579 * This function is called by the framework to determine the overhead required
580 * in the network frame for source routing to a particular destination.
582 * @param destination The node id of the destination Ver.: always
584 uint8_t __attribute__((weak)) emberAfGetSourceRouteOverheadCallback(chip::NodeId destination)
589 /** @brief Registration Abort
591 * This callback is called when the device should abort the registration
595 void __attribute__((weak)) emberAfRegistrationAbortCallback() {}
597 /** @brief Interpan Send Message
599 * This function will send a raw MAC message with interpan frame format using
600 * the passed parameters.
602 * @param header Interpan header info Ver.: always
603 * @param messageLength The length of the message received or to send Ver.:
605 * @param message The message data received or to send. Ver.: always
607 EmberStatus __attribute__((weak))
608 emberAfInterpanSendMessageCallback(EmberAfInterpanHeader * header, uint16_t messageLength, uint8_t * message)
610 return EMBER_LIBRARY_NOT_PRESENT;
613 /** @brief Start Move
615 * This function is called to initiate the process for a device to move (rejoin)
619 bool __attribute__((weak)) emberAfStartMoveCallback()