Android AOSP - Definition of scan interval and scan window in android source code

后端 未结 2 1919
死守一世寂寞
死守一世寂寞 2020-12-16 06:27

I have downloaded the AOSP Source code for Lollipop 5.0. In api level 21, under bluetooth low energy scan settings there are three options for scanning the ble devices-

2条回答
  •  孤街浪徒
    2020-12-16 07:24

    I found below values in http://androidxref.com/5.0.0_r2/xref/packages/apps/Bluetooth/src/com/android/bluetooth/gatt/ScanManager.java while greping the keyword "SCAN_MODE_BALANCED" :

        /**
         * Scan params corresponding to regular 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 = 2000;
        private static final int SCAN_MODE_BALANCED_INTERVAL_MS = 5000;
        private static final int SCAN_MODE_LOW_LATENCY_WINDOW_MS = 5000;
        private static final int SCAN_MODE_LOW_LATENCY_INTERVAL_MS = 5000;
    
        /**
         * Scan params corresponding to batch scan setting
         */
        private static final int SCAN_MODE_BATCH_LOW_POWER_WINDOW_MS = 1500;
        private static final int SCAN_MODE_BATCH_LOW_POWER_INTERVAL_MS = 150000;
        private static final int SCAN_MODE_BATCH_BALANCED_WINDOW_MS = 1500;
        private static final int SCAN_MODE_BATCH_BALANCED_INTERVAL_MS = 15000;
        private static final int SCAN_MODE_BATCH_LOW_LATENCY_WINDOW_MS = 1500;
        private static final int SCAN_MODE_BATCH_LOW_LATENCY_INTERVAL_MS = 5000;
    

    Also checkout out ScanManager.ScanNative.configureRegularScanParams(). Two params scanWindow and scanInterval are set according to the scan setting (ScanSettings.SCAN_MODE_LOW_POWER, ScanSettings.SCAN_MODE_BALANCED, ScanSettings.SCAN_MODE_LOW_LATENCY), converted into BLE units, and then passed to gattSetScanParametersNative().

    Hope this helps.

提交回复
热议问题