Tag: windows 10 desktop

如何使用C#手动绑定到WinForm中的BlueTooth低能耗设备?

这个问题主要通过以下方式解答: Windows UWP在发现后连接到BLE设备 我正在编写一个自定义服务并测试,目前,在Windows 10上使用C#.NET WinForm连接到蓝牙低功耗(BLE)设备。 我正在使用Framework 4.6.1。 我们使用TI SmartRF06评估板和TI CC2650 BLE子卡。 另一位开发人员正在处理董事会的固件。 目前使用类似于上面参考答案的方法,我能够连接到已经绑定的BLE设备。 此设备是手动绑定的,Windows确实要求我输入PIN。 由于设备没有PIN,只需输入“0”即可让设备连接。 一旦连接,以这种方式,我可以获得所有GATT服务并做我需要做的事情。 所以我找到并获得广告BLE设备没有任何问题。 问题是如何连接尚未配对的BLE设备? 我已经浏览了网络并找到了许多BLE代码示例,但没有具体说明如何完成代码中的配对。 不确定我甚至需要它配对,但Windows似乎只在配对设备上显示我的GATT服务。 当我使用不成对的设备执行此操作时: private void BleWatcherOnReceived(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args) { var dev = await BluetoothLEDevice.FromBluetoothAddressAsync(args.BluetoothAddress); // dev.DeviceInformation.Pairing.CanPair is true // dpr.Status is Failed DevicePairingResult dpr = await dev.DeviceInformation.Pairing.PairAsync(DevicePairingProtectionLevel.None); var service = await GattDeviceService.FromIdAsync(dev.DeviceInformation.Id); } 当设备尚未手动配对时,dpr的结果始终失败。 这导致GattDeviceServices为空。 […]

WPF桌面应用程序,Windows 10通知Toast 2016(UWP社区工具包)

我正在尝试使用我的WPF C#Desktop应用程序显示Windows 10 Toast。 可悲的是,关于非UWP或商店应用程序中的Windows 10通知的API和一般支持似乎非常有限和混乱。 最近发布了UWP社区工具包 ,它似乎试图让我们更容易。 还有这个商店应用程序Notifications Visualizer ,它可以帮助制作像这样的Toasts: 我接着尝试使用C#和UWP社区工具包提供的API生成Toast。 使用Microsoft.Toolkit.Uwp.Notifications; ToastContent toastContent = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = “Matt sent you a friend request” }, new AdaptiveText() { Text = “Hey, wanna dress up as wizards […]