diff options
author | Sven Gothel <[email protected]> | 2021-09-18 22:54:03 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2021-09-18 22:54:03 +0200 |
commit | fa733201d719ca64d203d7adccd6b127f4fa73d5 (patch) | |
tree | ee53519b86e5875db9b29e9c7993767ec41171bf /java | |
parent | 1480355ba4c81057f702130d6f4b7c5315d9e0c8 (diff) |
Add BTAdapter::isInitialized(): Allow to avoid re-initialization of an adapter.
Diffstat (limited to 'java')
-rw-r--r-- | java/jau/direct_bt/DBTAdapter.java | 3 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTAdapter.cxx | 11 | ||||
-rw-r--r-- | java/org/direct_bt/BTAdapter.java | 7 |
3 files changed, 21 insertions, 0 deletions
diff --git a/java/jau/direct_bt/DBTAdapter.java b/java/jau/direct_bt/DBTAdapter.java index 56139e14..f9d7183f 100644 --- a/java/jau/direct_bt/DBTAdapter.java +++ b/java/jau/direct_bt/DBTAdapter.java @@ -290,6 +290,9 @@ public class DBTAdapter extends DBTObject implements BTAdapter private native byte initializeImpl(final byte btModeInt); @Override + public final native boolean isInitialized(); + + @Override public final HCIStatusCode reset() { return HCIStatusCode.get( resetImpl() ); } diff --git a/java/jni/direct_bt/DBTAdapter.cxx b/java/jni/direct_bt/DBTAdapter.cxx index b5bd1083..259686c3 100644 --- a/java/jni/direct_bt/DBTAdapter.cxx +++ b/java/jni/direct_bt/DBTAdapter.cxx @@ -890,6 +890,17 @@ jbyte Java_jau_direct_1bt_DBTAdapter_initializeImpl(JNIEnv *env, jobject obj, jb return (jbyte) number(HCIStatusCode::INTERNAL_FAILURE); } +jboolean Java_jau_direct_1bt_DBTAdapter_isInitialized(JNIEnv *env, jobject obj) { + try { + BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj); + jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE); + return adapter->isInitialized(); + } catch(...) { + rethrow_and_raise_java_exception(env); + } + return JNI_FALSE; +} + jbyte Java_jau_direct_1bt_DBTAdapter_resetImpl(JNIEnv *env, jobject obj) { try { BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj); diff --git a/java/org/direct_bt/BTAdapter.java b/java/org/direct_bt/BTAdapter.java index eff93a62..bc54586d 100644 --- a/java/org/direct_bt/BTAdapter.java +++ b/java/org/direct_bt/BTAdapter.java @@ -490,6 +490,13 @@ public interface BTAdapter extends BTObject public HCIStatusCode initialize(final BTMode btMode); /** + * Returns true, if this adapter has already been {@link #initialize(BTMode)} 'ed. Otherwise false. + * + * This helps avoiding re-initializing, if not so desired. + */ + boolean isInitialized(); + + /** * Reset the adapter. * <p> * The semantics are specific to the HCI host implementation, |