@@ -72,7 +72,11 @@ class ATTManager(private val adapter: BluetoothAdapter, private val device: Blue
7272 fun connect () {
7373 val uuid = ParcelUuid .fromString(" 00000000-0000-0000-0000-000000000000" )
7474
75- socket = createBluetoothSocket(adapter, device, uuid)
75+ try {
76+ socket = createBluetoothSocket(adapter, device, uuid)
77+ } catch (e: Exception ) {
78+ Log .w(TAG , " Failed to create socket" )
79+ }
7680 try {
7781 socket!! .connect()
7882 } catch (e: Exception ) {
@@ -203,7 +207,7 @@ class ATTManager(private val adapter: BluetoothAdapter, private val device: Blue
203207 private fun createBluetoothSocket (adapter : BluetoothAdapter , device : BluetoothDevice , uuid : ParcelUuid ): BluetoothSocket {
204208 val type = 3 // L2CAP
205209 val constructorSpecs = listOf (
206- arrayOf(adapter, device, type, true , 31 , uuid),
210+ arrayOf(adapter, device, type, true , true , 31 , uuid),
207211 arrayOf(device, type, true , true , 31 , uuid),
208212 arrayOf(device, type, 1 , true , true , 31 , uuid),
209213 arrayOf(type, 1 , true , true , device, 31 , uuid),
0 commit comments