Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit df4a0594 authored by Prerepa Viswanadham's avatar Prerepa Viswanadham
Browse files

Set scan parameters in ScanClient based on BluetoothLeScanSettings

configuration

scan_mode              scan_window_ms    scan_interval_ms
SCAN_MODE_LOW_POWER    500               5000
SCAN_MODE_BALANCED     1000              5000
SCAN_MODE_LOW_LATENCY  2500              5000

Change-Id: I2382c7b584b102555f175a94206c4379141af3fa
parent 0d7a5d60
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -39,6 +39,16 @@ import java.util.UUID;
     */
    private static final int LE_SCAN_INTERVAL_MS = 100;

    /**
     * Scan params corresponding to scan setting
     */
    private static final int SCAN_MODE_LOW_POWER_WINDOW_MS = 500;
    private static final int SCAN_MODE_LOW_POWER_INTERVAL_MS = 5000;
    private static final int SCAN_MODE_BALANCED_WINDOW_MS = 1000;
    private static final int SCAN_MODE_BALANCED_INTERVAL_MS = 5000;
    private static final int SCAN_MODE_LOW_LATENCY_WINDOW_MS = 2500;
    private static final int SCAN_MODE_LOW_LATENCY_INTERVAL_MS = 5000;

    int appIf;
    boolean isServer;
    UUID[] uuids;
@@ -73,5 +83,25 @@ import java.util.UUID;
        this.scanInterval = scanInterval;
        this.settings = settings;
        this.filters = filters;
        if (settings != null) {
            switch (settings.getScanMode()) {
                case BluetoothLeScanSettings.SCAN_MODE_LOW_POWER:
                    this.scanWindow = SCAN_MODE_LOW_POWER_WINDOW_MS;
                    this.scanInterval = SCAN_MODE_LOW_POWER_INTERVAL_MS;
                    break;
                case BluetoothLeScanSettings.SCAN_MODE_BALANCED:
                    this.scanWindow = SCAN_MODE_BALANCED_WINDOW_MS;
                    this.scanInterval = SCAN_MODE_BALANCED_INTERVAL_MS;
                    break;
                case BluetoothLeScanSettings.SCAN_MODE_LOW_LATENCY:
                    this.scanWindow = SCAN_MODE_LOW_LATENCY_WINDOW_MS;
                    this.scanInterval = SCAN_MODE_LOW_LATENCY_INTERVAL_MS;
                    break;
                default:
                    this.scanWindow = SCAN_MODE_BALANCED_WINDOW_MS;
                    this.scanInterval = SCAN_MODE_BALANCED_INTERVAL_MS;
                    break;
            }
        }
    }
}