Skip to content

Commit 89cb67f

Browse files
committed
Add ability to retrieve BT device from BT transprt
1 parent 4aa6a62 commit 89cb67f

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport {
7777
Handler timeOutHandler;
7878
Runnable socketRunnable;
7979
boolean keepSocketAlive = true;
80-
80+
BluetoothDevice connectedDevice;
81+
8182
/**
8283
* Constructor. Prepares a new BluetoothChat session.
8384
*
@@ -112,6 +113,14 @@ public void setKeepSocketAlive(boolean keepSocketAlive) {
112113
this.keepSocketAlive = keepSocketAlive;
113114
}
114115

116+
/**
117+
* A method to retrieve the currently connected bluetooth device
118+
* @return the connected bluetooth device if connected, null otherwise.
119+
*/
120+
public BluetoothDevice getConnectedDevice(){
121+
return connectedDevice;
122+
}
123+
115124
/**
116125
* Start the chat service. Specifically start AcceptThread to begin a
117126
* session in listening (server) mode. Called by the Activity onResume()
@@ -225,6 +234,7 @@ public synchronized void connected(BluetoothSocket socket, BluetoothDevice devic
225234

226235
//Store a static name of the device that is connected.
227236
if (device != null) {
237+
connectedDevice = device;
228238
connectedDeviceName = device.getName();
229239
connectedDeviceAddress = device.getAddress();
230240
if (connectedDeviceAddress != null) {

0 commit comments

Comments
 (0)