4 #include "cluster-id.h"
8 // Cluster Init Functions
9 void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
13 {{#all_user_clusters_names}}
14 case ZCL_{{asDelimitedMacro define}}_ID :
15 emberAf{{asCamelCased name false}}ClusterInitCallback(endpoint);
17 {{/all_user_clusters_names}}
19 // Unrecognized cluster ID
24 {{#all_user_clusters_names}}
25 void __attribute__((weak)) emberAf{{asCamelCased name false}}ClusterInitCallback(EndpointId endpoint)
30 {{/all_user_clusters_names}}
33 // Non-Cluster Related Callbacks
36 /** @brief Add To Current App Tasks
38 * This function is only useful to sleepy end devices. This function will note
39 * the passed item as part of a set of tasks the application has outstanding
40 * (e.g. message sent requiring APS acknwoledgement). This will affect how the
41 * application behaves with regard to sleeping and polling. Until the
42 * outstanding task is completed, the device may poll more frequently and sleep
45 * @param tasks Ver.: always
47 void emberAfAddToCurrentAppTasksCallback(EmberAfApplicationTask tasks) {}
49 /** @brief Remove From Current App Tasks
51 * This function is only useful to sleepy end devices. This function will
52 * remove the passed item from the set of tasks the application has outstanding
53 * (e.g. message sent requiring APS acknwoledgement). This will affect how the
54 * application behaves with regard to sleeping and polling. Removing the item
55 * from the list of outstanding tasks may allow the device to sleep longer and
56 * poll less frequently. If there are other outstanding tasks the system may
57 * still have to stay away and poll more often.
59 * @param tasks Ver.: always
61 void emberAfRemoveFromCurrentAppTasksCallback(EmberAfApplicationTask tasks) {}
63 /** @brief Allow Network Write Attribute
65 * This function is called by the application framework before it writes an
66 * attribute in response to a write attribute request from an external device.
67 * The value passed into this callback is the value to which the attribute is to
68 * be set by the framework.
69 Example: In mirroring simple metering data
70 * on an Energy Services Interface (ESI) (formerly called Energy Service Portal
71 * (ESP) in SE 1.0).), a mirrored simple meter needs to write read-only
72 * attributes on its mirror. The-meter-mirror sample application, located in
73 * app/framework/sample-apps, uses this callback to allow the mirrored device to
74 * write simple metering attributes on the mirror regardless of the fact that
75 * most simple metering attributes are defined as read-only by the ZigBee
77 Note: The ZCL specification does not (as of this
78 * writing) specify any permission-level security for writing writeable
79 * attributes. As far as the ZCL specification is concerned, if an attribute is
80 * writeable, any device that has a link key for the device should be able to
81 * write that attribute. Furthermore if an attribute is read only, it should not
82 * be written over the air. Thus, if you implement permissions for writing
83 * attributes as a feature, you MAY be operating outside the specification. This
84 * is unlikely to be a problem for writing read-only attributes, but it may be a
85 * problem for attributes that are writeable according to the specification but
86 * restricted by the application implementing this callback.
88 * @param endpoint Ver.: always
89 * @param clusterId Ver.: always
90 * @param attributeId Ver.: always
91 * @param mask Ver.: always
92 * @param manufacturerCode Ver.: always
93 * @param value Ver.: always
94 * @param type Ver.: always
96 EmberAfAttributeWritePermission emberAfAllowNetworkWriteAttributeCallback(EndpointId endpoint, ClusterId clusterId,
97 AttributeId attributeId, uint8_t mask,
98 uint16_t manufacturerCode, uint8_t * value, uint8_t type)
100 return EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL; // Default
103 /** @brief Attribute Read Access
105 * This function is called whenever the Application Framework needs to check
106 * access permission for an attribute read.
108 * @param endpoint Ver.: always
109 * @param clusterId Ver.: always
110 * @param manufacturerCode Ver.: always
111 * @param attributeId Ver.: always
113 bool emberAfAttributeReadAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode,
114 AttributeId attributeId)
119 /** @brief Attribute Write Access
121 * This function is called whenever the Application Framework needs to check
122 * access permission for an attribute write.
124 * @param endpoint Ver.: always
125 * @param clusterId Ver.: always
126 * @param manufacturerCode Ver.: always
127 * @param attributeId Ver.: always
129 bool emberAfAttributeWriteAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode,
130 AttributeId attributeId)
135 /** @brief Default Response
137 * This function is called by the application framework when a Default Response
138 * command is received from an external device. The application should return
139 * true if the message was processed or false if it was not.
141 * @param clusterId The cluster identifier of this response. Ver.: always
142 * @param commandId The command identifier to which this is a response. Ver.:
144 * @param status Specifies either SUCCESS or the nature of the error that was
145 * detected in the received command. Ver.: always
147 bool emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, EmberAfStatus status)
152 /** @brief Discover Attributes Response
154 * This function is called by the application framework when a Discover
155 * Attributes Response or Discover Attributes Extended Response command is
156 * received from an external device. The Discover Attributes Response command
157 * contains a bool indicating if discovery is complete and a list of zero or
158 * more attribute identifier/type records. The final argument indicates whether
159 * the response is in the extended format or not. The application should return
160 * true if the message was processed or false if it was not.
162 * @param clusterId The cluster identifier of this response. Ver.: always
163 * @param discoveryComplete Indicates whether there are more attributes to be
164 * discovered. true if there are no more attributes to be discovered. Ver.:
166 * @param buffer Buffer containing the list of attribute identifier/type
167 * records. Ver.: always
168 * @param bufLen The length in bytes of the list. Ver.: always
169 * @param extended Indicates whether the response is in the extended format or
172 bool emberAfDiscoverAttributesResponseCallback(ClusterId clusterId, bool discoveryComplete, uint8_t * buffer,
173 uint16_t bufLen, bool extended)
178 /** @brief Discover Commands Generated Response
180 * This function is called by the framework when Discover Commands Generated
181 * Response is received.
183 * @param clusterId The cluster identifier of this response. Ver.: always
184 * @param manufacturerCode Manufacturer code Ver.: always
185 * @param discoveryComplete Indicates whether there are more commands to be
186 * discovered. Ver.: always
187 * @param commandIds Buffer containing the list of command identifiers. Ver.:
189 * @param commandIdCount The length of bytes of the list, whish is the same as
190 * the number of identifiers. Ver.: always
192 bool emberAfDiscoverCommandsGeneratedResponseCallback(ClusterId clusterId, uint16_t manufacturerCode, bool discoveryComplete,
193 CommandId * commandIds, uint16_t commandIdCount)
198 /** @brief Discover Commands Received Response
200 * This function is called by the framework when Discover Commands Received
201 * Response is received.
203 * @param clusterId The cluster identifier of this response. Ver.: always
204 * @param manufacturerCode Manufacturer code Ver.: always
205 * @param discoveryComplete Indicates whether there are more commands to be
206 * discovered. Ver.: always
207 * @param commandIds Buffer containing the list of command identifiers. Ver.:
209 * @param commandIdCount The length of bytes of the list, whish is the same as
210 * the number of identifiers. Ver.: always
212 bool emberAfDiscoverCommandsReceivedResponseCallback(ClusterId clusterId, uint16_t manufacturerCode, bool discoveryComplete,
213 CommandId * commandIds, uint16_t commandIdCount)
218 /** @brief Pre Command Received
220 * This callback is the second in the Application Framework's message processing
221 * chain. At this point in the processing of incoming over-the-air messages, the
222 * application has determined that the incoming message is a ZCL command. It
223 * parses enough of the message to populate an EmberAfClusterCommand struct. The
224 * Application Framework defines this struct value in a local scope to the
225 * command processing but also makes it available through a global pointer
226 * called emberAfCurrentCommand, in app/framework/util/util.c. When command
227 * processing is complete, this pointer is cleared.
229 * @param cmd Ver.: always
231 bool emberAfPreCommandReceivedCallback(EmberAfClusterCommand * cmd)
236 /** @brief Pre Message Send
238 * This function is called by the framework when it is about to pass a message
239 * to the stack primitives for sending. This message may or may not be ZCL,
240 * ZDO, or some other protocol. This is called prior to
242 * fragmentation that may be done. If the function returns true it is assumed
243 * the callback has consumed and processed the message. The callback must also
244 * set the EmberStatus status code to be passed back to the caller. The
245 * framework will do no further processing on the message.
247 * function returns false then it is assumed that the callback has not processed
248 * the mesasge and the framework will continue to process accordingly.
250 * @param messageStruct The structure containing the parameters of the APS
251 * message to be sent. Ver.: always
252 * @param status A pointer to the status code value that will be returned to the
253 * caller. Ver.: always
255 bool emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberStatus * status)
260 /** @brief Message Sent
262 * This function is called by the application framework from the message sent
263 * handler, when it is informed by the stack regarding the message sent status.
264 * All of the values passed to the emberMessageSentHandler are passed on to this
265 * callback. This provides an opportunity for the application to verify that its
266 * message has been sent successfully and take the appropriate action. This
267 * callback should return a bool value of true or false. A value of true
268 * indicates that the message sent notification has been handled and should not
269 * be handled by the application framework.
271 * @param type Ver.: always
272 * @param indexOrDestination Ver.: always
273 * @param apsFrame Ver.: always
274 * @param msgLen Ver.: always
275 * @param message Ver.: always
276 * @param status Ver.: always
278 bool emberAfMessageSentCallback(EmberOutgoingMessageType type, uint16_t indexOrDestination, EmberApsFrame * apsFrame,
279 uint16_t msgLen, uint8_t * message, EmberStatus status)
284 /** @brief Pre Attribute Change
286 * This function is called by the application framework before it changes an
287 * attribute value. The value passed into this callback is the value to which
288 * the attribute is to be set by the framework. The application should return
289 * ::EMBER_ZCL_STATUS_SUCCESS to permit the change or any other ::EmberAfStatus
292 * @param endpoint Ver.: always
293 * @param clusterId Ver.: always
294 * @param attributeId Ver.: always
295 * @param mask Ver.: always
296 * @param manufacturerCode Ver.: always
297 * @param type Ver.: always
298 * @param size Ver.: always
299 * @param value Ver.: always
301 EmberAfStatus emberAfPreAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId,
302 uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint8_t size,
305 return EMBER_ZCL_STATUS_SUCCESS;
308 /** @brief Post Attribute Change
310 * This function is called by the application framework after it changes an
311 * attribute value. The value passed into this callback is the value to which
312 * the attribute was set by the framework.
314 * @param endpoint Ver.: always
315 * @param clusterId Ver.: always
316 * @param attributeId Ver.: always
317 * @param mask Ver.: always
318 * @param manufacturerCode Ver.: always
319 * @param type Ver.: always
320 * @param size Ver.: always
321 * @param value Ver.: always
323 void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
324 uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value) {}
326 /** @brief Read Attributes Response
328 * This function is called by the application framework when a Read Attributes
329 * Response command is received from an external device. The application should
330 * return true if the message was processed or false if it was not.
332 * @param clusterId The cluster identifier of this response. Ver.: always
333 * @param buffer Buffer containing the list of read attribute status records.
335 * @param bufLen The length in bytes of the list. Ver.: always
337 bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
342 /** @brief External Attribute Read
344 * Like emberAfExternalAttributeWriteCallback above, this function is called
345 * when the framework needs to read an attribute that is not stored within the
346 * Application Framework's data structures.
348 * information about the attribute itself is passed as a pointer to an
349 * EmberAfAttributeMetadata struct, which is stored within the application and
350 * used to manage the attribute. A complete description of the
351 * EmberAfAttributeMetadata struct is provided in
352 * app/framework/include/af-types.h
353 This function assumes that the
354 * application is able to read the attribute, write it into the passed buffer,
355 * and return immediately. Any attributes that require a state machine for
356 * reading and writing are not really candidates for externalization at the
357 * present time. The Application Framework does not currently include a state
358 * machine for reading or writing attributes that must take place across a
359 * series of application ticks. Attributes that cannot be read in a timely
360 * manner should be stored within the Application Framework and updated
361 * occasionally by the application code from within the
362 * emberAfMainTickCallback.
363 If the application was successfully able to
364 * read the attribute and write it into the passed buffer, it should return a
365 * value of EMBER_ZCL_STATUS_SUCCESS. Ensure that the size of the externally
366 * managed attribute value is smaller than what the buffer can hold. In the case
367 * of a buffer overflow throw an appropriate error such as
368 * EMBER_ZCL_STATUS_INSUFFICIENT_SPACE. Any other return value indicates the
369 * application was not able to read the attribute.
371 * @param endpoint Ver.: always
372 * @param clusterId Ver.: always
373 * @param attributeMetadata Ver.: always
374 * @param manufacturerCode Ver.: always
375 * @param buffer Ver.: always
376 * @param maxReadLength Ver.: always
378 EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
379 EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode,
380 uint8_t * buffer, uint16_t maxReadLength)
382 return EMBER_ZCL_STATUS_FAILURE;
385 /** @brief Write Attributes Response
387 * This function is called by the application framework when a Write Attributes
388 * Response command is received from an external device. The application should
389 * return true if the message was processed or false if it was not.
391 * @param clusterId The cluster identifier of this response. Ver.: always
392 * @param buffer Buffer containing the list of write attribute status records.
394 * @param bufLen The length in bytes of the list. Ver.: always
396 bool emberAfWriteAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
401 /** @brief External Attribute Write
403 * This function is called whenever the Application Framework needs to write an
404 * attribute which is not stored within the data structures of the Application
405 * Framework itself. One of the new features in Version 2 is the ability to
406 * store attributes outside the Framework. This is particularly useful for
407 * attributes that do not need to be stored because they can be read off the
408 * hardware when they are needed, or are stored in some central location used by
409 * many modules within the system. In this case, you can indicate that the
410 * attribute is stored externally. When the framework needs to write an external
411 * attribute, it makes a call to this callback.
412 This callback is very
413 * useful for host micros which need to store attributes in persistent memory.
414 * Because each host micro (used with an Ember NCP) has its own type of
415 * persistent memory storage, the Application Framework does not include the
416 * ability to mark attributes as stored in flash the way that it does for Ember
417 * SoCs like the EM35x. On a host micro, any attributes that need to be stored
418 * in persistent memory should be marked as external and accessed through the
419 * external read and write callbacks. Any host code associated with the
420 * persistent storage should be implemented within this callback.
422 * the important information about the attribute itself is passed as a pointer
423 * to an EmberAfAttributeMetadata struct, which is stored within the application
424 * and used to manage the attribute. A complete description of the
425 * EmberAfAttributeMetadata struct is provided in
426 * app/framework/include/af-types.h.
427 This function assumes that the
428 * application is able to write the attribute and return immediately. Any
429 * attributes that require a state machine for reading and writing are not
430 * candidates for externalization at the present time. The Application Framework
431 * does not currently include a state machine for reading or writing attributes
432 * that must take place across a series of application ticks. Attributes that
433 * cannot be written immediately should be stored within the Application
434 * Framework and updated occasionally by the application code from within the
435 * emberAfMainTickCallback.
436 If the application was successfully able to
437 * write the attribute, it returns a value of EMBER_ZCL_STATUS_SUCCESS. Any
438 * other return value indicates the application was not able to write the
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
447 EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId,
448 EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode,
451 return EMBER_ZCL_STATUS_FAILURE;
454 /** @brief Report Attributes
456 * This function is called by the application framework when a Report Attributes
457 * command is received from an external device. The application should return
458 * true if the message was processed or false if it was not.
460 * @param clusterId The cluster identifier of this command. Ver.: always
461 * @param buffer Buffer containing the list of attribute report records. Ver.:
463 * @param bufLen The length in bytes of the list. Ver.: always
465 bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen)
470 /** @brief Get Current Time
472 * This callback is called when device attempts to get current time from the
473 * hardware. If this device has means to retrieve exact time, then this method
474 * should implement it. If the callback can't provide the exact time it should
475 * return 0 to indicate failure. Default action is to return 0, which indicates
476 * that device does not have access to real time.
479 uint32_t emberAfGetCurrentTimeCallback()
484 /** @brief Get Endpoint Info
486 * This function is a callback to an application implemented endpoint that
487 * operates outside the normal application framework. When the framework wishes
488 * to perform operations with that endpoint it uses this callback to retrieve
489 * the endpoint's information. If the endpoint exists and the application can
490 * provide data then true shall be returned. Otherwise the callback must return
493 * @param endpoint The endpoint to retrieve data for. Ver.: always
494 * @param returnNetworkIndex The index corresponding to the ZigBee network the
495 * endpoint belongs to. If not using a multi-network device, 0 must be
496 * returned. Otherwise on a multi-network device the stack will switch to this
497 * network before sending the message. Ver.: always
498 * @param returnEndpointInfo A pointer to a data struct that will be written
499 * with information about the endpoint. Ver.: always
501 bool emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex, EmberAfEndpointInfoStruct * returnEndpointInfo)
506 /** @brief Get Source Route Overhead
508 * This function is called by the framework to determine the overhead required
509 * in the network frame for source routing to a particular destination.
511 * @param destination The node id of the destination Ver.: always
513 uint8_t emberAfGetSourceRouteOverheadCallback(EmberNodeId destination)
518 /** @brief Registration Abort
520 * This callback is called when the device should abort the registration
524 void emberAfRegistrationAbortCallback() {}
526 /** @brief Interpan Send Message
528 * This function will send a raw MAC message with interpan frame format using
529 * the passed parameters.
531 * @param header Interpan header info Ver.: always
532 * @param messageLength The length of the message received or to send Ver.:
534 * @param message The message data received or to send. Ver.: always
536 EmberStatus emberAfInterpanSendMessageCallback(EmberAfInterpanHeader * header, uint16_t messageLength, uint8_t * message)
538 return EMBER_LIBRARY_NOT_PRESENT;
541 /** @brief Start Move
543 * This function is called to initiate the process for a device to move (rejoin)
547 bool emberAfStartMoveCallback()