C#建立从笔记本电脑内部蓝牙4.0到蓝牙低功耗(BLE)外设的流

Jes*_*off 7 .net c# bluetooth-lowenergy 32feet

我正在尝试编写一个连接到蓝牙低功耗设备(BLE)的程序,然后在更新或给定间隔内读取特征.

我的外设是德州仪器CC2540 BLE设备.

我的出发点是查看TI的示例程序,该程序具有心率监视器:http://processors.wiki.ti.com/index.php/Category : HealthDemo

然而,这使用了加密狗,我的任务是使用内部蓝牙4.0调制解调器(稍后将在Android上制作它,但是现在,我只使用Windows).

现在我的问题是加密狗创建了一个COM端口,但内部调制解调器没有.我仍然设法使用32feet API扫描并成功找到CC2540.但是,从这里我不知道该怎么办.我已经尝试过调用connect()方法,但它总是无法连接,无论是通过超时还是声明存在死网络.

任何想法为什么会这样?我应该做些什么而不是调用我的device.connect()?

代码段:

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.
     }
}
Run Code Online (Sandbox Code Playgroud)

Jam*_*ter 3

我不想误会您的意思,但 32feet 目前不支持蓝牙低功耗。(截至 2012 年 11 月)。