【问题标题】:Can't connect the Hololens to a Bluetooth Low Energy device无法将 Hololens 连接到蓝牙低功耗设备
【发布时间】: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


【解决方案1】:

我终于找到了如何获得所有服务以及每个服务的特征。通过创建 GattDevice,我可以使用GattDevice.GattServices 获得服务。 当我找到正确的 GattDeviceService 时,我可以通过以下方式获得特征:

GattService s = new GattService(GattDeviceService)
GattCharacteristic.GetCharacteristics(s)

【讨论】:

  • 这适用于 HoloLens 吗?如果是的话,你能给我一个例子吗?
  • 它确实适用于 Hololens,我不能给你一个简单的例子。如果您可以检索附近设备的列表,您可以创建一个 GattDevice 并使用上面的代码连接到您想要连接的服务。
  • 是的,使用 HoloLens 上的新操作系统更新,这可以正常工作。对于第一个 HL OS,它无法工作,因为接口存在但未实现。
猜你喜欢
  • 2013-11-17
  • 1970-01-01
  • 2014-02-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多