我正在尝试编写一个连接到蓝牙低功耗设备(BLE)的程序,然后在更新时或在给定的时间间隔读取特征。
我的外设是 Texas Instruments CC2540 BLE 设备。
我的出发点是查看 TI 的示例程序,它有一个心率监视器:http://processors.wiki.ti.com/index.php/Category:HealthDemo 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.
}
}
我不想误会您的意思,但 32feet 目前不支持蓝牙低功耗。 (截至 2012 年 11 月)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)