Skip to content

Commit

Permalink
Update BluetoothConnection.java
Browse files Browse the repository at this point in the history
  • Loading branch information
DantSu committed Aug 24, 2022
1 parent a97f817 commit 8cb56e5
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public BluetoothConnection connect() throws EscPosConnectionException {

BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

UUID uuid = getDeviceUUID();
UUID uuid = this.getDeviceUUID();

try {
this.socket = this.device.createRfcommSocketToServiceRecord(uuid);
Expand All @@ -80,13 +80,10 @@ public BluetoothConnection connect() throws EscPosConnectionException {
/**
* Get bluetooth device UUID
*/
@SuppressLint("MissingPermission")
protected UUID getDeviceUUID() {
// https://developer.android.com/reference/android/bluetooth/BluetoothDevice - "00001101-0000-1000-8000-00805f9b34fb" SPP UUID
ParcelUuid[] uuids = device.getUuids();
// https://developer.android.com/reference/android/bluetooth/BluetoothDevice
UUID sppUid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");

return (uuids != null && uuids.length > 0) ? uuids[0].getUuid() : sppUid;
return (uuids != null && uuids.length > 0) ? uuids[0].getUuid() : UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
}

/**
Expand Down

0 comments on commit 8cb56e5

Please sign in to comment.