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
20 // Prevent multiple inclusion
23 #include "af-structs.h"
25 #include "basic-types.h"
27 /** @brief Cluster Init
29 * This function is called when a specific cluster is initialized. It gives the
30 * application an opportunity to take care of cluster initialization procedures.
31 * It is called exactly once for each endpoint where cluster is present.
33 * @param endpoint Ver.: always
34 * @param clusterId Ver.: always
36 void emberAfClusterInitCallback(chip::EndpointId endpoint, chip::ClusterId clusterId);
38 // Cluster Init Functions
40 /** @brief On/off Cluster Init
44 * @param endpoint Endpoint that is being initialized
46 void emberAfOnOffClusterInitCallback(chip::EndpointId endpoint);
48 // Cluster Server/Client Init Functions
51 // On/off Cluster server
54 /** @brief On/off Cluster Server Init
58 * @param endpoint Endpoint that is being initialized
60 void emberAfOnOffClusterServerInitCallback(chip::EndpointId endpoint);
62 /** @brief On/off Cluster Server Attribute Changed
64 * Server Attribute Changed
66 * @param endpoint Endpoint that is being initialized
67 * @param attributeId Attribute that changed
69 void emberAfOnOffClusterServerAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId);
71 /** @brief On/off Cluster Server Manufacturer Specific Attribute Changed
73 * Server Manufacturer Specific Attribute Changed
75 * @param endpoint Endpoint that is being initialized
76 * @param attributeId Attribute that changed
77 * @param manufacturerCode Manufacturer Code of the attribute that changed
79 void emberAfOnOffClusterServerManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId,
80 uint16_t manufacturerCode);
82 /** @brief On/off Cluster Server Message Sent
86 * @param type The type of message sent
87 * @param indexOrDestination The destination or address to which the message was sent
88 * @param apsFrame The APS frame for the message
89 * @param msgLen The length of the message
90 * @param message The message that was sent
91 * @param status The status of the sent message
93 void emberAfOnOffClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination,
94 EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status);
96 /** @brief On/off Cluster Server Pre Attribute Changed
98 * server Pre Attribute Changed
100 * @param endpoint Endpoint that is being initialized
101 * @param attributeId Attribute to be changed
102 * @param attributeType Attribute type
103 * @param size Attribute size
104 * @param value Attribute value
106 EmberAfStatus emberAfOnOffClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId,
107 EmberAfAttributeType attributeType, uint8_t size,
110 /** @brief On/off Cluster Server Tick
114 * @param endpoint Endpoint that is being served
116 void emberAfOnOffClusterServerTickCallback(chip::EndpointId endpoint);
118 // Cluster Commands Callback
121 * @brief On/off Cluster Off Command callback
124 bool emberAfOnOffClusterOffCallback();
127 * @brief On/off Cluster On Command callback
130 bool emberAfOnOffClusterOnCallback();
133 * @brief On/off Cluster Toggle Command callback
136 bool emberAfOnOffClusterToggleCallback();
139 // Non-Cluster Related Callbacks
142 /** @brief Add To Current App Tasks
144 * This function is only useful to sleepy end devices. This function will note
145 * the passed item as part of a 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. Until the
148 * outstanding task is completed, the device may poll more frequently and sleep
151 * @param tasks Ver.: always
153 void emberAfAddToCurrentAppTasksCallback(EmberAfApplicationTask tasks);
155 /** @brief Remove From Current App Tasks
157 * This function is only useful to sleepy end devices. This function will
158 * remove the passed item from the set of tasks the application has outstanding
159 * (e.g. message sent requiring APS acknwoledgement). This will affect how the
160 * application behaves with regard to sleeping and polling. Removing the item
161 * from the list of outstanding tasks may allow the device to sleep longer and
162 * poll less frequently. If there are other outstanding tasks the system may
163 * still have to stay away and poll more often.
165 * @param tasks Ver.: always
167 void emberAfRemoveFromCurrentAppTasksCallback(EmberAfApplicationTask tasks);
169 /** @brief Allow Network Write Attribute
171 * This function is called by the application framework before it writes an
172 * attribute in response to a write attribute request from an external device.
173 * The value passed into this callback is the value to which the attribute is to
174 * be set by the framework.
175 Example: In mirroring simple metering data
176 * on an Energy Services Interface (ESI) (formerly called Energy Service Portal
177 * (ESP) in SE 1.0).), a mirrored simple meter needs to write read-only
178 * attributes on its mirror. The-meter-mirror sample application, located in
179 * app/framework/sample-apps, uses this callback to allow the mirrored device to
180 * write simple metering attributes on the mirror regardless of the fact that
181 * most simple metering attributes are defined as read-only by the ZigBee
183 Note: The ZCL specification does not (as of this
184 * writing) specify any permission-level security for writing writeable
185 * attributes. As far as the ZCL specification is concerned, if an attribute is
186 * writeable, any device that has a link key for the device should be able to
187 * write that attribute. Furthermore if an attribute is read only, it should not
188 * be written over the air. Thus, if you implement permissions for writing
189 * attributes as a feature, you MAY be operating outside the specification. This
190 * is unlikely to be a problem for writing read-only attributes, but it may be a
191 * problem for attributes that are writeable according to the specification but
192 * restricted by the application implementing this callback.
194 * @param endpoint Ver.: always
195 * @param clusterId Ver.: always
196 * @param attributeId Ver.: always
197 * @param mask Ver.: always
198 * @param manufacturerCode Ver.: always
199 * @param value Ver.: always
200 * @param type Ver.: always
202 EmberAfAttributeWritePermission emberAfAllowNetworkWriteAttributeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId,
203 chip::AttributeId attributeId, uint8_t mask,
204 uint16_t manufacturerCode, uint8_t * value, uint8_t type);
206 /** @brief Attribute Read Access
208 * This function is called whenever the Application Framework needs to check
209 * access permission for an attribute read.
211 * @param endpoint Ver.: always
212 * @param clusterId Ver.: always
213 * @param manufacturerCode Ver.: always
214 * @param attributeId Ver.: always
216 bool emberAfAttributeReadAccessCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, uint16_t manufacturerCode,
217 chip::AttributeId attributeId);
219 /** @brief Attribute Write Access
221 * This function is called whenever the Application Framework needs to check
222 * access permission for an attribute write.
224 * @param endpoint Ver.: always
225 * @param clusterId Ver.: always
226 * @param manufacturerCode Ver.: always
227 * @param attributeId Ver.: always
229 bool emberAfAttributeWriteAccessCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, uint16_t manufacturerCode,
230 chip::AttributeId attributeId);
232 /** @brief Default Response
234 * This function is called by the application framework when a Default Response
235 * command is received from an external device. The application should return
236 * true if the message was processed or false if it was not.
238 * @param clusterId The cluster identifier of this response. Ver.: always
239 * @param commandId The command identifier to which this is a response. Ver.:
241 * @param status Specifies either SUCCESS or the nature of the error that was
242 * detected in the received command. Ver.: always
244 bool emberAfDefaultResponseCallback(chip::ClusterId clusterId, chip::CommandId commandId, EmberAfStatus status);
246 /** @brief Configure Reporting Response
248 * This function is called by the application framework when a Configure
249 * Reporting Response command is received from an external device. The
250 * application should return true if the message was processed or false if it
253 * @param clusterId The cluster identifier of this response. Ver.: always
254 * @param buffer Buffer containing the list of attribute status records. Ver.:
256 * @param bufLen The length in bytes of the list. Ver.: always
258 bool emberAfConfigureReportingResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen);
260 /** @brief Read Reporting Configuration Response
262 * This function is called by the application framework when a Read Reporting
263 * Configuration Response command is received from an external device. The
264 * application should return true if the message was processed or false if it
267 * @param clusterId The cluster identifier of this response. Ver.: always
268 * @param buffer Buffer containing the list of attribute reporting configuration
269 * records. Ver.: always
270 * @param bufLen The length in bytes of the list. Ver.: always
272 bool emberAfReadReportingConfigurationResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen);
274 /** @brief Discover Attributes Response
276 * This function is called by the application framework when a Discover
277 * Attributes Response or Discover Attributes Extended Response command is
278 * received from an external device. The Discover Attributes Response command
279 * contains a bool indicating if discovery is complete and a list of zero or
280 * more attribute identifier/type records. The final argument indicates whether
281 * the response is in the extended format or not. The application should return
282 * true if the message was processed or false if it was not.
284 * @param clusterId The cluster identifier of this response. Ver.: always
285 * @param discoveryComplete Indicates whether there are more attributes to be
286 * discovered. true if there are no more attributes to be discovered. Ver.:
288 * @param buffer Buffer containing the list of attribute identifier/type
289 * records. Ver.: always
290 * @param bufLen The length in bytes of the list. Ver.: always
291 * @param extended Indicates whether the response is in the extended format or
294 bool emberAfDiscoverAttributesResponseCallback(chip::ClusterId clusterId, bool discoveryComplete, uint8_t * buffer, uint16_t bufLen,
297 /** @brief Discover Commands Generated Response
299 * This function is called by the framework when Discover Commands Generated
300 * Response is received.
302 * @param clusterId The cluster identifier of this response. Ver.: always
303 * @param manufacturerCode Manufacturer code Ver.: always
304 * @param discoveryComplete Indicates whether there are more commands to be
305 * discovered. Ver.: always
306 * @param commandIds Buffer containing the list of command identifiers. Ver.:
308 * @param commandIdCount The length of bytes of the list, whish is the same as
309 * the number of identifiers. Ver.: always
311 bool emberAfDiscoverCommandsGeneratedResponseCallback(chip::ClusterId clusterId, uint16_t manufacturerCode, bool discoveryComplete,
312 chip::CommandId * commandIds, uint16_t commandIdCount);
314 /** @brief Discover Commands Received Response
316 * This function is called by the framework when Discover Commands Received
317 * Response is received.
319 * @param clusterId The cluster identifier of this response. Ver.: always
320 * @param manufacturerCode Manufacturer code Ver.: always
321 * @param discoveryComplete Indicates whether there are more commands to be
322 * discovered. Ver.: always
323 * @param commandIds Buffer containing the list of command identifiers. Ver.:
325 * @param commandIdCount The length of bytes of the list, whish is the same as
326 * the number of identifiers. Ver.: always
328 bool emberAfDiscoverCommandsReceivedResponseCallback(chip::ClusterId clusterId, uint16_t manufacturerCode, bool discoveryComplete,
329 chip::CommandId * commandIds, uint16_t commandIdCount);
331 /** @brief Pre Command Received
333 * This callback is the second in the Application Framework's message processing
334 * chain. At this point in the processing of incoming over-the-air messages, the
335 * application has determined that the incoming message is a ZCL command. It
336 * parses enough of the message to populate an EmberAfClusterCommand struct. The
337 * Application Framework defines this struct value in a local scope to the
338 * command processing but also makes it available through a global pointer
339 * called emberAfCurrentCommand, in app/framework/util/util.c. When command
340 * processing is complete, this pointer is cleared.
342 * @param cmd Ver.: always
344 bool emberAfPreCommandReceivedCallback(EmberAfClusterCommand * cmd);
346 /** @brief Pre Message Send
348 * This function is called by the framework when it is about to pass a message
349 * to the stack primitives for sending. This message may or may not be ZCL,
350 * ZDO, or some other protocol. This is called prior to
352 * fragmentation that may be done. If the function returns true it is assumed
353 * the callback has consumed and processed the message. The callback must also
354 * set the EmberStatus status code to be passed back to the caller. The
355 * framework will do no further processing on the message.
357 * function returns false then it is assumed that the callback has not processed
358 * the mesasge and the framework will continue to process accordingly.
360 * @param messageStruct The structure containing the parameters of the APS
361 * message to be sent. Ver.: always
362 * @param status A pointer to the status code value that will be returned to the
363 * caller. Ver.: always
365 bool emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberStatus * status);
367 /** @brief Message Sent
369 * This function is called by the application framework from the message sent
370 * handler, when it is informed by the stack regarding the message sent status.
371 * All of the values passed to the emberMessageSentHandler are passed on to this
372 * callback. This provides an opportunity for the application to verify that its
373 * message has been sent successfully and take the appropriate action. This
374 * callback should return a bool value of true or false. A value of true
375 * indicates that the message sent notification has been handled and should not
376 * be handled by the application framework.
378 * @param type Ver.: always
379 * @param indexOrDestination Ver.: always
380 * @param apsFrame Ver.: always
381 * @param msgLen Ver.: always
382 * @param message Ver.: always
383 * @param status Ver.: always
385 bool emberAfMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, EmberApsFrame * apsFrame,
386 uint16_t msgLen, uint8_t * message, EmberStatus status);
388 /** @brief Pre Attribute Change
390 * This function is called by the application framework before it changes an
391 * attribute value. The value passed into this callback is the value to which
392 * the attribute is to be set by the framework. The application should return
393 * ::EMBER_ZCL_STATUS_SUCCESS to permit the change or any other ::EmberAfStatus
396 * @param endpoint Ver.: always
397 * @param clusterId Ver.: always
398 * @param attributeId Ver.: always
399 * @param mask Ver.: always
400 * @param manufacturerCode Ver.: always
401 * @param type Ver.: always
402 * @param size Ver.: always
403 * @param value Ver.: always
405 EmberAfStatus emberAfPreAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
406 uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint8_t size,
409 /** @brief Post Attribute Change
411 * This function is called by the application framework after it changes an
412 * attribute value. The value passed into this callback is the value to which
413 * the attribute was set by the framework.
415 * @param endpoint Ver.: always
416 * @param clusterId Ver.: always
417 * @param attributeId Ver.: always
418 * @param mask Ver.: always
419 * @param manufacturerCode Ver.: always
420 * @param type Ver.: always
421 * @param size Ver.: always
422 * @param value Ver.: always
424 void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
425 uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value);
427 /** @brief Read Attributes Response
429 * This function is called by the application framework when a Read Attributes
430 * Response command is received from an external device. The application should
431 * return true if the message was processed or false if it was not.
433 * @param clusterId The cluster identifier of this response. Ver.: always
434 * @param buffer Buffer containing the list of read attribute status records.
436 * @param bufLen The length in bytes of the list. Ver.: always
438 bool emberAfReadAttributesResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen);
440 /** @brief External Attribute Read
442 * Like emberAfExternalAttributeWriteCallback above, this function is called
443 * when the framework needs to read an attribute that is not stored within the
444 * Application Framework's data structures.
446 * information about the attribute itself is passed as a pointer to an
447 * EmberAfAttributeMetadata struct, which is stored within the application and
448 * used to manage the attribute. A complete description of the
449 * EmberAfAttributeMetadata struct is provided in
450 * app/framework/include/af-types.h
451 This function assumes that the
452 * application is able to read the attribute, write it into the passed buffer,
453 * and return immediately. Any attributes that require a state machine for
454 * reading and writing are not really candidates for externalization at the
455 * present time. The Application Framework does not currently include a state
456 * machine for reading or writing attributes that must take place across a
457 * series of application ticks. Attributes that cannot be read in a timely
458 * manner should be stored within the Application Framework and updated
459 * occasionally by the application code from within the
460 * emberAfMainTickCallback.
461 If the application was successfully able to
462 * read the attribute and write it into the passed buffer, it should return a
463 * value of EMBER_ZCL_STATUS_SUCCESS. Ensure that the size of the externally
464 * managed attribute value is smaller than what the buffer can hold. In the case
465 * of a buffer overflow throw an appropriate error such as
466 * EMBER_ZCL_STATUS_INSUFFICIENT_SPACE. Any other return value indicates the
467 * application was not able to read the attribute.
469 * @param endpoint Ver.: always
470 * @param clusterId Ver.: always
471 * @param attributeMetadata Ver.: always
472 * @param manufacturerCode Ver.: always
473 * @param buffer Ver.: always
474 * @param maxReadLength Ver.: always
476 EmberAfStatus emberAfExternalAttributeReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId,
477 EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode,
478 uint8_t * buffer, uint16_t maxReadLength);
480 /** @brief Write Attributes Response
482 * This function is called by the application framework when a Write Attributes
483 * Response command is received from an external device. The application should
484 * return true if the message was processed or false if it was not.
486 * @param clusterId The cluster identifier of this response. Ver.: always
487 * @param buffer Buffer containing the list of write attribute status records.
489 * @param bufLen The length in bytes of the list. Ver.: always
491 bool emberAfWriteAttributesResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen);
493 /** @brief External Attribute Write
495 * This function is called whenever the Application Framework needs to write an
496 * attribute which is not stored within the data structures of the Application
497 * Framework itself. One of the new features in Version 2 is the ability to
498 * store attributes outside the Framework. This is particularly useful for
499 * attributes that do not need to be stored because they can be read off the
500 * hardware when they are needed, or are stored in some central location used by
501 * many modules within the system. In this case, you can indicate that the
502 * attribute is stored externally. When the framework needs to write an external
503 * attribute, it makes a call to this callback.
504 This callback is very
505 * useful for host micros which need to store attributes in persistent memory.
506 * Because each host micro (used with an Ember NCP) has its own type of
507 * persistent memory storage, the Application Framework does not include the
508 * ability to mark attributes as stored in flash the way that it does for Ember
509 * SoCs like the EM35x. On a host micro, any attributes that need to be stored
510 * in persistent memory should be marked as external and accessed through the
511 * external read and write callbacks. Any host code associated with the
512 * persistent storage should be implemented within this callback.
514 * the important information about the attribute itself is passed as a pointer
515 * to an EmberAfAttributeMetadata struct, which is stored within the application
516 * and used to manage the attribute. A complete description of the
517 * EmberAfAttributeMetadata struct is provided in
518 * app/framework/include/af-types.h.
519 This function assumes that the
520 * application is able to write the attribute and return immediately. Any
521 * attributes that require a state machine for reading and writing are not
522 * candidates for externalization at the present time. The Application Framework
523 * does not currently include a state machine for reading or writing attributes
524 * that must take place across a series of application ticks. Attributes that
525 * cannot be written immediately should be stored within the Application
526 * Framework and updated occasionally by the application code from within the
527 * emberAfMainTickCallback.
528 If the application was successfully able to
529 * write the attribute, it returns a value of EMBER_ZCL_STATUS_SUCCESS. Any
530 * other return value indicates the application was not able to write the
533 * @param endpoint Ver.: always
534 * @param clusterId Ver.: always
535 * @param attributeMetadata Ver.: always
536 * @param manufacturerCode Ver.: always
537 * @param buffer Ver.: always
539 EmberAfStatus emberAfExternalAttributeWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId,
540 EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode,
543 /** @brief Report Attributes
545 * This function is called by the application framework when a Report Attributes
546 * command is received from an external device. The application should return
547 * true if the message was processed or false if it was not.
549 * @param clusterId The cluster identifier of this command. Ver.: always
550 * @param buffer Buffer containing the list of attribute report records. Ver.:
552 * @param bufLen The length in bytes of the list. Ver.: always
554 bool emberAfReportAttributesCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen);
556 /** @brief Get Current Time
558 * This callback is called when device attempts to get current time from the
559 * hardware. If this device has means to retrieve exact time, then this method
560 * should implement it. If the callback can't provide the exact time it should
561 * return 0 to indicate failure. Default action is to return 0, which indicates
562 * that device does not have access to real time.
565 uint32_t emberAfGetCurrentTimeCallback();
567 /** @brief Get Endpoint Info
569 * This function is a callback to an application implemented endpoint that
570 * operates outside the normal application framework. When the framework wishes
571 * to perform operations with that endpoint it uses this callback to retrieve
572 * the endpoint's information. If the endpoint exists and the application can
573 * provide data then true shall be returned. Otherwise the callback must return
576 * @param endpoint The endpoint to retrieve data for. Ver.: always
577 * @param returnNetworkIndex The index corresponding to the ZigBee network the
578 * endpoint belongs to. If not using a multi-network device, 0 must be
579 * returned. Otherwise on a multi-network device the stack will switch to this
580 * network before sending the message. Ver.: always
581 * @param returnEndpointInfo A pointer to a data struct that will be written
582 * with information about the endpoint. Ver.: always
584 bool emberAfGetEndpointInfoCallback(chip::EndpointId endpoint, uint8_t * returnNetworkIndex,
585 EmberAfEndpointInfoStruct * returnEndpointInfo);
587 /** @brief Get Source Route Overhead
589 * This function is called by the framework to determine the overhead required
590 * in the network frame for source routing to a particular destination.
592 * @param destination The node id of the destination Ver.: always
594 uint8_t emberAfGetSourceRouteOverheadCallback(chip::NodeId destination);
596 /** @brief Registration Abort
598 * This callback is called when the device should abort the registration
602 void emberAfRegistrationAbortCallback();
604 /** @brief Interpan Send Message
606 * This function will send a raw MAC message with interpan frame format using
607 * the passed parameters.
609 * @param header Interpan header info Ver.: always
610 * @param messageLength The length of the message received or to send Ver.:
612 * @param message The message data received or to send. Ver.: always
614 EmberStatus emberAfInterpanSendMessageCallback(EmberAfInterpanHeader * header, uint16_t messageLength, uint8_t * message);
616 /** @brief Start Move
618 * This function is called to initiate the process for a device to move (rejoin)
622 bool emberAfStartMoveCallback();