Supports USB detection and control functionality to enable USB detection and control from application. So that one can ensure that This ensures that the USB port works as expected before using peripherals and capabilities that use the USB port.
- usbctl is loaded. It initializes data structures to store callbacks.
- App calls registerCallback()
- App calls init()
- usbctrl initializes internal data structures.
- usbctrl launches hotplug monitoring task.
- usbctl enumerates all usb_interface device types and assigns a unique number to each interface.
- Each interface is entered into a list of structs. Each struct has the unique identifier and the interface-specifier
- usbctrl launches callback for each interface with "add" event.
- Callback is allowed to internally call other usbctrl APIs to get properties.
- When a getProperty() call is received, usbctrl compares unique identifier against its internal data structures and validates.
- if unique identifier is valid,
- if property is defined by interface, return that.
- if property is not defined by interface, iterate up the USB hierarchy to find one that does and return the value.
- App calls term()
- usbctrl stops monitoring of hotplug events.
- usbctrl clears data structures storing callbacks and usb_interfaces.