Hi! I'm trying to connect to Zeemote (http://zeemote.com/) gaming controller from Moto Droid running 2.0.1 firmware. The test application below does connect to the device (LED flashes) but connection is dropped immediately. I can connect to the device perfectly fine using bluez tools (log attached as well).
I'm quite at a loss here, I work on it for so long that I ran out of ideas so any help would be very much appreciated. Btw, looks like this issue is somewhat similar to http://groups.google.com/group/android-developers/browse_thread/thread/a7ff7771ae3be1c/6f8bb2bc0300806c?hl=en&lnk=gst&q=bluetooth+connecting#6f8bb2bc0300806c Thanks, Max =========================================== Code: package zee.test; import java.io.IOException; import java.io.InputStream; import java.util.UUID; import android.app.Activity; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothSocket; import android.os.Bundle; import android.util.Log; public class ZeeTest extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); try { test(); } catch (IOException e) { e.printStackTrace(); } } public void test() throws IOException { BluetoothDevice zee = BluetoothAdapter.getDefaultAdapter().getRemoteDevice("00:1C:4D:02:A6:55"); Log.d("ZeeTest", "++++ Creating socket"); BluetoothSocket sock = zee.createRfcommSocketToServiceRecord(UUID.fromString("8e1f0cf7-508f-4875-b62c-fbb67fd34812")); Log.d("", "++++ Connecting"); sock.connect(); Log.d("", "++++ Connected"); final InputStream in = sock.getInputStream(); new Thread() { @Override public void run() { byte[] buffer = new byte[32]; int bytes = 0; int x = 0; Log.d("", "++++ Listening..."); while (x < 200) { x++; try { bytes = in.read(buffer); Log.d("ZeeTest", "++++ Read "+ bytes +" bytes"); } catch (IOException e) { if (x % 50 == 0) { Log.d("", "Tried "+ x +" times ("+ bytes +")"); } try { Thread.sleep(100); } catch (InterruptedException ie) {} } } Log.d("ZeeTest", "++++ Done: thread exit"); } }.start(); Log.d("ZeeTest", "++++ Done: test()"); } } =========================================== Log: I/ActivityManager( 1169): Start proc zee.test for activity zee.test/.ZeeTest: pid=4294 uid=10084 gids={3002, 3001, 3003} I/dalvikvm( 4294): Debugger thread not active, ignoring DDM send (t=0x41504e4d l=38) D/dalvikvm( 4287): LinearAlloc 0x0 used 640700 of 5242880 (12%) I/dalvikvm( 4294): Debugger thread not active, ignoring DDM send (t=0x41504e4d l=20) D/ZeeTest ( 4294): ++++ Creating socket D/ ( 4294): ++++ Connecting E/BluetoothEventLoop.cpp( 1169): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/1240/hci0/dev_00_1C_4D_02_A6_55 I/usbd ( 1068): process_usb_uevent_message(): buffer = add@ /devices/virtual/bluetooth/hci0/hci0:1 I/usbd ( 1068): main(): call select(...) E/BluetoothEventLoop.cpp( 1169): event_filter: Received signal org.bluez.Adapter:DeviceFound from /org/bluez/1240/hci0 V/BluetoothEventRedirector( 1242): Received android.bluetooth.device.action.FOUND V/BluetoothEventRedirector( 1242): Received android.bleutooth.device.action.UUID D/ ( 4294): ++++ Connected D/ZeeTest ( 4294): ++++ Done: test() D/ ( 4294): ++++ Listening... I/ActivityManager( 1169): Displayed activity zee.test/.ZeeTest: 2296 ms (total 2296 ms) E/BluetoothEventLoop.cpp( 1169): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/1240/hci0/dev_00_1C_4D_02_A6_55 I/usbd ( 1068): process_usb_uevent_message(): buffer = remove@ /devices/virtual/bluetooth/hci0/hci0:1 I/usbd ( 1068): main(): call select(...) V/BluetoothEventRedirector( 1242): Received android.bleutooth.device.action.UUID D/ ( 4294): Tried 50 times (0) D/ ( 4294): Tried 100 times (0) D/ ( 4294): Tried 150 times (0) D/ ( 4294): Tried 200 times (0) D/ZeeTest ( 4294): ++++ Done: thread exit =========================================== Terminal log: $ sdptool browse Inquiring ... Browsing 00:1C:4D:02:A6:55 ... $ sdptool records 00:1C:4D:02:A6:55 Service Name: Zeemote Service RecHandle: 0x10015 Service Class ID List: UUID 128: 8e1f0cf7-508f-4875-b62c-fbb67fd34812 Protocol Descriptor List: "L2CAP" (0x0100) "RFCOMM" (0x0003) Channel: 1 Language Base Attr List: code_ISO639: 0x656e encoding: 0x6a base_offset: 0x100 $ rfcomm connect /dev/tty10 00:1C:4D:02:A6:55 Connected /dev/rfcomm0 to 00:1C:4D:02:A6:55 on channel 1 Press CTRL-C for hangup # rfcomm show /dev/tty10 rfcomm0: 00:1F:3A:E4:C8:40 -> 00:1C:4D:02:A6:55 channel 1 connected [reuse-dlc release-on-hup tty-attached] # cat /dev/tty10 (nothing here) # hcidump HCI sniffer - Bluetooth packet analyzer ver 1.42 device: hci0 snap_len: 1028 filter: 0xffffffff < HCI Command: Create Connection (0x01|0x0005) plen 13 > HCI Event: Command Status (0x0f) plen 4 > HCI Event: Connect Complete (0x03) plen 11 < HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2 > HCI Event: Read Remote Supported Features (0x0b) plen 11 < ACL data: handle 11 flags 0x02 dlen 10 L2CAP(s): Info req: type 2 > HCI Event: Command Status (0x0f) plen 4 > HCI Event: Page Scan Repetition Mode Change (0x20) plen 7 > HCI Event: Max Slots Change (0x1b) plen 3 < HCI Command: Remote Name Request (0x01|0x0019) plen 10 > HCI Event: Command Status (0x0f) plen 4 > ACL data: handle 11 flags 0x02 dlen 16 L2CAP(s): Info rsp: type 2 result 0 Extended feature mask 0x0000 < ACL data: handle 11 flags 0x02 dlen 12 L2CAP(s): Connect req: psm 3 scid 0x0040 > HCI Event: Number of Completed Packets (0x13) plen 5 > ACL data: handle 11 flags 0x02 dlen 16 L2CAP(s): Connect rsp: dcid 0x04fb scid 0x0040 result 1 status 2 Connection pending - Authorization pending > HCI Event: Remote Name Req Complete (0x07) plen 255 > ACL data: handle 11 flags 0x02 dlen 16 L2CAP(s): Connect rsp: dcid 0x04fb scid 0x0040 result 0 status 0 Connection successful < ACL data: handle 11 flags 0x02 dlen 16 L2CAP(s): Config req: dcid 0x04fb flags 0x00 clen 4 MTU 1013 > ACL data: handle 11 flags 0x02 dlen 14 L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 0 Success > ACL data: handle 11 flags 0x02 dlen 16 L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 4 MTU 1013 < ACL data: handle 11 flags 0x02 dlen 18 L2CAP(s): Config rsp: scid 0x04fb flags 0x00 result 0 clen 4 MTU 1013 < ACL data: handle 11 flags 0x02 dlen 8 L2CAP(d): cid 0x04fb len 4 [psm 3] RFCOMM(s): SABM: cr 1 dlci 0 pf 1 ilen 0 fcs 0x1c > HCI Event: Number of Completed Packets (0x13) plen 5 > ACL data: handle 11 flags 0x02 dlen 8 L2CAP(d): cid 0x0040 len 4 [psm 3] RFCOMM(s): UA: cr 1 dlci 0 pf 1 ilen 0 fcs 0xd7 < ACL data: handle 11 flags 0x02 dlen 18 L2CAP(d): cid 0x04fb len 14 [psm 3] RFCOMM(s): PN CMD: cr 1 dlci 0 pf 0 ilen 10 fcs 0x70 mcc_len 8 dlci 2 frame_type 0 credit_flow 15 pri 7 ack_timer 0 frame_size 1008 max_retrans 0 credits 7 > HCI Event: Number of Completed Packets (0x13) plen 5 > ACL data: handle 11 flags 0x02 dlen 18 L2CAP(d): cid 0x0040 len 14 [psm 3] RFCOMM(s): PN RSP: cr 0 dlci 0 pf 0 ilen 10 fcs 0xaa mcc_len 8 dlci 2 frame_type 0 credit_flow 14 pri 7 ack_timer 0 frame_size 1008 max_retrans 0 credits 0 < ACL data: handle 11 flags 0x02 dlen 8 L2CAP(d): cid 0x04fb len 4 [psm 3] RFCOMM(s): SABM: cr 1 dlci 2 pf 1 ilen 0 fcs 0x59 > ACL data: handle 11 flags 0x02 dlen 8 L2CAP(d): cid 0x0040 len 4 [psm 3] RFCOMM(s): UA: cr 1 dlci 2 pf 1 ilen 0 fcs 0x92 < ACL data: handle 11 flags 0x02 dlen 12 L2CAP(d): cid 0x04fb len 8 [psm 3] RFCOMM(s): MSC CMD: cr 1 dlci 0 pf 0 ilen 4 fcs 0x70 mcc_len 2 dlci 2 fc 0 rtc 1 rtr 1 ic 0 dv 1 b1 0 b2 0 b3 0 len 0 > ACL data: handle 11 flags 0x02 dlen 12 L2CAP(d): cid 0x0040 len 8 [psm 3] RFCOMM(s): MSC CMD: cr 0 dlci 0 pf 0 ilen 4 fcs 0xaa mcc_len 2 dlci 2 fc 0 rtc 1 rtr 1 ic 0 dv 0 b1 0 b2 0 b3 0 len 0 < ACL data: handle 11 flags 0x02 dlen 12 L2CAP(d): cid 0x04fb len 8 [psm 3] RFCOMM(s): MSC RSP: cr 1 dlci 0 pf 0 ilen 4 fcs 0x70 mcc_len 2 dlci 2 fc 0 rtc 1 rtr 1 ic 0 dv 0 b1 0 b2 0 b3 0 len 0 > HCI Event: Number of Completed Packets (0x13) plen 5 > ACL data: handle 11 flags 0x02 dlen 12 L2CAP(d): cid 0x0040 len 8 [psm 3] RFCOMM(s): MSC RSP: cr 0 dlci 0 pf 0 ilen 4 fcs 0xaa mcc_len 2 dlci 2 fc 0 rtc 1 rtr 1 ic 0 dv 1 b1 0 b2 0 b3 0 len 0 > ACL data: handle 11 flags 0x02 dlen 9 L2CAP(d): cid 0x0040 len 5 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 1 ilen 0 fcs 0x5c credits 1 < ACL data: handle 11 flags 0x02 dlen 9 L2CAP(d): cid 0x04fb len 5 [psm 3] RFCOMM(d): UIH: cr 1 dlci 2 pf 1 ilen 0 fcs 0x86 credits 33 > HCI Event: Number of Completed Packets (0x13) plen 5 > HCI Event: Role Change (0x12) plen 8 > ACL data: handle 11 flags 0x02 dlen 17 > ACL data: handle 11 flags 0x01 dlen 17 > ACL data: handle 11 flags 0x01 dlen 17 > ACL data: handle 11 flags 0x01 dlen 3 L2CAP(d): cid 0x0040 len 50 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 46 fcs 0x40 > ACL data: handle 11 flags 0x02 dlen 16 L2CAP(d): cid 0x0040 len 12 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 8 fcs 0x40 > ACL data: handle 11 flags 0x02 dlen 46 L2CAP(d): cid 0x0040 len 42 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 38 fcs 0x40 > ACL data: handle 11 flags 0x02 dlen 46 L2CAP(d): cid 0x0040 len 42 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 38 fcs 0x40 > ACL data: handle 11 flags 0x02 dlen 46 L2CAP(d): cid 0x0040 len 42 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 38 fcs 0x40 > ACL data: handle 11 flags 0x02 dlen 46 L2CAP(d): cid 0x0040 len 42 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 38 fcs 0x40 > ACL data: handle 11 flags 0x02 dlen 16 L2CAP(d): cid 0x0040 len 12 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 8 fcs 0x40 > ACL data: handle 11 flags 0x02 dlen 16 L2CAP(d): cid 0x0040 len 12 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 8 fcs 0x40 > ACL data: handle 11 flags 0x02 dlen 16 L2CAP(d): cid 0x0040 len 12 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 8 fcs 0x40 > ACL data: handle 11 flags 0x02 dlen 16 L2CAP(d): cid 0x0040 len 12 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 8 fcs 0x40 > ACL data: handle 11 flags 0x02 dlen 16 L2CAP(d): cid 0x0040 len 12 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 8 fcs 0x40 > ACL data: handle 11 flags 0x02 dlen 16 L2CAP(d): cid 0x0040 len 12 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 8 fcs 0x40 > ACL data: handle 11 flags 0x02 dlen 16 L2CAP(d): cid 0x0040 len 12 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 8 fcs 0x40 > ACL data: handle 11 flags 0x02 dlen 16 L2CAP(d): cid 0x0040 len 12 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 8 fcs 0x40 > HCI Event: Max Slots Change (0x1b) plen 3 > HCI Event: Mode Change (0x14) plen 6 ...events are received... disconnection sequence (device being shut down): > HCI Event: Mode Change (0x14) plen 6 > ACL data: handle 11 flags 0x02 dlen 17 L2CAP(d): cid 0x0040 len 13 [psm 3] RFCOMM(d): UIH: cr 0 dlci 2 pf 0 ilen 9 fcs 0x40 > HCI Event: Max Slots Change (0x1b) plen 3 > ACL data: handle 11 flags 0x02 dlen 8 L2CAP(d): cid 0x0040 len 4 [psm 3] RFCOMM(s): DISC: cr 0 dlci 2 pf 1 ilen 0 fcs 0xd9 < ACL data: handle 11 flags 0x02 dlen 8 L2CAP(d): cid 0x04fb len 4 [psm 3] RFCOMM(s): UA: cr 0 dlci 2 pf 1 ilen 0 fcs 0xf3 < ACL data: handle 11 flags 0x02 dlen 8 L2CAP(d): cid 0x04fb len 4 [psm 3] RFCOMM(s): DISC: cr 1 dlci 0 pf 1 ilen 0 fcs 0xfd < ACL data: handle 11 flags 0x02 dlen 12 L2CAP(s): Disconn req: dcid 0x04fb scid 0x0040 > HCI Event: Number of Completed Packets (0x13) plen 5 > ACL data: handle 11 flags 0x02 dlen 8 L2CAP(d): cid 0x0040 len 4 [psm 3] RFCOMM(s): UA: cr 1 dlci 0 pf 1 ilen 0 fcs 0xd7 > ACL data: handle 11 flags 0x02 dlen 12 L2CAP(s): Disconn rsp: dcid 0x04fb scid 0x0040 > HCI Event: Number of Completed Packets (0x13) plen 5 < HCI Command: Disconnect (0x01|0x0006) plen 3 > HCI Event: Command Status (0x0f) plen 4 > HCI Event: Disconn Complete (0x05) plen 4 -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en