【发布时间】: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 !");
}
}
我不知道如何解决这个问题。有什么建议吗?
【问题讨论】:
-
您可以尝试使用
BluetoothDevice.Name属性。 docs.microsoft.com/en-us/dotnet/api/… -
@WendyZang-MSFT 我试过了,但它是空的
标签: xamarin xamarin.forms bluetooth-lowenergy