So I want to connect to a bluetooth module(RN-42) using my android phone. I know the MAC address, but I don't know much about UUID. First of all, do I need the UUID of the device I'm connecting to or am I giving that device the UUID of my phone?
Right now my code goes something like this:
BluetoothDevice device = bluetooth.getRemoteDevice("00:06:66:43:40:70");
BluetoothSocket tmp = null;
BluetoothSocket mmSocket = null;
try {
tmp = device.createRfcommSocketToServiceRecord(UUID);
} catch (IOException e) {
output = "Connecting to device failed!\n" + output;
if (output.length() > maxOutputLenght) {
output = output.substring(0, maxOutputLenght);
}
editText.setText(outputStart + output);
}
mmSocket = tmp;
try
{
mmSocket.connect();
} catch (IOException e)
{
output = "Connect() error\n" + output;
if (output.length() > maxOutputLenght) {
output = output.substring(0, maxOutputLenght);
}
editText.setText(outputStart + output);
error = true;
}
if(!error) {
changeScreen(1);
}
else
{
output = "Failure :C\n" + output;
if (output.length() > maxOutputLenght) {
output = output.substring(0, maxOutputLenght);
}
editText.setText(outputStart + output);
}
The purpose is to control a RC-car by sending data from my android app through the bluetooth module an into a picaxe processor. which has a program I've already written that controls the car depending on the data it receives.