diff options
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, |