首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我无法配对我的BLE设备?

为什么我无法配对我的BLE设备?
EN

Stack Overflow用户
提问于 2018-05-22 14:49:20
回答 1查看 312关注 0票数 0

这是我的配对代码。

代码语言:javascript
复制
var Name = listBox1.SelectedItem as BluetoothLEDeviceDisplay;
          DevicePairingResult result = await Name.DeviceInformation.Pairing.PairAsync();
          updateUI("Paired.");

我设置了我的"Name“来发现我的ble设备。

代码语言:javascript
复制
private void OnAdvertisementReceived(BluetoothLEAdvertisementWatcher watcher, BluetoothLEAdvertisementReceivedEventArgs eventArgs)
    {

      Name = eventArgs.Advertisement.LocalName;
      if (items.Contains(Name) == false)
      {
        items.Add(Name);
      }

    }

当我尝试配对BLE设备(Rfduino)时。我得到了error "<Name>5_1 is null"。我该如何解决这个问题?

EN

回答 1

Stack Overflow用户

发布于 2018-05-24 03:51:48

我确信你不需要配对你的设备。大多数,如果不是所有的Ble设备都不需要配对,除非你想要一个配对对话框来输入pin-number。

你的代码一点意义都没有。

BluetoothLEDeviceDisplay是一个单独的类,包含对象和枚举以便于显示,在一些UWP示例中使用。

因此作为选定项的名称将始终为空。

代码语言:javascript
复制
DeviceInformationCustomPairing customPairing = bleDeviceDisplay.DeviceInformation.Pairing.Custom;
                DevicePairingKinds ceremoniesSelected = DevicePairingKinds.None | DevicePairingKinds.ProvidePin;
                DevicePairingProtectionLevel protectionLevel = DevicePairingProtectionLevel.None;
                customPairing.PairingRequested += new TypedEventHandler<DeviceInformationCustomPairing,
                                                      DevicePairingRequestedEventArgs>(CustomPairing_PairingRequested);
                DevicePairingResult result = await customPairing.PairAsync(ceremoniesSelected,
                                                   protectionLevel);                


        private void CustomPairing_PairingRequested(DeviceInformationCustomPairing sender, DevicePairingRequestedEventArgs args)
        {
            //this is where your pin goes.
            //windows requires at least a "0".
            args.Accept("000000");//123456
        }

我在Windows10创建者更新之前使用过这个,但在那之后就再也没有使用过。看看我的Github示例,让您在不进行配对的情况下继续:https://github.com/GrooverFromHolland/SimpleBleExample_by_Devicename

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50461451

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档