Hi,

Ok, trying running in debug, add some breakpoints & observe what is
happening when you switch between devices, perhaps you need a bit of a
delay when switching to ensure the connection is ready.

Study the different bluetooth chat classes carefully to understand
what they are doing, in theory you should also be able to connect to
both UARTS at the same time by having more than one instance of the
relevant objects. Often the hardest part is getting devices to connect
successfully, perhaps you don't need to disconnect & reconnect each
time ? Maybe just read / write to each device alternatively rather
than disconnect & reconnect between ?

Good luck.

Regards

On May 16, 7:33 pm, Yamanoor Sai Ram <yamanoor...@gmail.com> wrote:
> >>  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 <garyjamessi...@gmail.com> 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 <yamanoor...@gmail.com> 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 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

-- 
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

Reply via email to