public class NetworkVehicleInterface extends BytestreamDataSource implements VehicleInterface
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BROADCAST_NETWORK_DISCONNECTED |
mConnectionLock, mDataFormatValue, mDeviceChanged, RECONNECTION_ATTEMPT_WAIT_TIME_S, SLOW_RECONNECTION_ATTEMPT_WAIT_TIME_S
Constructor and Description |
---|
NetworkVehicleInterface(android.content.Context context,
java.lang.String uriString) |
NetworkVehicleInterface(android.content.Context context,
java.net.URI uri) |
NetworkVehicleInterface(SourceCallback callback,
android.content.Context context,
java.net.URI uri)
Construct an instance of NetworkVehicleInterface with a receiver
callback and custom device URI.
|
Modifier and Type | Method and Description |
---|---|
protected void |
connect()
Initiate a connection to the vehicle interface.
|
protected void |
disconnect()
Perform any cleanup necessary to disconnect from the interface.
|
protected java.lang.String |
getTag()
Return a string suitable as a tag for logging.
|
boolean |
isConnected()
Return true if the data source is actively connected to its target, be it
a USB endpoint, a Bluetooth channel, a trace file, etc.
|
protected int |
read(byte[] bytes)
Read data from the source into the given array.
|
protected void |
sendNetworkDisconnectBroadcast() |
boolean |
setResource(java.lang.String otherResource)
Change the resource used by the instance to connect to the interface,
restarting any necessary services.
|
java.lang.String |
toString() |
static boolean |
validateResource(java.lang.String uriString)
Return true if the address and port are valid.
|
protected boolean |
write(byte[] bytes)
Writes given data to the socket.
|
connected, disconnected, isRunning, receive, run, setFastPolling, start, stop, stopConnectionAttempts, waitForConnection
getContext
getCallback, handleMessage, onPipelineActivated, onPipelineDeactivated, setCallback, waitForCallback
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
setCallback, stop
onPipelineActivated, onPipelineDeactivated
receive, stop
public static final java.lang.String BROADCAST_NETWORK_DISCONNECTED
public NetworkVehicleInterface(SourceCallback callback, android.content.Context context, java.net.URI uri) throws DataSourceException
context
- The Activity or Service context, used to get access to the
Android NetworkManager.callback
- An object implementing the SourceCallback that should receive
data as it is received and parsed.uri
- The network host's address.DataSourceException
- If no connection could be establishedpublic NetworkVehicleInterface(android.content.Context context, java.net.URI uri) throws DataSourceException
DataSourceException
public NetworkVehicleInterface(android.content.Context context, java.lang.String uriString) throws DataSourceException
DataSourceException
public boolean setResource(java.lang.String otherResource) throws DataSourceException
VehicleInterface
setResource
in interface VehicleInterface
otherResource
- The new resource to use for the interface.DataSourceException
public static boolean validateResource(java.lang.String uriString)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isConnected()
VehicleDataSource
isConnected
in interface VehicleInterface
isConnected
in interface VehicleDataSource
isConnected
in class BytestreamDataSource
protected int read(byte[] bytes) throws java.io.IOException
BytestreamDataSource
read
in class BytestreamDataSource
bytes
- the destination array for bytes from the data source.java.io.IOException
- if the source is unexpectedly closed or returns an
error.protected void connect() throws NetworkSourceException
BytestreamDataSource
connect
in class BytestreamDataSource
NetworkSourceException
protected void disconnect()
BytestreamDataSource
disconnect
in class BytestreamDataSource
protected boolean write(byte[] bytes)
write
in class BytestreamDataSource
bytes
- data to write to the socket.protected java.lang.String getTag()
BaseVehicleDataSource
getTag
in class BaseVehicleDataSource
protected void sendNetworkDisconnectBroadcast()