Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
Android Documentation
MultiplexBluetoothTransport

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, ERROR_REASON_KEY, REASON_SPP_ERROR, REASON_NONE, LOG, DEVICE_NAME, DEVICE_ADDRESS, mState, handler, transportType, transportRecord, connectedDeviceName, connectedDeviceAddress

Constructors

MultiplexBluetoothTransport( Handler handler )

Constructor. Prepares a new BluetoothChat session.

public MultiplexBluetoothTransport(Handler handler)

Constructor Parameters

handler
A Handler to send messages back to the UI Activity

Methods

setStateManually( int state )

protected synchronized void setStateManually(int state)

Method Parameters

state

getState()

Return the current connection state.

public synchronized int getState()

setKeepSocketAlive( boolean keepSocketAlive )

public void setKeepSocketAlive(boolean keepSocketAlive)

Method Parameters

keepSocketAlive

getConnectedDevice()

A method to retrieve the currently connected bluetooth device

public android.bluetooth.BluetoothDevice getConnectedDevice()

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)

Method 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)

Method 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)

Method Parameters

stateToTransitionTo

stop( int stateToTransitionTo, byte error )

protected synchronized void stop(int stateToTransitionTo,byte error)

Method Parameters

stateToTransitionTo
error

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

Write to the ConnectedThread in an unsynchronized manner

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

Method Parameters

out
The bytes to write
offset
count

getBTSocket( BluetoothServerSocket bsSocket )

public android.bluetooth.BluetoothSocket getBTSocket(BluetoothServerSocket bsSocket)

Method Parameters

bsSocket

getChannel( BluetoothSocket bsSocket )

public int getChannel(BluetoothSocket bsSocket)

Method Parameters

bsSocket

Inherited Methods

From Class Methods
com.smartdevicelink.transport.MultiplexBaseTransport setState, setState, getAddress, getDeviceName, getTransportRecord, getState, isConnected, stop, 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