ASUS Aura SDK v3.1 Developer's Guide
C# Tutorial

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.

  1. In main menu, select File -> New -> Project... to create a new project.
  2. In New Project wizard, select Visual C# -> Console App (.NET Framework). Input AuraTutorial in Name field, then press OK.
  1. 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.

  1. Back to the source editor. You have to import the AURA SDK by using using directive in Program.cs:
    Type library AuraServiceLib.
    Definition: AuraService.idl:55
  2. Now we can create the instance of AuraSdk in Main() with operator new:

    static void Main(string[] args)
    {
    // Create SDK instance
    IAuraSdk sdk = new AuraSdk();

    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:

    IAuraSdk2 sdk = (AuraSdk2) new AuraSdk();
    // You can consider to use 'is' or 'as' provided by C# for safer casting

    Since IAuraSdk is inherited by IAuraSdk2, all methods IAuraSdk supports can still be accessed via IAuraSdk2Ptr. See AuraServiceLib::IAuraSdk2 for more details.

  3. After the instance of AuraSdk is created, we can aquire the control and then enumerated all AURA-compatible devices:

    // Aquire control
    sdk.SwitchMode();
    // enumerate all devices
    IAuraSyncDeviceCollection devices =
    sdk.Enumerate(0); // 0 means all

    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.

  4. The devices returned by AuraSdk.Enumerate() is a "collection" of all devices. You can access each device by using foreach statement:
    // Traverse all devices
    foreach (IAuraSyncDevice dev in devices)
    {
  5. All LED's of a certain device can be accessed via the 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:
    // Traverse all devices
    foreach (IAuraSyncDevice dev in devices)
    {
    // Traverse all LED's
    foreach (IAuraRgbLight light in dev.Lights)
    {
  6. 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:

    // Traverse all LED's
    foreach (IAuraRgbLight light in dev.Lights)
    {
    // Set all LED's to blue
    light.Color = 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.

  7. After setting each LED's color of a device, AuraServiceLib.IAuraSyncDevice.Apply() should be called to make the new settings take effect:
    // Traverse all devices
    foreach (IAuraSyncDevice dev in devices)
    {
    // Traverse all LED's
    foreach (IAuraRgbLight light in dev.Lights)
    {
    // Set all LED's to blue
    light.Color = 0x00FF0000;
    }
    // Apply colors that we have just set
    dev.Apply();
    }
  8. Now you can build and execute the project. All LED's on all AURA compatible devices (with proper HAL installed) should become blue after execution.
  9. Starting from version 1.02.01, Aura SDK will release control when it is detached. This means that you don't have to release control explicitly if your application can be terminated properly. If you, however, want to explicitly release control before application is closed and use IAuraSdk2 interface as described in step 6, you can call AuraServiceLib.IAuraSdk2.ReleaseControl() whenever you want to release control:
    sdk.ReleaseControl();