diff options
author | Sven Gothel <[email protected]> | 2023-11-24 09:55:31 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-11-24 09:55:31 +0100 |
commit | ac74ddd26a08c2ed7eac31311863cda5ff6ca1d7 (patch) | |
tree | 161ced0f5c653e9b1fe45473046a6bd07a13e16b /java | |
parent | 8b3d6dd4e72f8d5a98055756eac6f2a3212ad453 (diff) |
BTDevice: Properly expose isPrePaired() to Javav3.2.3
Diffstat (limited to 'java')
-rw-r--r-- | java/jau/direct_bt/DBTDevice.java | 3 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTDevice.cxx | 13 | ||||
-rw-r--r-- | java/org/direct_bt/BTDevice.java | 10 |
3 files changed, 26 insertions, 0 deletions
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) |