C# Can';t将全息镜头连接到蓝牙低能设备

C# Can';t将全息镜头连接到蓝牙低能设备,c#,visual-studio,unity3d,bluetooth,hololens,C#,Visual Studio,Unity3d,Bluetooth,Hololens,对于我正在进行的项目,我需要从蓝牙模块(HM-10)读取数据。我需要从Unity应用程序读取并使用这些数据。为了连接和读取数据,我正在使用Visual Studio 2017为Unity构建一个插件。我可以通过以下方式获得蓝牙设备列表: string[] requestedProperties = { "System.Devices.Aep.DeviceAddress", "System.Devices.Aep.IsConnected" }; deviceWatcher =

对于我正在进行的项目,我需要从蓝牙模块(HM-10)读取数据。我需要从Unity应用程序读取并使用这些数据。为了连接和读取数据,我正在使用Visual Studio 2017为Unity构建一个插件。我可以通过以下方式获得蓝牙设备列表:

 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”

我是否使用了错误的方法来获得结果


任何帮助都将不胜感激

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

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

可能是重复的否,我已经按照你所指的链接中描述的完全相同的步骤,但我仍然得到相同的错误。嗨,埃里克,你找到你的答案了吗?事实上,我也在寻找一些插件,将全息镜头连接到蓝牙设备。你好,Nishant,是的,我终于在hololens和我的蓝牙设备之间建立了工作连接。我会提交我的答案。全息镜头能用吗?如果是的话,你能给我举个例子吗?它对全息透镜有效,我不能给你一个简单的例子。如果您可以检索附近设备的列表,您可以创建一个GattDevice,并使用上面的代码连接到您想要连接的服务。是的,HoloLens上的新操作系统更新可以这样做。对于第一个HL操作系统,它无法工作,因为接口在那里,但没有实现。