I'm trying to write a program that connects to a Bluetooth Low Energy (BLE) device, and then read the feature either on updates or at a given interval.
My Peripheral is a Texas Instruments CC2540 BLE device.
My starting point was looking at a sample program from TI that has a heart rate monitor: http://processors.wiki.ti.com/index.php/Category:HealthDemo
However, this uses the key, and I am instructed to use the internal bluetooth 4.0 modem (I am going to do it on android later, but for now I just use windows).
Now my problem is that the key creates a COM port, but there is no internal modem. I still managed to use the 32-bit API to scan and successfully search for CC2540. However, from here I do not know what to do. I tried to call the connect () method, but it cannot always connect, either with a timeout or with an expression that there is a dead network.
Any ideas why this is happening? Can I do something else besides 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. } }
Jesper hoff
source share