C# Establishing stream from laptop internal blueto

2019-03-27 19:46发布

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.
     }
}

2条回答
在下西门庆
2楼-- · 2019-03-27 19:59

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

查看更多
一纸荒年 Trace。
3楼-- · 2019-03-27 20:04

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

查看更多
登录 后发表回答