yamanoorsai
Lurker
I am an inexperienced Android programmer and I am currently trying to connect to my two bluetooth devices alternatively. The bluetooth devices are Bluetooth UART modules like the one in link here.
I tweaked the android bluetooth chat example to talk to one device. All I had to do was changing the UUID. I got the app communicating to my module. Now, I want to talk to two devices. I am not sure how to do it as the Eclipse environment seems to be complicated.
I got this concept working on Processing Language for Android. I was not able to enhance the user interface while I was using Processing. I got the app working to store the MAC address of the two devices that I want to connect. My main objective is that after I finish a reading a value from one device, it should disconnect and talk to another device. This is how I am doing it now:
I am able to connect and reconnect only for a few cycles. Though my app doesn't fail, it stops reconnecting after some time. I am looking forward to hear some thoughts on connecting the device using a robust mechanism
I tweaked the android bluetooth chat example to talk to one device. All I had to do was changing the UUID. I got the app communicating to my module. Now, I want to talk to two devices. I am not sure how to do it as the Eclipse environment seems to be complicated.
I got this concept working on Processing Language for Android. I was not able to enhance the user interface while I was using Processing. I got the app working to store the MAC address of the two devices that I want to connect. My main objective is that after I finish a reading a value from one device, it should disconnect and talk to another device. This is how I am doing it now:
Code:
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;
}
I am able to connect and reconnect only for a few cycles. Though my app doesn't fail, it stops reconnecting after some time. I am looking forward to hear some thoughts on connecting the device using a robust mechanism