【发布时间】:2017-06-15 14:52:58
【问题描述】:
对于我正在进行的项目,我需要从 BluetoothLE 模块 (HM-10) 读取数据。我需要从 Unity 应用程序中读取和使用这些数据。为了连接和读取数据,我正在使用 Visual Studio 2017 为 Unity 构建一个插件。我可以使用以下方法获取 BluetoothLE 设备列表:
string[] requestedProperties = { "System.Devices.Aep.DeviceAddress", "System.Devices.Aep.IsConnected" };
deviceWatcher =
DeviceInformation.CreateWatcher(
BluetoothLEDevice.GetDeviceSelectorFromPairingState(false),
requestedProperties,
DeviceInformationKind.AssociationEndpoint);
连接到设备似乎也可以。我用:
BluetoothLEDevice btDevice = await BluetoothLEDevice.FromIdAsync(device.Id);
接下来,我要读取此设备正在发送的数据。我了解我需要先收集服务和特征,然后才能读取此数据。但由于某种原因,我不能等待服务。使用此方法时出现错误:var gattservices = await btDevice.GetGattServicesAsync();
错误显示:
无法将类型为“Windows.Devices.Bluetooth.BluetoothLEDevice”的对象转换为类型“Windows.Devices.Bluetooth.IBluetoothLEDevice3”
我是否使用了错误的方法来获得结果?
任何帮助将不胜感激!
【问题讨论】:
-
不,我已按照您所指的链接中描述的完全相同的步骤进行操作,但我仍然收到相同的错误。
-
嗨 Erik,你找到答案了吗?实际上我也在寻找一些插件,可以将全息透镜连接到蓝牙设备。
-
你好 Nishant,是的,我终于在 hololens 和我的蓝牙 LE 设备之间建立了一个工作连接。我会提交我的答案。
标签: c# visual-studio unity3d bluetooth hololens