public class BridgeSerial extends NetworkBridge<Integer>
| Modifier and Type | Class and Description |
|---|---|
static class |
BridgeSerial.UnableToObtainDeviceException
Runtime exception thrown if the requested USB device could not be opened
|
| Constructor and Description |
|---|
BridgeSerial(String serialPortName)
Constructs a BridgeSerial object to communicate on a specific port.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this BridgeSerial connection.
|
void |
connect() |
void |
connect(Integer newBaudRate) |
Integer |
currentConnectionOption() |
static List<String> |
getAvailableSerials() |
List<Integer> |
getConnectionOptions() |
String |
getNetworkIdentifier() |
static void |
init(Context context)
Assigns static variables.
|
boolean |
isConnected() |
void |
sendMessage(MoppyMessage messageToSend) |
acceptNetworkMessage, deregisterMessageReceiver, registerMessageReceiverpublic BridgeSerial(String serialPortName)
serialPortName - the port to communicate onIllegalArgumentException - if the specified device doesn't existBridgeSerial.UnableToObtainDeviceException - if the serial port representing the specified device could not be obtainedpublic static void init(Context context)
context - the context used to retrieve Android system resourcespublic void connect(Integer newBaudRate) throws IOException
connect in class NetworkBridge<Integer>IOExceptionpublic void connect()
throws IOException
connect in class NetworkBridge<Integer>IOExceptionpublic void sendMessage(MoppyMessage messageToSend) throws IOException
sendMessage in class NetworkBridge<Integer>IOExceptionpublic void close()
throws IOException
IOException - if unable to write the SYS_STOP messageBridgeSerial.UnableToObtainDeviceException - if the serial port could not be recreated after closing communicationpublic String getNetworkIdentifier()
getNetworkIdentifier in class NetworkBridge<Integer>public boolean isConnected()
isConnected in class NetworkBridge<Integer>public List<Integer> getConnectionOptions()
getConnectionOptions in class NetworkBridge<Integer>public Integer currentConnectionOption()
currentConnectionOption in class NetworkBridge<Integer>