问题描述
我正在使用 BLE.Plugin 扫描 Xamarin 中的其他设备。扫描没有问题,插件找到了一些设备,但所有设备都有相同的mac-address。找到的地址与它应该找到的设备的设备地址不匹配。在我使用的代码下方。
adapter.Devicediscovered += (s,a) =>
{
if (a.Device.NativeDevice is BluetoothDevice device)
{
if (addresses.Contains(device.Address))
{
...
}
}
};
await adapter.StartScanningForDevicesAsync();
解决方法
你需要使用 NativeDevice 吗? a.Device 上的 Id 字段是找到的每个蓝牙外设的唯一 ID。
似乎无论如何都不能在 iOS 上使用 Mac 地址,而且 Id 跨平台兼容 -> How to get Mac Address From CBPeripheral And CBCenter