BLE-GATT GetGattServicesAsync功能 [英] BLE-GATT GetGattServicesAsync function
问题描述
您好
我正在尝试在我的应用中获得支持的服务和特性。
我按照此处的说明操作= > https://docs.microsoft.com/en-us/windows/uwp/devices-sensors/gatt-client
但实际上我想从windows命令运行程序提示。 所以我创建了一个C#项目,没有使用任何窗口。
我可以毫无问题地获得BluetoothLEDevice类的对象。
但是我无法调用以下代码:
var service = await bluetoothLeDevice.GetGattServicesAsync();
错误消息显示 BluetoothLEDevice不包含该函数的定义。
我知道如果我创建一个UWP项目它可以工作,但我正在开发一个BLE测试程序并需要它由脚本运行。
有任何建议吗?
Bert
嗨林,
你在用吗?控制台应用程序?
阅读文档: https://docs.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.bluetoothledevice
As上面说过,我们可以访问了在UWP和桌面应用程序(具有属性" DualApiPartitionAttribute "的API)中的类 BluetoothLEDevice
,但方法 GetGattServicesAsync
在桌面应用程序中不可用。
这就是为什么它只适用于UWP项目的原因。
祝你好运,
科尔跨度>
Hi
I'm trying to get the supported services and characteristics in my app.
I followed the instruction here => https://docs.microsoft.com/en-us/windows/uwp/devices-sensors/gatt-client
But actually I'd like to run the program from windows command prompt. So I created a C# project and no window is used.
I can get a object of BluetoothLEDevice class without problems.
But I'm not able to call the following code:
var service = await bluetoothLeDevice.GetGattServicesAsync();
The error message shows BluetoothLEDevice doesn't contain the definition of the function.
I know it can work if I create a UWP project, but I'm developing a BLE test program and needs it to be run by a script.
Any suggestion?
Bert
Hi Lin,
Are you using Console application?
Read the documentation: https://docs.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.bluetoothledevice
As above said , We can access the Class BluetoothLEDevice both in UWP and desktop Application(the API with the attributes "DualApiPartitionAttribute"), but the method GetGattServicesAsync is not available in desktop application.
So that's the reason why it works in UWP project only.
Best regards,
Cole
这篇关于BLE-GATT GetGattServicesAsync功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!