Tuesday, May 15, 2012

[android-developers] Re: Connecting to two bluetooth devices alternatively

It would be really helpful if someone responded to my question. I would be glad to furnish more information

Sai

On May 14, 2012 10:18 PM, "yamanoorsai" <yamanoorsai@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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate