Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
696 views
in Technique[技术] by (71.8m points)

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

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- SCAN_MODE_BALANCED, SCAN_MODE_LOW_LATENCY, SCAN_MODE_LOW_POWER. Are the based on different scan interval and scan window values? If so, where can I find the values defined for these macros in the source code directory.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...