>> My objective is to read data from a bluetooth device alternatively.
1) I would like to connect to device 1. 2) Read data from the device 3) Disconnect from device 1 and connect to device 2. 4) Repeat from step 1 for device 2. I achieved this when I was using Processing language for Android. I took a video of the same: http://www.youtube.com/watch?v=MVut3Vn5BFAch I am also able to read and write data to the UART data module once the connection is established. I am not able to close the Bluetooth Socket and switch devices properly when I try to establish the above mentioned sequence. It seems to get stuck in an infinite loop. Thanks, Sai On Wed, May 16, 2012 at 2:24 AM, gjs <[email protected]> wrote: > Hi > > What you mean by - > > My objective is to read data from a bluetooth device alternatively. I > was successful in storing the address of the devices selected. This > is > how I am trying to connect to the devices alternatively: > > - Specifically what do you mean by 'read data from a bluetooth device > alternatively' ??? > > Can you get your bluetooth UART to echo back the data to the bluetooth > Android (chat) example, once the devices are connected ? > > Regards > > On May 15, 1:18 pm, yamanoorsai <[email protected]> wrote: > > Hi, > > > > I tweaked the android bluetooth example to get my android device to > > communicate with my UART Bluetooth module. I just changed the UUID to > > communicate to the module. > > > > My objective is to read data from a bluetooth device alternatively. I > > was successful in storing the address of the devices selected. This is > > how I am trying to connect to the devices alternatively: > > > > case MESSAGE_READ: > > byte[] readBuf = (byte[]) msg.obj; > > // construct a string from the valid bytes in the buffer > > String readMessage = new String(readBuf, 0, msg.arg1); > > mConversationArrayAdapter.add(mConnectedDeviceName+": " + > > readMessage); > > if(status==0) > > { > > mChatService.stop(); > > BluetoothDevice device = > > mBluetoothAdapter.getRemoteDevice(address); > > mChatService.connect(device); > > status =1; > > break; > > } > > else { > > mChatService.stop(); > > BluetoothDevice device = > > mBluetoothAdapter.getRemoteDevice(address1); > > mChatService.connect(device); > > status =0; > > } > > > > The device successfully disconnects and reconnect successfully. This > > activity repeats only for a few cycles then it stops connecting. I am > > an inexperienced programmer and I am not sure how to establish a > > robust mechanism. > > > > Any thoughts would be appreciated. > > > > Thanks, > > Sai > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

