6. Application Framework Callback Interface
The Ember application framework callbacks are intended to be used as a means to remove all customer code from the Ember applica-
tion framework. If any of your application code needs to be put into the Ember application framework, Silicon Labs views this as a bug
with the Ember application framework, because it means that a callback that would satisfy your application requirement is missing. In
this case, please open a ticket on the support portal at www.silabs.com/zigbee-support.
Generally, when a callback is called the Ember application framework is giving the application code a first crack at some incoming mes-
sage or requesting some piece of application data. Within the callback API, some callbacks return a Boolean value indicating that the
message has been handled and no further processing should be done. If you are doing something that conflicts with the Ember applica-
tion framework’s handling of a particular message, return TRUE to indicate that the message was complete. This ensures that the Em-
ber application framework does not interfere with your handling of the message.
6.1 Callback Generation
AppBuilder has the ability to generate a stub callback file for you. By default, AppBuilder chooses not to generate the callback stub file if
it finds that the file already exists in the generation directory. You must specifically tell the application to overwrite an existing file.
When you regenerate files in the future, AppBuilder protects your generated callbacks file from being overwritten by asking if you want
to overwrite it. By default, AppBuilder will not overwrite any previously created callbacks file. If you choose to overwrite the file, App-
Builder backs up the previous version to the file <appname>_callbacks.bak.
Note: You can implement your callbacks wherever you want; they do not need to be implemented in the generated callbacks file. How-
ever if you implement them in a different location, clear them out of the generated callback file so that your linker won’t complain about
duplicate definitions for the callback functions.
6.2 Non Cluster-Related Callbacks
The callback interface is divided up into sections within the AppBuilder GUI for ease of use. The first section, Non Cluster-Related Call-
backs, is made up of callbacks that are described in the callbacks.xml document located at tool/appbuilder/callbacks.xml. These call-
backs have been manually inserted into the Ember application framework code in locations where customers have indicated that they
wish to receive information about the function of the Ember application framework.
All global commands fall into this category. The Ember application framework contains handling code for global commands. If any glob-
al command callback returns TRUE, this indicates that the command has been handled by the application and no further command
handling should take place. If the callback returns FALSE, then the Ember application framework continues to process the command
normally.
Example
The pre-command received callback (emberAfPreCommandReceivedCallback(EmberAfClusterCommand* cmd, boolean
isInterpan) is called after a ZCL command has been received but has not yet been processed by the Ember application framework’s
command handling code. The command is parsed into a useful struct EmberAfClusterCommand, which provides an easy way to access
relevant data about the command including its EmberApsFrame, message type, source, buffer, length, and any relevant flags for the
command. This callback also returns a Boolean value indicating if the command has been handled. If the callback returns TRUE, then it
is assumed that the command has been handled by the application and no further action is taken.
6.3 Cluster-Specific Command Handling Callbacks
The cluster-related callbacks are generated by the Ember application framework to allow receipt of a pre-parsed command coming over
the air. Generally a one-to-one relationship exists between ZCL commands and the cluster-specific callbacks.
The cluster-specific command callbacks all return a Boolean value. This return value allows you to short-circuit command handling in-
cluded in the application framework. If you implement a cluster-specific command callback and it returns a value of TRUE to the Ember
application framework, the framework assumes that the command has been handled outside the framework and that any required com-
mand or default response has been sent. If the cluster-specific command returns FALSE, the framework assumes that the application
code did not understand the command and sends a default response with a status of ‘unsupported cluster command’.
UG102: Ember
®
Application Framework Developer Guide
Application Framework Callback Interface
silabs.com | Building a more connected world. Rev. 1.6 | 8