public class MultiplexBluetoothTransport extends MultiplexBaseTransport
| Modifier and Type | Field and Description |
|---|---|
protected static String |
SHARED_PREFS |
connectedDeviceAddress, connectedDeviceName, DEVICE_ADDRESS, DEVICE_NAME, ERROR_REASON_KEY, handler, LOG, mState, REASON_NONE, REASON_SPP_ERROR, STATE_CONNECTED, STATE_CONNECTING, STATE_ERROR, STATE_LISTEN, STATE_NONE, transportRecord, transportType| Constructor and Description |
|---|
MultiplexBluetoothTransport(Handler handler)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
connect(BluetoothDevice device)
Start the ConnectThread to initiate a connection to a remote device.
|
void |
connected(BluetoothSocket socket,
BluetoothDevice device)
Start the ConnectedThread to begin managing a Bluetooth connection
|
BluetoothSocket |
getBTSocket(BluetoothServerSocket bsSocket) |
int |
getChannel(BluetoothSocket bsSocket) |
BluetoothDevice |
getConnectedDevice()
A method to retrieve the currently connected bluetooth device
|
int |
getState()
Return the current connection state.
|
void |
setKeepSocketAlive(boolean keepSocketAlive) |
protected void |
setStateManually(int state) |
void |
start()
Start the chat service.
|
void |
stop()
Stop all threads
|
protected void |
stop(int stateToTransitionTo) |
protected void |
stop(int stateToTransitionTo,
byte error) |
void |
write(byte[] out,
int offset,
int count)
Write to the ConnectedThread in an unsynchronized manner
|
getAddress, getDeviceName, getTransportRecord, isConnected, setState, setStateprotected static final String SHARED_PREFS
public MultiplexBluetoothTransport(Handler handler)
handler - A Handler to send messages back to the UI Activityprotected void setStateManually(int state)
public int getState()
getState in class MultiplexBaseTransportpublic void setKeepSocketAlive(boolean keepSocketAlive)
public BluetoothDevice getConnectedDevice()
public void start()
public void connect(BluetoothDevice device)
device - The BluetoothDevice to connectpublic void connected(BluetoothSocket socket, BluetoothDevice device)
socket - The BluetoothSocket on which the connection was madedevice - The BluetoothDevice that has been connectedpublic void stop()
stop in class MultiplexBaseTransportprotected void stop(int stateToTransitionTo)
stop in class MultiplexBaseTransportprotected void stop(int stateToTransitionTo,
byte error)
stop in class MultiplexBaseTransportpublic void write(byte[] out,
int offset,
int count)
write in class MultiplexBaseTransportout - The bytes to writeConnectedWriteThread#write(byte[], int, int)public BluetoothSocket getBTSocket(BluetoothServerSocket bsSocket)
public int getChannel(BluetoothSocket bsSocket)