public class MoppyUsbManager extends Object
| Constructor and Description |
|---|
MoppyUsbManager(StatusBus statusBus,
Context context)
Creates a MoppyUsbManager, using the specified bus to alert consumers to device change events.
|
| Modifier and Type | Method and Description |
|---|---|
void |
closeAllBridges()
Closes all open connections, logging and discarding any generated
IOExceptions. |
void |
closeBridge(String bridgeIdentifier)
Closes a specified network bridge using its serial port path (e.g.
|
void |
connectBridge(String bridgeIdentifier)
Connects to a specified network bridge using its serial port path (e.g.
|
List<String> |
getConnectedIdentifiers()
Retrieves the list of the identifiers for all connected bridges
|
UsbDevice |
getDeviceInfo(String identifier)
Uses the identifier of a device to get the associated
UsbDevice, which should only
be used to find information about the device. |
ArrayList<UsbDevice> |
getDeviceInfoForAll()
Retrieves the associated
UsbDevice instance for all devices, which should only
be used to find information about the device. |
List<String> |
getDevices()
Retrieves the list of bridge identifiers that are available for connection.
|
int |
getNumberConnected()
Retrieves the number of connected bridges.
|
NetworkBridge<Object> |
getPrimaryBridge()
Retrieves the
MultiBridge this MoppyUsbManager manages. |
boolean |
isConnected(String bridgeIdentifier)
Checks if a specific bridge is connected using its serial port path (e.g.
|
void |
refreshDeviceList()
Refreshes the list of bridge identifiers with connected devices guaranteed to remain.
|
public void connectBridge(String bridgeIdentifier) throws IOException
BridgeSerial.UnableToObtainDeviceException.bridgeIdentifier - the identifier of the bridge to connectIOException - if unable to create the bridgepublic void closeBridge(String bridgeIdentifier) throws IOException
IOException is informational and can be ignored without any side effects.bridgeIdentifier - the identifier of the bridge to closeIOException - if unable to send the close message to the devicepublic void closeAllBridges()
IOExceptions.public boolean isConnected(String bridgeIdentifier)
bridgeIdentifier - the identifier of the bridge to check connection statuspublic void refreshDeviceList()
public NetworkBridge<Object> getPrimaryBridge()
MultiBridge this MoppyUsbManager manages. Needed for registering
this MoppyUsbManager to receive messages from a MoppyMIDIReceiverSender.MultiBridgepublic List<String> getDevices()
connectBridge(String) is
updated automatically upon device plugging/unplugging, however the list returned here is not. This list can be updated
with refreshDeviceList().public int getNumberConnected()
public List<String> getConnectedIdentifiers()
public UsbDevice getDeviceInfo(String identifier)
UsbDevice, which should only
be used to find information about the device. Attempting to connect to the device may hamper
MoppyUsbManager operation.identifier - the identifier of the device to find information onnull if not found, otherwise the associated UsbDevicepublic ArrayList<UsbDevice> getDeviceInfoForAll()
UsbDevice instance for all devices, which should only
be used to find information about the device. ArrayList returned rather than
List because it implements Serializable.ArrayList<UsbDevice> containing all available devicesgetDeviceInfo(String)