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, waitForConnectiongetContextgetCallback, handleMessage, onPipelineActivated, onPipelineDeactivated, setCallback, waitForCallbackclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitsetCallback, stoponPipelineActivated, onPipelineDeactivatedreceive, stoppublic 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
DataSourceExceptionpublic NetworkVehicleInterface(android.content.Context context,
java.lang.String uriString)
throws DataSourceException
DataSourceExceptionpublic boolean setResource(java.lang.String otherResource)
throws DataSourceException
VehicleInterfacesetResource in interface VehicleInterfaceotherResource - The new resource to use for the interface.DataSourceExceptionpublic static boolean validateResource(java.lang.String uriString)
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean isConnected()
VehicleDataSourceisConnected in interface VehicleInterfaceisConnected in interface VehicleDataSourceisConnected in class BytestreamDataSourceprotected int read(byte[] bytes)
throws java.io.IOException
BytestreamDataSourceread in class BytestreamDataSourcebytes - 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
BytestreamDataSourceconnect in class BytestreamDataSourceNetworkSourceExceptionprotected void disconnect()
BytestreamDataSourcedisconnect in class BytestreamDataSourceprotected boolean write(byte[] bytes)
write in class BytestreamDataSourcebytes - data to write to the socket.protected java.lang.String getTag()
BaseVehicleDataSourcegetTag in class BaseVehicleDataSourceprotected void sendNetworkDisconnectBroadcast()