@gnaudio/jabra-js-button-customization

Button Customization Module for the Jabra SDK gen. 3 for JavaScript

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 createDeviceController function. This factory function creates an instance of IDeviceController. 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:

async function blinkGreen(device: IDevice): Promise<void> {
const controller = await createDeviceController(device);
if (!controller) {
console.error("Failed to create device controller. The device may not support button customization.");
return;
}

const programmableButton = await controller.getButton(ButtonId.threeDot);
programmableButton.open();
programmableButton.setColor(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 IButton.close. 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 IButton.listenFor 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:

async function logButtonPresses(device: IDevice): Promise<void> {
const controller = await createDeviceController(device);
if (!controller) {
console.error("Failed to create device controller. The device may not support button customization.");
return;
}

const programmableButton = await controller.getButton(ButtonId.threeDot);

const presses = await programmableButton.listenFor(ButtonInteraction.press);
presses.subscribe((e) => {
console.log(`The three-dot button was pressed...`);
})
}

Changelog

This is the first release of the Button Customization module. It has support for:

  • Listing what buttons and LEDs are available on a device.
  • Taking over functionality of buttons.
  • Setting the color on buttons and LEDs.