4
A
回答
2
我认为它不可用。你需要等到周年纪念更新(希望)。检查了这一点的Windows开发者的反馈UserVoice的页面上https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/7176829-gatt-server-api
GATT服务器API将提供给开发人员在更新敬请期待
他指出,在构建2016所示,周年更新更新
2
现在,Windows只能成为GATT客户端;但是,它仍然可以读取和写入GATT服务器的BLE设备。有几个步骤来连接到BLE设备在Windows 10
权限
首先,请确保您有正确的功能设置。转到Package.appxmanifest,Capabilities选项卡,然后打开蓝牙。
Package.appxmanifest > Capabilities > Turn on Bluetooth
找到一个BLE装置
的重要注意事项。目前,Windows 10不支持连接到 未配对的BLE设备。您必须在设置页面 中配对设备,或使用应用内配对API。
了解设备已配对,有几种方法可以找到BLE设备。您可以通过外观,BluetoothAddress,ConnectionStatus,DeviceName或PairingState查找。一旦你找到你正在寻找的设备,你使用它的ID来连接它。以下是通过名称查找设备的示例:
string deviceSelector = BluetoothLEDevice.GetDeviceSelectorFromDeviceName("SOME_NAME");
var devices = await DeviceInformation.FindAllAsync(deviceSelector);
// Choose which device you want, name it yourDevice
BluetoothLEDevice device = await BluetoothLEDevice.FromIdAsync(yourDevice.Id);
FromIdAsync方法是Windows将连接到BLE设备的位置。
沟通
您可以读取和写入的特性通过以下的设备上。
// First get the characteristic you're interested in
var characteristicId = new Guid("SOME_GUID");
var serviceId = new Guid("SOME_GUID");
var service = device.GetGattService(serviceId);
var characterstic = service.GetCharacteristics(characteristicId)[0];
// Read from the characteristic
GattReadResult result = await characterstic.ReadValueAsync(BluetoothCacheMode.Uncached);
byte[] data = (result.Value.ToArray());
// Write to the characteristic
DataWriter writer = new DataWriter();
byte[] data = SOME_DATA;
writer.WriteBytes(data);
GattCommunicationStatus status = await characteristic.WriteValueAsync(writer.DetachBuffer());
相关问题
- 1. 蓝牙ASCII协议
- 2. 通过wifi的蓝牙协议?
- 3. 强迫蓝牙2.1使用蓝牙2.0协议?
- 4. 使用GAP/GATT服务Windows 10中的蓝牙LE无需先配对
- 5. C#写蓝牙协议
- 6. 关于蓝牙协议
- 7. 的Windows Phone的Silverlight 8.1与Arduino的通信使用蓝牙
- 8. Windows 10 UWP与Arduino的蓝牙连接
- 9. GOSession使用什么协议的IOS蓝牙?
- 10. 蓝牙低功耗GATT安全级别
- 11. 获取辅助蓝牙gatt服务android
- 12. 如何发布蓝牙GATT连接
- 13. Xamarin android蓝牙通信
- 14. iPhone蓝牙通信示例
- 15. 单声道C蓝牙通信#
- 16. Android通过免提协议连接到蓝牙
- 17. Android中使用GATT的低能耗蓝牙
- 18. 使用协议的跨班通信
- 19. 如何使用Android蓝牙API调度BLE GATT交换?
- 20. 蓝牙通讯
- 21. 什么协议用于认证Windows 10机器对天蓝色的广告?
- 22. 蓝牙库的Windows
- 23. 如何用对象推送协议连接蓝牙适配器?
- 24. Mac和iPhone之间的蓝牙通信
- 25. iOS5上的蓝牙/ Bonjour通信示例
- 26. ZigBee和蓝牙之间的通信
- 27. Arduino和PyBluez之间的蓝牙通信
- 28. 三星Galaxy S上的蓝牙通信
- 29. 协议通信帮助
- 30. 通过蓝牙
如果GATT服务不可用,您应该配对设备并使用DeviceWatcher api。微软的人正在研究更好的API,但现在这是做到这一点的方法。更多信息可以在这里找到:http://stackoverflow.com/questions/35420940/windows-uwp-connect-to-ble-device-after-discovery/39040812#39040812 – LanderV