aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-11-24 09:55:31 +0100
committerSven Gothel <[email protected]>2023-11-24 09:55:31 +0100
commitac74ddd26a08c2ed7eac31311863cda5ff6ca1d7 (patch)
tree161ced0f5c653e9b1fe45473046a6bd07a13e16b
parent8b3d6dd4e72f8d5a98055756eac6f2a3212ad453 (diff)
BTDevice: Properly expose isPrePaired() to Javav3.2.3
-rw-r--r--api/direct_bt/BTDevice.hpp9
-rw-r--r--java/jau/direct_bt/DBTDevice.java3
-rw-r--r--java/jni/direct_bt/DBTDevice.cxx13
-rw-r--r--java/org/direct_bt/BTDevice.java10
4 files changed, 34 insertions, 1 deletions
diff --git a/api/direct_bt/BTDevice.hpp b/api/direct_bt/BTDevice.hpp
index 0d8c52c1..fb89beda 100644
--- a/api/direct_bt/BTDevice.hpp
+++ b/api/direct_bt/BTDevice.hpp
@@ -710,7 +710,11 @@ namespace direct_bt {
*/
HCIStatusCode disconnect(const HCIStatusCode reason=HCIStatusCode::REMOTE_USER_TERMINATED_CONNECTION ) noexcept;
- /** Returns true if this device has completed SMP pairing or keys are set via uploadKeys() */
+ /**
+ * Returns true if this device has completed SMP pairing or keys are set via uploadKeys()
+ * @see uploadKeys()
+ * @since 3.2.3
+ */
bool isPrePaired() const noexcept { return pairing_data.is_pre_paired; }
/**
@@ -756,6 +760,7 @@ namespace direct_bt {
*
* @param bin
* @return true if successful, false if pairing is currently in progress
+ * @see isPrePaired()
* @see setLongTermKey()
* @see setIdentityResolvingKey()
* @see setSignatureResolvingKey()
@@ -787,6 +792,7 @@ namespace direct_bt {
* @param bin the SMPKeyBin file
* @param req_min_level SMPKeyBin::getSecLevel() shall be greater or equal to this required minimum
* @return ::HCIStatusCode::SUCCESS if successful, otherwise the appropriate error code.
+ * @see isPrePaired()
* @see setSMPKeyBin()
* @see uploadKeys()
* @since 2.4.0
@@ -805,6 +811,7 @@ namespace direct_bt {
* @param smp_key_bin_path director for the SMPKeyBin file, derived by this BTDevice
* @param req_min_level SMPKeyBin::getSecLevel() shall be greater or equal to this required minimum
* @return ::HCIStatusCode::SUCCESS if successful, otherwise the appropriate error code.
+ * @see isPrePaired()
* @see SMPKeyBin::read()
* @see setSMPKeyBin()
* @see uploadKeys()
diff --git a/java/jau/direct_bt/DBTDevice.java b/java/jau/direct_bt/DBTDevice.java
index 025db3c9..6ea03453 100644
--- a/java/jau/direct_bt/DBTDevice.java
+++ b/java/jau/direct_bt/DBTDevice.java
@@ -292,6 +292,9 @@ public class DBTDevice extends DBTObject implements BTDevice
private native byte disconnectImpl();
@Override
+ public native boolean isPrePaired();
+
+ @Override
public native int getResponderSMPPassKey();
@Override
diff --git a/java/jni/direct_bt/DBTDevice.cxx b/java/jni/direct_bt/DBTDevice.cxx
index f7c54a68..353b534f 100644
--- a/java/jni/direct_bt/DBTDevice.cxx
+++ b/java/jni/direct_bt/DBTDevice.cxx
@@ -480,6 +480,19 @@ jbyte Java_jau_direct_1bt_DBTDevice_disconnectImpl(JNIEnv *env, jobject obj)
return (jbyte) number(HCIStatusCode::INTERNAL_FAILURE);
}
+jboolean Java_jau_direct_1bt_DBTDevice_isPrePaired(JNIEnv *env, jobject obj) {
+ try {
+ shared_ptr_ref<BTDevice> device(env, obj); // hold until done
+ JavaAnonRef device_java = device->getJavaObject(); // hold until done!
+ JavaGlobalObj::check(device_java, E_FILE_LINE);
+
+ return device->isPrePaired() ? JNI_TRUE : JNI_FALSE;
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
+ }
+ return JNI_FALSE;
+}
+
jint Java_jau_direct_1bt_DBTDevice_getResponderSMPPassKey(JNIEnv *env, jobject obj) {
try {
shared_ptr_ref<BTDevice> device(env, obj); // hold until done
diff --git a/java/org/direct_bt/BTDevice.java b/java/org/direct_bt/BTDevice.java
index f5e97aa7..be7d21fe 100644
--- a/java/org/direct_bt/BTDevice.java
+++ b/java/org/direct_bt/BTDevice.java
@@ -105,6 +105,13 @@ public interface BTDevice extends BTObject
HCIStatusCode disconnect() throws BTException;
/**
+ * Returns true if this device has completed SMP pairing or keys are set via uploadKeys()
+ * @see #uploadKeys()
+ * @since 3.2.3
+ */
+ boolean isPrePaired();
+
+ /**
* Returns the responder SMP passkey, ranging from [0..999999].
* <p>
* Authentication (MITM) PASSKEY (produced by this responder adapter, acting as peripheral GATT server) and shall be displayed for the initiating remote device, see {@link PairingMode#PASSKEY_ENTRY_ini}
@@ -235,6 +242,7 @@ public interface BTDevice extends BTObject
* Must be called before connecting to this device, otherwise {@link HCIStatusCode#CONNECTION_ALREADY_EXISTS} will be returned.
*
* @return {@link HCIStatusCode#SUCCESS} if successful, otherwise the appropriate error code.
+ * @see #isPrePaired()
* @see #setLongTermKey(SMPLongTermKey)
* @see #setIdentityResolvingKey(SMPIdentityResolvingKey)
* @see #setSignatureResolvingKey(SMPSignatureResolvingKey)
@@ -250,6 +258,7 @@ public interface BTDevice extends BTObject
* @param bin the SMPKeyBin file
* @param req_min_level SMPKeyBin::getSecLevel() shall be greater or equal to this required minimum
* @return ::HCIStatusCode::SUCCESS if successful, otherwise the appropriate error code.
+ * @see #isPrePaired()
* @see #setSMPKeyBin(SMPKeyBin)
* @see #uploadKeys()
* @since 2.4.0
@@ -262,6 +271,7 @@ public interface BTDevice extends BTObject
* @param smp_key_bin_path director for the SMPKeyBin file, derived by this BTDevice
* @param req_min_level SMPKeyBin::getSecLevel() shall be greater or equal to this required minimum
* @return ::HCIStatusCode::SUCCESS if successful, otherwise the appropriate error code.
+ * @see #isPrePaired()
* @see SMPKeyBin#read(String, BTDevice, boolean)
* @see #setSMPKeyBin(SMPKeyBin)
* @see #uploadKeys(SMPKeyBin, BTSecurityLevel)