Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Establishing stream from laptop internal bluetooth 4.0 to Bluetooth Low Energy (BLE) peripheral

I am trying to write a program that connects to a Bluetooth Low Energy device (BLE), and then read a characteristic either on updates, or on a given interval.

My Peripheral is a Texas instruments CC2540 BLE device.

My starting point was looking at the example program from TI, that has a heart rate monitor: http://processors.wiki.ti.com/index.php/Category:HealthDemo

However, this uses the dongle, and I am tasked at using the internal bluetooth 4.0 modem (going to make it on android later on, but for now, I just use windows).

Now my problem is that the dongle creates a COM port, but the internal modem does not. I still managed to use the 32feet API to scan and succesfully find the CC2540. However, from here I do not know what to do. I've tried calling the connect() method, but it always fails to connect, either by timeout or stating that there is a dead network.

Any ideas why this happens? Am i supposed to do something else than calling my device.connect() ?

Code snippet:

BluetoothClient cli;
BluetoothDeviceInfo[] peers;
BluetoothDeviceInfo device;
BluetoothAddress adr;

//... skipping code that finds the device and assigns the address to it.

if (device.InstalledServices.Length != 0)
{
     try
     {
          //MessageBox.Show("attempting to connect");
          cli.Connect(device.DeviceAddress, device.InstalledServices[2]);
          //tbDeviceInfo.AppendText("\n\nConnected " + device.Connected);
     }
     catch (Exception ex)
     {                        
          MessageBox.Show(ex.Message);
          // i always get this exception.
     }
}
like image 505
Jesper Hoff Avatar asked Sep 06 '12 16:09

Jesper Hoff


2 Answers

I do not want to mistake you , but 32feet currently does not support Bluetooth low energy. (As for Nov 2012).

like image 137
James Roeiter Avatar answered Oct 19 '22 10:10

James Roeiter


There does not seem to be support for Bluetooth Low Energy using the 32Feet library . See here . Alternatatively you can have a look at this Bluetooth library that does provide support but i have not tried it and cannot claim how good the support is . See here

like image 40
rockstar Avatar answered Oct 19 '22 08:10

rockstar