xamarin - 蓝牙设备名称在 Xamarin 表单中使用蓝牙 LE 返回 null
问题描述
我正在尝试在我的 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 !");
}
}
我不知道如何解决这个问题。有什么建议么?
解决方案
我通过从外围设备发送设备名称来修复它。您可以在外围设备中公布设备名称。