目前在尝试用笔记本电脑自身的蓝牙设备搜索BLE模块,发起连接配对,并能在两者间进行数据收发。目前已经能扫描搜索到BLE设备,虽然不知道连接配对是否成功,但是想请问一下,官方提供的蓝牙BLE数据收发的API是什么?有类似的demo就更好了。

        BluetoothLEAdvertisementWatcher Watcher;
        BluetoothLEDevice device;
        private void SetupBluetooth()
        {
            Watcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active };
            Watcher.Received += DeviceFound;
            Watcher.Start();
        }
       
        private async void DeviceFound(BluetoothLEAdvertisementWatcher watcher, BluetoothLEAdvertisementReceivedEventArgs btAdv)
        {
            // 按名称筛选特定设备
            if (btAdv.Advertisement.LocalName == "5")
            {
                Watcher.Stop();//停止扫描
                await Dispatcher.RunAsync(CoreDispatcherPriority.Low, async () =>
                {
                Debug.WriteLine($"-------------BLE name: {btAdv.Advertisement.LocalName} ----------------");
                device = await BluetoothLEDevice.FromBluetoothAddressAsync(btAdv.BluetoothAddress);
                var resultt = await device.DeviceInformation.Pairing.PairAsync(DevicePairingProtectionLevel.None);   //尝试与设备配对
                Debug.WriteLine($"Pairing Result: {resultt.Status}");        //配对结果
                });
            }
        }      为了更有效的帮助您,请您至TechNet论坛中发帖询问。https://social.technet.microsoft.com/Forums/zh-cn/home

点赞(38) 打赏

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部