【问题标题】:The Bluetooth device name returns null using Bluetooth LE in Xamarin forms蓝牙设备名称在 Xamarin 表单中使用蓝牙 LE 返回 null
【发布时间】:2021-02-16 18:13:15
【问题描述】:

我正在尝试在我的 Xamarin 表单应用程序中实现蓝牙 LE。但是当蓝牙设备被发现时,我只能访问蓝牙设备的地址。我无法发现蓝牙设备的名称。我尝试了各种解决方案,但都没有奏效。这是我的代码

 private async void btnScan_Clicked(object sender, EventArgs e)
        {
            try
            {
                deviceList.Clear();
                adapter.ScanMode = ScanMode.LowLatency;
 adapter.DeviceDiscovered += (s, a) =>
                {
                    deviceList.Add(a.Device);


                };

                //We have to test if the device is scanning 
                if (!ble.Adapter.IsScanning)
                {
                    await adapter.StartScanningForDevicesAsync();

                }
            }
            catch (Exception ex)
            {
                DisplayAlert("Notice", ex.Message.ToString(), "Error !");
            }
          
        }

我不知道如何解决这个问题。有什么建议吗?

【问题讨论】:

标签: xamarin xamarin.forms bluetooth-lowenergy


【解决方案1】:

我通过从外围设备发送设备名称来修复它。您可以在外围设备中公布设备名称。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-04
    • 1970-01-01
    • 2021-12-26
    • 1970-01-01
    • 1970-01-01
    • 2021-12-15
    相关资源
    最近更新 更多