diff options
author | Sven Gothel <[email protected]> | 2020-07-27 07:33:12 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-07-27 07:33:12 +0200 |
commit | 6e71e6e8fcf1a075d2b14ce5b2f18081cb436abd (patch) | |
tree | 8d047dadc1488f3a091d9df7ed58d830821c5cef /java/direct_bt/tinyb/DBTDevice.java | |
parent | b7d7d08c108fb3a1d17d3542dce1f942f6bb4059 (diff) |
C++/Java *Device::connect*(..), disconnect(): Return HCIStatusCode instead of just boolean, passing through potential HCI error detail
The HCIStatusCode on failed connect*/disconnect commands issued via direct_bt HCI,
could help applications making a better fail-recovery decision than just having the binary result.
Diffstat (limited to 'java/direct_bt/tinyb/DBTDevice.java')
-rw-r--r-- | java/direct_bt/tinyb/DBTDevice.java | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/java/direct_bt/tinyb/DBTDevice.java b/java/direct_bt/tinyb/DBTDevice.java index 65301141..601a30a7 100644 --- a/java/direct_bt/tinyb/DBTDevice.java +++ b/java/direct_bt/tinyb/DBTDevice.java @@ -356,36 +356,36 @@ public class DBTDevice extends DBTObject implements BluetoothDevice public final boolean getConnected() { return isConnected.get(); } @Override - public final boolean disconnect() throws BluetoothException { + public final HCIStatusCode disconnect() throws BluetoothException { if( isConnected.get() ) { - return disconnectImpl(); // event callbacks will be generated by implementation + return HCIStatusCode.get( disconnectImpl() ); // event callbacks will be generated by implementation } - return false; + return HCIStatusCode.CONNECTION_TERMINATED_BY_LOCAL_HOST; } - private native boolean disconnectImpl() throws BluetoothException; + private native byte disconnectImpl() throws BluetoothException; @Override - public final boolean connect() throws BluetoothException { + public final HCIStatusCode connect() throws BluetoothException { if( !isConnected.get() ) { - return connectImpl(); // event callbacks will be generated by implementation + return HCIStatusCode.get( connectImpl() ); // event callbacks will be generated by implementation } - return false; + return HCIStatusCode.CONNECTION_ALREADY_EXISTS; } - private native boolean connectImpl() throws BluetoothException; + private native byte connectImpl() throws BluetoothException; @Override - public boolean connect(final short le_scan_interval, final short le_scan_window, - final short conn_interval_min, final short conn_interval_max, - final short conn_latency, final short timeout) { + public HCIStatusCode connect(final short le_scan_interval, final short le_scan_window, + final short conn_interval_min, final short conn_interval_max, + final short conn_latency, final short timeout) { if( !isConnected.get() ) { // event callbacks will be generated by implementation - return connectImpl(le_scan_interval, le_scan_window, conn_interval_min, conn_interval_max, conn_latency, timeout); + return HCIStatusCode.get( connectImpl(le_scan_interval, le_scan_window, conn_interval_min, conn_interval_max, conn_latency, timeout) ); } - return false; + return HCIStatusCode.CONNECTION_ALREADY_EXISTS; } - private native boolean connectImpl(final short le_scan_interval, final short le_scan_window, - final short conn_interval_min, final short conn_interval_max, - final short conn_latency, final short timeout); + private native byte connectImpl(final short le_scan_interval, final short le_scan_window, + final short conn_interval_min, final short conn_interval_max, + final short conn_latency, final short timeout); /* DBT Java callbacks */ |