为什么在 xamarin 表单中进行写入操作后,我会在 iOS 中获得 BLE 的配对请求对话框?

Why I'm getting pairing request dialog in iOS for BLE after write operation in xamarin forms?

我创建了一个应用程序,我可以在其中连接到 BLE 设备并获取 GATT 服务和特性。但是在我用 GATT 特性写了一些东西之后,我在 iOS 中得到了配对请求对话框,并且在我接受配对请求后特性值变为空。我不知道为什么这个配对请求只有在我写我的 GATT 特征时才会出现。根据我的研究,BLE 不要求在 iOS 中进行配对。即使配对请求对话框即将到来,我也需要配对请求在连接之后或连接之前出现,而不是在写入操作之后。这是我收到的配对请求的图片。

这是我连接和写入 GATT 服务器的代码

 private async Task<string> ProcessDeviceInformationService(IService deviceInfoService)
        {
            try
            {
               await adapter.ConnectToDeviceAsync(device);
                var sb = new StringBuilder("Getting information from Device Information service: \n");
                var characteristics = await deviceInfoService.GetCharacteristicsAsync();
                var characteristic = await deviceInfoService.GetCharacteristicAsync(Guid.Parse("00002A39-0000-1000-8000-00805F9B34FB"));
               
                    try
                    {
                        
                     
                        if (characteristic != null)
                        {
                        var sbnew = new StringBuilder("BLE Characteristics\n");
                        byte[] senddata = Encoding.UTF8.GetBytes(string.IsNullOrEmpty(SendMessageLabel.Text) ? "Judson was here" : SendMessageLabel.Text);
                            await Task.Delay(300);
                            var newbytes = await characteristic.WriteAsync(senddata);
                        
                            var bytes = await characteristic.ReadAsync();
                        var str = Encoding.UTF8.GetString(bytes);

                        sbnew.AppendLine($"Characteristics found on this device: {string.Join(", ", str.ToString())}");
                        CharactericsLabel.Text = sbnew.ToString();
                       
                    }

                }
                    catch (Exception ex)
                    {
                        return ex.Message;
                    }
                
                return CharactericsLabel.Text;
           
            }
            catch (Exception ex)
            {
                
                return ex.ToString();
            }
 }

我的特征值在 WriteAsync 方法之后变为空。我不知道如何解决这个问题,有什么建议吗?

外围设备端的写操作没有权限。我在外围端为我的特性添加了这段代码,它起作用了

BluetoothGattCharacteristic sampleText = new BluetoothGattCharacteristic(SAMPLE_TEXT,
        //Read-only characteristic
        BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE,
        BluetoothGattCharacteristic.PERMISSION_WRITE);