Table of Contents

The Button Customization Jabra SDK Module

The Button Customization module is an extension module of the Jabra SDK gen. 3 for JavaScript. It provides support for controlling the color of the LEDs of supported devices as well as react to interactions with buttons.

The entrypoint of the module is the DeviceControllerFactory class. This factory can create an instance of IDeviceController for a given device. The IDeviceController can be used to get access to the individual buttons and LEDs on the device.

Below is a basic example that shows how to take over the three-dot button and set the LED of the button to a slow pulsing green light:

public async Task BlinkGreen(IDevice device)
{
    var controllerFactory = new DeviceControllerFactory();
    var deviceController = await controllerFactory.TryCreateDeviceControllerAsync(device);
    if (deviceController is null)
    {
        Console.WriteLine("Device does not support button customization.");
        return;
    }

    var programmableButton = await deviceController.GetButtonAsync(ButtonId.ThreeDot);
    await programmableButton.OpenAsync();
    await programmableButton.SetColorAsync(Color.Green, LedMode.SlowPulse);
}

When a button is opened for control in this way, any other functionality assigned to the button is disabled until control is released again through CloseAsync(). When a button or LED is closed then any configurations of color and events are reset, and any standard functionality assigned to the button is restored.

Please note that LEDs that are part of a button must be controlled as a button. The IDeviceController methods for retrieving LEDs only consider LEDs that are not part of a button.

A user may interact with the buttons of the device. When the button is opened for control, the ListenForAsync(ButtonInteraction) method can be used to get an observable that emits events based on specified button interactions. Below is an example that shows how to listen for presses on the three-dot button:

public async Task<IDisposable> LogButtonPresses(IDeviceController deviceController)
{
    var programmableButton = await deviceController.GetButtonAsync(ButtonId.ThreeDot);

    var presses = await programmableButton.ListenForAsync(ButtonInteraction.Press);
    return presses.Subscribe((e) => Console.WriteLine("The three-dot button was pressed..."));
}