我正在使用XAMARIN CrossBluetoothLE扫描附近的设备和电话。我有一个可以正常工作的原型,但是即使打开蓝牙设置以便可见,该扫描也无法拾取平板电脑和手机。是否还有另一个级别可以识别常规BLE扫描不包括的电话。
此外,对于扫描除BLE以外的设备的其他方法有何建议?我不需要任何细节,只需要知道范围内的设备数量即可。
以下是XAMARIN代码:
private async void BLE()
{
var ble = CrossBluetoothLE.Current;
var adapter = CrossBluetoothLE.Current.Adapter;
var state = ble.State;
adapter.ScanMode = Plugin.BLE.Abstractions.Contracts.ScanMode.LowLatency;
adapter.ScanTimeout = 10000;
ble.StateChanged += (s, e) =>
{
Log.Info(TAG, "The bluetooth state changed to {e.NewState}");
};
adapter.DeviceDiscovered += (s, a) =>
{
if (a.Device.Name != null)
Log.Info(TAG, "Discovered: " + a.Device.Name.ToString());
};
adapter.DeviceAdvertised += (s, a) =>
{
if (a.Device.Id != null)
Log.Info(TAG, "Device advertised: " + a.Device.Id.ToString());
};
await adapter.StartScanningForDevicesAsync();
}