Md Afzaal Khan
Md Afzaal Khan

Reputation: 11

BLE scanning not detecting specific device on Samsung device running Android 11 and below

I'm encountering an issue with Bluetooth scanning on a Samsung device running Android 11 and below. Specifically, I'm unable to detect a specific Bluetooth Low Energy (BLE) device, named "TEMP", using Bluetooth scanning in my Android application. This issue occurs only on Samsung devices running Android 11 and below; devices running Android 12 and above seem to work fine.

Background:

Application Context: I'm developing an Android application that advertise the data using BLE and then listen to the device by starting the BLE scan.

Issue Description: Despite implementing Bluetooth scanning functionality in my application, I'm unable to detect the "TEMP" device on Samsung devices running Android 11 and below. Strangely, the scanning process works as expected on other Android devices and on Samsung devices running Android 12 and above.

Code Implementation: I've provided the relevant code snippet from my application's BleModule module, which handles Bluetooth scanning and advertising. The ReceiveDataRedDot method initiates the Bluetooth scanning process, and I've verified that it's being executed correctly.

@ReactMethod
void ReceiveDataRedDot() {
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (bluetoothAdapter != null) {
        BluetoothLeScanner bluetoothLeScanner = bluetoothAdapter.getBluetoothLeScanner();
        if (bluetoothLeScanner != null) {
            if (bluetoothAdapter.isEnabled()) {
                if (scanStarted == false) {
                    Log.d("BLEEEEE", "Receiver");

                    // Create a ScanFilter for your target device
                    ScanFilter filter = new ScanFilter.Builder().setDeviceName("TEMP").build();

                    // Create a ScanSettings object
                    ScanSettings settings = new ScanSettings.Builder()
                            .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
                            .build();

                    try {
                        // Start filtered scanning
                        bluetoothLeScanner.startScan(  
                         Collections.singletonList(filter),
                         settings,
                         leScanCallback);
                    } catch (Exception e) {
                        Log.d("BLEEEE", e + "");
                    }
                }
                scanStarted = true;
            } else {
                IS_RX_ENABLE_UNTREATED = true;
            }
        }
    }
}

I can advertise the data using the same device but unable to read it using BLE scan The device i am using is samsung A50 with bluetooth version of V5.0

Troubleshooting Steps Taken:

Permissions: I've ensured that my application has the necessary Bluetooth permissions declared in the AndroidManifest.xml file, including BLUETOOTH, BLUETOOTH_ADMIN, and ACCESS_FINE_LOCATION.

Samsung Device-Specific Considerations: I've checked for any Samsung-specific settings or optimizations that might affect Bluetooth scanning, such as power-saving modes or developer options.

Error Logs: I've reviewed the log messages from the application to check for any errors or exceptions occurring during the Bluetooth scanning process. However, no relevant errors or warnings were found.

Upvotes: 0

Views: 360

Answers (0)

Related Questions