diff options
author | Sven Gothel <[email protected]> | 2022-05-06 10:54:01 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-05-06 10:54:01 +0200 |
commit | 7b1b83bfa1041c4c93cb6eac0c4994c2bd44f6b8 (patch) | |
tree | 33c627e75ca4d65c17836c8d49a5684f0a3489ed /examples | |
parent | b3d62d2336744481bc83377d780d9ac79f534207 (diff) |
API Change: AdapterStatusListener::deviceConnected(): `const uint16_t handle` -> `const bool discovered`
Motivation:
- the connection handle is known to the device already and can be retrieved, redundant information
- the flag discovered gives information whether BTAdapter has sent out a deviceFound message, i.e. the user actually issued the connection (default).
We like to detect issues where devices are automatically connected by the underlying host implementation,
i.e. BlueZ/kernel's whitelist mechanism or otherwise - an unsusal and undesired situation.
In such case, no `DEVICE FOUND` advertising is promoted and the underlying BlueZ/kernel
issues the connection itself.
Here `discovered` will be `false`.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dbt_peripheral00.cpp | 6 | ||||
-rw-r--r-- | examples/dbt_repeater00.cpp | 13 | ||||
-rw-r--r-- | examples/dbt_scanner10.cpp | 6 | ||||
-rw-r--r-- | examples/dbt_test_gattcharlifecycle01.cpp | 12 | ||||
-rw-r--r-- | examples/java/DBTPeripheral00.java | 4 | ||||
-rw-r--r-- | examples/java/DBTScanner10.java | 8 |
6 files changed, 24 insertions, 25 deletions
diff --git a/examples/dbt_peripheral00.cpp b/examples/dbt_peripheral00.cpp index 98d791fc..667d3de2 100644 --- a/examples/dbt_peripheral00.cpp +++ b/examples/dbt_peripheral00.cpp @@ -249,14 +249,14 @@ class MyAdapterStatusListener : public AdapterStatusListener { (void)timestamp; } - void deviceConnected(BTDeviceRef device, const uint16_t handle, const uint64_t timestamp) override { - fprintf_td(stderr, "****** CONNECTED: %s\n", device->toString(true).c_str()); + void deviceConnected(BTDeviceRef device, const bool discovered, const uint64_t timestamp) override { + fprintf_td(stderr, "****** CONNECTED (discovered %d): %s\n", discovered, device->toString(true).c_str()); const bool available = nullptr == getDevice(); if( available ) { setDevice(device); BTDeviceRegistry::addToProcessingDevices(device->getAddressAndType(), device->getName()); } - (void)handle; + (void)discovered; (void)timestamp; } diff --git a/examples/dbt_repeater00.cpp b/examples/dbt_repeater00.cpp index 62293d40..76bb9ad6 100644 --- a/examples/dbt_repeater00.cpp +++ b/examples/dbt_repeater00.cpp @@ -174,9 +174,9 @@ class AdapterToServerStatusListener : public AdapterStatusListener { } } - void deviceConnected(BTDeviceRef device, const uint16_t handle, const uint64_t timestamp) override { - fprintf_td(stderr, "****** To Server: CONNECTED: %s\n", device->toString(true).c_str()); - (void)handle; + void deviceConnected(BTDeviceRef device, const bool discovered, const uint64_t timestamp) override { + fprintf_td(stderr, "****** To Server: CONNECTED (discovered %d): %s\n", discovered, device->toString(true).c_str()); + (void)discovered; (void)timestamp; } @@ -612,10 +612,9 @@ class AdapterToClientStatusListener : public AdapterStatusListener { return false; } - void deviceConnected(BTDeviceRef device, const uint16_t handle, const uint64_t timestamp) override { - fprintf_td(stderr, "****** To Client: CONNECTED: %s\n", device->toString(true).c_str()); - - (void)handle; + void deviceConnected(BTDeviceRef device, const bool discovered, const uint64_t timestamp) override { + fprintf_td(stderr, "****** To Client: CONNECTED (discovered %d): %s\n", discovered, device->toString(true).c_str()); + (void)discovered; (void)timestamp; } diff --git a/examples/dbt_scanner10.cpp b/examples/dbt_scanner10.cpp index 0aee218e..1721be24 100644 --- a/examples/dbt_scanner10.cpp +++ b/examples/dbt_scanner10.cpp @@ -213,9 +213,9 @@ class MyAdapterStatusListener : public AdapterStatusListener { (void)timestamp; } - void deviceConnected(BTDeviceRef device, const uint16_t handle, const uint64_t timestamp) override { - fprintf_td(stderr, "****** CONNECTED: %s\n", device->toString(true).c_str()); - (void)handle; + void deviceConnected(BTDeviceRef device, const bool discovered, const uint64_t timestamp) override { + fprintf_td(stderr, "****** CONNECTED (discovered %d): %s\n", discovered, device->toString(true).c_str()); + (void)discovered; (void)timestamp; } diff --git a/examples/dbt_test_gattcharlifecycle01.cpp b/examples/dbt_test_gattcharlifecycle01.cpp index 6db8d339..f38b044a 100644 --- a/examples/dbt_test_gattcharlifecycle01.cpp +++ b/examples/dbt_test_gattcharlifecycle01.cpp @@ -136,9 +136,9 @@ class MyAdapterStatusListener : public AdapterStatusListener { (void)timestamp; } - void deviceConnected(std::shared_ptr<BTDevice> device, const uint16_t handle, const uint64_t timestamp) override { - fprintf_td(stderr, "****** CONNECTED: %s\n", device->toString(true).c_str()); - (void)handle; + void deviceConnected(BTDeviceRef device, const bool discovered, const uint64_t timestamp) override { + fprintf_td(stderr, "****** CONNECTED (discovered %d): %s\n", discovered, device->toString(true).c_str()); + (void)discovered; (void)timestamp; } @@ -277,9 +277,9 @@ static void connectDiscoveredDevice(std::shared_ptr<BTDevice> device) { fprintf_td(stderr, "****** UPDATED(2): %s of %s\n", to_string(updateMask).c_str(), device->toString(true).c_str()); (void)timestamp; } - void deviceConnected(std::shared_ptr<BTDevice> device, const uint16_t handle, const uint64_t timestamp) override { - fprintf_td(stderr, "****** CONNECTED(2): %s\n", device->toString(true).c_str()); - (void)handle; + void deviceConnected(BTDeviceRef device, const bool discovered, const uint64_t timestamp) override { + fprintf_td(stderr, "****** CONNECTED(2) (discovered %d): %s\n", discovered, device->toString(true).c_str()); + (void)discovered; (void)timestamp; } std::string toString() const override { diff --git a/examples/java/DBTPeripheral00.java b/examples/java/DBTPeripheral00.java index df4ac622..00b3f7ad 100644 --- a/examples/java/DBTPeripheral00.java +++ b/examples/java/DBTPeripheral00.java @@ -272,8 +272,8 @@ public class DBTPeripheral00 { } @Override - public void deviceConnected(final BTDevice device, final short handle, final long timestamp) { - BTUtils.println(System.err, "****** CONNECTED: "+device.toString()); + public void deviceConnected(final BTDevice device, final boolean discovered, final long timestamp) { + BTUtils.println(System.err, "****** CONNECTED (discovered "+discovered+"): "+device.toString()); final boolean available = null == getDevice(); if( available ) { setDevice(device); diff --git a/examples/java/DBTScanner10.java b/examples/java/DBTScanner10.java index 10b61082..2845f9e0 100644 --- a/examples/java/DBTScanner10.java +++ b/examples/java/DBTScanner10.java @@ -175,8 +175,8 @@ public class DBTScanner10 { } @Override - public void deviceConnected(final BTDevice device, final short handle, final long timestamp) { - BTUtils.println(System.err, "****** CONNECTED: "+device.toString()); + public void deviceConnected(final BTDevice device, final boolean discovered, final long timestamp) { + BTUtils.println(System.err, "****** CONNECTED (discovered "+discovered+"): "+device.toString()); } @Override @@ -321,8 +321,8 @@ public class DBTScanner10 { } } @Override - public void deviceConnected(final BTDevice device, final short handle, final long timestamp) { - BTUtils.println(System.err, "****** CONNECTED(2): "+device.toString()); + public void deviceConnected(final BTDevice device, final boolean discovered, final long timestamp) { + BTUtils.println(System.err, "****** CONNECTED(2) (discovered "+discovered+"): "+device.toString()); } @Override |