usbhotplug
The usbhotplug object can be used to generate events when USB devices are added or removed.Â
usbhotplug IDL
interface usbhotplugevent {
attribute String action; // "add", "remove"
attribute String path; // platform specific device path
};
callback UsbHotplugEventCallback = void (usbhotplugevent event);
interface UsbHotplug {
void addEventListener(String type, UsbHotplugEventCallback callback);
void removeEventListener(String type, UsbHotplugEventCallback callback);
};
Event Creation
To create a usbhotplug event, load the @brightsign/usbhotplug module using the require()
 method:
let usbhotplugClass = require("@brightsign/usbhotplug");
let usbhotplug = new usbhotplugClass();
UsbHotPlugÂ
Use this interface to configure a usbhotplug event.
usbhotplugevent
: This event is raised when the hotplug status changes. Use the addEventListener()
 method to listen for this event, or the removeEventListener()
 method to remove an event listener.
usbhotplugevent PropertiesÂ
action
string:Â Indicates whether a USB device has been added or removed.path
string: The path is an arbitrary string which varies between models and should not be parsed. It may be useful for diagnostics. The path will be the same for add and remove events for a particular USB device. Use@brightsign/deviceinfo
getUsbBusTopology()
to examine attached devices. These events are hints that the topology has changed.
Example
let usbhotplugClass = require("@brightsign/usbhotplug");
let usbhotplug = new usbhotplugClass();
function onusbhotplugevent(event) {
if (event.action == 'add') {
console.log('New device at' + event.path)
} else if (event.action == 'remove')
{
console.log('Device removed from' + event.path)
}
}
usbhotplug.addEventListener("usbhotplugevent", onusbhotplugevent);