Android AOSP - determining the scan interval and scan window in the Android source code

I downloaded the AOSP source code for Lollipop 5.0. In the 21st level api when setting the low-energy bluetooth scan, there are three options for scanning devices - SCAN_MODE_BALANCED, SCAN_MODE_LOW_LATENCY, SCAN_MODE_LOW_POWER . Are they based on different values ​​of the scan interval and scan? If so, where can I find the values ​​defined for these macros in the source code directory.

+5
source share
2 answers

I found below the values ​​in http://androidxref.com/5.0.0_r2/xref/packages/apps/Bluetooth/src/com/android/bluetooth/gatt/ScanManager.java showing 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 exit ScanManager.ScanNative.configureRegularScanParams (). The two parameters scanWindow and scanInterval are set according to the scan settings ( ScanSettings.SCAN_MODE_LOW_POWER , ScanSettings.SCAN_MODE_BALANCED , ScanSettings.SCAN_MODE_LOW_LATENCY ), converted to BLE units, and then passed to gattSetScanParameters.

Hope this helps.

+5
source

I'm not sure if this is accurate, or if you can even use it to find the values ​​you need, but I found code from Google regarding the scan settings :

  // Constants for Scan Cycle // Low Power: 2.5 minute period with 1.5 seconds active (1% duty cycle) /* @VisibleForTesting */ static final int LOW_POWER_IDLE_MILLIS = 148500; /* @VisibleForTesting */ static final int LOW_POWER_ACTIVE_MILLIS = 1500; // Balanced: 15 second period with 1.5 second active (10% duty cycle) /* @VisibleForTesting */ static final int BALANCED_IDLE_MILLIS = 13500; /* @VisibleForTesting */ static final int BALANCED_ACTIVE_MILLIS = 1500; // Low Latency: 1.67 second period with 1.5 seconds active (90% duty cycle) /* @VisibleForTesting */ static final int LOW_LATENCY_IDLE_MILLIS = 167; /* @VisibleForTesting */ static final int LOW_LATENCY_ACTIVE_MILLIS = 1500; 
+1
source

Source: https://habr.com/ru/post/1210443/


All Articles