android ble scan power consumption test

1. Background

We usually call andriod public interface when calling standard interface through Android to do the ble scan, which is the startScan method in BluetoothLeScanner. You may not pay much attention to the problem of power consumption in short-time scanning, but if the time scanning is long, it must be needed. Pay attention to the impact of power consumption. This article is mainly for this long-time scanning, no, short-term scanning should also pay attention to power consumption

2. Power consumption test

a. Scan without adding filter condition

Directly call as follows:

  bleScanner!!.startScan(null, getScanSetting(ScanSettings.SCAN_MODE_LOW_LATENCY), mScanCallback)

View cpu usage:

adb shell top -m 40

Insert picture description here
It can be seen that the Bluetooth cpu usage rate reaches 46% during scanning, which is very high

b. Test to add Bluetooth name filtering

The test code is as follows:

 val scanFilter = ScanFilter.Builder()
        .setDeviceName(BLE_NAME)
        .build()
 val list = ArrayList<ScanFilter>()
 list.add(scanFilter)
 bleScanner!!.startScan(list, getScanSetting(ScanSettings.SCAN_MODE_LOW_LATENCY), mScanCallback)

View CPU usage:
Insert picture description here
Bluetooth occupancy at the moment of scanning is only 1.3,
and then look at the occupancy when the scan is stable: the
Insert picture description here
occupancy is very low at this time.

3. Conclusion

In the actual production and application, if you can define the filtering conditions, you must add ScanFilter during scanning, which can greatly reduce the power

Published 159 original articles · 22 praises · 90,000+ views

Guess you like

Origin blog.csdn.net/ytuglt/article/details/101058087