Issue
I am trying to find BLE devices using Xamarin Plugin.BLE The code is
adapter.DeviceDiscovered += (s, a) => deviceList.Add(a.Device);
adapter.ScanTimeout = 30000;
await adapter.StartScanningForDevicesAsync();
UWP finds 0 devices. At the same time Bluetooth LE Explorer (a utility from Microsoft) finds and my device, and a dozen of others. What could be the problem? Windows 10, .NET v4.8, Plugin.BLE v2.2.0-pre, Xamarin.Forms 5.0 I prefer to use Xamarin because I want my code to be cross platform - Windows and Android
Nico's comment solved it. However I have another question, closely related. Now UWP finds service and updates characteristic suceesfully. However on Android simulator that I run from Visual Studio, the same code doesn't find anything. Is there something I am missing again? I have these lines in AndroidManifest
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<!--this is necessary for Android v6+ to get the device name and address-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
TIA
Solution
UWP doesn't find any BLE devices using StartScanningForDevicesAsync (Plugin.BLE for Xamarin)
Please check if you have added Bluetooth capability for UWP platform, double click Package.appxmainfest
file -> find Capabilities -> enable Bluetooth capablity.
However on Android simulator that I run from Visual Studio, the same code doesn't find anything.
I'm afraid you can't enable bluetooth device for Android simulator, please refer this document limitations, please test the app with physical device.
Answered By - Nico Zhu - MSFT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.