Subject: No Bluetooth Devices Found in .NET MAUI Using Plugin.BLE
Hi community,
I’m developing a .NET MAUI application that uses Plugin.BLE to scan for Bluetooth devices. However, I’m encountering an issue where no Bluetooth devices are being detected during the scanning process, even though Bluetooth is enabled and working on my device.
Problem Description:
- I’m using Plugin.BLE to scan for Bluetooth devices in my .NET MAUI app.
- I've followed the documentation to handle Bluetooth permissions (Bluetooth Scan, Connect, and Location) on Android 12+.
- Issue: Despite following all steps, no devices are found during the scan, and the
DeviceDiscovered
event is not triggered.
- Platform: Testing on Android 12 device.
Troubleshooting Steps I’ve Tried:
- Verified that Bluetooth is enabled on the device.
- Granted Bluetooth Scan, Connect, and Location permissions as required for Android 12+.
- Monitored the logs (
adb logcat
) during the scan but did not see any specific error messages or discovered devices.
- Increased scan timeout to ensure the scan has enough time to discover devices.
- Used nRF Connect (a BLE sniffer tool) to verify that the Bluetooth devices are indeed broadcasting.
Code Snippet:
Here’s the relevant code I’m using for scanning:
_adapter.DeviceDiscovered += (s, a) =>
{
Debug.WriteLine($"Device discovered: {a.Device.Name ?? "Unnamed Device"}");
AvailableDevices.Add(a.Device);
};
await _adapter.StartScanningForDevicesAsync();
- Permissions: I’m handling permissions using
ContextCompat
for Android 12+ as suggested in the Plugin.BLE documentation.
- Expected Behavior: The scan should find nearby Bluetooth devices (like my BLE printer), but nothing is being discovered.
Questions:
- What could be causing the scan to not detect any devices?
- Are there any additional permissions or setup steps required for Android 12+?
- How can I further troubleshoot this issue? Is there any way to confirm that the scan is running correctly?
Thanks in advance for any help!