Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public BluetoothConnection(BluetoothAdapter bluetoothAdapter) {
// @TODO . `connect` other methods than `createRfcommSocketToServiceRecord`, including hidden one raw `createRfcommSocket` (on channel).
// @TODO ? how about turning it into factoried?
/// Connects to given device by hardware address

public void connect(String address, UUID uuid) throws IOException {
if (isConnected()) {
throw new IOException("already connected");
Expand All @@ -61,8 +62,11 @@ public void connect(String address, UUID uuid) throws IOException {
}
/// Connects to given device by hardware address (default UUID used)
public void connect(String address) throws IOException {
connect(address, DEFAULT_UUID);
}
BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
BluetoothDevice device = btAdapter.getRemoteDevice(address);
ParcelUuid[] uuids = (ParcelUuid[]) device.getUuids();
connect(address, uuids[0].getUuid());
}

/// Disconnects current session (ignore if not connected)
public void disconnect() {
Expand Down