Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Documentation
Sidebar

Class MultiplexBluetoothTransport

Hierarchy

java.lang.Object
     com.smartdevicelink.transport.MultiplexBaseTransport

Package
com.smartdevicelink.transport

Overview

This class does all the work for setting up and managing Bluetooth connections with other devices. It has a thread that listens for incoming connections, a thread for connecting with a device, and a thread for performing data transmissions when connected.

Fields

SHARED_PREFS

protected static final java.lang.String SHARED_PREFS
Constant Value
"sdl.bluetoothprefs"

Inherited Fields

From Class Fields
com.smartdevicelink.transport.MultiplexBaseTransport STATE_NONE, STATE_LISTEN, STATE_CONNECTING, STATE_CONNECTED, STATE_ERROR, LOG, DEVICE_NAME, DEVICE_ADDRESS, mState, handler, transportType, transportRecord, currentlyConnectedDevice, connectedDeviceName, connectedDeviceAddress

Constructors

MultiplexBluetoothTransport( Handler handler )

Constructor. Prepares a new BluetoothChat session.

public MultiplexBluetoothTransport(Handler handler)

Parameters

handler
A Handler to send messages back to the UI Activity

Methods

getBluetoothSerialServerInstance( Handler handler )

Deprecated
This method has been deprecated. It will return an instance of MultiplexBluetoothTransport but should not be used.

public static synchronized com.smartdevicelink.transport.MultiplexBluetoothTransport getBluetoothSerialServerInstance(Handler handler)

Parameters

handler
for receiving status messages from the transport

getBluetoothSerialServerInstance( Handler handler, boolean keepSocketAlive )

Deprecated
This method has been deprecated. It will return an instance of MultiplexBluetoothTransport but should not be used.

public static synchronized com.smartdevicelink.transport.MultiplexBluetoothTransport getBluetoothSerialServerInstance(Handler handler,boolean keepSocketAlive)

Parameters

handler
for receiving status messages from the transport
keepSocketAlive
Flag for keeping the socket alive

getBluetoothSerialServerInstance()

Deprecated
This method has been deprecated. It will always return null.

public static synchronized com.smartdevicelink.transport.MultiplexBluetoothTransport getBluetoothSerialServerInstance()

setStateManually( int state )

protected synchronized void setStateManually(int state)

Parameters

state

getState()

Return the current connection state.

public synchronized int getState()

setKeepSocketAlive( boolean keepSocketAlive )

public void setKeepSocketAlive(boolean keepSocketAlive)

Parameters

keepSocketAlive

start()

Start the chat service. Specifically start AcceptThread to begin a session in listening (server) mode. Called by the Activity onResume()

public synchronized void start()

connect( BluetoothDevice device )

Start the ConnectThread to initiate a connection to a remote device.

public synchronized void connect(BluetoothDevice device)

Parameters

device
The BluetoothDevice to connect

connected( BluetoothSocket socket, BluetoothDevice device )

Start the ConnectedThread to begin managing a Bluetooth connection

public synchronized void connected(BluetoothSocket socket,BluetoothDevice device)

Parameters

socket
The BluetoothSocket on which the connection was made
device
The BluetoothDevice that has been connected

stop()

Stop all threads

public synchronized void stop()

stop( int stateToTransitionTo )

protected synchronized void stop(int stateToTransitionTo)

Parameters

stateToTransitionTo

write( byte[] out, int offset, int count )

Write to the ConnectedThread in an unsynchronized manner

public void write(byte[] out,int offset,int count)

Parameters

out
The bytes to write
offset
count

getBTSocket( BluetoothServerSocket bsSocket )

public android.bluetooth.BluetoothSocket getBTSocket(BluetoothServerSocket bsSocket)

Parameters

bsSocket

getChannel( BluetoothSocket bsSocket )

public int getChannel(BluetoothSocket bsSocket)

Parameters

bsSocket

Inherited Methods

From Class Methods
com.smartdevicelink.transport.MultiplexBaseTransport setState, getAddress, getDeviceName, getTransportRecord, getState, isConnected, stop, stop, write
java.lang.Object getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize
View on GitHub.com
Previous Section Next Section