question

Wobbles avatar image
Wobbles asked

Failed Connection to Amazon Basics Bluetooth Keyboard

Hello, I am having great difficulty getting my Android App to connect to an Amazon Basics Bluetooth Keyboard. I can pair the keyboard with the Android device manually, no problem. However, doing it programmatically fails. The App successfully recognises the device as an Amazon Basic Keyboard and gets the MAC address, it just won't connect. I am running the code on an Amazon Kindle Fire HD - I've also tried on another Android device running OS v2.3.3), but the result is the same. Trying the documented method (code fragment): private final UUID MY_UUID = UUID.fromString("b1b9aee2-a388-11e4-89d3-123b93f75cba"); // I generated this UUID ... tmp = mmDevice.createRfcommSocketToServiceRecord(MY_UUID); tmp.connect(); This fails with: [b]java.io.IOException: Service discovery failed[/b] I've also tried using a couple of other "standard" UUIDs such as 00001101-0000-1000-8000-00805F9B34FB, 00001124-0000-1000-8000-00805F9B34FB with the same error. I am also cancelling Device Discovery before trying to connect. I have also tried the undocumented method (code fragment): BluetoothSocket socket; Method m; m = device.getClass().getMethod("createRfcommSocket",new Class[] { int.class }); socket = (BluetoothSocket) m.invoke(device, 1); mBluetoothAdapter.cancelDiscovery(); socket.connect(); This also fails, but with a different error: [b]java.io.IOException: Connection refused[/b] I have tried both these methods with the device paired and unpaired with the same results. I also resorted to an unlikely Thread.sleep(5000) before connecting without success. After several days trying I'm at a loss as to what to do. Is there a particular UUID that I have to use? Any help would be greatly appreciated! Thanks Colin
fire tablet
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Wobbles avatar image
Wobbles answered
Hello, This is clearly a difficult issue to resolve. Has anyone managed to communicate via code with the Amazon Basics Bluetooth Keyboard? I'm including the full log output when running the App to see if that can help anyone to fix this. As you can see the device is recognized as paired with the Kindle, but when the app tries to do it it fails and connection is set to false. To me, it looks like it doesn't like the UUID channel - but what channel should I use? Thanks for any help, Wobbles --------------------------------- 02-28 11:06:22.721: I/ActivityStack(201): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 pkg=com.example.bluetoothtest cmp=com.example.bluetoothtest/.MainActivity} from pid 547 02-28 11:06:22.721: V/ActivityStack(201): Prepare open transition: starting ActivityRecord{41a90e60 com.example.bluetoothtest/.MainActivity} 02-28 11:06:22.768: V/ActivityStack(201): Prepare open transition: prev=ActivityRecord{41a972d0 com.amazon.kindle.otter/.Launcher} 02-28 11:06:22.775: D/bluetooth2(996): ...Bluetooth ON... 02-28 11:06:22.775: D/bluetooth2(996): ...onResume - try connect... 02-28 11:06:22.775: D/bluetooth2(996): Socket Created! 02-28 11:06:22.775: D/BluetoothService.cpp(201): stopDiscoveryNative 02-28 11:06:22.775: E/BluetoothService.cpp(201): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session) 02-28 11:06:22.775: D/bluetooth2(996): ...Connecting... 02-28 11:06:22.775: D/BluetoothService.cpp(201): createDeviceNative 02-28 11:06:22.775: D/BluetoothService.cpp(201): ... address = 90:7F:61:97:AE:BE 02-28 11:06:22.783: D/BluetoothEventLoop.cpp(201): onCreateDeviceResult 02-28 11:06:22.783: D/BluetoothEventLoop.cpp(201): ... Address = 90:7F:61:97:AE:BE 02-28 11:06:22.783: E/BluetoothEventLoop.cpp(201): onCreateDeviceResult: D-Bus error: org.bluez.Error.AlreadyExists (Already Exists) 02-28 11:06:22.783: D/BluetoothEventLoop(201): Result of onCreateDeviceResult:1 02-28 11:06:22.783: D/BluetoothService.cpp(201): discoverServicesNative 02-28 11:06:22.783: D/BluetoothService.cpp(201): ... Object Path = /org/bluez/121/hci0/dev_90_7F_61_97_AE_BE 02-28 11:06:22.783: D/BluetoothService.cpp(201): ... Pattern = , strlen = 0 02-28 11:06:22.783: I//system/bin/bluetoothd(110): bluetoothd[121]: external/bluetooth/bluez/src/device.c:btd_device_ref() 0x1e90a88: ref=3 02-28 11:06:22.924: D/dalvikvm(201): GC_EXPLICIT freed 415K, 21% free 21196K/26503K, paused 3ms+9ms 02-28 11:06:23.455: I//system/bin/bluetoothd(110): bluetoothd[121]: external/bluetooth/bluez/plugins/hciops.c:conn_complete() status 0x00 02-28 11:06:23.471: D/BluetoothEventLoop.cpp(201): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/121/hci0/dev_90_7F_61_97_AE_BE 02-28 11:06:23.471: D/BluetoothEventLoop(201): Device property changed: 90:7F:61:97:AE:BE property: Connected value: true 02-28 11:06:23.479: I//system/bin/bluetoothd(110): bluetoothd[121]: external/bluetooth/bluez/plugins/hciops.c:remote_features_information() hci0 status 0 02-28 11:06:23.479: I//system/bin/bluetoothd(110): bluetoothd[121]: external/bluetooth/bluez/plugins/hciops.c:remote_name_information() hci0 status 0 02-28 11:06:23.682: I//system/bin/bluetoothd(110): bluetoothd[121]: external/bluetooth/bluez/src/device.c:search_cb() 90:7F:61:97:AE:BE: No service update 02-28 11:06:23.682: D/BluetoothEventLoop.cpp(201): onDiscoverServicesResult 02-28 11:06:23.682: D/BluetoothEventLoop.cpp(201): ... Device Path = /org/bluez/121/hci0/dev_90_7F_61_97_AE_BE 02-28 11:06:23.682: D/BluetoothService.cpp(201): getDevicePropertiesNative 02-28 11:06:23.682: I//system/bin/bluetoothd(110): bluetoothd[121]: external/bluetooth/bluez/src/device.c:btd_device_unref() 0x1e90a88: ref=2 02-28 11:06:23.689: D/BluetoothService(201): updateDeviceServiceChannelCache(90:7F:61:97:AE:BE) 02-28 11:06:23.689: D/BluetoothService(201): Cleaning up failed UUID channel lookup: 90:7F:61:97:AE:BE 00001101-0000-1000-8000-00805f9b34fb 02-28 11:06:23.689: D/bluetooth2(996): ....Connection failed... 02-28 11:06:23.689: W/System.err(996): java.io.IOException: Service discovery failed 02-28 11:06:23.689: W/System.err(996): at android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoothSocket.java:397) 02-28 11:06:23.689: W/System.err(996): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:207) 02-28 11:06:23.689: W/System.err(996): at com.example.bluetoothtest.MainActivity.onResume(MainActivity.java:138) 02-28 11:06:23.689: W/System.err(996): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1154) 02-28 11:06:23.689: W/System.err(996): at android.app.Activity.performResume(Activity.java:4711) 02-28 11:06:23.689: W/System.err(996): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2516) 02-28 11:06:23.689: W/System.err(996): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2562) 02-28 11:06:23.689: W/System.err(996): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2065) 02-28 11:06:23.689: W/System.err(996): at android.app.ActivityThread.access$600(ActivityThread.java:127) 02-28 11:06:23.689: W/System.err(996): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1181) 02-28 11:06:23.689: W/System.err(996): at android.os.Handler.dispatchMessage(Handler.java:99) 02-28 11:06:23.689: W/System.err(996): at android.os.Looper.loop(Looper.java:137) 02-28 11:06:23.689: W/System.err(996): at android.app.ActivityThread.main(ActivityThread.java:4558) 02-28 11:06:23.689: W/System.err(996): at java.lang.reflect.Method.invokeNative(Native Method) 02-28 11:06:23.689: W/System.err(996): at java.lang.reflect.Method.invoke(Method.java:511) 02-28 11:06:23.689: W/System.err(996): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 02-28 11:06:23.689: W/System.err(996): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 02-28 11:06:23.689: W/System.err(996): at dalvik.system.NativeStart.main(Native Method) 02-28 11:06:23.791: I/ActivityManager(201): Displayed com.example.bluetoothtest/.MainActivity: +1s23ms 02-28 11:06:24.814: V/Sensors(201): accel data: 0.028740 0.076641 9.091495 02-28 11:06:28.088: I//system/bin/bluetoothd(110): bluetoothd[121]: external/bluetooth/bluez/plugins/hciops.c:disconn_complete() handle 12 status 0x00 02-28 11:06:28.088: I//system/bin/bluetoothd(110): bluetoothd[121]: external/bluetooth/bluez/src/event.c:btd_event_disconn_complete() 02-28 11:06:28.088: I//system/bin/bluetoothd(110): bluetoothd[121]: external/bluetooth/bluez/src/adapter.c:adapter_remove_connection() 02-28 11:06:28.088: D/BluetoothEventLoop.cpp(201): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/121/hci0/dev_90_7F_61_97_AE_BE 02-28 11:06:28.088: D/BluetoothEventLoop(201): Device property changed: 90:7F:61:97:AE:BE property: Connected value: false
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Nick Gardner avatar image
Nick Gardner answered
Hi, I'll raise this issue with the appropriate internal team. Thanks, Nick
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.