I'm trying to get a simple python script running on my Andorid phone (using SL4A) to connect to a BlueSMiRF bluetooth modem (based on an RN41 device), however no matter what I try I keep getting the following error when I try to connect.
java.io.IOException: Unable to start Service Discovery
The python script is shown below
import android
droid = android.Android()
droid.toggleBluetoothState(True)
result = droid.bluetoothConnect()
#result = droid.bluetoothConnect('00001101-0000-1000-8000-00805f9B34fb')
#result = droid.bluetoothConnect('00001101-0000-1000-8000-00805f9B34fb', '00:06:66:07:AE:44')
print repr(result)
droid.toggleBluetoothState(False)
I have tried all three variations of bluetoothConnect()
as shown in the code above. If I try the first two methods of connecting I can see the blueSMiRF
in the list of devices to connect too.
My arduino sketch (running on an Arduino Mega) is shown below. It simply forwards the characters from one port to another. Serial
is connected to my laptop at 9600, Serial1
is connected to the BlueSMiRF
at 115200.
void setup ()
{
// initialise serial
Serial.begin(9600);
Serial1.begin(115200);
}
void loop ()
{
if (Serial1.available())
{
char c = Serial1.read();
Serial.print(c);
}
if (Serial.available())
{
char c = Serial.read();
Serial1.print(c);
}
}
I am able to use Putty to access the blueSMiRF
's command mode by typing $$$
. Everything appears to be okay. I only have slight concerns about the settings for the Service Class and Device Class. These are set to the factory default values of 0x0000
and 0x1f00
respectively and I wonder if the service class might need to be set to 0x1101
(UUID for SSP).
Other info: Android version 2.3.3 SL4A r4