Skip to content

Commit a9bdd48

Browse files
committed
Add support for extended advertisements while scanning
1 parent 539d81b commit a9bdd48

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/src/androidTest/java/com/welie/blessedexample/ExampleInstrumentedTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class ExampleInstrumentedTest {
1919
@Test
2020
public void useAppContext() {
2121
// Context of the app under test.
22-
Context appContext = InstrumentationRegistry.getTargetContext();
22+
Context appContext = InstrumentationRegistry.getInstrumentation().getContext();
2323

2424
assertEquals("com.welie.blessedexample", appContext.getPackageName());
2525
}

blessed/src/main/java/com/welie/blessed/BluetoothCentralManager.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,16 @@ public void disableLogging() {
346346
private @NotNull ScanSettings getScanSettings(@NotNull final ScanMode scanMode) {
347347
Objects.requireNonNull(scanMode, "scanMode is null");
348348

349-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
349+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
350+
return new ScanSettings.Builder()
351+
.setScanMode(scanMode.value)
352+
.setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES)
353+
.setMatchMode(ScanSettings.MATCH_MODE_AGGRESSIVE)
354+
.setNumOfMatches(ScanSettings.MATCH_NUM_ONE_ADVERTISEMENT)
355+
.setReportDelay(0L)
356+
.setLegacy(false)
357+
.build();
358+
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
350359
return new ScanSettings.Builder()
351360
.setScanMode(scanMode.value)
352361
.setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES)

0 commit comments

Comments
 (0)