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

人盡茶涼 提交于 2019-12-04 21:07:58

问题


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

回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/12304377/c-sharp-establishing-stream-from-laptop-internal-bluetooth-4-0-to-bluetooth-low

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!