The following step-by-step example is done with Microsoft Visual Studio 2017. Theoretically, you can use Visual Studio 2008 or newer versions, but 2013 or newer are recommended.
After the project is created, the source editor will appear. The first thing we have to do is to add reference of AURA SDK into project. You can do that by adding AuraServiceLib as the project's reference.
In Solution Explorer, right-click on the project to activate the context menu. In the context menu, select Add -> Reference...:
Then you will see the Reference Manager dialog. In the left part of this dialog, select COM, then all COM components that has been registered in this system will be listed. Now find AsusServiceLib, check it, and then press OK:
And it's done.
using
directive in Program.cs: Now we can create the instance of AuraSdk in Main()
with operator new
:
Note that starting from version 1.02.01, a new interface IAuraSdk2
is provided to support "explicit control releasing" function. If you prefer to use IAuraSdk2
, you can explicitly cast the object returned by new AuraSdk()
to IAuraSdk2
:
Since IAuraSdk
is inherited by IAuraSdk2
, all methods IAuraSdk
supports can still be accessed via IAuraSdk2Ptr
. See AuraServiceLib::IAuraSdk2 for more details.
After the instance of AuraSdk is created, we can aquire the control and then enumerated all AURA-compatible devices:
The parameter passed into AuraSdk.Enumerate()
means the type of devices that should be enumerated. 0 means all types of devices. You can enumerate specific type of devices by passing other values. Please refer to the reference of AuraServiceLib.IAuraSdk.Enumerate() for more details.
devices
returned by AuraSdk.Enumerate()
is a "collection" of all devices. You can access each device by using foreach
statement: Lights
property of the corresponding AuraServiceLib.IAuraSyncDevice interface. The Lights
property is also a "collection", so the each LED can be easily accessed similar to the devices in a device collection: Now, lets set all the LED's color to blue by modifying the Color
property of IAuraRgbLight
interface. The data type of Color
property is 32-bit unsigned integer, and it's format is "0x00GGBBRR", where G == Green, B == Blue, and R == Red. So "blue" should be 0x00FF0000:
Note that besides IAuraRgbLight.Color
, there are also IAuraRgbLight.Red
, IAuraRgbLight.Green
and IAuraRgbLight.Blue
properties that can set each color directly. Please refer to AuraServiceLib.IAuraRgbLight for more details.
AuraServiceLib.IAuraSyncDevice.Apply()
should be called to make the new settings take effect: IAuraSdk2
interface as described in step 6, you can call AuraServiceLib.IAuraSdk2.ReleaseControl()
whenever you want to release control: