Author Topic: Connecting to a paired device  (Read 14745 times)

LucaUWF

  • Guest
Connecting to a paired device
« on: October 18, 2012, 01:03:51 AM »
Hi,

I'm currently evaluating Bluetooth libraries that are available for .NET.
I have a device that currently requires pairing and uses RFCOMM for communicating data.

Looking at the sample it appeared that I'd be able to make use of the Discovery and the ChatClient samples. Noting the documentation on setting Authenticate to True and then having to Pair before making the connection I threw the following together:


Code: [Select]
        private void btConnect_Click(object sender, EventArgs e)
        {
            wcl.wclBluetoothRadio Radio = GetSelectedRadio();
            if (Radio != null)
            {
                if (lvDevices.SelectedItems.Count == 0)
                    MessageBox.Show("Selected device");
                else
                {
                    wcl.wclBluetoothDevice Device = new wcl.wclBluetoothDevice();
                    Device.Address = lvDevices.SelectedItems[0].Text;
                    wcl.wclErrors.wclShowError(Device.Pair(Radio, "1235"));

                    string Address = lvDevices.SelectedItems[0].Text;
                    wclClient.BluetoothParams.Address = Address;
                    wclClient.BluetoothParams.Radio = Radio;
                    wclClient.BluetoothParams.Service = new Guid("{71D47FA1-87B6-4629-AB78-77B482AE5316}");
                    wclClient.BluetoothParams.Authentication = true;
                   
                    wclClient.BluetoothParams.Encryption = false;
                    wclClient.Transport = wcl.wclClientTransport.ctBluetooth;
                    wcl.wclErrors.wclShowError(wclClient.Connect());
                }
            }
        }

The pairing appears to work, but the connection throws an error 44,  WCL_E_SERVICE_NOT_FOUND from the API doc.
I don't seem to be able to locate any documentation on what parts of the Bluetooth stack the samples are exercising (I assumed RFCOMM/SerialPort profile in this case) so I may be misunderstanding this particular sample.

Can anyone point me in the right direction please?

LucaUWF

  • Guest
Re: Connecting to a paired device
« Reply #1 on: October 18, 2012, 01:11:28 AM »
Sorry, my bad...
I did not modify the service ID!

I need sleep.  ::)

Now works...

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Connecting to a paired device
« Reply #2 on: October 18, 2012, 06:45:06 AM »
Hello,

Not problem. Also I do recomend to take a look on Authenticator demo. wclAuthenticator allows you to handle Pairing requests for legacy PIN and for BT 2.1 SSP.

 

Sitemap 1 2 3 4 5 6 7