File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
escposprinter/src/main/java/com/dantsu/escposprinter/connection/bluetooth Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -60,8 +60,8 @@ public BluetoothConnection connect() throws EscPosConnectionException {
6060 }
6161
6262 BluetoothAdapter bluetoothAdapter = BluetoothAdapter .getDefaultAdapter ();
63- ParcelUuid [] uuids = this . device . getUuids ();
64- UUID uuid = ( uuids != null && uuids . length > 0 ) ? uuids [ 0 ]. getUuid () : UUID . randomUUID ();
63+
64+ UUID uuid = this . getDeviceUUID ();
6565
6666 try {
6767 this .socket = this .device .createRfcommSocketToServiceRecord (uuid );
@@ -77,6 +77,15 @@ public BluetoothConnection connect() throws EscPosConnectionException {
7777 return this ;
7878 }
7979
80+ /**
81+ * Get bluetooth device UUID
82+ */
83+ protected UUID getDeviceUUID () {
84+ // https://developer.android.com/reference/android/bluetooth/BluetoothDevice - "00001101-0000-1000-8000-00805f9b34fb" SPP UUID
85+ ParcelUuid [] uuids = device .getUuids ();
86+ return (uuids != null && uuids .length > 0 ) ? uuids [0 ].getUuid () : UUID .fromString ("00001101-0000-1000-8000-00805f9b34fb" );
87+ }
88+
8089 /**
8190 * Close the socket connection with the bluetooth device.
8291 */
You can’t perform that action at this time.
0 commit comments