Utility library for simplifying BTLE scanning for API 19 and up. By using compat versions of internal classes combined with wrapper classes it is possible to write tests for BTLE scanning.
#Getting Started (Gradle / Android Studio)
Add gradle dependency to your application.
compile 'com.ToxicBakery.library.btle.scanning:btle-Scanner-Compat:+'
After configuration, optionally use the SimpleLeScanConfiguration implementation to initiate a configured BTLE scan.
ILeScanCallback leScanCallback = new ILeScanCallback() {
@Override
public void onDeviceFound(@NonNull ScanResultCompat scanResult) {
}
@Override
public void onDeviceLost(@NonNull ScanResultCompat scanResult) {
}
}
SimpleLeScanConfiguration scanConfiguration = new SimpleLeScanConfiguration(context);
ILeScanBinder leScanBinder = LeDiscovery.startScanning(leScanCallback, scanConfiguration);
Note that ScanResultCompat
implements hashCode()
and equals(Object)
so it may be used in common Java data types such as maps, sets, and collections.