在 Xamarin 表单中使用蓝牙 LE 的蓝牙设备名称 returns null
The Bluetooth device name returns null using Bluetooth LE in Xamarin forms
我正在尝试在我的 Xamarin 表单应用程序中实现低功耗蓝牙。但是当发现蓝牙设备时,我只能访问蓝牙设备的地址。我无法找到蓝牙设备的名称。我尝试了各种解决方案,但其中 none 有效。这是我的代码
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 表单应用程序中实现低功耗蓝牙。但是当发现蓝牙设备时,我只能访问蓝牙设备的地址。我无法找到蓝牙设备的名称。我尝试了各种解决方案,但其中 none 有效。这是我的代码
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 !");
}
}
我不知道如何解决这个问题。有什么建议吗?
我通过从外围设备发送设备名称修复了它。您可以在外围设备中发布设备名称。