diff options
author | Sven Gothel <[email protected]> | 2020-06-25 00:30:09 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-06-25 00:30:09 +0200 |
commit | a1a31f0b59b9896a04973846bfad2aa0bc9e8d1f (patch) | |
tree | 782d40db1b54693d32d07d841a8cca4a3bb08573 /java/direct_bt | |
parent | 8693aa160c4c4f7b72c34c99e7550a224a856644 (diff) |
GATTHandler/DBTDevice (incl Java): Add ping[GATT](), testing device availability via retrieval of GATT info
Issues a ping to the device, validating whether it is still reachable.
This method could be periodically utilized to shorten the underlying OS disconnect period
after turning the device off, which lies within 7-13s.
In case the device is no more reachable, disconnect will be initiated due to the occurring IO error.
+++
Implementation attempts to read the mandatory APPEARANCE CharacteristicValue
of the mandatory GENERIC_ACCESS service.
Diffstat (limited to 'java/direct_bt')
-rw-r--r-- | java/direct_bt/tinyb/DBTDevice.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/java/direct_bt/tinyb/DBTDevice.java b/java/direct_bt/tinyb/DBTDevice.java index e2390a51..6c1b6342 100644 --- a/java/direct_bt/tinyb/DBTDevice.java +++ b/java/direct_bt/tinyb/DBTDevice.java @@ -521,6 +521,20 @@ public class DBTDevice extends DBTObject implements BluetoothDevice } private native List<BluetoothGattService> getServicesImpl(); + @Override + public boolean pingGATT() { + try { + return pingGATTImpl(); + } catch (final Throwable t) { + if(DEBUG) { + System.err.println("Caught "+t.getMessage()+" on thread "+Thread.currentThread().toString()); + t.printStackTrace(); + } + } + return false; + } + private native boolean pingGATTImpl(); + /* property accessors: */ @Override |