Support smart home properties on your device
To support the smart home interfaces that you defined for your virtual product, you list the same interfaces in your ACK Device SDK ack_user_config.h file and then implement the corresponding callbacks in your application code. For example, if your device supportsPowerController, BrightnessController and two instances of ModeControllers (with instance ids 1 and 2), your application code must report the states of these four interfaces to the ACK Device SDK. Your code also must maintain and report the state for each defined interface using the application defined properties.
For example:
First, declare the support for the power, brightness and mode controllers in your ack_user_config.h file.
Report smart home property values to Alexa
For each on-device property, your application must also define a callback method that reports the property values to Alexa.PowerController callback function uses the ACK_AddPowerControllerProperty API to report the Boolean value of the current power on/off state.
Respond to smart home directives
Each smart home interface also requires that you implement a callback when your device receives relevant smart home directives. For example, when an ACK-based device receives aPowerController directive from the Alexa service, the ACK Device SDK invokes the ACKUser_OnPowerControllerDirective() callback method. This callback needs to process reported changes and respond to the directive.
- For a successful response, use the
ACK_CompleteDirectiveWithSuccess()APIs. - For errors, use one of the relevant
ACK_CompleteDirectiveWithXXXError()APIs. Errors might include out-of-range values or returning an incorrect device state.
ACKUser_OnPowerControllerDirective() callback.
This example uses the POWER_STATE_PROPERTY ordinal to indicate which properties to include in the response to the PowerController directive and in the follow-up change report to Alexa services. If your application doesn’t detect any changes, it can use a changed properties bitmask value of 0, which skips sending the change report.
Report smart home state changes to Alexa
In certain situations, your application code might also need to indicate that an incoming Alexa directive changed the state of the other Alexa control interfaces on the device. For example, if a device that’s powered off receives aAlexa.BrightnessController SetBrightness directive, it might have to power on before changing the brightness level. In this example, your application needs to indicate both the brightness level change and the power state change when responding to the directive.
The following code shows how you handle this example.
Respond to smart home ReportState directives
Alexa sends aReportState directive to your device to retrieve the current state of supported Alexa interfaces on your device. For example, a user might check their Alexa app to determine the on/off status of a light on a different floor of their house. In this case, when a user opens the app, Alexa sends a ReportState directive to your devices to retrieve the status. After Alexa determines the status, it displays it to the user.
You handle ReportState directives with the ACKUser_OnReportStateDirective() callback. When you do so, you should continuously return all device properties in your application.
Support smart home proactive state updates
If your device properties change their state due to a user interaction or additional logic that you programmed, you must report the change to Alexa services. This is called a proactive state update. If you don’t report these changes, your device might not pass Works with Alexa (WWA) certification. To report these changes, use theACK_SendChangeReport() API. For example, you could use the following code to report when a user turns on a fan using the physical ON button affixed to a device.

