Problem connecting to RN41 bluetooth device

Topics: Bluetooth - Microsoft, Bluetooth - Other
Dec 5, 2013 at 9:23 PM
Hi,
I am new to bluetooth and 32feet, but have spend many days now to learn and figure this out.
The goal is to connect a C# windows desktop app to a arduino microprocessor board with a RN41 bluetooth device.
I can control and set parameters in the RN41 just fine. So I have a valid devicename and a known pin. ServiceClass on the RN41 is set to 0000 name=SPP DevClass 1F00. These could be changed.
Simply looking to send data values (IO-status) in the form a short strings from the RN41 to the desktop app. Reading the discussions, I thought I should do this with the "BluetoothClient" not using the serial ports created by the device. Correct?
I have been using the bluetooth tutorial on youtube and I am able to discover the device, however when trying to connect I can't seem to solve the error in the last line (my output):

"Local radio : 20689DB85303
  manufacturer: AtherosCommunications
  mode : Connectable
  claas : 7E010C
Scan complete
3 devices discovered.
EK45-1 was selected. attempting connect
device paired..
starting connect thread
Attempting to connect
The requested address is not valid in its context 0006664BE957:0000110100001000000000005f9834fb
"
So somehow I don't understand how to use the Guid correctly, hoping somebody can help.
The "0006664BE957" is the address from the RN41.

Relevant code sections:
  Guid mUUID = new Guid("00001101-0000-1000-0000-00005F9834FB");

 private void ClientConnectThread()
    {
        BluetoothClient client = new BluetoothClient();
        updateUI("Attempting to connect");
        client.SetPin(myPin);  
        client.BeginConnect(deviceInfo.DeviceAddress, mUUID, this.BluetoothClientConnectCallback, client);
}


BluetoothDeviceInfo deviceInfo;
    private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
    {
        deviceInfo = devices.ElementAt(listBox1.SelectedIndex);
        updateUI(deviceInfo.DeviceName  + " was selected. attempting connect") ;

        if (pairDevice())
        {
            updateUI("device paired..");
            updateUI("starting connect thread");
            Thread bluetoothClientThread = new Thread(new ThreadStart(ClientConnectThread));
            bluetoothClientThread.Start();
        }
        else
        {
            updateUI("Pair failed"); 
        }

    }
Developer
Dec 6, 2013 at 9:36 AM
You have two typos in the "Guid mUUID = ..." line. Please just use
Guid mUUID = BluetoothService.SerialPort;
That should fix it. :-)
Dec 7, 2013 at 6:15 AM

THANKS!!!
Yes that works much better!
Johannes
Dec 20, 2013 at 8:31 PM

Hi Alan,
thanks gain for the help!
I have one more issue which appears very intermittend:
This error shows while running debug in VS2010, but only once in a while. Timing?
"SocketException occured"
"A connection attempt failed because the connected party did not respond after a period of time, or established connection failed because connected host has failed to respond"
0006666180B1:0000110100001000800000805f9b34fb
This on a connect: (Client is BluetoothClient) which is only called after a successfull pairing and after a listening thread was started.
BTServerEndPoint=new BluetoothEndPoint(BTServerDevice.DeviceAddress,BluetoothService.SerialPort);
Client.Connect(BTServerEndPoint)
I may have to cut the code out and create a sample project, however was hoping you might have some pointers for me.
THANKS and Merry Chistmas!
Johannes
Dec 30, 2013 at 1:46 AM
I am having the exact same problem (I am using a BlueSmirf Gold), do you have any advice?

Thanks and Happy New Year!

jhedmonton wrote:
 Hi Alan, thanks gain for the help! I have one more issue which appears very intermittend: This error shows while running debug in VS2010, but only once in a while. Timing? "SocketException occured" "A connection attempt failed because the connected party did not respond after a period of time, or established connection failed because connected host has failed to respond" 0006666180B1:0000110100001000800000805f9b34fb This on a connect: (Client is BluetoothClient) which is only called after a successfull pairing and after a listening thread was started. BTServerEndPoint=new BluetoothEndPoint(BTServerDevice.DeviceAddress,BluetoothService.SerialPort); Client.Connect(BTServerEndPoint) I may have to cut the code out and create a sample project, however was hoping you might have some pointers for me. THANKS and Merry Chistmas! Johannes
Jan 15, 2014 at 8:01 PM
I am using visual studio 2010 C++ and RN42 device. I can search and find the device, get the address, but fail to connect. I am using a Trendnet Mico Bluetooth USB adapter on my computer, I am not sure if that's the problem!
Here is the piece of code I wrote to connect:
BTClient->Connect(BTAddr, InTheHand::Net::Bluetooth::BluetoothService::SerialPort);
I go the exception: A socket operation is attempted to an unreachable network 0000666xxxxx:000011010000100080000805f9b34fb
Jan 16, 2014 at 2:09 AM

Sorry I have not seen this error here and I am very new to 32feet and bluetooth.
Johannes