got another error from writing. wondering if this might be related. 11-24 13:07:27.731: ERROR/BluetoothEventLoop.cpp(1015): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/1973/hci0/dev_00_08_1B_CA_C7_29 11-24 13:07:28.606: VERBOSE/BluetoothEventRedirector(1138): Received android.bleutooth.device.action.UUID 11-24 13:07:30.015: DEBUG/(2254): getOutputStream 11-24 13:07:30.052: ERROR/(2254): bt write failed *11-24 13:07:30.052: ERROR/(2254): java.io.IOException: Transport endpoint is not connected*
I connected an debugger into remote device, and found the Android/My test driver initiated an disconnect immediately after connect. Really appreciate if you can point out what is wrong with my test driver. Sean On Tue, Nov 24, 2009 at 12:45 PM, Sean Liao <wirelessw...@gmail.com> wrote: > Hi, I wrote a simple test driver to test the bluetooth apis. Anyone can > verify whether I am using the API correctly? Everything seems good but no > data read :-( > > > > =========================================================================== > // before calling the following, inquiry scan successfully returned, and > the remote device is pre-paired. > > private boolean doTestConnection() { > > Log.d("SwxBtCommImpl", "doTestConnection"); > > String btAddr = "00:08:1B:CA:C7:29"; > > BluetoothDevice btdev = > BluetoothAdapterImpl.getInstance().getRemoteDevice(btAddr); > > // widcom using the following GUID > // 00001101-0000-1000-8000-00805F9B34FB > UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); > > try { > BluetoothSocket btsocket = > btdev.createRfcommSocketToServiceRecord(uuid); > > btsocket.connect(); > Log.d("SwxBtCommImpl", "connected"); > > try { > Thread.sleep(1000); > } catch (InterruptedException e1) { > // TODO Auto-generated catch block > e1.printStackTrace(); > } > > InputStream instream = btsocket.getInputStream(); > Log.d("", "getInputStream"); > > byte[] data = new byte[512]; > for (int i = 0; i < 20; i++) { > int numOfAvailable = instream.available(); > > Log.d("SwxBtCommImpl", "read " + i + ": " + numOfAvailable + " > bytes"); > if(numOfAvailable > 0) { > int numOfRead = instream.read(data); > Log.d("SwxBtCommImpl", new String(data) + "-" + numOfRead); > } else { > > try { > Thread.sleep(500); > } catch (InterruptedException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > } > > instream.close(); > instream = null; > > btsocket.close(); > > } catch (IOException e) { > // TODO Auto-generated catch block > Log.e("", "bt connection failed", e); > } > > > > return true; > } > > -- 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