diff options
author | Sven Gothel <[email protected]> | 2020-10-23 06:56:52 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-10-23 06:56:52 +0200 |
commit | 0a71109c4105d2b9f3880a83252c39f8720eb832 (patch) | |
tree | 0e1c9a087823ea5aee07c12c5507c37f41f27248 /examples | |
parent | fcbe2b39e5eb5bf2aafc876bdf5e6bf1a300f3ae (diff) |
AdapterStatusListener::discoveringChanged: Add meta ScanType and changed ScanType for the changedEnabled value; Expose meta ScanType.
The additional information in the callback is essential in a LE + BREDR environment.
User can also see the current meta ScanType.
ScanType is exposed to Java.
Java's BluetoothAdapter also adds 'ScanType getCurrentScanType()', exposing the last sent meta ScanType.
DBTAdapter.java stores the meta ScanType instead of a boolean flag, hence we can react on LE only scanning for example.
DBTAdapter can call all discovery callbacks for all ScanTypes now.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/direct_bt_scanner00/dbt_scanner00.cpp | 5 | ||||
-rw-r--r-- | examples/direct_bt_scanner01/dbt_scanner01.cpp | 5 | ||||
-rw-r--r-- | examples/direct_bt_scanner10/dbt_scanner10.cpp | 5 | ||||
-rw-r--r-- | examples/java/DBTScanner10.java | 5 | ||||
-rw-r--r-- | examples/java/ScannerTinyB01.java | 5 | ||||
-rw-r--r-- | examples/java/ScannerTinyB02.java | 5 |
6 files changed, 18 insertions, 12 deletions
diff --git a/examples/direct_bt_scanner00/dbt_scanner00.cpp b/examples/direct_bt_scanner00/dbt_scanner00.cpp index 17328897..ede0ea95 100644 --- a/examples/direct_bt_scanner00/dbt_scanner00.cpp +++ b/examples/direct_bt_scanner00/dbt_scanner00.cpp @@ -64,8 +64,9 @@ class MyAdapterStatusListener : public AdapterStatusListener { (void)timestamp; } - void discoveringChanged(DBTAdapter &a, const bool enabled, const bool keepAlive, const uint64_t timestamp) override { - fprintf(stderr, "****** DISCOVERING: enabled %d, keepAlive %d: %s\n", enabled, keepAlive, a.toString().c_str()); + void discoveringChanged(DBTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) override { + fprintf(stderr, "****** DISCOVERING: meta %s, changed[%s, enabled %d, keepAlive %d]: %s\n", + getScanTypeString(currentMeta).c_str(), getScanTypeString(changedType).c_str(), changedEnabled, keepAlive, a.toString().c_str()); (void)timestamp; } diff --git a/examples/direct_bt_scanner01/dbt_scanner01.cpp b/examples/direct_bt_scanner01/dbt_scanner01.cpp index 9f71bf27..9759faa6 100644 --- a/examples/direct_bt_scanner01/dbt_scanner01.cpp +++ b/examples/direct_bt_scanner01/dbt_scanner01.cpp @@ -63,8 +63,9 @@ class MyAdapterStatusListener : public AdapterStatusListener { (void)timestamp; } - void discoveringChanged(DBTAdapter &a, const bool enabled, const bool keepAlive, const uint64_t timestamp) override { - fprintf(stderr, "****** DISCOVERING: enabled %d, keepAlive %d: %s\n", enabled, keepAlive, a.toString().c_str()); + void discoveringChanged(DBTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) override { + fprintf(stderr, "****** DISCOVERING: meta %s, changed[%s, enabled %d, keepAlive %d]: %s\n", + getScanTypeString(currentMeta).c_str(), getScanTypeString(changedType).c_str(), changedEnabled, keepAlive, a.toString().c_str()); (void)timestamp; } diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp index c20b02cc..b89c498b 100644 --- a/examples/direct_bt_scanner10/dbt_scanner10.cpp +++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp @@ -172,8 +172,9 @@ class MyAdapterStatusListener : public AdapterStatusListener { } } - void discoveringChanged(DBTAdapter &a, const bool enabled, const bool keepAlive, const uint64_t timestamp) override { - fprintf(stderr, "****** DISCOVERING: enabled %d, keepAlive %d: %s\n", enabled, keepAlive, a.toString().c_str()); + void discoveringChanged(DBTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) override { + fprintf(stderr, "****** DISCOVERING: meta %s, changed[%s, enabled %d, keepAlive %d]: %s\n", + getScanTypeString(currentMeta).c_str(), getScanTypeString(changedType).c_str(), changedEnabled, keepAlive, a.toString().c_str()); (void)timestamp; } diff --git a/examples/java/DBTScanner10.java b/examples/java/DBTScanner10.java index 478d7c48..843cf54e 100644 --- a/examples/java/DBTScanner10.java +++ b/examples/java/DBTScanner10.java @@ -53,6 +53,7 @@ import org.tinyb.GATTCharacteristicListener; import org.tinyb.HCIStatusCode; import org.tinyb.HCIWhitelistConnectType; import org.tinyb.PairingMode; +import org.tinyb.ScanType; import direct_bt.tinyb.DBTManager; @@ -134,8 +135,8 @@ public class DBTScanner10 { } @Override - public void discoveringChanged(final BluetoothAdapter adapter, final boolean enabled, final boolean keepAlive, final long timestamp) { - println("****** DISCOVERING: enabled "+enabled+", keepAlive "+keepAlive+" on "+adapter); + public void discoveringChanged(final BluetoothAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) { + println("****** DISCOVERING: meta "+currentMeta+", changed["+changedType+", enabled "+changedEnabled+", keepAlive "+keepAlive+"] on "+adapter); } @Override diff --git a/examples/java/ScannerTinyB01.java b/examples/java/ScannerTinyB01.java index cfd45ec9..533b3160 100644 --- a/examples/java/ScannerTinyB01.java +++ b/examples/java/ScannerTinyB01.java @@ -44,6 +44,7 @@ import org.tinyb.BluetoothUtils; import org.tinyb.EIRDataTypeSet; import org.tinyb.GATTCharacteristicListener; import org.tinyb.HCIStatusCode; +import org.tinyb.ScanType; /** * This Java scanner example is a TinyB backward compatible and not fully event driven. @@ -167,8 +168,8 @@ public class ScannerTinyB01 { } @Override - public void discoveringChanged(final BluetoothAdapter adapter, final boolean enabled, final boolean keepAlive, final long timestamp) { - System.err.println("****** DISCOVERING: enabled "+enabled+", keepAlive "+keepAlive+" on "+adapter); + public void discoveringChanged(final BluetoothAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) { + System.err.println("****** DISCOVERING: meta "+currentMeta+", changed["+changedType+", enabled "+changedEnabled+", keepAlive "+keepAlive+"] on "+adapter); System.err.println("Status Adapter:"); System.err.println(adapter.toString()); } diff --git a/examples/java/ScannerTinyB02.java b/examples/java/ScannerTinyB02.java index 815d5876..d8409397 100644 --- a/examples/java/ScannerTinyB02.java +++ b/examples/java/ScannerTinyB02.java @@ -42,6 +42,7 @@ import org.tinyb.BluetoothUtils; import org.tinyb.EIRDataTypeSet; import org.tinyb.GATTCharacteristicListener; import org.tinyb.HCIStatusCode; +import org.tinyb.ScanType; /** * Test and debugging application for certain situation. @@ -147,8 +148,8 @@ public class ScannerTinyB02 { } @Override - public void discoveringChanged(final BluetoothAdapter adapter, final boolean enabled, final boolean keepAlive, final long timestamp) { - System.err.println("****** DISCOVERING: enabled "+enabled+", keepAlive "+keepAlive+" on "+adapter); + public void discoveringChanged(final BluetoothAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) { + System.err.println("****** DISCOVERING: meta "+currentMeta+", changed["+changedType+", enabled "+changedEnabled+", keepAlive "+keepAlive+"] on "+adapter); System.err.println("Status Adapter:"); System.err.println(adapter.toString()); } |