diff options
author | Sven Gothel <[email protected]> | 2022-06-06 22:10:12 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-06-06 22:10:12 +0200 |
commit | d34b29395e569a9811764d8c397f11c4fbe562d6 (patch) | |
tree | c8aacfde94e46c1f40023b3a2e82b5638af17765 /java | |
parent | 076c82ab5a95714d7295d520fe0aa5bfa62bf6cd (diff) |
Adopt to jaulib jau::jni namespace changes
Diffstat (limited to 'java')
-rw-r--r-- | java/jni/direct_bt/BTFactory.cxx | 6 | ||||
-rw-r--r-- | java/jni/direct_bt/BTUtils.cxx | 4 | ||||
-rw-r--r-- | java/jni/direct_bt/DBGattServer.cxx | 283 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTAdapter.cxx | 617 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTDevice.cxx | 218 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTGattChar.cxx | 36 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTGattDesc.cxx | 18 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTGattService.cxx | 24 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTManager.cxx | 40 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTNativeDownlink.cxx | 8 | ||||
-rw-r--r-- | java/jni/direct_bt/EInfoReport.cxx | 125 | ||||
-rw-r--r-- | java/jni/direct_bt/helper_dbt.cxx | 12 | ||||
-rw-r--r-- | java/jni/direct_bt/helper_dbt.hpp | 2 | ||||
-rw-r--r-- | java/jni/helper_base.cxx | 36 | ||||
-rw-r--r-- | java/jni/helper_base.hpp | 28 |
15 files changed, 731 insertions, 726 deletions
diff --git a/java/jni/direct_bt/BTFactory.cxx b/java/jni/direct_bt/BTFactory.cxx index 3be7d34c..e61ad310 100644 --- a/java/jni/direct_bt/BTFactory.cxx +++ b/java/jni/direct_bt/BTFactory.cxx @@ -29,8 +29,6 @@ #include "helper_base.hpp" -using namespace jau; - jstring Java_org_direct_1bt_BTFactory_getNativeVersion(JNIEnv *env, jclass clazz) { try { @@ -62,8 +60,8 @@ void Java_org_direct_1bt_BTFactory_setenv(JNIEnv *env, jclass clazz, jstring jna try { (void) clazz; - std::string name = from_jstring_to_string(env, jname); - std::string value = from_jstring_to_string(env, jval); + std::string name = jau::jni::from_jstring_to_string(env, jname); + std::string value = jau::jni::from_jstring_to_string(env, jval); if( name.length() > 0 ) { if( value.length() > 0 ) { setenv(name.c_str(), value.c_str(), overwrite); diff --git a/java/jni/direct_bt/BTUtils.cxx b/java/jni/direct_bt/BTUtils.cxx index fe60be35..565e105d 100644 --- a/java/jni/direct_bt/BTUtils.cxx +++ b/java/jni/direct_bt/BTUtils.cxx @@ -90,12 +90,12 @@ jstring Java_org_direct_1bt_BTUtils_decodeUTF8String(JNIEnv *env, jclass clazz, std::string sres; { - jau::JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release + jau::jni::JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * buffer_ptr = criticalArray.get(jbuffer, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == buffer_ptr ) { throw jau::IllegalArgumentException("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); } sres = jau::dfa_utf8_decode(buffer_ptr+offset, static_cast<size_t>(size)); } - return jau::from_string_to_jstring(env, sres); + return jau::jni::from_string_to_jstring(env, sres); } diff --git a/java/jni/direct_bt/DBGattServer.cxx b/java/jni/direct_bt/DBGattServer.cxx index f6719748..a7eed750 100644 --- a/java/jni/direct_bt/DBGattServer.cxx +++ b/java/jni/direct_bt/DBGattServer.cxx @@ -39,6 +39,7 @@ #include "direct_bt/DBGattServer.hpp" using namespace direct_bt; +using namespace jau::jni; /** * @@ -55,10 +56,10 @@ static jobject _createDBGattValueFromDesc(JNIEnv *env_, jclass clazz, jmethodID const jau::POctets& value = valueHolder->getValue(); jbyteArray jval = env_->NewByteArray(value.size()); env_->SetByteArrayRegion(jval, 0, value.size(), (const jbyte*)(value.get_ptr())); - jau::java_exception_check_and_throw(env_, E_FILE_LINE); + java_exception_check_and_throw(env_, E_FILE_LINE); jobject jDBGattValue = env_->NewObject(clazz, clazz_ctor, jval, (jint)value.capacity(), valueHolder->hasVariableLength()); - jau::java_exception_check_and_throw(env_, E_FILE_LINE); + java_exception_check_and_throw(env_, E_FILE_LINE); env_->DeleteLocalRef(jval); @@ -69,10 +70,10 @@ static jobject _createDBGattValueFromChar(JNIEnv *env_, jclass clazz, jmethodID const jau::POctets& value = valueHolder->getValue(); jbyteArray jval = env_->NewByteArray(value.size()); env_->SetByteArrayRegion(jval, 0, value.size(), (const jbyte*)(value.get_ptr())); - jau::java_exception_check_and_throw(env_, E_FILE_LINE); + java_exception_check_and_throw(env_, E_FILE_LINE); jobject jDBGattValue = env_->NewObject(clazz, clazz_ctor, jval, (jint)value.capacity(), valueHolder->hasVariableLength()); - jau::java_exception_check_and_throw(env_, E_FILE_LINE); + java_exception_check_and_throw(env_, E_FILE_LINE); env_->DeleteLocalRef(jval); @@ -87,9 +88,9 @@ static jobject _createDBGattValueFromChar(JNIEnv *env_, jclass clazz, jmethodID jobject Java_org_direct_1bt_DBGattDesc_getValue(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattDesc> ref(env, obj); // hold until done - jclass clazz = jau::search_class(env, _dbGattValueClazzName.c_str()); - return jau::convert_instance_to_jobject<DBGattDesc>(env, clazz, _dbGattValueClazzCtorArgs.c_str(), _createDBGattValueFromDesc, ref.shared_ptr()); + shared_ptr_ref<DBGattDesc> ref(env, obj); // hold until done + jclass clazz = search_class(env, _dbGattValueClazzName.c_str()); + return convert_instance_to_jobject<DBGattDesc>(env, clazz, _dbGattValueClazzCtorArgs.c_str(), _createDBGattValueFromDesc, ref.shared_ptr()); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -98,7 +99,7 @@ jobject Java_org_direct_1bt_DBGattDesc_getValue(JNIEnv *env, jobject obj) { jboolean Java_org_direct_1bt_DBGattDesc_setValue(JNIEnv *env, jobject obj, jbyteArray jsource, jint jsource_pos, jint jsource_len, jint jdest_pos) { try { - jau::shared_ptr_ref<DBGattDesc> ref(env, obj); // hold until done + shared_ptr_ref<DBGattDesc> ref(env, obj); // hold until done if( nullptr == jsource ) { return JNI_FALSE; @@ -110,7 +111,7 @@ jboolean Java_org_direct_1bt_DBGattDesc_setValue(JNIEnv *env, jobject obj, jbyte const jau::nsize_t dest_pos = jdest_pos; if( 0 < source_len0 && 0 < source_len1 && source_pos1 + source_len1 <= source_len0 ) { - jau::JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release + JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release const uint8_t * source = criticalArray.get(jsource, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( nullptr == source ) { throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); @@ -136,12 +137,12 @@ jlong Java_org_direct_1bt_DBGattDesc_ctorImpl(JNIEnv *env, jobject obj, if( nullptr == jvalue_ ) { throw jau::IllegalArgumentException("byte array null", E_FILE_LINE); } - jau::JNIGlobalRef global_obj(obj); // lock instance first (global reference), inserted below + JNIGlobalRef global_obj(obj); // lock instance first (global reference), inserted below // POctets value jau::POctets value(jcapacity_, env->GetArrayLength(jvalue_), jau::endian::little); if( 0 < value.size() ) { - jau::JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release + JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release const uint8_t * value_ptr = criticalArray.get(jvalue_, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( nullptr == value_ptr ) { throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); @@ -150,14 +151,14 @@ jlong Java_org_direct_1bt_DBGattDesc_ctorImpl(JNIEnv *env, jobject obj, } // uuid_t type - std::string stype = jau::from_jstring_to_string(env, jtype_); + std::string stype = from_jstring_to_string(env, jtype_); std::shared_ptr<const jau::uuid_t> type( jau::uuid_t::create(stype) ); // new instance - jau::shared_ptr_ref<DBGattDesc> ref( new DBGattDesc(type, std::move(value), JNI_TRUE == jvariable_length_) ); + shared_ptr_ref<DBGattDesc> ref( new DBGattDesc(type, std::move(value), JNI_TRUE == jvariable_length_) ); - ref->setJavaObject( std::make_shared<jau::JavaGlobalObj>( std::move(global_obj), nullptr ) ); - jau::JavaGlobalObj::check(ref->getJavaObject(), E_FILE_LINE); + ref->setJavaObject( std::make_shared<JavaGlobalObj>( std::move(global_obj), nullptr ) ); + JavaGlobalObj::check(ref->getJavaObject(), E_FILE_LINE); return ref.release_to_jlong(); } catch(...) { @@ -169,14 +170,14 @@ jlong Java_org_direct_1bt_DBGattDesc_ctorImpl(JNIEnv *env, jobject obj, void Java_org_direct_1bt_DBGattDesc_dtorImpl(JNIEnv *env, jclass clazz, jlong nativeInstance) { (void)clazz; try { - jau::shared_ptr_ref<DBGattDesc> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done + shared_ptr_ref<DBGattDesc> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done if( nullptr != sref.pointer() ) { if( !sref.is_null() ) { - jau::JavaAnonRef sref_java = sref->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(sref_java, E_FILE_LINE); + JavaAnonRef sref_java = sref->getJavaObject(); // hold until done! + JavaGlobalObj::check(sref_java, E_FILE_LINE); sref->setJavaObject(); } - std::shared_ptr<DBGattDesc>* sref_ptr = jau::castInstance<DBGattDesc>(nativeInstance); + std::shared_ptr<DBGattDesc>* sref_ptr = castInstance<DBGattDesc>(nativeInstance); delete sref_ptr; } } catch(...) { @@ -187,7 +188,7 @@ void Java_org_direct_1bt_DBGattDesc_dtorImpl(JNIEnv *env, jclass clazz, jlong na jshort Java_org_direct_1bt_DBGattDesc_getHandle(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattDesc> ref(env, obj); // hold until done + shared_ptr_ref<DBGattDesc> ref(env, obj); // hold until done return (jshort)( ref->getHandle() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -199,7 +200,7 @@ jshort Java_org_direct_1bt_DBGattDesc_getHandle(JNIEnv *env, jobject obj) void Java_org_direct_1bt_DBGattDesc_bzero(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattDesc> ref(env, obj); // hold until done + shared_ptr_ref<DBGattDesc> ref(env, obj); // hold until done ref->bzero(); } catch(...) { rethrow_and_raise_java_exception(env); @@ -208,8 +209,8 @@ void Java_org_direct_1bt_DBGattDesc_bzero(JNIEnv *env, jobject obj) jstring Java_org_direct_1bt_DBGattDesc_toString(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattDesc> ref(env, obj); // hold until done - return jau::from_string_to_jstring(env, ref->toString()); + shared_ptr_ref<DBGattDesc> ref(env, obj); // hold until done + return from_string_to_jstring(env, ref->toString()); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -225,9 +226,9 @@ jstring Java_org_direct_1bt_DBGattDesc_toString(JNIEnv *env, jobject obj) { jobject Java_org_direct_1bt_DBGattChar_getValue(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattChar> ref(env, obj); // hold until done - jclass clazz = jau::search_class(env, _dbGattValueClazzName.c_str()); - return jau::convert_instance_to_jobject<DBGattChar>(env, clazz, _dbGattValueClazzCtorArgs.c_str(), _createDBGattValueFromChar, ref.shared_ptr()); + shared_ptr_ref<DBGattChar> ref(env, obj); // hold until done + jclass clazz = search_class(env, _dbGattValueClazzName.c_str()); + return convert_instance_to_jobject<DBGattChar>(env, clazz, _dbGattValueClazzCtorArgs.c_str(), _createDBGattValueFromChar, ref.shared_ptr()); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -236,7 +237,7 @@ jobject Java_org_direct_1bt_DBGattChar_getValue(JNIEnv *env, jobject obj) { jboolean Java_org_direct_1bt_DBGattChar_setValue(JNIEnv *env, jobject obj, jbyteArray jsource, jint jsource_pos, jint jsource_len, jint jdest_pos) { try { - jau::shared_ptr_ref<DBGattChar> ref(env, obj); // hold until done + shared_ptr_ref<DBGattChar> ref(env, obj); // hold until done if( nullptr == jsource ) { return JNI_FALSE; @@ -248,7 +249,7 @@ jboolean Java_org_direct_1bt_DBGattChar_setValue(JNIEnv *env, jobject obj, jbyte const jau::nsize_t dest_pos = jdest_pos; if( 0 < source_len0 && 0 < source_len1 && source_pos1 + source_len1 <= source_len0 ) { - jau::JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release + JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release const uint8_t * source = criticalArray.get(jsource, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( nullptr == source ) { throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); @@ -279,12 +280,12 @@ jlong Java_org_direct_1bt_DBGattChar_ctorImpl(JNIEnv *env, jobject obj, if( nullptr == jDescriptors ) { throw jau::IllegalArgumentException("descriptor array null", E_FILE_LINE); } - jau::JNIGlobalRef global_obj(obj); // lock instance first (global reference), inserted below + JNIGlobalRef global_obj(obj); // lock instance first (global reference), inserted below // POctets value jau::POctets value(jcapacity_, env->GetArrayLength(jvalue_), jau::endian::little); if( 0 < value.size() ) { - jau::JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release + JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release const uint8_t * value_ptr = criticalArray.get(jvalue_, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( nullptr == value_ptr ) { throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); @@ -296,7 +297,7 @@ jlong Java_org_direct_1bt_DBGattChar_ctorImpl(JNIEnv *env, jobject obj, jau::darray<DBGattDescRef> descriptors( env->GetArrayLength(jDescriptors) /* capacity */ ); const jau::nsize_t count = descriptors.capacity(); if( 0 < count ) { - jau::JNICriticalArray<jlong, jlongArray> criticalArray(env); // RAII - release + JNICriticalArray<jlong, jlongArray> criticalArray(env); // RAII - release jlong * jlong_desc_ref_array = criticalArray.get(jDescriptors, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( nullptr == jlong_desc_ref_array ) { throw jau::InternalError("GetPrimitiveArrayCritical(DBGattDesc* array) is null", E_FILE_LINE); @@ -311,16 +312,16 @@ jlong Java_org_direct_1bt_DBGattChar_ctorImpl(JNIEnv *env, jobject obj, const BTGattChar::PropertyBitVal properties = static_cast<BTGattChar::PropertyBitVal>(jproperties); // uuid_t type - std::string stype = jau::from_jstring_to_string(env, jtype_); + std::string stype = from_jstring_to_string(env, jtype_); std::shared_ptr<const jau::uuid_t> type( jau::uuid_t::create(stype) ); // new instance - jau::shared_ptr_ref<DBGattChar> ref( new DBGattChar(type, properties, + shared_ptr_ref<DBGattChar> ref( new DBGattChar(type, properties, std::move(descriptors), std::move(value), JNI_TRUE == jvariable_length_) ); - ref->setJavaObject( std::make_shared<jau::JavaGlobalObj>( std::move(global_obj), nullptr ) ); - jau::JavaGlobalObj::check(ref->getJavaObject(), E_FILE_LINE); + ref->setJavaObject( std::make_shared<JavaGlobalObj>( std::move(global_obj), nullptr ) ); + JavaGlobalObj::check(ref->getJavaObject(), E_FILE_LINE); return ref.release_to_jlong(); } catch(...) { @@ -332,14 +333,14 @@ jlong Java_org_direct_1bt_DBGattChar_ctorImpl(JNIEnv *env, jobject obj, void Java_org_direct_1bt_DBGattChar_dtorImpl(JNIEnv *env, jclass clazz, jlong nativeInstance) { (void)clazz; try { - jau::shared_ptr_ref<BTGattChar> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done + shared_ptr_ref<BTGattChar> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done if( nullptr != sref.pointer() ) { if( !sref.is_null() ) { - jau::JavaAnonRef sref_java = sref->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(sref_java, E_FILE_LINE); + JavaAnonRef sref_java = sref->getJavaObject(); // hold until done! + JavaGlobalObj::check(sref_java, E_FILE_LINE); sref->setJavaObject(); } - std::shared_ptr<BTGattChar>* sref_ptr = jau::castInstance<BTGattChar>(nativeInstance); + std::shared_ptr<BTGattChar>* sref_ptr = castInstance<BTGattChar>(nativeInstance); delete sref_ptr; } } catch(...) { @@ -350,7 +351,7 @@ void Java_org_direct_1bt_DBGattChar_dtorImpl(JNIEnv *env, jclass clazz, jlong na jshort Java_org_direct_1bt_DBGattChar_getHandle(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattChar> ref(env, obj); // hold until done + shared_ptr_ref<DBGattChar> ref(env, obj); // hold until done return (jshort)( ref->getHandle() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -361,7 +362,7 @@ jshort Java_org_direct_1bt_DBGattChar_getHandle(JNIEnv *env, jobject obj) jshort Java_org_direct_1bt_DBGattChar_getEndHandle(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattChar> ref(env, obj); // hold until done + shared_ptr_ref<DBGattChar> ref(env, obj); // hold until done return (jshort)( ref->getEndHandle() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -372,7 +373,7 @@ jshort Java_org_direct_1bt_DBGattChar_getEndHandle(JNIEnv *env, jobject obj) jshort Java_org_direct_1bt_DBGattChar_getValueHandle(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattChar> ref(env, obj); // hold until done + shared_ptr_ref<DBGattChar> ref(env, obj); // hold until done return (jshort)( ref->getValueHandle() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -384,7 +385,7 @@ jshort Java_org_direct_1bt_DBGattChar_getValueHandle(JNIEnv *env, jobject obj) void Java_org_direct_1bt_DBGattChar_bzero(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattChar> ref(env, obj); // hold until done + shared_ptr_ref<DBGattChar> ref(env, obj); // hold until done ref->bzero(); } catch(...) { rethrow_and_raise_java_exception(env); @@ -393,8 +394,8 @@ void Java_org_direct_1bt_DBGattChar_bzero(JNIEnv *env, jobject obj) jstring Java_org_direct_1bt_DBGattChar_toString(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattChar> ref(env, obj); // hold until done - return jau::from_string_to_jstring(env, ref->toString()); + shared_ptr_ref<DBGattChar> ref(env, obj); // hold until done + return from_string_to_jstring(env, ref->toString()); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -418,13 +419,13 @@ jlong Java_org_direct_1bt_DBGattService_ctorImpl(JNIEnv *env, jobject obj, if( nullptr == jCharacteristics ) { throw jau::IllegalArgumentException("characteristics array null", E_FILE_LINE); } - jau::JNIGlobalRef global_obj(obj); // lock instance first (global reference), inserted below + JNIGlobalRef global_obj(obj); // lock instance first (global reference), inserted below // DBGattCharRef List jau::darray<DBGattCharRef> characteristics( env->GetArrayLength(jCharacteristics) /* capacity */ ); const jau::nsize_t count = characteristics.capacity(); if( 0 < count ) { - jau::JNICriticalArray<jlong, jlongArray> criticalArray(env); // RAII - release + JNICriticalArray<jlong, jlongArray> criticalArray(env); // RAII - release jlong * jlong_char_ref_array = criticalArray.get(jCharacteristics, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( nullptr == jlong_char_ref_array ) { throw jau::InternalError("GetPrimitiveArrayCritical(DBGattChar* array) is null", E_FILE_LINE); @@ -436,14 +437,14 @@ jlong Java_org_direct_1bt_DBGattService_ctorImpl(JNIEnv *env, jobject obj, } // uuid_t type - std::string stype = jau::from_jstring_to_string(env, jtype_); + std::string stype = from_jstring_to_string(env, jtype_); std::shared_ptr<const jau::uuid_t> type( jau::uuid_t::create(stype) ); // new instance - jau::shared_ptr_ref<DBGattService> ref( new DBGattService( JNI_TRUE == jprimary, type, std::move(characteristics) ) ); + shared_ptr_ref<DBGattService> ref( new DBGattService( JNI_TRUE == jprimary, type, std::move(characteristics) ) ); - ref->setJavaObject( std::make_shared<jau::JavaGlobalObj>( std::move(global_obj), nullptr ) ); - jau::JavaGlobalObj::check(ref->getJavaObject(), E_FILE_LINE); + ref->setJavaObject( std::make_shared<JavaGlobalObj>( std::move(global_obj), nullptr ) ); + JavaGlobalObj::check(ref->getJavaObject(), E_FILE_LINE); return ref.release_to_jlong(); } catch(...) { @@ -455,14 +456,14 @@ jlong Java_org_direct_1bt_DBGattService_ctorImpl(JNIEnv *env, jobject obj, void Java_org_direct_1bt_DBGattService_dtorImpl(JNIEnv *env, jclass clazz, jlong nativeInstance) { (void)clazz; try { - jau::shared_ptr_ref<DBGattService> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done + shared_ptr_ref<DBGattService> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done if( nullptr != sref.pointer() ) { if( !sref.is_null() ) { - jau::JavaAnonRef sref_java = sref->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(sref_java, E_FILE_LINE); + JavaAnonRef sref_java = sref->getJavaObject(); // hold until done! + JavaGlobalObj::check(sref_java, E_FILE_LINE); sref->setJavaObject(); } - std::shared_ptr<DBGattService>* sref_ptr = jau::castInstance<DBGattService>(nativeInstance); + std::shared_ptr<DBGattService>* sref_ptr = castInstance<DBGattService>(nativeInstance); delete sref_ptr; } } catch(...) { @@ -473,7 +474,7 @@ void Java_org_direct_1bt_DBGattService_dtorImpl(JNIEnv *env, jclass clazz, jlong jshort Java_org_direct_1bt_DBGattService_getHandle(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattService> ref(env, obj); // hold until done + shared_ptr_ref<DBGattService> ref(env, obj); // hold until done return (jshort)( ref->getHandle() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -484,7 +485,7 @@ jshort Java_org_direct_1bt_DBGattService_getHandle(JNIEnv *env, jobject obj) jshort Java_org_direct_1bt_DBGattService_getEndHandle(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattService> ref(env, obj); // hold until done + shared_ptr_ref<DBGattService> ref(env, obj); // hold until done return (jshort)( ref->getEndHandle() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -494,8 +495,8 @@ jshort Java_org_direct_1bt_DBGattService_getEndHandle(JNIEnv *env, jobject obj) jstring Java_org_direct_1bt_DBGattService_toString(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattService> ref(env, obj); // hold until done - return jau::from_string_to_jstring(env, ref->toString()); + shared_ptr_ref<DBGattService> ref(env, obj); // hold until done + return from_string_to_jstring(env, ref->toString()); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -518,13 +519,13 @@ jlong Java_org_direct_1bt_DBGattServer_ctorImpl(JNIEnv *env, jobject obj, if( nullptr == jService ) { throw jau::IllegalArgumentException("characteristics array null", E_FILE_LINE); } - jau::JNIGlobalRef global_obj(obj); // lock instance first (global reference), inserted below + JNIGlobalRef global_obj(obj); // lock instance first (global reference), inserted below // DBGattServiceRef List jau::darray<DBGattServiceRef> services( env->GetArrayLength(jService) /* capacity */ ); const jau::nsize_t count = services.capacity(); if( 0 < count ) { - jau::JNICriticalArray<jlong, jlongArray> criticalArray(env); // RAII - release + JNICriticalArray<jlong, jlongArray> criticalArray(env); // RAII - release jlong * jlong_service_ref_array = criticalArray.get(jService, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( nullptr == jlong_service_ref_array ) { throw jau::InternalError("GetPrimitiveArrayCritical(DBGattService* array) is null", E_FILE_LINE); @@ -536,10 +537,10 @@ jlong Java_org_direct_1bt_DBGattServer_ctorImpl(JNIEnv *env, jobject obj, } // new instance - jau::shared_ptr_ref<DBGattServer> ref( new DBGattServer( jmax_att_mtu, std::move(services) ) ); + shared_ptr_ref<DBGattServer> ref( new DBGattServer( jmax_att_mtu, std::move(services) ) ); - ref->setJavaObject( std::make_shared<jau::JavaGlobalObj>( std::move(global_obj), nullptr ) ); - jau::JavaGlobalObj::check(ref->getJavaObject(), E_FILE_LINE); + ref->setJavaObject( std::make_shared<JavaGlobalObj>( std::move(global_obj), nullptr ) ); + JavaGlobalObj::check(ref->getJavaObject(), E_FILE_LINE); return ref.release_to_jlong(); } catch(...) { @@ -551,14 +552,14 @@ jlong Java_org_direct_1bt_DBGattServer_ctorImpl(JNIEnv *env, jobject obj, void Java_org_direct_1bt_DBGattServer_dtorImpl(JNIEnv *env, jclass clazz, jlong nativeInstance) { (void)clazz; try { - jau::shared_ptr_ref<DBGattServer> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done + shared_ptr_ref<DBGattServer> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done if( nullptr != sref.pointer() ) { if( !sref.is_null() ) { - jau::JavaAnonRef sref_java = sref->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(sref_java, E_FILE_LINE); + JavaAnonRef sref_java = sref->getJavaObject(); // hold until done! + JavaGlobalObj::check(sref_java, E_FILE_LINE); sref->setJavaObject(); } - std::shared_ptr<DBGattServer>* sref_ptr = jau::castInstance<DBGattServer>(nativeInstance); + std::shared_ptr<DBGattServer>* sref_ptr = castInstance<DBGattServer>(nativeInstance); delete sref_ptr; } } catch(...) { @@ -569,7 +570,7 @@ void Java_org_direct_1bt_DBGattServer_dtorImpl(JNIEnv *env, jclass clazz, jlong jint Java_org_direct_1bt_DBGattServer_getMaxAttMTU(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattServer> ref(env, obj); // hold until done + shared_ptr_ref<DBGattServer> ref(env, obj); // hold until done return (jint)( ref->getMaxAttMTU() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -580,7 +581,7 @@ jint Java_org_direct_1bt_DBGattServer_getMaxAttMTU(JNIEnv *env, jobject obj) void Java_org_direct_1bt_DBGattServer_setMaxAttMTU(JNIEnv *env, jobject obj, jint v) { try { - jau::shared_ptr_ref<DBGattServer> ref(env, obj); // hold until done + shared_ptr_ref<DBGattServer> ref(env, obj); // hold until done ref->setMaxAttMTU(v); } catch(...) { rethrow_and_raise_java_exception(env); @@ -589,8 +590,8 @@ void Java_org_direct_1bt_DBGattServer_setMaxAttMTU(JNIEnv *env, jobject obj, jin jstring Java_org_direct_1bt_DBGattServer_toString(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<DBGattServer> ref(env, obj); // hold until done - return jau::from_string_to_jstring(env, ref->toString()); + shared_ptr_ref<DBGattServer> ref(env, obj); // hold until done + return from_string_to_jstring(env, ref->toString()); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -606,7 +607,7 @@ jstring Java_org_direct_1bt_DBGattServer_toString(JNIEnv *env, jobject obj) { class JNIDBGattServerListener : public DBGattServer::Listener { private: - jau::JavaGlobalObj listenerObjRef; + JavaGlobalObj listenerObjRef; jmethodID mConnected = nullptr; jmethodID mDisconnected = nullptr; jmethodID mMtuChanged = nullptr; @@ -622,131 +623,131 @@ class JNIDBGattServerListener : public DBGattServer::Listener { JNIDBGattServerListener(JNIEnv *env, jclass clazz, jobject obj) : listenerObjRef(obj, nullptr) { - mConnected = jau::search_method(env, clazz, "connected", "(Lorg/direct_bt/BTDevice;I)V", false); - mDisconnected = jau::search_method(env, clazz, "disconnected", "(Lorg/direct_bt/BTDevice;)V", false); - mMtuChanged = jau::search_method(env, clazz, "mtuChanged", "(Lorg/direct_bt/BTDevice;I)V", false); - mReadCharValue = jau::search_method(env, clazz, "readCharValue", "(Lorg/direct_bt/BTDevice;Lorg/direct_bt/DBGattService;Lorg/direct_bt/DBGattChar;)Z", false); - mReadDescValue = jau::search_method(env, clazz, "readDescValue", "(Lorg/direct_bt/BTDevice;Lorg/direct_bt/DBGattService;Lorg/direct_bt/DBGattChar;Lorg/direct_bt/DBGattDesc;)Z", false); - mWriteCharValue = jau::search_method(env, clazz, "writeCharValue", "(Lorg/direct_bt/BTDevice;Lorg/direct_bt/DBGattService;Lorg/direct_bt/DBGattChar;[BI)Z", false); - mWriteCharValueDone = jau::search_method(env, clazz, "writeCharValueDone", "(Lorg/direct_bt/BTDevice;Lorg/direct_bt/DBGattService;Lorg/direct_bt/DBGattChar;)V", false); - mWriteDescValue = jau::search_method(env, clazz, "writeDescValue", "(Lorg/direct_bt/BTDevice;Lorg/direct_bt/DBGattService;Lorg/direct_bt/DBGattChar;Lorg/direct_bt/DBGattDesc;[BI)Z", false); - mWriteDescValueDone = jau::search_method(env, clazz, "writeDescValueDone", "(Lorg/direct_bt/BTDevice;Lorg/direct_bt/DBGattService;Lorg/direct_bt/DBGattChar;Lorg/direct_bt/DBGattDesc;)V", false); - mCCDChanged = jau::search_method(env, clazz, "clientCharConfigChanged", "(Lorg/direct_bt/BTDevice;Lorg/direct_bt/DBGattService;Lorg/direct_bt/DBGattChar;Lorg/direct_bt/DBGattDesc;ZZ)V", false); + mConnected = search_method(env, clazz, "connected", "(Lorg/direct_bt/BTDevice;I)V", false); + mDisconnected = search_method(env, clazz, "disconnected", "(Lorg/direct_bt/BTDevice;)V", false); + mMtuChanged = search_method(env, clazz, "mtuChanged", "(Lorg/direct_bt/BTDevice;I)V", false); + mReadCharValue = search_method(env, clazz, "readCharValue", "(Lorg/direct_bt/BTDevice;Lorg/direct_bt/DBGattService;Lorg/direct_bt/DBGattChar;)Z", false); + mReadDescValue = search_method(env, clazz, "readDescValue", "(Lorg/direct_bt/BTDevice;Lorg/direct_bt/DBGattService;Lorg/direct_bt/DBGattChar;Lorg/direct_bt/DBGattDesc;)Z", false); + mWriteCharValue = search_method(env, clazz, "writeCharValue", "(Lorg/direct_bt/BTDevice;Lorg/direct_bt/DBGattService;Lorg/direct_bt/DBGattChar;[BI)Z", false); + mWriteCharValueDone = search_method(env, clazz, "writeCharValueDone", "(Lorg/direct_bt/BTDevice;Lorg/direct_bt/DBGattService;Lorg/direct_bt/DBGattChar;)V", false); + mWriteDescValue = search_method(env, clazz, "writeDescValue", "(Lorg/direct_bt/BTDevice;Lorg/direct_bt/DBGattService;Lorg/direct_bt/DBGattChar;Lorg/direct_bt/DBGattDesc;[BI)Z", false); + mWriteDescValueDone = search_method(env, clazz, "writeDescValueDone", "(Lorg/direct_bt/BTDevice;Lorg/direct_bt/DBGattService;Lorg/direct_bt/DBGattChar;Lorg/direct_bt/DBGattDesc;)V", false); + mCCDChanged = search_method(env, clazz, "clientCharConfigChanged", "(Lorg/direct_bt/BTDevice;Lorg/direct_bt/DBGattService;Lorg/direct_bt/DBGattChar;Lorg/direct_bt/DBGattDesc;ZZ)V", false); } ~JNIDBGattServerListener() noexcept { } void connected(BTDeviceRef device, const uint16_t initialMTU) override { - jobject j_device = jau::JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); - JNIEnv *env = *jau::jni_env; + jobject j_device = JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); + JNIEnv *env = *jni_env; env->CallVoidMethod(listenerObjRef.getObject(), mConnected, j_device, (jint)initialMTU); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); } void disconnected(BTDeviceRef device) override { - jobject j_device = jau::JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); - JNIEnv *env = *jau::jni_env; + jobject j_device = JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); + JNIEnv *env = *jni_env; env->CallVoidMethod(listenerObjRef.getObject(), mDisconnected, j_device); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); } void mtuChanged(BTDeviceRef device, const uint16_t mtu) override { - jobject j_device = jau::JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); - JNIEnv *env = *jau::jni_env; + jobject j_device = JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); + JNIEnv *env = *jni_env; env->CallVoidMethod(listenerObjRef.getObject(), mMtuChanged, j_device, (jint)mtu); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); } bool readCharValue(BTDeviceRef device, DBGattServiceRef s, DBGattCharRef c) override { - jobject j_device = jau::JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); - jobject j_s = jau::JavaGlobalObj::checkAndGetObject(s->getJavaObject(), E_FILE_LINE); - jobject j_c = jau::JavaGlobalObj::checkAndGetObject(c->getJavaObject(), E_FILE_LINE); - JNIEnv *env = *jau::jni_env; + jobject j_device = JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); + jobject j_s = JavaGlobalObj::checkAndGetObject(s->getJavaObject(), E_FILE_LINE); + jobject j_c = JavaGlobalObj::checkAndGetObject(c->getJavaObject(), E_FILE_LINE); + JNIEnv *env = *jni_env; jboolean res = env->CallBooleanMethod(listenerObjRef.getObject(), mReadCharValue, j_device, j_s, j_c); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); return JNI_TRUE == res; } bool readDescValue(BTDeviceRef device, DBGattServiceRef s, DBGattCharRef c, DBGattDescRef d) override { - jobject j_device = jau::JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); - jobject j_s = jau::JavaGlobalObj::checkAndGetObject(s->getJavaObject(), E_FILE_LINE); - jobject j_c = jau::JavaGlobalObj::checkAndGetObject(c->getJavaObject(), E_FILE_LINE); - jobject j_d = jau::JavaGlobalObj::checkAndGetObject(d->getJavaObject(), E_FILE_LINE); - JNIEnv *env = *jau::jni_env; + jobject j_device = JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); + jobject j_s = JavaGlobalObj::checkAndGetObject(s->getJavaObject(), E_FILE_LINE); + jobject j_c = JavaGlobalObj::checkAndGetObject(c->getJavaObject(), E_FILE_LINE); + jobject j_d = JavaGlobalObj::checkAndGetObject(d->getJavaObject(), E_FILE_LINE); + JNIEnv *env = *jni_env; jboolean res = env->CallBooleanMethod(listenerObjRef.getObject(), mReadDescValue, j_device, j_s, j_c, j_d); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); return JNI_TRUE == res; } bool writeCharValue(BTDeviceRef device, DBGattServiceRef s, DBGattCharRef c, const jau::TROOctets & value, const uint16_t value_offset) override { - jobject j_device = jau::JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); - jobject j_s = jau::JavaGlobalObj::checkAndGetObject(s->getJavaObject(), E_FILE_LINE); - jobject j_c = jau::JavaGlobalObj::checkAndGetObject(c->getJavaObject(), E_FILE_LINE); - JNIEnv *env = *jau::jni_env; + jobject j_device = JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); + jobject j_s = JavaGlobalObj::checkAndGetObject(s->getJavaObject(), E_FILE_LINE); + jobject j_c = JavaGlobalObj::checkAndGetObject(c->getJavaObject(), E_FILE_LINE); + JNIEnv *env = *jni_env; const size_t value_size = value.size(); jbyteArray j_value = env->NewByteArray((jsize)value_size); env->SetByteArrayRegion(j_value, 0, (jsize)value_size, (const jbyte *)value.get_ptr()); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); jboolean res = env->CallBooleanMethod(listenerObjRef.getObject(), mWriteCharValue, j_device, j_s, j_c, j_value, (jint)value_offset); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); env->DeleteLocalRef(j_value); return JNI_TRUE == res; } void writeCharValueDone(BTDeviceRef device, DBGattServiceRef s, DBGattCharRef c) override { - jobject j_device = jau::JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); - jobject j_s = jau::JavaGlobalObj::checkAndGetObject(s->getJavaObject(), E_FILE_LINE); - jobject j_c = jau::JavaGlobalObj::checkAndGetObject(c->getJavaObject(), E_FILE_LINE); - JNIEnv *env = *jau::jni_env; + jobject j_device = JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); + jobject j_s = JavaGlobalObj::checkAndGetObject(s->getJavaObject(), E_FILE_LINE); + jobject j_c = JavaGlobalObj::checkAndGetObject(c->getJavaObject(), E_FILE_LINE); + JNIEnv *env = *jni_env; env->CallVoidMethod(listenerObjRef.getObject(), mWriteCharValueDone, j_device, j_s, j_c); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); } bool writeDescValue(BTDeviceRef device, DBGattServiceRef s, DBGattCharRef c, DBGattDescRef d, const jau::TROOctets & value, const uint16_t value_offset) override { - jobject j_device = jau::JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); - jobject j_s = jau::JavaGlobalObj::checkAndGetObject(s->getJavaObject(), E_FILE_LINE); - jobject j_c = jau::JavaGlobalObj::checkAndGetObject(c->getJavaObject(), E_FILE_LINE); - jobject j_d = jau::JavaGlobalObj::checkAndGetObject(d->getJavaObject(), E_FILE_LINE); - JNIEnv *env = *jau::jni_env; + jobject j_device = JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); + jobject j_s = JavaGlobalObj::checkAndGetObject(s->getJavaObject(), E_FILE_LINE); + jobject j_c = JavaGlobalObj::checkAndGetObject(c->getJavaObject(), E_FILE_LINE); + jobject j_d = JavaGlobalObj::checkAndGetObject(d->getJavaObject(), E_FILE_LINE); + JNIEnv *env = *jni_env; const size_t value_size = value.size(); jbyteArray j_value = env->NewByteArray((jsize)value_size); env->SetByteArrayRegion(j_value, 0, (jsize)value_size, (const jbyte *)value.get_ptr()); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); jboolean res = env->CallBooleanMethod(listenerObjRef.getObject(), mWriteDescValue, j_device, j_s, j_c, j_d, j_value, (jint)value_offset); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); env->DeleteLocalRef(j_value); return JNI_TRUE == res; } void writeDescValueDone(BTDeviceRef device, DBGattServiceRef s, DBGattCharRef c, DBGattDescRef d) override { - jobject j_device = jau::JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); - jobject j_s = jau::JavaGlobalObj::checkAndGetObject(s->getJavaObject(), E_FILE_LINE); - jobject j_c = jau::JavaGlobalObj::checkAndGetObject(c->getJavaObject(), E_FILE_LINE); - jobject j_d = jau::JavaGlobalObj::checkAndGetObject(d->getJavaObject(), E_FILE_LINE); - JNIEnv *env = *jau::jni_env; + jobject j_device = JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); + jobject j_s = JavaGlobalObj::checkAndGetObject(s->getJavaObject(), E_FILE_LINE); + jobject j_c = JavaGlobalObj::checkAndGetObject(c->getJavaObject(), E_FILE_LINE); + jobject j_d = JavaGlobalObj::checkAndGetObject(d->getJavaObject(), E_FILE_LINE); + JNIEnv *env = *jni_env; env->CallVoidMethod(listenerObjRef.getObject(), mWriteDescValueDone, j_device, j_s, j_c, j_d); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); } void clientCharConfigChanged(BTDeviceRef device, DBGattServiceRef s, DBGattCharRef c, DBGattDescRef d, const bool notificationEnabled, const bool indicationEnabled) override { - jobject j_device = jau::JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); - jobject j_s = jau::JavaGlobalObj::checkAndGetObject(s->getJavaObject(), E_FILE_LINE); - jobject j_c = jau::JavaGlobalObj::checkAndGetObject(c->getJavaObject(), E_FILE_LINE); - jobject j_d = jau::JavaGlobalObj::checkAndGetObject(d->getJavaObject(), E_FILE_LINE); - JNIEnv *env = *jau::jni_env; + jobject j_device = JavaGlobalObj::checkAndGetObject(device->getJavaObject(), E_FILE_LINE); + jobject j_s = JavaGlobalObj::checkAndGetObject(s->getJavaObject(), E_FILE_LINE); + jobject j_c = JavaGlobalObj::checkAndGetObject(c->getJavaObject(), E_FILE_LINE); + jobject j_d = JavaGlobalObj::checkAndGetObject(d->getJavaObject(), E_FILE_LINE); + JNIEnv *env = *jni_env; env->CallVoidMethod(listenerObjRef.getObject(), mCCDChanged, j_device, j_s, j_c, j_d, notificationEnabled? JNI_TRUE : JNI_FALSE, indicationEnabled? JNI_TRUE : JNI_FALSE); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); } }; @@ -758,8 +759,8 @@ class JNIDBGattServerListener : public DBGattServer::Listener { */ jboolean Java_org_direct_1bt_DBGattServer_addListenerImpl(JNIEnv *env, jobject obj, jobject jlistener) { try { - jau::shared_ptr_ref<DBGattServer> ref(env, obj); // hold until done - jau::shared_ptr_ref<JNIDBGattServerListener> listener_ref(env, jlistener); // hold until done + shared_ptr_ref<DBGattServer> ref(env, obj); // hold until done + shared_ptr_ref<JNIDBGattServerListener> listener_ref(env, jlistener); // hold until done bool res = ref->addListener(listener_ref.shared_ptr()); return res ? JNI_TRUE : JNI_FALSE; } catch(...) { @@ -775,8 +776,8 @@ jboolean Java_org_direct_1bt_DBGattServer_addListenerImpl(JNIEnv *env, jobject o */ jboolean Java_org_direct_1bt_DBGattServer_removeListenerImpl(JNIEnv *env, jobject obj, jobject jlistener) { try { - jau::shared_ptr_ref<DBGattServer> ref(env, obj); // hold until done - jau::shared_ptr_ref<JNIDBGattServerListener> listener_ref(env, jlistener); // hold until done + shared_ptr_ref<DBGattServer> ref(env, obj); // hold until done + shared_ptr_ref<JNIDBGattServerListener> listener_ref(env, jlistener); // hold until done bool res = ref->removeListener(listener_ref.shared_ptr()); return res ? JNI_TRUE : JNI_FALSE; } catch(...) { @@ -793,8 +794,8 @@ jboolean Java_org_direct_1bt_DBGattServer_removeListenerImpl(JNIEnv *env, jobjec */ jlong Java_org_direct_1bt_DBGattServer_00024Listener_ctorImpl(JNIEnv *env, jobject obj) { try { - jclass clazz = jau::search_class(env, obj); - jau::shared_ptr_ref<JNIDBGattServerListener> ref( new JNIDBGattServerListener(env, clazz, obj) ); + jclass clazz = search_class(env, obj); + shared_ptr_ref<JNIDBGattServerListener> ref( new JNIDBGattServerListener(env, clazz, obj) ); env->DeleteLocalRef(clazz); return ref.release_to_jlong(); @@ -812,9 +813,9 @@ jlong Java_org_direct_1bt_DBGattServer_00024Listener_ctorImpl(JNIEnv *env, jobje void Java_org_direct_1bt_DBGattServer_00024Listener_dtorImpl(JNIEnv *env, jclass clazz, jlong nativeInstance) { (void)clazz; try { - jau::shared_ptr_ref<JNIDBGattServerListener> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done + shared_ptr_ref<JNIDBGattServerListener> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done if( nullptr != sref.pointer() ) { - std::shared_ptr<JNIDBGattServerListener>* sref_ptr = jau::castInstance<JNIDBGattServerListener>(nativeInstance); + std::shared_ptr<JNIDBGattServerListener>* sref_ptr = castInstance<JNIDBGattServerListener>(nativeInstance); delete sref_ptr; } } catch(...) { diff --git a/java/jni/direct_bt/DBTAdapter.cxx b/java/jni/direct_bt/DBTAdapter.cxx index 7c509f90..c16d1553 100644 --- a/java/jni/direct_bt/DBTAdapter.cxx +++ b/java/jni/direct_bt/DBTAdapter.cxx @@ -36,6 +36,7 @@ #include "direct_bt/BTManager.hpp" using namespace direct_bt; +using namespace jau::jni; static const std::string _adapterSettingsClassName("org/direct_bt/AdapterSettings"); static const std::string _adapterSettingsClazzCtorArgs("(I)V"); @@ -83,22 +84,22 @@ class JNIAdapterStatusListener : public AdapterStatusListener { static std::atomic<int> iname_next; int const iname; - jau::JNIGlobalRef adapterSettingsClazzRef; + JNIGlobalRef adapterSettingsClazzRef; jmethodID adapterSettingsClazzCtor; - jau::JNIGlobalRef eirDataTypeSetClazzRef; + JNIGlobalRef eirDataTypeSetClazzRef; jmethodID eirDataTypeSetClazzCtor; - jau::JNIGlobalRef hciStatusCodeClazzRef; + JNIGlobalRef hciStatusCodeClazzRef; jmethodID hciStatusCodeClazzGet; - jau::JNIGlobalRef scanTypeClazzRef; + JNIGlobalRef scanTypeClazzRef; jmethodID scanTypeClazzGet; - jau::JNIGlobalRef discoveryPolicyClazzRef; + JNIGlobalRef discoveryPolicyClazzRef; jmethodID discoveryPolicyClazzGet; - jau::JNIGlobalRef pairingModeClazzRef; + JNIGlobalRef pairingModeClazzRef; jmethodID pairingModeClazzGet; - jau::JNIGlobalRef pairingStateClazzRef; + JNIGlobalRef pairingStateClazzRef; jmethodID pairingStateClazzGet; - jau::JNIGlobalRef deviceClazzRef; + JNIGlobalRef deviceClazzRef; jmethodID deviceClazzCtor; jfieldID deviceClazzTSLastDiscoveryField; jfieldID deviceClazzTSLastUpdateField; @@ -125,141 +126,141 @@ class JNIAdapterStatusListener : public AdapterStatusListener { JNIAdapterStatusListener(JNIEnv *env, jobject statusListenerObj) : iname(iname_next.fetch_add(1)) { - jclass listenerClazz = jau::search_class(env, statusListenerObj); + jclass listenerClazz = search_class(env, statusListenerObj); // adapterSettingsClazzRef, adapterSettingsClazzCtor { - jclass adapterSettingsClazz = jau::search_class(env, _adapterSettingsClassName.c_str()); - adapterSettingsClazzRef = jau::JNIGlobalRef(adapterSettingsClazz); + jclass adapterSettingsClazz = search_class(env, _adapterSettingsClassName.c_str()); + adapterSettingsClazzRef = JNIGlobalRef(adapterSettingsClazz); env->DeleteLocalRef(adapterSettingsClazz); } - adapterSettingsClazzCtor = jau::search_method(env, adapterSettingsClazzRef.getClass(), "<init>", _adapterSettingsClazzCtorArgs.c_str(), false); + adapterSettingsClazzCtor = search_method(env, adapterSettingsClazzRef.getClass(), "<init>", _adapterSettingsClazzCtorArgs.c_str(), false); // eirDataTypeSetClazzRef, eirDataTypeSetClazzCtor { - jclass eirDataTypeSetClazz = jau::search_class(env, _eirDataTypeSetClassName.c_str()); - eirDataTypeSetClazzRef = jau::JNIGlobalRef(eirDataTypeSetClazz); + jclass eirDataTypeSetClazz = search_class(env, _eirDataTypeSetClassName.c_str()); + eirDataTypeSetClazzRef = JNIGlobalRef(eirDataTypeSetClazz); env->DeleteLocalRef(eirDataTypeSetClazz); } - eirDataTypeSetClazzCtor = jau::search_method(env, eirDataTypeSetClazzRef.getClass(), "<init>", _eirDataTypeSetClazzCtorArgs.c_str(), false); + eirDataTypeSetClazzCtor = search_method(env, eirDataTypeSetClazzRef.getClass(), "<init>", _eirDataTypeSetClazzCtorArgs.c_str(), false); // hciStatusCodeClazzRef, hciStatusCodeClazzGet { - jclass hciErrorCodeClazz = jau::search_class(env, _hciStatusCodeClassName.c_str()); - hciStatusCodeClazzRef = jau::JNIGlobalRef(hciErrorCodeClazz); + jclass hciErrorCodeClazz = search_class(env, _hciStatusCodeClassName.c_str()); + hciStatusCodeClazzRef = JNIGlobalRef(hciErrorCodeClazz); env->DeleteLocalRef(hciErrorCodeClazz); } - hciStatusCodeClazzGet = jau::search_method(env, hciStatusCodeClazzRef.getClass(), "get", _hciStatusCodeClazzGetArgs.c_str(), true); + hciStatusCodeClazzGet = search_method(env, hciStatusCodeClazzRef.getClass(), "get", _hciStatusCodeClazzGetArgs.c_str(), true); // scanTypeClazzRef, scanTypeClazzGet { - jclass scanTypeClazz = jau::search_class(env, _scanTypeClassName.c_str()); - scanTypeClazzRef = jau::JNIGlobalRef(scanTypeClazz); + jclass scanTypeClazz = search_class(env, _scanTypeClassName.c_str()); + scanTypeClazzRef = JNIGlobalRef(scanTypeClazz); env->DeleteLocalRef(scanTypeClazz); } - scanTypeClazzGet = jau::search_method(env, scanTypeClazzRef.getClass(), "get", _scanTypeClazzGetArgs.c_str(), true); + scanTypeClazzGet = search_method(env, scanTypeClazzRef.getClass(), "get", _scanTypeClazzGetArgs.c_str(), true); // discoveryPolicyClazzRef, discoveryPolicyClazzGet; { - jclass discoveryPolicyClazz = jau::search_class(env, _discoveryPolicyClassName.c_str()); - discoveryPolicyClazzRef = jau::JNIGlobalRef(discoveryPolicyClazz); + jclass discoveryPolicyClazz = search_class(env, _discoveryPolicyClassName.c_str()); + discoveryPolicyClazzRef = JNIGlobalRef(discoveryPolicyClazz); env->DeleteLocalRef(discoveryPolicyClazz); } - discoveryPolicyClazzGet = jau::search_method(env, discoveryPolicyClazzRef.getClass(), "get", _discoveryPolicyClazzGetArgs.c_str(), true); + discoveryPolicyClazzGet = search_method(env, discoveryPolicyClazzRef.getClass(), "get", _discoveryPolicyClazzGetArgs.c_str(), true); // pairingModeClazzRef, pairingModeClazzGet { - jclass pairingModeClazz = jau::search_class(env, _pairingModeClassName.c_str()); - pairingModeClazzRef = jau::JNIGlobalRef(pairingModeClazz); + jclass pairingModeClazz = search_class(env, _pairingModeClassName.c_str()); + pairingModeClazzRef = JNIGlobalRef(pairingModeClazz); env->DeleteLocalRef(pairingModeClazz); } - pairingModeClazzGet = jau::search_method(env, pairingModeClazzRef.getClass(), "get", _pairingModeClazzGetArgs.c_str(), true); + pairingModeClazzGet = search_method(env, pairingModeClazzRef.getClass(), "get", _pairingModeClazzGetArgs.c_str(), true); // pairingStateClazzRef, pairingStateClazzGet { - jclass pairingStateClazz = jau::search_class(env, _pairingStateClassName.c_str()); - pairingStateClazzRef = jau::JNIGlobalRef(pairingStateClazz); + jclass pairingStateClazz = search_class(env, _pairingStateClassName.c_str()); + pairingStateClazzRef = JNIGlobalRef(pairingStateClazz); env->DeleteLocalRef(pairingStateClazz); } - pairingStateClazzGet = jau::search_method(env, pairingStateClazzRef.getClass(), "get", _pairingStateClazzGetArgs.c_str(), true); + pairingStateClazzGet = search_method(env, pairingStateClazzRef.getClass(), "get", _pairingStateClazzGetArgs.c_str(), true); // deviceClazzRef, deviceClazzCtor { - jclass deviceClazz = jau::search_class(env, BTDevice::java_class().c_str()); - deviceClazzRef = jau::JNIGlobalRef(deviceClazz); + jclass deviceClazz = search_class(env, BTDevice::java_class().c_str()); + deviceClazzRef = JNIGlobalRef(deviceClazz); env->DeleteLocalRef(deviceClazz); } - deviceClazzCtor = jau::search_method(env, deviceClazzRef.getClass(), "<init>", _deviceClazzCtorArgs.c_str(), false); - - deviceClazzTSLastDiscoveryField = jau::search_field(env, deviceClazzRef.getClass(), "ts_last_discovery", "J", false); - deviceClazzTSLastUpdateField = jau::search_field(env, deviceClazzRef.getClass(), "ts_last_update", "J", false); - deviceClazzConnectionHandleField = jau::search_field(env, deviceClazzRef.getClass(), "hciConnHandle", "S", false); - - mAdapterSettingsChanged = jau::search_method(env, listenerClazz, "adapterSettingsChanged", _adapterSettingsChangedMethodArgs.c_str(), false); - mDiscoveringChanged = jau::search_method(env, listenerClazz, "discoveringChanged", _discoveringChangedMethodArgs.c_str(), false); - mDeviceFound = jau::search_method(env, listenerClazz, "deviceFound", _deviceFoundMethodArgs.c_str(), false); - mDeviceUpdated = jau::search_method(env, listenerClazz, "deviceUpdated", _deviceUpdatedMethodArgs.c_str(), false); - mDeviceConnected = jau::search_method(env, listenerClazz, "deviceConnected", _deviceConnectedMethodArgs.c_str(), false); - mDevicePairingState = jau::search_method(env, listenerClazz, "devicePairingState", _devicePairingStateMethodArgs.c_str(), false); - mDeviceReady = jau::search_method(env, listenerClazz, "deviceReady", _deviceReadyMethodArgs.c_str(), false); - mDeviceDisconnected = jau::search_method(env, listenerClazz, "deviceDisconnected", _deviceDisconnectedMethodArgs.c_str(), false); + deviceClazzCtor = search_method(env, deviceClazzRef.getClass(), "<init>", _deviceClazzCtorArgs.c_str(), false); + + deviceClazzTSLastDiscoveryField = search_field(env, deviceClazzRef.getClass(), "ts_last_discovery", "J", false); + deviceClazzTSLastUpdateField = search_field(env, deviceClazzRef.getClass(), "ts_last_update", "J", false); + deviceClazzConnectionHandleField = search_field(env, deviceClazzRef.getClass(), "hciConnHandle", "S", false); + + mAdapterSettingsChanged = search_method(env, listenerClazz, "adapterSettingsChanged", _adapterSettingsChangedMethodArgs.c_str(), false); + mDiscoveringChanged = search_method(env, listenerClazz, "discoveringChanged", _discoveringChangedMethodArgs.c_str(), false); + mDeviceFound = search_method(env, listenerClazz, "deviceFound", _deviceFoundMethodArgs.c_str(), false); + mDeviceUpdated = search_method(env, listenerClazz, "deviceUpdated", _deviceUpdatedMethodArgs.c_str(), false); + mDeviceConnected = search_method(env, listenerClazz, "deviceConnected", _deviceConnectedMethodArgs.c_str(), false); + mDevicePairingState = search_method(env, listenerClazz, "devicePairingState", _devicePairingStateMethodArgs.c_str(), false); + mDeviceReady = search_method(env, listenerClazz, "deviceReady", _deviceReadyMethodArgs.c_str(), false); + mDeviceDisconnected = search_method(env, listenerClazz, "deviceDisconnected", _deviceDisconnectedMethodArgs.c_str(), false); } void adapterSettingsChanged(BTAdapter &a, const AdapterSetting oldmask, const AdapterSetting newmask, const AdapterSetting changedmask, const uint64_t timestamp) override { - JNIEnv *env = *jau::jni_env; + JNIEnv *env = *jni_env; (void)a; - jau::JavaAnonRef asl_java = getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(asl_java, E_FILE_LINE); + JavaAnonRef asl_java = getJavaObject(); // hold until done! + JavaGlobalObj::check(asl_java, E_FILE_LINE); - jau::JavaAnonRef adapter_java = a.getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + JavaAnonRef adapter_java = a.getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); jobject adapterSettingOld = env->NewObject(adapterSettingsClazzRef.getClass(), adapterSettingsClazzCtor, (jint)oldmask); - jau::java_exception_check_and_throw(env, E_FILE_LINE); - jau::JNIGlobalRef::check(adapterSettingOld, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); + JNIGlobalRef::check(adapterSettingOld, E_FILE_LINE); jobject adapterSettingNew = env->NewObject(adapterSettingsClazzRef.getClass(), adapterSettingsClazzCtor, (jint)newmask); - jau::java_exception_check_and_throw(env, E_FILE_LINE); - jau::JNIGlobalRef::check(adapterSettingNew, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); + JNIGlobalRef::check(adapterSettingNew, E_FILE_LINE); jobject adapterSettingChanged = env->NewObject(adapterSettingsClazzRef.getClass(), adapterSettingsClazzCtor, (jint)changedmask); - jau::java_exception_check_and_throw(env, E_FILE_LINE); - jau::JNIGlobalRef::check(adapterSettingChanged, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); + JNIGlobalRef::check(adapterSettingChanged, E_FILE_LINE); - env->CallVoidMethod(jau::JavaGlobalObj::GetObject(asl_java), mAdapterSettingsChanged, - jau::JavaGlobalObj::GetObject(adapter_java), adapterSettingOld, adapterSettingNew, adapterSettingChanged, (jlong)timestamp); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + env->CallVoidMethod(JavaGlobalObj::GetObject(asl_java), mAdapterSettingsChanged, + JavaGlobalObj::GetObject(adapter_java), adapterSettingOld, adapterSettingNew, adapterSettingChanged, (jlong)timestamp); + java_exception_check_and_throw(env, E_FILE_LINE); env->DeleteLocalRef(adapterSettingOld); env->DeleteLocalRef(adapterSettingNew); env->DeleteLocalRef(adapterSettingChanged); } void discoveringChanged(BTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const DiscoveryPolicy policy, const uint64_t timestamp) override { - JNIEnv *env = *jau::jni_env; + JNIEnv *env = *jni_env; (void)a; - jau::JavaAnonRef asl_java = getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(asl_java, E_FILE_LINE); + JavaAnonRef asl_java = getJavaObject(); // hold until done! + JavaGlobalObj::check(asl_java, E_FILE_LINE); - jau::JavaAnonRef adapter_java = a.getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + JavaAnonRef adapter_java = a.getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); jobject jcurrentMeta = env->CallStaticObjectMethod(scanTypeClazzRef.getClass(), scanTypeClazzGet, (jbyte)number(currentMeta)); - jau::java_exception_check_and_throw(env, E_FILE_LINE); - jau::JNIGlobalRef::check(jcurrentMeta, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); + JNIGlobalRef::check(jcurrentMeta, E_FILE_LINE); jobject jchangedType = env->CallStaticObjectMethod(scanTypeClazzRef.getClass(), scanTypeClazzGet, (jbyte)number(changedType)); - jau::java_exception_check_and_throw(env, E_FILE_LINE); - jau::JNIGlobalRef::check(jchangedType, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); + JNIGlobalRef::check(jchangedType, E_FILE_LINE); jobject jdiscoveryPolicy = env->CallStaticObjectMethod(discoveryPolicyClazzRef.getClass(), discoveryPolicyClazzGet, (jbyte)number(policy)); - jau::java_exception_check_and_throw(env, E_FILE_LINE); - jau::JNIGlobalRef::check(jdiscoveryPolicy, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); + JNIGlobalRef::check(jdiscoveryPolicy, E_FILE_LINE); - env->CallVoidMethod(jau::JavaGlobalObj::GetObject(asl_java), mDiscoveringChanged, - jau::JavaGlobalObj::GetObject(adapter_java), + env->CallVoidMethod(JavaGlobalObj::GetObject(asl_java), mDiscoveringChanged, + JavaGlobalObj::GetObject(adapter_java), jcurrentMeta, jchangedType, (jboolean)changedEnabled, jdiscoveryPolicy, (jlong)timestamp); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); } private: @@ -267,24 +268,24 @@ class JNIAdapterStatusListener : public AdapterStatusListener { jobject newJavaBTDevice(JNIEnv *env, BTDeviceRef device, const uint64_t timestamp) { // DBTDevice(final long nativeInstance, final DBTAdapter adptr, final byte byteAddress[/*6*/], final byte byteAddressType, // final long ts_creation, final String name) - jau::JavaAnonRef adapter_java = device->getAdapter().getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + JavaAnonRef adapter_java = device->getAdapter().getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); const EUI48 & addr = device->getAddressAndType().address; jbyteArray jaddr = env->NewByteArray(sizeof(addr)); env->SetByteArrayRegion(jaddr, 0, sizeof(addr), (const jbyte*)(addr.b)); - jau::java_exception_check_and_throw(env, E_FILE_LINE); - const jstring name = jau::from_string_to_jstring(env, device->getName()); - jau::java_exception_check_and_throw(env, E_FILE_LINE); - jau::shared_ptr_ref<BTDevice> device_sref(device); // new instance to be released into new jobject + java_exception_check_and_throw(env, E_FILE_LINE); + const jstring name = from_string_to_jstring(env, device->getName()); + java_exception_check_and_throw(env, E_FILE_LINE); + shared_ptr_ref<BTDevice> device_sref(device); // new instance to be released into new jobject jobject tmp_jdevice = env->NewObject(deviceClazzRef.getClass(), deviceClazzCtor, - device_sref.release_to_jlong(), jau::JavaGlobalObj::GetObject(adapter_java), + device_sref.release_to_jlong(), JavaGlobalObj::GetObject(adapter_java), jaddr, device->getAddressAndType().type, (jlong)timestamp, name); - jau::java_exception_check_and_throw(env, E_FILE_LINE); - jau::JNIGlobalRef::check(tmp_jdevice, E_FILE_LINE); - jau::JavaAnonRef jDeviceRef1 = device->getJavaObject(); - jau::JavaGlobalObj::check(jDeviceRef1, E_FILE_LINE); - jobject jdevice = jau::JavaGlobalObj::GetObject(jDeviceRef1); + java_exception_check_and_throw(env, E_FILE_LINE); + JNIGlobalRef::check(tmp_jdevice, E_FILE_LINE); + JavaAnonRef jDeviceRef1 = device->getJavaObject(); + JavaGlobalObj::check(jDeviceRef1, E_FILE_LINE); + jobject jdevice = JavaGlobalObj::GetObject(jDeviceRef1); env->DeleteLocalRef(jaddr); env->DeleteLocalRef(name); env->DeleteLocalRef(tmp_jdevice); @@ -294,134 +295,134 @@ class JNIAdapterStatusListener : public AdapterStatusListener { public: bool deviceFound(BTDeviceRef device, const uint64_t timestamp) override { - JNIEnv *env = *jau::jni_env; - jau::JavaAnonRef asl_java = getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(asl_java, E_FILE_LINE); + JNIEnv *env = *jni_env; + JavaAnonRef asl_java = getJavaObject(); // hold until done! + JavaGlobalObj::check(asl_java, E_FILE_LINE); jobject jdevice; - jau::JavaAnonRef device_java = device->getJavaObject(); - if( jau::JavaGlobalObj::isValid(device_java) ) { + JavaAnonRef device_java = device->getJavaObject(); + if( JavaGlobalObj::isValid(device_java) ) { // Reuse Java instance - jdevice = jau::JavaGlobalObj::GetObject(device_java); + jdevice = JavaGlobalObj::GetObject(device_java); } else { jdevice = newJavaBTDevice(env, device, timestamp); } env->SetLongField(jdevice, deviceClazzTSLastDiscoveryField, (jlong)device->getLastDiscoveryTimestamp()); - jau::java_exception_check_and_throw(env, E_FILE_LINE); - jboolean res = env->CallBooleanMethod(jau::JavaGlobalObj::GetObject(asl_java), mDeviceFound, jdevice, (jlong)timestamp); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); + jboolean res = env->CallBooleanMethod(JavaGlobalObj::GetObject(asl_java), mDeviceFound, jdevice, (jlong)timestamp); + java_exception_check_and_throw(env, E_FILE_LINE); return JNI_TRUE == res; } void deviceUpdated(BTDeviceRef device, const EIRDataType updateMask, const uint64_t timestamp) override { - JNIEnv *env = *jau::jni_env; - jau::JavaAnonRef asl_java = getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(asl_java, E_FILE_LINE); + JNIEnv *env = *jni_env; + JavaAnonRef asl_java = getJavaObject(); // hold until done! + JavaGlobalObj::check(asl_java, E_FILE_LINE); - jau::JavaAnonRef device_java = device->getJavaObject(); - if( !jau::JavaGlobalObj::isValid(device_java) ) { + JavaAnonRef device_java = device->getJavaObject(); + if( !JavaGlobalObj::isValid(device_java) ) { return; // java device has been pulled } - env->SetLongField(jau::JavaGlobalObj::GetObject(device_java), deviceClazzTSLastUpdateField, (jlong)timestamp); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + env->SetLongField(JavaGlobalObj::GetObject(device_java), deviceClazzTSLastUpdateField, (jlong)timestamp); + java_exception_check_and_throw(env, E_FILE_LINE); jobject eirDataTypeSet = env->NewObject(eirDataTypeSetClazzRef.getClass(), eirDataTypeSetClazzCtor, (jint)updateMask); - jau::java_exception_check_and_throw(env, E_FILE_LINE); - jau::JNIGlobalRef::check(eirDataTypeSet, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); + JNIGlobalRef::check(eirDataTypeSet, E_FILE_LINE); - env->CallVoidMethod(jau::JavaGlobalObj::GetObject(asl_java), mDeviceUpdated, jau::JavaGlobalObj::GetObject(device_java), eirDataTypeSet, (jlong)timestamp); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + env->CallVoidMethod(JavaGlobalObj::GetObject(asl_java), mDeviceUpdated, JavaGlobalObj::GetObject(device_java), eirDataTypeSet, (jlong)timestamp); + java_exception_check_and_throw(env, E_FILE_LINE); env->DeleteLocalRef(eirDataTypeSet); } void deviceConnected(BTDeviceRef device, const bool discovered, const uint64_t timestamp) override { - JNIEnv *env = *jau::jni_env; - jau::JavaAnonRef asl_java = getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(asl_java, E_FILE_LINE); + JNIEnv *env = *jni_env; + JavaAnonRef asl_java = getJavaObject(); // hold until done! + JavaGlobalObj::check(asl_java, E_FILE_LINE); jobject jdevice; - jau::JavaAnonRef device_java = device->getJavaObject(); - if( jau::JavaGlobalObj::isValid(device_java) ) { + JavaAnonRef device_java = device->getJavaObject(); + if( JavaGlobalObj::isValid(device_java) ) { // Reuse Java instance - jdevice = jau::JavaGlobalObj::GetObject(device_java); + jdevice = JavaGlobalObj::GetObject(device_java); } else { jdevice = newJavaBTDevice(env, device, timestamp); } env->SetShortField(jdevice, deviceClazzConnectionHandleField, (jshort)device->getConnectionHandle()); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); env->SetLongField(jdevice, deviceClazzTSLastDiscoveryField, (jlong)device->getLastDiscoveryTimestamp()); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); env->SetLongField(jdevice, deviceClazzTSLastUpdateField, (jlong)timestamp); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); - env->CallVoidMethod(jau::JavaGlobalObj::GetObject(asl_java), mDeviceConnected, jdevice, (jboolean)discovered, (jlong)timestamp); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + env->CallVoidMethod(JavaGlobalObj::GetObject(asl_java), mDeviceConnected, jdevice, (jboolean)discovered, (jlong)timestamp); + java_exception_check_and_throw(env, E_FILE_LINE); } void devicePairingState(BTDeviceRef device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp) override { - JNIEnv *env = *jau::jni_env; - jau::JavaAnonRef asl_java = getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(asl_java, E_FILE_LINE); + JNIEnv *env = *jni_env; + JavaAnonRef asl_java = getJavaObject(); // hold until done! + JavaGlobalObj::check(asl_java, E_FILE_LINE); - jau::JavaAnonRef device_java = device->getJavaObject(); - if( !jau::JavaGlobalObj::isValid(device_java) ) { + JavaAnonRef device_java = device->getJavaObject(); + if( !JavaGlobalObj::isValid(device_java) ) { return; // java device has been pulled } - jobject jdevice = jau::JavaGlobalObj::GetObject(device_java); + jobject jdevice = JavaGlobalObj::GetObject(device_java); env->SetLongField(jdevice, deviceClazzTSLastUpdateField, (jlong)timestamp); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); jobject jstate = env->CallStaticObjectMethod(pairingStateClazzRef.getClass(), pairingStateClazzGet, static_cast<uint8_t>(state)); - jau::java_exception_check_and_throw(env, E_FILE_LINE); - jau::JNIGlobalRef::check(jstate, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); + JNIGlobalRef::check(jstate, E_FILE_LINE); jobject jmode = env->CallStaticObjectMethod(pairingModeClazzRef.getClass(), pairingModeClazzGet, static_cast<uint8_t>(mode)); - jau::java_exception_check_and_throw(env, E_FILE_LINE); - jau::JNIGlobalRef::check(jmode, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); + JNIGlobalRef::check(jmode, E_FILE_LINE); - env->CallVoidMethod(jau::JavaGlobalObj::GetObject(asl_java), mDevicePairingState, jdevice, jstate, jmode, (jlong)timestamp); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + env->CallVoidMethod(JavaGlobalObj::GetObject(asl_java), mDevicePairingState, jdevice, jstate, jmode, (jlong)timestamp); + java_exception_check_and_throw(env, E_FILE_LINE); } void deviceReady(BTDeviceRef device, const uint64_t timestamp) override { - JNIEnv *env = *jau::jni_env; - jau::JavaAnonRef asl_java = getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(asl_java, E_FILE_LINE); + JNIEnv *env = *jni_env; + JavaAnonRef asl_java = getJavaObject(); // hold until done! + JavaGlobalObj::check(asl_java, E_FILE_LINE); - jau::JavaAnonRef device_java = device->getJavaObject(); - if( !jau::JavaGlobalObj::isValid(device_java) ) { + JavaAnonRef device_java = device->getJavaObject(); + if( !JavaGlobalObj::isValid(device_java) ) { return; // java device has been pulled } - jobject jdevice = jau::JavaGlobalObj::GetObject(device_java); + jobject jdevice = JavaGlobalObj::GetObject(device_java); env->SetLongField(jdevice, deviceClazzTSLastUpdateField, (jlong)timestamp); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); - env->CallVoidMethod(jau::JavaGlobalObj::GetObject(asl_java), mDeviceReady, jdevice, (jlong)timestamp); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + env->CallVoidMethod(JavaGlobalObj::GetObject(asl_java), mDeviceReady, jdevice, (jlong)timestamp); + java_exception_check_and_throw(env, E_FILE_LINE); } void deviceDisconnected(BTDeviceRef device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp) override { - JNIEnv *env = *jau::jni_env; - jau::JavaAnonRef asl_java = getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(asl_java, E_FILE_LINE); + JNIEnv *env = *jni_env; + JavaAnonRef asl_java = getJavaObject(); // hold until done! + JavaGlobalObj::check(asl_java, E_FILE_LINE); - jau::JavaAnonRef device_java = device->getJavaObject(); - if( !jau::JavaGlobalObj::isValid(device_java) ) { + JavaAnonRef device_java = device->getJavaObject(); + if( !JavaGlobalObj::isValid(device_java) ) { return; // java device has been pulled } - jobject jdevice = jau::JavaGlobalObj::GetObject(device_java); + jobject jdevice = JavaGlobalObj::GetObject(device_java); env->SetLongField(jdevice, deviceClazzTSLastUpdateField, (jlong)timestamp); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); jobject hciErrorCode = env->CallStaticObjectMethod(hciStatusCodeClazzRef.getClass(), hciStatusCodeClazzGet, (jbyte)static_cast<uint8_t>(reason)); - jau::java_exception_check_and_throw(env, E_FILE_LINE); - jau::JNIGlobalRef::check(hciErrorCode, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); + JNIGlobalRef::check(hciErrorCode, E_FILE_LINE); env->SetShortField(jdevice, deviceClazzConnectionHandleField, (jshort)0); // zero out, disconnected - jau::java_exception_check_and_throw(env, E_FILE_LINE); + java_exception_check_and_throw(env, E_FILE_LINE); - env->CallVoidMethod(jau::JavaGlobalObj::GetObject(asl_java), mDeviceDisconnected, jdevice, hciErrorCode, (jshort)handle, (jlong)timestamp); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + env->CallVoidMethod(JavaGlobalObj::GetObject(asl_java), mDeviceDisconnected, jdevice, hciErrorCode, (jshort)handle, (jlong)timestamp); + java_exception_check_and_throw(env, E_FILE_LINE); } }; std::atomic<int> JNIAdapterStatusListener::iname_next(0); @@ -434,7 +435,7 @@ std::atomic<int> JNIAdapterStatusListener::iname_next(0); jlong Java_org_direct_1bt_AdapterStatusListener_ctorImpl(JNIEnv *env, jobject obj) { try { // new instance - jau::shared_ptr_ref<JNIAdapterStatusListener> ref( new JNIAdapterStatusListener(env, obj) ); + shared_ptr_ref<JNIAdapterStatusListener> ref( new JNIAdapterStatusListener(env, obj) ); return ref.release_to_jlong(); } catch(...) { @@ -452,9 +453,9 @@ jlong Java_org_direct_1bt_AdapterStatusListener_ctorImpl(JNIEnv *env, jobject ob void Java_org_direct_1bt_AdapterStatusListener_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance) { (void)obj; try { - jau::shared_ptr_ref<JNIAdapterStatusListener> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done + shared_ptr_ref<JNIAdapterStatusListener> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done if( nullptr != sref.pointer() ) { - std::shared_ptr<JNIAdapterStatusListener>* sref_ptr = jau::castInstance<JNIAdapterStatusListener>(nativeInstance); + std::shared_ptr<JNIAdapterStatusListener>* sref_ptr = castInstance<JNIAdapterStatusListener>(nativeInstance); delete sref_ptr; } } catch(...) { @@ -466,7 +467,7 @@ void Java_jau_direct_1bt_DBTAdapter_deleteImpl(JNIEnv *env, jobject obj, jlong n { (void)obj; try { - jau::shared_ptr_ref<BTAdapter> adapter(nativeInstance, false /* throw_on_nullptr */); // hold copy until done + shared_ptr_ref<BTAdapter> adapter(nativeInstance, false /* throw_on_nullptr */); // hold copy until done if( nullptr != adapter.pointer() ) { if( !adapter.is_null() ) { DBG_PRINT("Java_jau_direct_1bt_DBTAdapter_deleteImpl (w/ close) %s", adapter->toString().c_str()); @@ -474,7 +475,7 @@ void Java_jau_direct_1bt_DBTAdapter_deleteImpl(JNIEnv *env, jobject obj, jlong n } else { DBG_PRINT("Java_jau_direct_1bt_DBTAdapter_deleteImpl null reference"); } - std::shared_ptr<BTAdapter>* ref_ptr = jau::castInstance<BTAdapter>(nativeInstance); + std::shared_ptr<BTAdapter>* ref_ptr = castInstance<BTAdapter>(nativeInstance); delete ref_ptr; } else { DBG_PRINT("Java_jau_direct_1bt_DBTAdapter_deleteImpl null reference store"); @@ -487,17 +488,17 @@ void Java_jau_direct_1bt_DBTAdapter_deleteImpl(JNIEnv *env, jobject obj, jlong n jboolean Java_jau_direct_1bt_DBTAdapter_addStatusListenerImpl(JNIEnv *env, jobject obj, jobject jdeviceOwnerAndMatch, jobject jstatusListener) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); - jau::shared_ptr_ref<JNIAdapterStatusListener> asl(env, jstatusListener); // hold until done - jau::JavaAnonRef asl_java = asl->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(asl_java, E_FILE_LINE); + shared_ptr_ref<JNIAdapterStatusListener> asl(env, jstatusListener); // hold until done + JavaAnonRef asl_java = asl->getJavaObject(); // hold until done! + JavaGlobalObj::check(asl_java, E_FILE_LINE); - jau::shared_ptr_ref<BTDevice> deviceOwnerAndMatchRef(env, jdeviceOwnerAndMatch, false /* throw_on_nullptr */); + shared_ptr_ref<BTDevice> deviceOwnerAndMatchRef(env, jdeviceOwnerAndMatch, false /* throw_on_nullptr */); if( !deviceOwnerAndMatchRef.is_null() ) { - jau::JavaGlobalObj::check(deviceOwnerAndMatchRef->getJavaObject(), E_FILE_LINE); + JavaGlobalObj::check(deviceOwnerAndMatchRef->getJavaObject(), E_FILE_LINE); } bool addRes; @@ -519,13 +520,13 @@ jboolean Java_jau_direct_1bt_DBTAdapter_addStatusListenerImpl(JNIEnv *env, jobje jboolean Java_jau_direct_1bt_DBTAdapter_removeStatusListenerImpl(JNIEnv *env, jobject obj, jobject jstatusListener) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); - jau::shared_ptr_ref<JNIAdapterStatusListener> asl(env, jstatusListener); // hold until done - jau::JavaAnonRef asl_java = asl->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(asl_java, E_FILE_LINE); + shared_ptr_ref<JNIAdapterStatusListener> asl(env, jstatusListener); // hold until done + JavaAnonRef asl_java = asl->getJavaObject(); // hold until done! + JavaGlobalObj::check(asl_java, E_FILE_LINE); if( ! adapter->removeStatusListener( asl.shared_ptr() ) ) { WARN_PRINT("Failed to remove statusListener with nativeInstance: %p at %s", asl.shared_ptr().get(), adapter->toString().c_str()); @@ -540,9 +541,9 @@ jboolean Java_jau_direct_1bt_DBTAdapter_removeStatusListenerImpl(JNIEnv *env, jo jint Java_jau_direct_1bt_DBTAdapter_removeAllStatusListenerImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return adapter->removeAllStatusListener(); } catch(...) { rethrow_and_raise_java_exception(env); @@ -552,9 +553,9 @@ jint Java_jau_direct_1bt_DBTAdapter_removeAllStatusListenerImpl(JNIEnv *env, job jboolean Java_jau_direct_1bt_DBTAdapter_isDeviceWhitelisted(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); if( nullptr == jaddress ) { throw jau::IllegalArgumentException("address null", E_FILE_LINE); @@ -563,7 +564,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_isDeviceWhitelisted(JNIEnv *env, jobject if( sizeof(EUI48) > address_size ) { throw jau::IllegalArgumentException("address byte size "+std::to_string(address_size)+" < "+std::to_string(sizeof(EUI48)), E_FILE_LINE); } - jau::JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release + JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * address_ptr = criticalArray.get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == address_ptr ) { throw jau::InternalError("GetPrimitiveArrayCritical(address byte array) is null", E_FILE_LINE); @@ -582,9 +583,9 @@ jboolean Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl1(JNIEnv *env, j jshort min_interval, jshort max_interval, jshort latency, jshort timeout) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); if( nullptr == jaddress ) { throw jau::IllegalArgumentException("address null", E_FILE_LINE); @@ -593,7 +594,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl1(JNIEnv *env, j if( sizeof(EUI48) > address_size ) { throw jau::IllegalArgumentException("address byte size "+std::to_string(address_size)+" < "+std::to_string(sizeof(EUI48)), E_FILE_LINE); } - jau::JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release + JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * address_ptr = criticalArray.get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == address_ptr ) { throw jau::InternalError("GetPrimitiveArrayCritical(address byte array) is null", E_FILE_LINE); @@ -611,9 +612,9 @@ jboolean Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl1(JNIEnv *env, j jboolean Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl2(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType, int jctype) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); if( nullptr == jaddress ) { throw jau::IllegalArgumentException("address null", E_FILE_LINE); @@ -622,7 +623,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl2(JNIEnv *env, j if( sizeof(EUI48) > address_size ) { throw jau::IllegalArgumentException("address byte size "+std::to_string(address_size)+" < "+std::to_string(sizeof(EUI48)), E_FILE_LINE); } - jau::JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release + JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * address_ptr = criticalArray.get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == address_ptr ) { throw jau::InternalError("GetPrimitiveArrayCritical(address byte array) is null", E_FILE_LINE); @@ -639,9 +640,9 @@ jboolean Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl2(JNIEnv *env, j } jboolean Java_jau_direct_1bt_DBTAdapter_removeDeviceFromWhitelistImpl(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); if( nullptr == jaddress ) { throw jau::IllegalArgumentException("address null", E_FILE_LINE); @@ -650,7 +651,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_removeDeviceFromWhitelistImpl(JNIEnv *en if( sizeof(EUI48) > address_size ) { throw jau::IllegalArgumentException("address byte size "+std::to_string(address_size)+" < "+std::to_string(sizeof(EUI48)), E_FILE_LINE); } - jau::JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release + JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * address_ptr = criticalArray.get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == address_ptr ) { throw jau::InternalError("GetPrimitiveArrayCritical(address byte array) is null", E_FILE_LINE); @@ -667,11 +668,11 @@ jboolean Java_jau_direct_1bt_DBTAdapter_removeDeviceFromWhitelistImpl(JNIEnv *en jstring Java_jau_direct_1bt_DBTAdapter_toStringImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); - return jau::from_string_to_jstring(env, adapter->toString()); + return from_string_to_jstring(env, adapter->toString()); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -681,9 +682,9 @@ jstring Java_jau_direct_1bt_DBTAdapter_toStringImpl(JNIEnv *env, jobject obj) { jint Java_jau_direct_1bt_DBTAdapter_getBTMajorVersion(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return (jint) adapter->getBTMajorVersion(); } catch(...) { @@ -695,9 +696,9 @@ jint Java_jau_direct_1bt_DBTAdapter_getBTMajorVersion(JNIEnv *env, jobject obj) jboolean Java_jau_direct_1bt_DBTAdapter_isPoweredImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return adapter->isPowered(); } catch(...) { @@ -709,9 +710,9 @@ jboolean Java_jau_direct_1bt_DBTAdapter_isPoweredImpl(JNIEnv *env, jobject obj) jboolean Java_jau_direct_1bt_DBTAdapter_isSuspendedImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return adapter->isSuspended(); } catch(...) { @@ -723,9 +724,9 @@ jboolean Java_jau_direct_1bt_DBTAdapter_isSuspendedImpl(JNIEnv *env, jobject obj jboolean Java_jau_direct_1bt_DBTAdapter_isValidImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return adapter->isValid(); } catch(...) { @@ -737,9 +738,9 @@ jboolean Java_jau_direct_1bt_DBTAdapter_isValidImpl(JNIEnv *env, jobject obj) jlong Java_jau_direct_1bt_DBTAdapter_getLEFeaturesImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return (jlong) number( adapter->getLEFeatures() ); } catch(...) { @@ -754,9 +755,9 @@ jbyte Java_jau_direct_1bt_DBTAdapter_startDiscoveryImpl(JNIEnv *env, jobject obj jboolean filter_dup) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return (jbyte) number( adapter->startDiscovery(static_cast<DiscoveryPolicy>(policy), le_scan_active, le_scan_interval, le_scan_window, filter_policy, filter_dup==JNI_TRUE) ); } catch(...) { @@ -768,9 +769,9 @@ jbyte Java_jau_direct_1bt_DBTAdapter_startDiscoveryImpl(JNIEnv *env, jobject obj jbyte Java_jau_direct_1bt_DBTAdapter_stopDiscoveryImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return (jbyte) number( adapter->stopDiscovery() ); } catch(...) { @@ -782,9 +783,9 @@ jbyte Java_jau_direct_1bt_DBTAdapter_stopDiscoveryImpl(JNIEnv *env, jobject obj) jbyte Java_jau_direct_1bt_DBTAdapter_getCurrentDiscoveryPolicyImpl(JNIEnv *env, jobject obj) { DiscoveryPolicy current = DiscoveryPolicy::AUTO_OFF; try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); current = adapter->getCurrentDiscoveryPolicy(); } catch(...) { @@ -795,13 +796,13 @@ jbyte Java_jau_direct_1bt_DBTAdapter_getCurrentDiscoveryPolicyImpl(JNIEnv *env, jboolean Java_jau_direct_1bt_DBTAdapter_removeDevicePausingDiscovery(JNIEnv *env, jobject obj, jobject jdevice) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); - jau::shared_ptr_ref<BTDevice> device(env, jdevice); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(device_java, E_FILE_LINE); + shared_ptr_ref<BTDevice> device(env, jdevice); // hold until done + JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaGlobalObj::check(device_java, E_FILE_LINE); return adapter->removeDevicePausingDiscovery(*device) ? JNI_TRUE : JNI_FALSE; } catch(...) { @@ -813,9 +814,9 @@ jboolean Java_jau_direct_1bt_DBTAdapter_removeDevicePausingDiscovery(JNIEnv *env jbyte Java_jau_direct_1bt_DBTAdapter_getRoleImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return (jbyte) number( adapter->getRole() ); } catch(...) { @@ -827,9 +828,9 @@ jbyte Java_jau_direct_1bt_DBTAdapter_getRoleImpl(JNIEnv *env, jobject obj) jbyte Java_jau_direct_1bt_DBTAdapter_getBTModeImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return (jbyte) number( adapter->getBTMode() ); } catch(...) { @@ -841,9 +842,9 @@ jbyte Java_jau_direct_1bt_DBTAdapter_getBTModeImpl(JNIEnv *env, jobject obj) jobject Java_jau_direct_1bt_DBTAdapter_getDiscoveredDevicesImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); jau::darray<BTDeviceRef> array = adapter->getDiscoveredDevices(); return convert_vector_sharedptr_to_jarraylist(env, array); @@ -856,9 +857,9 @@ jobject Java_jau_direct_1bt_DBTAdapter_getDiscoveredDevicesImpl(JNIEnv *env, job jint Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDevicesImpl1(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return adapter->removeDiscoveredDevices(); } catch(...) { @@ -870,9 +871,9 @@ jint Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDevicesImpl1(JNIEnv *env, jo jboolean Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDeviceImpl1(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); if( nullptr == jaddress ) { throw jau::IllegalArgumentException("address null", E_FILE_LINE); @@ -881,7 +882,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDeviceImpl1(JNIEnv *env, if( sizeof(EUI48) > address_size ) { throw jau::IllegalArgumentException("address byte size "+std::to_string(address_size)+" < "+std::to_string(sizeof(EUI48)), E_FILE_LINE); } - jau::JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release + JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * address_ptr = criticalArray.get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == address_ptr ) { throw jau::InternalError("GetPrimitiveArrayCritical(address byte array) is null", E_FILE_LINE); @@ -902,9 +903,9 @@ jboolean Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDeviceImpl1(JNIEnv *env, jboolean Java_jau_direct_1bt_DBTAdapter_setPowered(JNIEnv *env, jobject obj, jboolean power_on) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return adapter->setPowered(JNI_TRUE == power_on ? true : false) ? JNI_TRUE : JNI_FALSE; } catch(...) { @@ -915,9 +916,9 @@ jboolean Java_jau_direct_1bt_DBTAdapter_setPowered(JNIEnv *env, jobject obj, jbo jboolean Java_jau_direct_1bt_DBTAdapter_getSecureConnectionsEnabled(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return adapter->getSecureConnectionsEnabled() ? JNI_TRUE : JNI_FALSE; } catch(...) { @@ -928,9 +929,9 @@ jboolean Java_jau_direct_1bt_DBTAdapter_getSecureConnectionsEnabled(JNIEnv *env, jbyte Java_jau_direct_1bt_DBTAdapter_setSecureConnectionsImpl(JNIEnv *env, jobject obj, jboolean enable) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); HCIStatusCode res = adapter->setSecureConnections(JNI_TRUE == enable ? true : false); return (jbyte) number(res); @@ -944,9 +945,9 @@ jbyte Java_jau_direct_1bt_DBTAdapter_setDefaultConnParamImpl(JNIEnv *env, jobjec jshort conn_interval_min, jshort conn_interval_max, jshort conn_latency, jshort supervision_timeout) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); HCIStatusCode res = adapter->setDefaultConnParam(static_cast<uint16_t>(conn_interval_min), static_cast<uint16_t>(conn_interval_max), @@ -961,9 +962,9 @@ jbyte Java_jau_direct_1bt_DBTAdapter_setDefaultConnParamImpl(JNIEnv *env, jobjec void Java_jau_direct_1bt_DBTAdapter_setServerConnSecurityImpl(JNIEnv *env, jobject obj, jbyte jsec_level, jbyte jio_cap) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); adapter->setServerConnSecurity( to_BTSecurityLevel( static_cast<uint8_t>(jsec_level) ), to_SMPIOCapability( static_cast<uint8_t>(jio_cap) ) ); @@ -974,11 +975,11 @@ void Java_jau_direct_1bt_DBTAdapter_setServerConnSecurityImpl(JNIEnv *env, jobje void Java_jau_direct_1bt_DBTAdapter_setSMPKeyPath(JNIEnv *env, jobject obj, jstring jpath) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); - std::string path = jau::from_jstring_to_string(env, jpath); + std::string path = from_jstring_to_string(env, jpath); adapter->setSMPKeyPath(path); } catch(...) { rethrow_and_raise_java_exception(env); @@ -987,9 +988,9 @@ void Java_jau_direct_1bt_DBTAdapter_setSMPKeyPath(JNIEnv *env, jobject obj, jstr jbyte Java_jau_direct_1bt_DBTAdapter_initializeImpl(JNIEnv *env, jobject obj, jbyte jbtMode) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); const BTMode btMode = static_cast<BTMode>(jbtMode); HCIStatusCode res = adapter->initialize(btMode); @@ -1002,9 +1003,9 @@ jbyte Java_jau_direct_1bt_DBTAdapter_initializeImpl(JNIEnv *env, jobject obj, jb jboolean Java_jau_direct_1bt_DBTAdapter_isInitialized(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return adapter->isInitialized(); } catch(...) { @@ -1015,9 +1016,9 @@ jboolean Java_jau_direct_1bt_DBTAdapter_isInitialized(JNIEnv *env, jobject obj) jbyte Java_jau_direct_1bt_DBTAdapter_resetImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); HCIStatusCode res = adapter->reset(); return (jbyte) number(res); @@ -1030,9 +1031,9 @@ jbyte Java_jau_direct_1bt_DBTAdapter_resetImpl(JNIEnv *env, jobject obj) { jbyte Java_jau_direct_1bt_DBTAdapter_setDefaultLE_1PHYImpl(JNIEnv *env, jobject obj, jbyte jTx, jbyte jRx) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); const LE_PHYs Tx = static_cast<LE_PHYs>(jTx); const LE_PHYs Rx = static_cast<LE_PHYs>(jRx); @@ -1046,11 +1047,11 @@ jbyte Java_jau_direct_1bt_DBTAdapter_setDefaultLE_1PHYImpl(JNIEnv *env, jobject jstring Java_jau_direct_1bt_DBTAdapter_getNameImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); - return jau::from_string_to_jstring(env, adapter->getName()); + return from_string_to_jstring(env, adapter->getName()); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -1059,11 +1060,11 @@ jstring Java_jau_direct_1bt_DBTAdapter_getNameImpl(JNIEnv *env, jobject obj) { jstring Java_jau_direct_1bt_DBTAdapter_getShortNameImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); - return jau::from_string_to_jstring(env, adapter->getShortName()); + return from_string_to_jstring(env, adapter->getShortName()); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -1072,12 +1073,12 @@ jstring Java_jau_direct_1bt_DBTAdapter_getShortNameImpl(JNIEnv *env, jobject obj jbyte Java_jau_direct_1bt_DBTAdapter_setNameImpl(JNIEnv *env, jobject obj, jstring jname, jstring jshort_name) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); - std::string name = jau::from_jstring_to_string(env, jname); - std::string short_name = jau::from_jstring_to_string(env, jshort_name); + std::string name = from_jstring_to_string(env, jname); + std::string short_name = from_jstring_to_string(env, jshort_name); return (jbyte) number( adapter->setName(name, short_name) ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -1087,9 +1088,9 @@ jbyte Java_jau_direct_1bt_DBTAdapter_setNameImpl(JNIEnv *env, jobject obj, jstri jobject Java_jau_direct_1bt_DBTAdapter_connectDeviceImpl(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); if( nullptr == jaddress ) { throw jau::IllegalArgumentException("address null", E_FILE_LINE); @@ -1098,7 +1099,7 @@ jobject Java_jau_direct_1bt_DBTAdapter_connectDeviceImpl(JNIEnv *env, jobject ob if( sizeof(EUI48) > address_size ) { throw jau::IllegalArgumentException("address byte size "+std::to_string(address_size)+" < "+std::to_string(sizeof(EUI48)), E_FILE_LINE); } - jau::JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release + JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * address_ptr = criticalArray.get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == address_ptr ) { throw jau::InternalError("GetPrimitiveArrayCritical(address byte array) is null", E_FILE_LINE); @@ -1115,11 +1116,11 @@ jobject Java_jau_direct_1bt_DBTAdapter_connectDeviceImpl(JNIEnv *env, jobject ob if( !hci.isOpen() ) { throw BTException("Adapter's HCI closed "+adapter->toString(), E_FILE_LINE); } - jau::JavaAnonRef jDeviceRef = device->getJavaObject(); - jau::JavaGlobalObj::check(jDeviceRef, E_FILE_LINE); + JavaAnonRef jDeviceRef = device->getJavaObject(); + JavaGlobalObj::check(jDeviceRef, E_FILE_LINE); device->connectDefault(); - return jau::JavaGlobalObj::GetObject(jDeviceRef); + return JavaGlobalObj::GetObject(jDeviceRef); } } catch(...) { rethrow_and_raise_java_exception(env); @@ -1129,9 +1130,9 @@ jobject Java_jau_direct_1bt_DBTAdapter_connectDeviceImpl(JNIEnv *env, jobject ob void Java_jau_direct_1bt_DBTAdapter_printDeviceListsImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); adapter->printDeviceLists(); } catch(...) { @@ -1147,13 +1148,13 @@ jbyte Java_jau_direct_1bt_DBTAdapter_startAdvertising1Impl(JNIEnv *env, jobject jshort adv_interval_min, jshort adv_interval_max, jbyte jadv_type, jbyte adv_chan_map, jbyte filter_policy) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); - jau::shared_ptr_ref<DBGattServer> gatt_server_ref(env, jgattServerData, false /** throw_on_null */); // hold until done + shared_ptr_ref<DBGattServer> gatt_server_ref(env, jgattServerData, false /** throw_on_null */); // hold until done gatt_server_ref.null_check1(); - jau::shared_ptr_ref<EInfoReport> eir_ref(env, jeir); // hold until done + shared_ptr_ref<EInfoReport> eir_ref(env, jeir); // hold until done const EIRDataType adv_mask = static_cast<EIRDataType>(jadv_mask); const EIRDataType scanrsp_mask = static_cast<EIRDataType>(jscanrsp_mask); @@ -1171,11 +1172,11 @@ jbyte Java_jau_direct_1bt_DBTAdapter_startAdvertising2Impl(JNIEnv *env, jobject jshort adv_interval_min, jshort adv_interval_max, jbyte jadv_type, jbyte adv_chan_map, jbyte filter_policy) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); - jau::shared_ptr_ref<DBGattServer> gatt_server_ref(env, jgattServerData, false /** throw_on_null */); // hold until done + shared_ptr_ref<DBGattServer> gatt_server_ref(env, jgattServerData, false /** throw_on_null */); // hold until done gatt_server_ref.null_check1(); const AD_PDU_Type adv_type = static_cast<AD_PDU_Type>(jadv_type); @@ -1189,9 +1190,9 @@ jbyte Java_jau_direct_1bt_DBTAdapter_startAdvertising2Impl(JNIEnv *env, jobject jbyte Java_jau_direct_1bt_DBTAdapter_stopAdvertisingImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); HCIStatusCode res = adapter->stopAdvertising(); return (jbyte) number(res); @@ -1203,9 +1204,9 @@ jbyte Java_jau_direct_1bt_DBTAdapter_stopAdvertisingImpl(JNIEnv *env, jobject ob jboolean Java_jau_direct_1bt_DBTAdapter_isAdvertising(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done - jau::JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(adapter_java, E_FILE_LINE); + shared_ptr_ref<BTAdapter> adapter(env, obj); // hold until done + JavaAnonRef adapter_java = adapter->getJavaObject(); // hold until done! + JavaGlobalObj::check(adapter_java, E_FILE_LINE); return adapter->isAdvertising() ? JNI_TRUE : JNI_FALSE; } catch(...) { diff --git a/java/jni/direct_bt/DBTDevice.cxx b/java/jni/direct_bt/DBTDevice.cxx index f054b4af..efd9e6ee 100644 --- a/java/jni/direct_bt/DBTDevice.cxx +++ b/java/jni/direct_bt/DBTDevice.cxx @@ -38,7 +38,7 @@ #include "direct_bt/BTGattService.hpp" using namespace direct_bt; -using namespace jau; +using namespace jau::jni; static const std::string _notificationReceivedMethodArgs("(Lorg/direct_bt/BTGattChar;[BJ)V"); static const std::string _indicationReceivedMethodArgs("(Lorg/direct_bt/BTGattChar;[BJZ)V"); @@ -70,7 +70,7 @@ class JNIGattCharListener : public BTGattCharListener { jclass listenerClazz = search_class(env, listenerObj.getObject()); java_exception_check_and_throw(env, E_FILE_LINE); if( nullptr == listenerClazz ) { - throw InternalError("BTGattCharListener not found", E_FILE_LINE); + throw jau::InternalError("BTGattCharListener not found", E_FILE_LINE); } mNotificationReceived = search_method(env, listenerClazz, "notificationReceived", _notificationReceivedMethodArgs.c_str(), false); @@ -81,13 +81,13 @@ class JNIGattCharListener : public BTGattCharListener { } void notificationReceived(BTGattCharRef charDecl, - const TROOctets& charValue, const uint64_t timestamp) override { - jau::JavaAnonRef jCharDeclRef = charDecl->getJavaObject(); - if( !jau::JavaGlobalObj::isValid(jCharDeclRef) ) { + const jau::TROOctets& charValue, const uint64_t timestamp) override { + JavaAnonRef jCharDeclRef = charDecl->getJavaObject(); + if( !JavaGlobalObj::isValid(jCharDeclRef) ) { return; // java object has been pulled } JNIEnv *env = *jni_env; - jobject jCharDecl = jau::JavaGlobalObj::GetObject(jCharDeclRef); + jobject jCharDecl = JavaGlobalObj::GetObject(jCharDeclRef); const size_t value_size = charValue.size(); jbyteArray jval = env->NewByteArray((jsize)value_size); @@ -101,14 +101,14 @@ class JNIGattCharListener : public BTGattCharListener { } void indicationReceived(BTGattCharRef charDecl, - const TROOctets& charValue, const uint64_t timestamp, + const jau::TROOctets& charValue, const uint64_t timestamp, const bool confirmationSent) override { - jau::JavaAnonRef jCharDeclRef = charDecl->getJavaObject(); - if( !jau::JavaGlobalObj::isValid(jCharDeclRef) ) { + JavaAnonRef jCharDeclRef = charDecl->getJavaObject(); + if( !JavaGlobalObj::isValid(jCharDeclRef) ) { return; // java object has been pulled } JNIEnv *env = *jni_env; - jobject jCharDecl = jau::JavaGlobalObj::GetObject(jCharDeclRef); + jobject jCharDecl = JavaGlobalObj::GetObject(jCharDeclRef); const size_t value_size = charValue.size(); jbyteArray jval = env->NewByteArray((jsize)value_size); @@ -130,7 +130,7 @@ class JNIGattCharListener : public BTGattCharListener { jlong Java_org_direct_1bt_BTGattCharListener_ctorImpl(JNIEnv *env, jobject obj) { try { // new instance - jau::shared_ptr_ref<JNIGattCharListener> ref( new JNIGattCharListener(env, obj) ); + shared_ptr_ref<JNIGattCharListener> ref( new JNIGattCharListener(env, obj) ); return ref.release_to_jlong(); } catch(...) { @@ -148,9 +148,9 @@ jlong Java_org_direct_1bt_BTGattCharListener_ctorImpl(JNIEnv *env, jobject obj) void Java_org_direct_1bt_BTGattCharListener_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance) { (void)obj; try { - jau::shared_ptr_ref<JNIGattCharListener> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done + shared_ptr_ref<JNIGattCharListener> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done if( nullptr != sref.pointer() ) { - std::shared_ptr<JNIGattCharListener>* sref_ptr = jau::castInstance<JNIGattCharListener>(nativeInstance); + std::shared_ptr<JNIGattCharListener>* sref_ptr = castInstance<JNIGattCharListener>(nativeInstance); delete sref_ptr; } } catch(...) { @@ -162,7 +162,7 @@ void Java_jau_direct_1bt_DBTDevice_deleteImpl(JNIEnv *env, jobject obj, jlong na { (void)obj; try { - jau::shared_ptr_ref<BTDevice> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done + shared_ptr_ref<BTDevice> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done if( nullptr != sref.pointer() ) { if( !sref.is_null() ) { DBG_PRINT("Java_jau_direct_1bt_DBTDevice_deleteImpl (w/ remove) %s", sref->toString().c_str()); @@ -170,7 +170,7 @@ void Java_jau_direct_1bt_DBTDevice_deleteImpl(JNIEnv *env, jobject obj, jlong na } else { DBG_PRINT("Java_jau_direct_1bt_DBTDevice_deleteImpl null reference"); } - std::shared_ptr<BTDevice>* sref_ptr = jau::castInstance<BTDevice>(nativeInstance); + std::shared_ptr<BTDevice>* sref_ptr = castInstance<BTDevice>(nativeInstance); delete sref_ptr; } else { DBG_PRINT("Java_jau_direct_1bt_DBTDevice_deleteImpl null reference store"); @@ -184,7 +184,7 @@ void Java_jau_direct_1bt_DBTDevice_initImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); } catch(...) { rethrow_and_raise_java_exception(env); @@ -194,7 +194,7 @@ void Java_jau_direct_1bt_DBTDevice_initImpl(JNIEnv *env, jobject obj) jstring Java_jau_direct_1bt_DBTDevice_getNameImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return from_string_to_jstring(env, device->getName()); } catch(...) { @@ -206,7 +206,7 @@ jstring Java_jau_direct_1bt_DBTDevice_getNameImpl(JNIEnv *env, jobject obj) { jstring Java_jau_direct_1bt_DBTDevice_toStringImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return from_string_to_jstring(env, device->toString()); } catch(...) { @@ -223,16 +223,16 @@ jstring Java_jau_direct_1bt_DBTDevice_toStringImpl(JNIEnv *env, jobject obj) { jboolean Java_jau_direct_1bt_DBTDevice_addCharListenerImpl(JNIEnv *env, jobject obj, jobject jlistener, jobject jAssociatedCharacteristic) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); - jau::shared_ptr_ref<JNIGattCharListener> gcl(env, jlistener); // hold until done - jau::JavaAnonRef gcl_java = gcl->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(gcl_java, E_FILE_LINE); + shared_ptr_ref<JNIGattCharListener> gcl(env, jlistener); // hold until done + JavaAnonRef gcl_java = gcl->getJavaObject(); // hold until done! + JavaGlobalObj::check(gcl_java, E_FILE_LINE); - jau::shared_ptr_ref<BTGattChar> charMatchRef(env, jAssociatedCharacteristic, false /* throw_on_nullptr */); + shared_ptr_ref<BTGattChar> charMatchRef(env, jAssociatedCharacteristic, false /* throw_on_nullptr */); if( !charMatchRef.is_null() ) { - jau::JavaGlobalObj::check(charMatchRef->getJavaObject(), E_FILE_LINE); + JavaGlobalObj::check(charMatchRef->getJavaObject(), E_FILE_LINE); } std::shared_ptr<BTGattHandler> gatt = device->getGattHandler(); @@ -264,12 +264,12 @@ jboolean Java_jau_direct_1bt_DBTDevice_removeCharListener(JNIEnv *env, jobject o // OK to have device being deleted already @ shutdown return JNI_FALSE; } - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); - jau::shared_ptr_ref<JNIGattCharListener> gcl(env, jlistener); // hold until done - jau::JavaAnonRef gcl_java = gcl->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(gcl_java, E_FILE_LINE); + shared_ptr_ref<JNIGattCharListener> gcl(env, jlistener); // hold until done + JavaAnonRef gcl_java = gcl->getJavaObject(); // hold until done! + JavaGlobalObj::check(gcl_java, E_FILE_LINE); std::shared_ptr<BTGattHandler> gatt = device->getGattHandler(); if( nullptr == gatt ) { @@ -296,11 +296,11 @@ jint Java_jau_direct_1bt_DBTDevice_removeAllAssociatedCharListener(JNIEnv *env, // OK to have device being deleted already @ shutdown return 0; } - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); shared_ptr_ref<BTGattChar> associatedCharacteristicRef(env, jAssociatedCharacteristic); - jau::JavaAnonRef device_gattchar = associatedCharacteristicRef->getJavaObject(); // hold until done! + JavaAnonRef device_gattchar = associatedCharacteristicRef->getJavaObject(); // hold until done! JavaGlobalObj::check(device_gattchar, E_FILE_LINE); std::shared_ptr<BTGattHandler> gatt = device->getGattHandler(); @@ -324,7 +324,7 @@ jint Java_jau_direct_1bt_DBTDevice_removeAllCharListener(JNIEnv *env, jobject ob // OK to have device being deleted already @ shutdown return 0; } - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); std::shared_ptr<BTGattHandler> gatt = device->getGattHandler(); @@ -344,7 +344,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_getRoleImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return (jbyte) number( device->getRole() ); } catch(...) { @@ -357,34 +357,34 @@ jbyte Java_jau_direct_1bt_DBTDevice_getConnectedLE_1PHYImpl(JNIEnv *env, jobject jbyteArray jresTx, jbyteArray jresRx) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); if( nullptr == jresTx ) { - throw IllegalArgumentException("resTx byte array null", E_FILE_LINE); + throw jau::IllegalArgumentException("resTx byte array null", E_FILE_LINE); } if( nullptr == jresRx ) { - throw IllegalArgumentException("resRx byte array null", E_FILE_LINE); + throw jau::IllegalArgumentException("resRx byte array null", E_FILE_LINE); } const size_t resTx_size = env->GetArrayLength(jresTx); if( 1 > resTx_size ) { - throw IllegalArgumentException("resTx byte array "+std::to_string(resTx_size)+" < 1", E_FILE_LINE); + throw jau::IllegalArgumentException("resTx byte array "+std::to_string(resTx_size)+" < 1", E_FILE_LINE); } const size_t resRx_size = env->GetArrayLength(jresRx); if( 1 > resRx_size ) { - throw IllegalArgumentException("resRx byte array "+std::to_string(resRx_size)+" < 1", E_FILE_LINE); + throw jau::IllegalArgumentException("resRx byte array "+std::to_string(resRx_size)+" < 1", E_FILE_LINE); } JNICriticalArray<uint8_t, jbyteArray> criticalArrayTx(env); // RAII - release uint8_t * resTx_ptr = criticalArrayTx.get(jresTx, criticalArrayTx.Mode::UPDATE_AND_RELEASE); if( NULL == resTx_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(resTx byte array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(resTx byte array) is null", E_FILE_LINE); } JNICriticalArray<uint8_t, jbyteArray> criticalArrayRx(env); // RAII - release uint8_t * resRx_ptr = criticalArrayRx.get(jresRx, criticalArrayTx.Mode::UPDATE_AND_RELEASE); if( NULL == resRx_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(resRx byte array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(resRx byte array) is null", E_FILE_LINE); } LE_PHYs& resTx = *reinterpret_cast<LE_PHYs *>(resTx_ptr); @@ -401,7 +401,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_setConnectedLE_1PHYImpl(JNIEnv *env, jobject jbyte jTx, jbyte jRx) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); const LE_PHYs Tx = static_cast<LE_PHYs>(jTx); @@ -417,7 +417,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_setConnectedLE_1PHYImpl(JNIEnv *env, jobject jbyte Java_jau_direct_1bt_DBTDevice_getTxPhysImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return number( device->getTxPhys() ); @@ -430,7 +430,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_getTxPhysImpl(JNIEnv *env, jobject obj) { jbyte Java_jau_direct_1bt_DBTDevice_getRxPhysImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return number( device->getRxPhys() ); @@ -444,7 +444,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_disconnectImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return (jint) number( device->disconnect() ); } catch(...) { @@ -457,7 +457,7 @@ jboolean Java_jau_direct_1bt_DBTDevice_removeImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); device->remove(); } catch(...) { @@ -470,7 +470,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_connectDefaultImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return (jbyte) number( device->connectDefault() ); } catch(...) { @@ -483,7 +483,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_connectLEImpl0(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); HCIStatusCode res = device->connectLE(); return (jbyte) number(res); @@ -500,7 +500,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_connectLEImpl1(JNIEnv *env, jobject obj, { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); HCIStatusCode res = device->connectLE(interval, window, min_interval, max_interval, latency, timeout); return (jbyte) number(res); @@ -513,7 +513,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_connectLEImpl1(JNIEnv *env, jobject obj, jbyte Java_jau_direct_1bt_DBTDevice_getAvailableSMPKeysImpl(JNIEnv *env, jobject obj, jboolean responder) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return number( device->getAvailableSMPKeys(JNI_TRUE == responder) ); @@ -526,7 +526,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_getAvailableSMPKeysImpl(JNIEnv *env, jobject jbyte Java_jau_direct_1bt_DBTDevice_uploadKeysImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return number( device->uploadKeys() ); @@ -539,20 +539,20 @@ jbyte Java_jau_direct_1bt_DBTDevice_uploadKeysImpl(JNIEnv *env, jobject obj) { void Java_jau_direct_1bt_DBTDevice_getLongTermKeyImpl(JNIEnv *env, jobject obj, jboolean responder, jbyteArray jsink) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); if( nullptr == jsink ) { - throw IllegalArgumentException("byte array null", E_FILE_LINE); + throw jau::IllegalArgumentException("byte array null", E_FILE_LINE); } const size_t sink_size = env->GetArrayLength(jsink); if( sizeof(SMPLongTermKey) > sink_size ) { - throw IllegalArgumentException("byte array "+std::to_string(sink_size)+" < "+std::to_string(sizeof(SMPLongTermKey)), E_FILE_LINE); + throw jau::IllegalArgumentException("byte array "+std::to_string(sink_size)+" < "+std::to_string(sizeof(SMPLongTermKey)), E_FILE_LINE); } JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * sink_ptr = criticalArray.get(jsink, criticalArray.Mode::UPDATE_AND_RELEASE); if( NULL == sink_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); } SMPLongTermKey& ltk_sink = *reinterpret_cast<SMPLongTermKey *>(sink_ptr); ltk_sink = device->getLongTermKey(JNI_TRUE == responder); // assign data of new key copy to JNI critical-array @@ -564,20 +564,20 @@ void Java_jau_direct_1bt_DBTDevice_getLongTermKeyImpl(JNIEnv *env, jobject obj, void Java_jau_direct_1bt_DBTDevice_setLongTermKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); if( nullptr == jsource ) { - throw IllegalArgumentException("byte array null", E_FILE_LINE); + throw jau::IllegalArgumentException("byte array null", E_FILE_LINE); } const size_t source_size = env->GetArrayLength(jsource); if( sizeof(SMPLongTermKey) > source_size ) { - throw IllegalArgumentException("byte array "+std::to_string(source_size)+" < "+std::to_string(sizeof(SMPLongTermKey)), E_FILE_LINE); + throw jau::IllegalArgumentException("byte array "+std::to_string(source_size)+" < "+std::to_string(sizeof(SMPLongTermKey)), E_FILE_LINE); } JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * source_ptr = criticalArray.get(jsource, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == source_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); } const SMPLongTermKey& ltk = *reinterpret_cast<SMPLongTermKey *>(source_ptr); @@ -590,20 +590,20 @@ void Java_jau_direct_1bt_DBTDevice_setLongTermKeyImpl(JNIEnv *env, jobject obj, void Java_jau_direct_1bt_DBTDevice_getIdentityResolvingKeyImpl(JNIEnv *env, jobject obj, jboolean responder, jbyteArray jsink) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); if( nullptr == jsink ) { - throw IllegalArgumentException("byte array null", E_FILE_LINE); + throw jau::IllegalArgumentException("byte array null", E_FILE_LINE); } const size_t sink_size = env->GetArrayLength(jsink); if( sizeof(SMPIdentityResolvingKey) > sink_size ) { - throw IllegalArgumentException("byte array "+std::to_string(sink_size)+" < "+std::to_string(sizeof(SMPIdentityResolvingKey)), E_FILE_LINE); + throw jau::IllegalArgumentException("byte array "+std::to_string(sink_size)+" < "+std::to_string(sizeof(SMPIdentityResolvingKey)), E_FILE_LINE); } JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * sink_ptr = criticalArray.get(jsink, criticalArray.Mode::UPDATE_AND_RELEASE); if( NULL == sink_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); } SMPIdentityResolvingKey& irk_sink = *reinterpret_cast<SMPIdentityResolvingKey *>(sink_ptr); irk_sink = device->getIdentityResolvingKey(JNI_TRUE == responder); // assign data of new key copy to JNI critical-array @@ -615,20 +615,20 @@ void Java_jau_direct_1bt_DBTDevice_getIdentityResolvingKeyImpl(JNIEnv *env, jobj void Java_jau_direct_1bt_DBTDevice_setIdentityResolvingKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); if( nullptr == jsource ) { - throw IllegalArgumentException("byte array null", E_FILE_LINE); + throw jau::IllegalArgumentException("byte array null", E_FILE_LINE); } const size_t source_size = env->GetArrayLength(jsource); if( sizeof(SMPIdentityResolvingKey) > source_size ) { - throw IllegalArgumentException("byte array "+std::to_string(source_size)+" < "+std::to_string(sizeof(SMPIdentityResolvingKey)), E_FILE_LINE); + throw jau::IllegalArgumentException("byte array "+std::to_string(source_size)+" < "+std::to_string(sizeof(SMPIdentityResolvingKey)), E_FILE_LINE); } JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * source_ptr = criticalArray.get(jsource, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == source_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); } const SMPIdentityResolvingKey& irk = *reinterpret_cast<SMPIdentityResolvingKey *>(source_ptr); @@ -641,20 +641,20 @@ void Java_jau_direct_1bt_DBTDevice_setIdentityResolvingKeyImpl(JNIEnv *env, jobj void Java_jau_direct_1bt_DBTDevice_getSignatureResolvingKeyImpl(JNIEnv *env, jobject obj, jboolean responder, jbyteArray jsink) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); if( nullptr == jsink ) { - throw IllegalArgumentException("byte array null", E_FILE_LINE); + throw jau::IllegalArgumentException("byte array null", E_FILE_LINE); } const size_t sink_size = env->GetArrayLength(jsink); if( sizeof(SMPSignatureResolvingKey) > sink_size ) { - throw IllegalArgumentException("byte array "+std::to_string(sink_size)+" < "+std::to_string(sizeof(SMPSignatureResolvingKey)), E_FILE_LINE); + throw jau::IllegalArgumentException("byte array "+std::to_string(sink_size)+" < "+std::to_string(sizeof(SMPSignatureResolvingKey)), E_FILE_LINE); } JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * sink_ptr = criticalArray.get(jsink, criticalArray.Mode::UPDATE_AND_RELEASE); if( NULL == sink_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); } SMPSignatureResolvingKey& irk_sink = *reinterpret_cast<SMPSignatureResolvingKey *>(sink_ptr); irk_sink = device->getSignatureResolvingKey(JNI_TRUE == responder); // assign data of new key copy to JNI critical-array @@ -666,20 +666,20 @@ void Java_jau_direct_1bt_DBTDevice_getSignatureResolvingKeyImpl(JNIEnv *env, job void Java_jau_direct_1bt_DBTDevice_setSignatureResolvingKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); if( nullptr == jsource ) { - throw IllegalArgumentException("byte array null", E_FILE_LINE); + throw jau::IllegalArgumentException("byte array null", E_FILE_LINE); } const size_t source_size = env->GetArrayLength(jsource); if( sizeof(SMPSignatureResolvingKey) > source_size ) { - throw IllegalArgumentException("byte array "+std::to_string(source_size)+" < "+std::to_string(sizeof(SMPSignatureResolvingKey)), E_FILE_LINE); + throw jau::IllegalArgumentException("byte array "+std::to_string(source_size)+" < "+std::to_string(sizeof(SMPSignatureResolvingKey)), E_FILE_LINE); } JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * source_ptr = criticalArray.get(jsource, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == source_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); } const SMPSignatureResolvingKey& irk = *reinterpret_cast<SMPSignatureResolvingKey *>(source_ptr); @@ -692,20 +692,20 @@ void Java_jau_direct_1bt_DBTDevice_setSignatureResolvingKeyImpl(JNIEnv *env, job void Java_jau_direct_1bt_DBTDevice_getLinkKeyImpl(JNIEnv *env, jobject obj, jboolean responder, jbyteArray jsink) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); if( nullptr == jsink ) { - throw IllegalArgumentException("byte array null", E_FILE_LINE); + throw jau::IllegalArgumentException("byte array null", E_FILE_LINE); } const size_t sink_size = env->GetArrayLength(jsink); if( sizeof(SMPLinkKey) > sink_size ) { - throw IllegalArgumentException("byte array "+std::to_string(sink_size)+" < "+std::to_string(sizeof(SMPLinkKey)), E_FILE_LINE); + throw jau::IllegalArgumentException("byte array "+std::to_string(sink_size)+" < "+std::to_string(sizeof(SMPLinkKey)), E_FILE_LINE); } JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * sink_ptr = criticalArray.get(jsink, criticalArray.Mode::UPDATE_AND_RELEASE); if( NULL == sink_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); } SMPLinkKey& lk_sink = *reinterpret_cast<SMPLinkKey *>(sink_ptr); lk_sink = device->getLinkKey(JNI_TRUE == responder); // assign data of new key copy to JNI critical-array @@ -717,20 +717,20 @@ void Java_jau_direct_1bt_DBTDevice_getLinkKeyImpl(JNIEnv *env, jobject obj, jboo void Java_jau_direct_1bt_DBTDevice_setLinkKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); if( nullptr == jsource ) { - throw IllegalArgumentException("byte array null", E_FILE_LINE); + throw jau::IllegalArgumentException("byte array null", E_FILE_LINE); } const size_t source_size = env->GetArrayLength(jsource); if( sizeof(SMPLinkKey) > source_size ) { - throw IllegalArgumentException("byte array "+std::to_string(source_size)+" < "+std::to_string(sizeof(SMPLinkKey)), E_FILE_LINE); + throw jau::IllegalArgumentException("byte array "+std::to_string(source_size)+" < "+std::to_string(sizeof(SMPLinkKey)), E_FILE_LINE); } JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * source_ptr = criticalArray.get(jsource, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == source_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); } const SMPLinkKey& lk = *reinterpret_cast<SMPLinkKey *>(source_ptr); @@ -743,7 +743,7 @@ void Java_jau_direct_1bt_DBTDevice_setLinkKeyImpl(JNIEnv *env, jobject obj, jbyt jbyte Java_jau_direct_1bt_DBTDevice_unpairImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); HCIStatusCode res = device->unpair(); return (jbyte) number(res); @@ -756,7 +756,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_unpairImpl(JNIEnv *env, jobject obj) { jbyte Java_jau_direct_1bt_DBTDevice_getConnSecurityLevelImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return number( device->getConnSecurityLevel() ); @@ -769,7 +769,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_getConnSecurityLevelImpl(JNIEnv *env, jobjec jbyte Java_jau_direct_1bt_DBTDevice_getConnIOCapabilityImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return number( device->getConnIOCapability() ); @@ -782,7 +782,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_getConnIOCapabilityImpl(JNIEnv *env, jobject jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityImpl(JNIEnv *env, jobject obj, jbyte jsec_level, jbyte jio_cap) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return device->setConnSecurity( to_BTSecurityLevel( static_cast<uint8_t>(jsec_level) ), @@ -796,7 +796,7 @@ jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityImpl(JNIEnv *env, jobject jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityAutoImpl(JNIEnv *env, jobject obj, jbyte jio_cap) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return device->setConnSecurityAuto( to_SMPIOCapability( static_cast<uint8_t>(jio_cap) ) ); @@ -809,7 +809,7 @@ jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityAutoImpl(JNIEnv *env, jobj jboolean Java_jau_direct_1bt_DBTDevice_isConnSecurityAutoEnabled(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return device->isConnSecurityAutoEnabled(); @@ -822,7 +822,7 @@ jboolean Java_jau_direct_1bt_DBTDevice_isConnSecurityAutoEnabled(JNIEnv *env, jo jbyte Java_jau_direct_1bt_DBTDevice_getPairingModeImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return number( device->getPairingMode() ); @@ -835,7 +835,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_getPairingModeImpl(JNIEnv *env, jobject obj) jbyte Java_jau_direct_1bt_DBTDevice_getPairingStateImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return static_cast<uint8_t>( device->getPairingState() ); @@ -848,7 +848,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_getPairingStateImpl(JNIEnv *env, jobject obj jbyte Java_jau_direct_1bt_DBTDevice_setPairingPasskeyImpl(JNIEnv *env, jobject obj, jint jpasskey) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return number( device->setPairingPasskey( static_cast<uint32_t>(jpasskey) ) ); @@ -861,7 +861,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_setPairingPasskeyImpl(JNIEnv *env, jobject o jbyte Java_jau_direct_1bt_DBTDevice_setPairingPasskeyNegativeImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return number( device->setPairingPasskeyNegative() ); @@ -874,7 +874,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_setPairingPasskeyNegativeImpl(JNIEnv *env, j jbyte Java_jau_direct_1bt_DBTDevice_setPairingNumericComparisonImpl(JNIEnv *env, jobject obj, jboolean jequal) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return number( device->setPairingNumericComparison( JNI_TRUE == jequal ? true : false ) ); @@ -893,7 +893,7 @@ static const std::string _serviceClazzCtorArgs("(JLjau/direct_bt/DBTDevice;ZLjav jobject Java_jau_direct_1bt_DBTDevice_getGattServicesImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); jau::darray<BTGattServiceRef> services = device->getGattServices(); // implicit GATT connect and discovery if required incl GenericAccess retrieval @@ -911,7 +911,7 @@ jobject Java_jau_direct_1bt_DBTDevice_getGattServicesImpl(JNIEnv *env, jobject o if( nullptr == _device ) { throw jau::RuntimeException("Service's device null: "+service->toString(), E_FILE_LINE); } - jau::JavaAnonRef _device_java = _device->getJavaObject(); // hold until done! + JavaAnonRef _device_java = _device->getJavaObject(); // hold until done! JavaGlobalObj::check(_device_java, E_FILE_LINE); jobject jdevice = JavaGlobalObj::GetObject(_device_java); @@ -924,7 +924,7 @@ jobject Java_jau_direct_1bt_DBTDevice_getGattServicesImpl(JNIEnv *env, jobject o juuid, service->handle, service->end_handle); java_exception_check_and_throw(env_, E_FILE_LINE); JNIGlobalRef::check(jservice, E_FILE_LINE); - jau::JavaAnonRef jServiceRef = service->getJavaObject(); // GlobalRef + JavaAnonRef jServiceRef = service->getJavaObject(); // GlobalRef JavaGlobalObj::check(jServiceRef, E_FILE_LINE); env_->DeleteLocalRef(juuid); env_->DeleteLocalRef(jservice); @@ -941,11 +941,11 @@ jobject Java_jau_direct_1bt_DBTDevice_getGattServicesImpl(JNIEnv *env, jobject o jboolean Java_jau_direct_1bt_DBTDevice_sendNotification(JNIEnv *env, jobject obj, jshort char_value_handle, jbyteArray jval) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); if( nullptr == jval ) { - throw IllegalArgumentException("byte array null", E_FILE_LINE); + throw jau::IllegalArgumentException("byte array null", E_FILE_LINE); } const size_t value_size = env->GetArrayLength(jval); if( 0 >= value_size ) { @@ -954,9 +954,9 @@ jboolean Java_jau_direct_1bt_DBTDevice_sendNotification(JNIEnv *env, jobject obj JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * value_ptr = criticalArray.get(jval, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == value_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); } - const jau::TROOctets value(value_ptr, value_size, endian::little); + const jau::TROOctets value(value_ptr, value_size, jau::endian::little); return device->sendNotification(char_value_handle, value) ? JNI_TRUE : JNI_FALSE; } catch(...) { rethrow_and_raise_java_exception(env); @@ -967,11 +967,11 @@ jboolean Java_jau_direct_1bt_DBTDevice_sendNotification(JNIEnv *env, jobject obj jboolean Java_jau_direct_1bt_DBTDevice_sendIndication(JNIEnv *env, jobject obj, jshort char_value_handle, jbyteArray jval) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); if( nullptr == jval ) { - throw IllegalArgumentException("byte array null", E_FILE_LINE); + throw jau::IllegalArgumentException("byte array null", E_FILE_LINE); } const size_t value_size = env->GetArrayLength(jval); if( 0 >= value_size ) { @@ -980,9 +980,9 @@ jboolean Java_jau_direct_1bt_DBTDevice_sendIndication(JNIEnv *env, jobject obj, JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * value_ptr = criticalArray.get(jval, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == value_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); } - const jau::TROOctets value(value_ptr, value_size, endian::little); + const jau::TROOctets value(value_ptr, value_size, jau::endian::little); return device->sendIndication(char_value_handle, value) ? JNI_TRUE : JNI_FALSE; } catch(...) { rethrow_and_raise_java_exception(env); @@ -994,7 +994,7 @@ jboolean Java_jau_direct_1bt_DBTDevice_pingGATTImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return device->pingGATT() ? JNI_TRUE : JNI_FALSE; @@ -1008,7 +1008,7 @@ jshort Java_jau_direct_1bt_DBTDevice_getRSSI(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return (jshort) device->getRSSI(); } catch(...) { @@ -1020,7 +1020,7 @@ jshort Java_jau_direct_1bt_DBTDevice_getRSSI(JNIEnv *env, jobject obj) void Java_jau_direct_1bt_DBTDevice_getEIRImpl(JNIEnv *env, jobject obj, jobject jeir_sink) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); shared_ptr_ref<EInfoReport> eir_sink(env, jeir_sink); @@ -1036,7 +1036,7 @@ void Java_jau_direct_1bt_DBTDevice_getEIRImpl(JNIEnv *env, jobject obj, jobject void Java_jau_direct_1bt_DBTDevice_getEIRIndImpl(JNIEnv *env, jobject obj, jobject jeir_sink) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); shared_ptr_ref<EInfoReport> eir_sink(env, jeir_sink); @@ -1052,7 +1052,7 @@ void Java_jau_direct_1bt_DBTDevice_getEIRIndImpl(JNIEnv *env, jobject obj, jobje void Java_jau_direct_1bt_DBTDevice_getEIRScanRspImpl(JNIEnv *env, jobject obj, jobject jeir_sink) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); shared_ptr_ref<EInfoReport> eir_sink(env, jeir_sink); @@ -1069,7 +1069,7 @@ jshort Java_jau_direct_1bt_DBTDevice_getTxPower(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTDevice> device(env, obj); // hold until done - jau::JavaAnonRef device_java = device->getJavaObject(); // hold until done! + JavaAnonRef device_java = device->getJavaObject(); // hold until done! JavaGlobalObj::check(device_java, E_FILE_LINE); return (jshort) device->getTxPower(); } catch(...) { diff --git a/java/jni/direct_bt/DBTGattChar.cxx b/java/jni/direct_bt/DBTGattChar.cxx index c438851a..3c8d20ef 100644 --- a/java/jni/direct_bt/DBTGattChar.cxx +++ b/java/jni/direct_bt/DBTGattChar.cxx @@ -34,14 +34,14 @@ #include "direct_bt/BTAdapter.hpp" using namespace direct_bt; -using namespace jau; +using namespace jau::jni; void Java_jau_direct_1bt_DBTGattChar_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance) { (void)obj; try { - jau::shared_ptr_ref<BTGattChar> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done + shared_ptr_ref<BTGattChar> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done if( nullptr != sref.pointer() ) { - std::shared_ptr<BTGattChar>* sref_ptr = jau::castInstance<BTGattChar>(nativeInstance); + std::shared_ptr<BTGattChar>* sref_ptr = castInstance<BTGattChar>(nativeInstance); delete sref_ptr; } } catch(...) { @@ -52,7 +52,7 @@ void Java_jau_direct_1bt_DBTGattChar_deleteImpl(JNIEnv *env, jobject obj, jlong jstring Java_jau_direct_1bt_DBTGattChar_toStringImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTGattChar> characteristic(env, obj); // hold until done - jau::JavaAnonRef characteristic_java = characteristic->getJavaObject(); // hold until done! + JavaAnonRef characteristic_java = characteristic->getJavaObject(); // hold until done! JavaGlobalObj::check(characteristic_java, E_FILE_LINE); return from_string_to_jstring(env, characteristic->toString()); } catch(...) { @@ -66,7 +66,7 @@ static const std::string _descriptorClazzCtorArgs("(JLjau/direct_bt/DBTGattChar; jobject Java_jau_direct_1bt_DBTGattChar_getDescriptorsImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTGattChar> characteristic(env, obj); // hold until done - jau::JavaAnonRef characteristic_java = characteristic->getJavaObject(); // hold until done! + JavaAnonRef characteristic_java = characteristic->getJavaObject(); // hold until done! JavaGlobalObj::check(characteristic_java, E_FILE_LINE); jau::darray<BTGattDescRef> & descriptorList = characteristic->descriptorList; @@ -84,7 +84,7 @@ jobject Java_jau_direct_1bt_DBTGattChar_getDescriptorsImpl(JNIEnv *env, jobject if( nullptr == _characteristic ) { throw jau::RuntimeException("Descriptor's characteristic null: "+descriptor->toString(), E_FILE_LINE); } - jau::JavaAnonRef _characteristic_java = _characteristic->getJavaObject(); // hold until done! + JavaAnonRef _characteristic_java = _characteristic->getJavaObject(); // hold until done! JavaGlobalObj::check(_characteristic_java, E_FILE_LINE); jobject jcharacteristic = JavaGlobalObj::GetObject(_characteristic_java); @@ -101,7 +101,7 @@ jobject Java_jau_direct_1bt_DBTGattChar_getDescriptorsImpl(JNIEnv *env, jobject juuid, (jshort)descriptor->handle, jval); java_exception_check_and_throw(env_, E_FILE_LINE); JNIGlobalRef::check(jdesc, E_FILE_LINE); - jau::JavaAnonRef jDescRef = descriptor->getJavaObject(); // GlobalRef + JavaAnonRef jDescRef = descriptor->getJavaObject(); // GlobalRef JavaGlobalObj::check(jDescRef, E_FILE_LINE); env_->DeleteLocalRef(juuid); env_->DeleteLocalRef(jval); @@ -119,10 +119,10 @@ jobject Java_jau_direct_1bt_DBTGattChar_getDescriptorsImpl(JNIEnv *env, jobject jbyteArray Java_jau_direct_1bt_DBTGattChar_readValueImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTGattChar> characteristic(env, obj); // hold until done - jau::JavaAnonRef characteristic_java = characteristic->getJavaObject(); // hold until done! + JavaAnonRef characteristic_java = characteristic->getJavaObject(); // hold until done! JavaGlobalObj::check(characteristic_java, E_FILE_LINE); - POctets res(BTGattHandler::number(BTGattHandler::Defaults::MAX_ATT_MTU), 0, jau::endian::little); + jau::POctets res(BTGattHandler::number(BTGattHandler::Defaults::MAX_ATT_MTU), 0, jau::endian::little); if( !characteristic->readValue(res) ) { ERR_PRINT("Characteristic readValue failed: %s", characteristic->toString().c_str()); return env->NewByteArray((jsize)0); @@ -143,11 +143,11 @@ jbyteArray Java_jau_direct_1bt_DBTGattChar_readValueImpl(JNIEnv *env, jobject ob jboolean Java_jau_direct_1bt_DBTGattChar_writeValueImpl(JNIEnv *env, jobject obj, jbyteArray jval, jboolean withResponse) { try { shared_ptr_ref<BTGattChar> characteristic(env, obj); // hold until done - jau::JavaAnonRef characteristic_java = characteristic->getJavaObject(); // hold until done! + JavaAnonRef characteristic_java = characteristic->getJavaObject(); // hold until done! JavaGlobalObj::check(characteristic_java, E_FILE_LINE); if( nullptr == jval ) { - throw IllegalArgumentException("byte array null", E_FILE_LINE); + throw jau::IllegalArgumentException("byte array null", E_FILE_LINE); } const int value_size = env->GetArrayLength(jval); if( 0 == value_size ) { @@ -157,9 +157,9 @@ jboolean Java_jau_direct_1bt_DBTGattChar_writeValueImpl(JNIEnv *env, jobject obj JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * value_ptr = criticalArray.get(jval, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == value_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); } - TROOctets value(value_ptr, value_size, jau::endian::little); + jau::TROOctets value(value_ptr, value_size, jau::endian::little); bool res; if( withResponse ) { res = characteristic->writeValue(value); @@ -188,22 +188,22 @@ jboolean Java_jau_direct_1bt_DBTGattChar_configNotificationIndicationImpl(JNIEnv DBG_PRINT("Characteristic's native instance has been deleted"); return false; } - throw IllegalStateException("Characteristic's native instance deleted", E_FILE_LINE); + throw jau::IllegalStateException("Characteristic's native instance deleted", E_FILE_LINE); } - jau::JavaAnonRef characteristic_java = characteristic->getJavaObject(); // hold until done! + JavaAnonRef characteristic_java = characteristic->getJavaObject(); // hold until done! JavaGlobalObj::check(characteristic_java, E_FILE_LINE); if( nullptr == jEnabledState ) { - throw IllegalArgumentException("boolean array null", E_FILE_LINE); + throw jau::IllegalArgumentException("boolean array null", E_FILE_LINE); } const int state_size = env->GetArrayLength(jEnabledState); if( 2 > state_size ) { - throw IllegalArgumentException("boolean array smaller than 2, length "+std::to_string(state_size), E_FILE_LINE); + throw jau::IllegalArgumentException("boolean array smaller than 2, length "+std::to_string(state_size), E_FILE_LINE); } JNICriticalArray<jboolean, jbooleanArray> criticalArray(env); // RAII - release jboolean * state_ptr = criticalArray.get(jEnabledState, criticalArray.Mode::UPDATE_AND_RELEASE); if( NULL == state_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(boolean array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(boolean array) is null", E_FILE_LINE); } bool cccdEnableResult[2]; diff --git a/java/jni/direct_bt/DBTGattDesc.cxx b/java/jni/direct_bt/DBTGattDesc.cxx index ad12259c..456dda31 100644 --- a/java/jni/direct_bt/DBTGattDesc.cxx +++ b/java/jni/direct_bt/DBTGattDesc.cxx @@ -35,14 +35,14 @@ #include "direct_bt/BTAdapter.hpp" using namespace direct_bt; -using namespace jau; +using namespace jau::jni; void Java_jau_direct_1bt_DBTGattDesc_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance) { (void)obj; try { - jau::shared_ptr_ref<BTGattDesc> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done + shared_ptr_ref<BTGattDesc> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done if( nullptr != sref.pointer() ) { - std::shared_ptr<BTGattDesc>* sref_ptr = jau::castInstance<BTGattDesc>(nativeInstance); + std::shared_ptr<BTGattDesc>* sref_ptr = castInstance<BTGattDesc>(nativeInstance); delete sref_ptr; } } catch(...) { @@ -54,7 +54,7 @@ jstring Java_jau_direct_1bt_DBTGattDesc_toStringImpl(JNIEnv *env, jobject obj) { (void)obj; try { shared_ptr_ref<BTGattDesc> descriptor(env, obj); // hold until done - jau::JavaAnonRef descriptor_java = descriptor->getJavaObject(); // hold until done! + JavaAnonRef descriptor_java = descriptor->getJavaObject(); // hold until done! JavaGlobalObj::check(descriptor_java, E_FILE_LINE); return from_string_to_jstring(env, descriptor->toString()); } catch(...) { @@ -66,7 +66,7 @@ jstring Java_jau_direct_1bt_DBTGattDesc_toStringImpl(JNIEnv *env, jobject obj) { jbyteArray Java_jau_direct_1bt_DBTGattDesc_readValueImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTGattDesc> descriptor(env, obj); // hold until done - jau::JavaAnonRef descriptor_java = descriptor->getJavaObject(); // hold until done! + JavaAnonRef descriptor_java = descriptor->getJavaObject(); // hold until done! JavaGlobalObj::check(descriptor_java, E_FILE_LINE); if( !descriptor->readValue() ) { @@ -88,11 +88,11 @@ jbyteArray Java_jau_direct_1bt_DBTGattDesc_readValueImpl(JNIEnv *env, jobject ob jboolean Java_jau_direct_1bt_DBTGattDesc_writeValueImpl(JNIEnv *env, jobject obj, jbyteArray jval) { try { shared_ptr_ref<BTGattDesc> descriptor(env, obj); // hold until done - jau::JavaAnonRef descriptor_java = descriptor->getJavaObject(); // hold until done! + JavaAnonRef descriptor_java = descriptor->getJavaObject(); // hold until done! JavaGlobalObj::check(descriptor_java, E_FILE_LINE); if( nullptr == jval ) { - throw IllegalArgumentException("byte array null", E_FILE_LINE); + throw jau::IllegalArgumentException("byte array null", E_FILE_LINE); } const size_t value_size = (size_t)env->GetArrayLength(jval); if( 0 == value_size ) { @@ -101,9 +101,9 @@ jboolean Java_jau_direct_1bt_DBTGattDesc_writeValueImpl(JNIEnv *env, jobject obj JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * value_ptr = criticalArray.get(jval, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == value_ptr ) { - throw InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); + throw jau::InternalError("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); } - TROOctets value(value_ptr, value_size, jau::endian::little); + jau::TROOctets value(value_ptr, value_size, jau::endian::little); descriptor->value = value; // copy data if( !descriptor->writeValue() ) { diff --git a/java/jni/direct_bt/DBTGattService.cxx b/java/jni/direct_bt/DBTGattService.cxx index 0873626f..43376524 100644 --- a/java/jni/direct_bt/DBTGattService.cxx +++ b/java/jni/direct_bt/DBTGattService.cxx @@ -36,14 +36,14 @@ #include "direct_bt/BTGattService.hpp" using namespace direct_bt; -using namespace jau; +using namespace jau::jni; void Java_jau_direct_1bt_DBTGattService_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance) { (void)obj; try { - jau::shared_ptr_ref<BTGattService> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done + shared_ptr_ref<BTGattService> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done if( nullptr != sref.pointer() ) { - std::shared_ptr<BTGattService>* sref_ptr = jau::castInstance<BTGattService>(nativeInstance); + std::shared_ptr<BTGattService>* sref_ptr = castInstance<BTGattService>(nativeInstance); delete sref_ptr; } } catch(...) { @@ -54,7 +54,7 @@ void Java_jau_direct_1bt_DBTGattService_deleteImpl(JNIEnv *env, jobject obj, jlo jstring Java_jau_direct_1bt_DBTGattService_toStringImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTGattService> service(env, obj); // hold until done - jau::JavaAnonRef service_java = service->getJavaObject(); // hold until done! + JavaAnonRef service_java = service->getJavaObject(); // hold until done! JavaGlobalObj::check(service_java, E_FILE_LINE); return from_string_to_jstring(env, service->toString()); } catch(...) { @@ -71,7 +71,7 @@ static const std::string _gattCharPropSetClazzCtorArgs("(B)V"); jobject Java_jau_direct_1bt_DBTGattService_getCharsImpl(JNIEnv *env, jobject obj) { try { shared_ptr_ref<BTGattService> service(env, obj); // hold until done - jau::JavaAnonRef service_java = service->getJavaObject(); // hold until done! + JavaAnonRef service_java = service->getJavaObject(); // hold until done! JavaGlobalObj::check(service_java, E_FILE_LINE); jau::darray<std::shared_ptr<BTGattChar>> & characteristics = service->characteristicList; @@ -80,14 +80,14 @@ jobject Java_jau_direct_1bt_DBTGattService_getCharsImpl(JNIEnv *env, jobject obj jmethodID gattCharPropSetClazzCtor; // gattCharPropSetClazzRef, gattCharPropSetClazzCtor { - gattCharPropSetClazz = jau::search_class(env, _gattCharPropSetClassName.c_str()); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + gattCharPropSetClazz = search_class(env, _gattCharPropSetClassName.c_str()); + java_exception_check_and_throw(env, E_FILE_LINE); if( nullptr == gattCharPropSetClazz ) { throw jau::InternalError("BTDevice::java_class not found: "+_gattCharPropSetClassName, E_FILE_LINE); } } - gattCharPropSetClazzCtor = jau::search_method(env, gattCharPropSetClazz, "<init>", _gattCharPropSetClazzCtorArgs.c_str(), false); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + gattCharPropSetClazzCtor = search_method(env, gattCharPropSetClazz, "<init>", _gattCharPropSetClazzCtorArgs.c_str(), false); + java_exception_check_and_throw(env, E_FILE_LINE); if( nullptr == gattCharPropSetClazzCtor ) { throw jau::InternalError("GattCharPropertySet ctor not found: "+_gattCharPropSetClassName+".<init>"+_gattCharPropSetClazzCtorArgs, E_FILE_LINE); } @@ -106,13 +106,13 @@ jobject Java_jau_direct_1bt_DBTGattService_getCharsImpl(JNIEnv *env, jobject obj if( nullptr == _service ) { throw jau::RuntimeException("Characteristic's service null: "+characteristic->toString(), E_FILE_LINE); } - jau::JavaAnonRef _service_java = _service->getJavaObject(); // hold until done! + JavaAnonRef _service_java = _service->getJavaObject(); // hold until done! JavaGlobalObj::check(_service_java, E_FILE_LINE); jobject jservice = JavaGlobalObj::GetObject(_service_java); jobject jGattCharPropSet = env_->NewObject(gattCharPropSetClazz, gattCharPropSetClazzCtor, (jbyte)characteristic->properties); - jau::java_exception_check_and_throw(env_, E_FILE_LINE); + java_exception_check_and_throw(env_, E_FILE_LINE); JNIGlobalRef::check(jGattCharPropSet, E_FILE_LINE); java_exception_check_and_throw(env_, E_FILE_LINE); @@ -127,7 +127,7 @@ jobject Java_jau_direct_1bt_DBTGattService_getCharsImpl(JNIEnv *env, jobject obj characteristic->userDescriptionIndex); java_exception_check_and_throw(env_, E_FILE_LINE); JNIGlobalRef::check(jcharVal, E_FILE_LINE); - jau::JavaAnonRef jCharRef = characteristic->getJavaObject(); // GlobalRef + JavaAnonRef jCharRef = characteristic->getJavaObject(); // GlobalRef JavaGlobalObj::check(jCharRef, E_FILE_LINE); env_->DeleteLocalRef(jGattCharPropSet); env_->DeleteLocalRef(jcharVal); diff --git a/java/jni/direct_bt/DBTManager.cxx b/java/jni/direct_bt/DBTManager.cxx index 60cb8525..2d49bf57 100644 --- a/java/jni/direct_bt/DBTManager.cxx +++ b/java/jni/direct_bt/DBTManager.cxx @@ -36,7 +36,7 @@ #include "direct_bt/BTManager.hpp" using namespace direct_bt; -using namespace jau; +using namespace jau::jni; static const std::string _removeAdapterCBMethodName("removeAdapterCB"); static const std::string _removeAdapterCBMethodArgs("(II)V"); @@ -90,19 +90,19 @@ static void _addMgmtCBOnce(JNIEnv *env, BTManager & mgmt, JNIGlobalRef jmgmtRef, }; - jclass mgmtClazz = jau::search_class(env, jmgmtRef.getObject()); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + jclass mgmtClazz = search_class(env, jmgmtRef.getObject()); + java_exception_check_and_throw(env, E_FILE_LINE); if( nullptr == mgmtClazz ) { throw jau::InternalError("BTManager not found", E_FILE_LINE); } - jmethodID mid = jau::search_method(env, mgmtClazz, jmethodName.c_str(), jmethodArgs.c_str(), false); - jau::java_exception_check_and_throw(env, E_FILE_LINE); + jmethodID mid = search_method(env, mgmtClazz, jmethodName.c_str(), jmethodArgs.c_str(), false); + java_exception_check_and_throw(env, E_FILE_LINE); if( nullptr == mid ) { throw jau::InternalError("BTManager has no "+jmethodName+"."+jmethodArgs+" method, for "+mgmt.toString(), E_FILE_LINE); } // move BooleanDeviceCBContextRef into CaptureValueInvocationFunc and operator== includes javaCallback comparison - FunctionDef<bool, const MgmtEvent&> funcDef = bindCaptureValueFunc(std::make_shared<BooleanMgmtCBContext>(opc, jmgmtRef, mid), nativeCallback); + jau::FunctionDef<bool, const MgmtEvent&> funcDef = jau::bindCaptureValueFunc(std::make_shared<BooleanMgmtCBContext>(opc, jmgmtRef, mid), nativeCallback); mgmt.addMgmtEventCallback(-1, opc, funcDef); } catch(...) { rethrow_and_raise_java_exception(env); @@ -112,13 +112,13 @@ static void _addMgmtCBOnce(JNIEnv *env, BTManager & mgmt, JNIGlobalRef jmgmtRef, jlong Java_jau_direct_1bt_DBTManager_ctorImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTManager> ref( BTManager::get() ); - jau::JNIGlobalRef global_obj(obj); // lock instance first (global reference), inserted below + shared_ptr_ref<BTManager> ref( BTManager::get() ); + JNIGlobalRef global_obj(obj); // lock instance first (global reference), inserted below java_exception_check_and_throw(env, E_FILE_LINE); - ref->setJavaObject( std::make_shared<jau::JavaGlobalObj>( std::move(global_obj), nullptr ) ); + ref->setJavaObject( std::make_shared<JavaGlobalObj>( std::move(global_obj), nullptr ) ); JavaGlobalObj::check(ref->getJavaObject(), E_FILE_LINE); - jau::JNIGlobalRef jmgmtRef = JavaGlobalObj::GetJavaObject(ref->getJavaObject()); + JNIGlobalRef jmgmtRef = JavaGlobalObj::GetJavaObject(ref->getJavaObject()); _addMgmtCBOnce(env, *ref, jmgmtRef, MgmtEvent::Opcode::INDEX_REMOVED, _removeAdapterCBMethodName, _removeAdapterCBMethodArgs); _addMgmtCBOnce(env, *ref, jmgmtRef, MgmtEvent::Opcode::INDEX_ADDED, _updatedAdapterCBMethodName, _updatedAdapterCBMethodArgs); _addMgmtCBOnce(env, *ref, jmgmtRef, MgmtEvent::Opcode::NEW_SETTINGS, _updatedAdapterCBMethodName, _updatedAdapterCBMethodArgs); @@ -134,15 +134,15 @@ void Java_jau_direct_1bt_DBTManager_dtorImpl(JNIEnv *env, jobject obj, jlong nat { (void)obj; try { - jau::shared_ptr_ref<BTManager> manager(nativeInstance, false /* throw_on_nullptr */); // hold copy until done + shared_ptr_ref<BTManager> manager(nativeInstance, false /* throw_on_nullptr */); // hold copy until done if( nullptr != manager.pointer() ) { if( !manager.is_null() ) { - jau::JavaAnonRef manager_java = manager->getJavaObject(); // hold until done! - jau::JavaGlobalObj::check(manager_java, E_FILE_LINE); + JavaAnonRef manager_java = manager->getJavaObject(); // hold until done! + JavaGlobalObj::check(manager_java, E_FILE_LINE); manager->setJavaObject(); manager->close(); } - std::shared_ptr<BTManager>* ref_ptr = jau::castInstance<BTManager>(nativeInstance); + std::shared_ptr<BTManager>* ref_ptr = castInstance<BTManager>(nativeInstance); delete ref_ptr; } } catch(...) { @@ -156,14 +156,14 @@ static jobject _createJavaAdapter(JNIEnv *env_, jclass clazz, jmethodID clazz_ct const EUI48 addr = adapter->getAddressAndType().address; jbyteArray jaddr = env_->NewByteArray(sizeof(addr)); env_->SetByteArrayRegion(jaddr, 0, sizeof(addr), (const jbyte*)(addr.b)); - jau::java_exception_check_and_throw(env_, E_FILE_LINE); + java_exception_check_and_throw(env_, E_FILE_LINE); const jstring name = from_string_to_jstring(env_, adapter->getName()); java_exception_check_and_throw(env_, E_FILE_LINE); - jau::shared_ptr_ref<BTAdapter> adapter_ref( adapter ); + shared_ptr_ref<BTAdapter> adapter_ref( adapter ); jobject jAdapter = env_->NewObject(clazz, clazz_ctor, adapter_ref.release_to_jlong(), jaddr, adapter->getAddressAndType().type, name, adapter->dev_id); java_exception_check_and_throw(env_, E_FILE_LINE); JNIGlobalRef::check(jAdapter, E_FILE_LINE); - jau::JavaAnonRef jAdapterRef = adapter->getJavaObject(); // GlobalRef + JavaAnonRef jAdapterRef = adapter->getJavaObject(); // GlobalRef JavaGlobalObj::check(jAdapterRef, E_FILE_LINE); env_->DeleteLocalRef(jaddr); env_->DeleteLocalRef(name); @@ -176,7 +176,7 @@ static jobject _createJavaAdapter(JNIEnv *env_, jclass clazz, jmethodID clazz_ct jobject Java_jau_direct_1bt_DBTManager_getAdapterListImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<BTManager> ref(env, obj); // hold until done + shared_ptr_ref<BTManager> ref(env, obj); // hold until done DBG_PRINT("Java_jau_direct_1bt_DBTManager_getAdapterListImpl: Manager %s", ref->toString().c_str()); jau::darray<std::shared_ptr<BTAdapter>> adapters = ref->getAdapters(); @@ -191,7 +191,7 @@ jobject Java_jau_direct_1bt_DBTManager_getAdapterListImpl(JNIEnv *env, jobject o jobject Java_jau_direct_1bt_DBTManager_getAdapterImpl(JNIEnv *env, jobject obj, jint dev_id) { try { - jau::shared_ptr_ref<BTManager> ref(env, obj); // hold until done + shared_ptr_ref<BTManager> ref(env, obj); // hold until done std::shared_ptr<BTAdapter> adapter = ref->getAdapter(dev_id); if( nullptr == adapter ) { @@ -200,7 +200,7 @@ jobject Java_jau_direct_1bt_DBTManager_getAdapterImpl(JNIEnv *env, jobject obj, } DBG_PRINT("BTManager::getAdapterImpl: Adapter dev_id %d: %s", dev_id, adapter->toString().c_str()); - return jau::convert_instance_to_jobject<BTAdapter>(env, adapter, _adapterClazzCtorArgs.c_str(), _createJavaAdapter); + return convert_instance_to_jobject<BTAdapter>(env, adapter, _adapterClazzCtorArgs.c_str(), _createJavaAdapter); } catch(...) { rethrow_and_raise_java_exception(env); } diff --git a/java/jni/direct_bt/DBTNativeDownlink.cxx b/java/jni/direct_bt/DBTNativeDownlink.cxx index c6a0ce57..2a2763c1 100644 --- a/java/jni/direct_bt/DBTNativeDownlink.cxx +++ b/java/jni/direct_bt/DBTNativeDownlink.cxx @@ -33,7 +33,7 @@ #include "direct_bt/BTTypes1.hpp" using namespace direct_bt; -using namespace jau; +using namespace jau::jni; void Java_jau_direct_1bt_DBTNativeDownlink_initNativeJavaObject(JNIEnv *env, jobject obj, jlong nativeInstance) { @@ -44,14 +44,14 @@ void Java_jau_direct_1bt_DBTNativeDownlink_initNativeJavaObject(JNIEnv *env, job jclass javaClazz = search_class(env, global_obj.getObject()); java_exception_check_and_throw(env, E_FILE_LINE); if( nullptr == javaClazz ) { - throw InternalError("DBTNativeDownlink class not found", E_FILE_LINE); + throw jau::InternalError("DBTNativeDownlink class not found", E_FILE_LINE); } jmethodID mNotifyDeleted = search_method(env, javaClazz, "notifyDeleted", "()V", false); java_exception_check_and_throw(env, E_FILE_LINE); if( nullptr == mNotifyDeleted ) { - throw InternalError("DBTNativeDownlink class has no notifyDeleted() method, for "+javaUplink->toString(), E_FILE_LINE); + throw jau::InternalError("DBTNativeDownlink class has no notifyDeleted() method, for "+javaUplink->toString(), E_FILE_LINE); } - javaUplink->setJavaObject( std::make_shared<jau::JavaGlobalObj>( std::move(global_obj), mNotifyDeleted ) ); + javaUplink->setJavaObject( std::make_shared<JavaGlobalObj>( std::move(global_obj), mNotifyDeleted ) ); JavaGlobalObj::check(javaUplink->getJavaObject(), E_FILE_LINE); DBG_JNI_PRINT("Java_jau_direct_1bt_DBTNativeDownlink_initNativeJavaObject %p -> %s", javaUplink.shared_ptr().get(), javaUplink->toString().c_str()); } catch(...) { diff --git a/java/jni/direct_bt/EInfoReport.cxx b/java/jni/direct_bt/EInfoReport.cxx index 47a69981..97a70520 100644 --- a/java/jni/direct_bt/EInfoReport.cxx +++ b/java/jni/direct_bt/EInfoReport.cxx @@ -34,6 +34,7 @@ #include "direct_bt/BTTypes0.hpp" using namespace direct_bt; +using namespace jau::jni; /* * Class: org_direct_bt_EInfoReport @@ -44,7 +45,7 @@ jlong Java_org_direct_1bt_EInfoReport_ctorImpl1(JNIEnv *env, jobject obj) { try { (void)obj; // new instance - jau::shared_ptr_ref<EInfoReport> ref( new EInfoReport() ); + shared_ptr_ref<EInfoReport> ref( new EInfoReport() ); return ref.release_to_jlong(); } catch(...) { @@ -61,7 +62,7 @@ jlong Java_org_direct_1bt_EInfoReport_ctorImpl1(JNIEnv *env, jobject obj) { jlong Java_org_direct_1bt_EInfoReport_ctorImpl2(JNIEnv *env, jobject obj, jlong nativeInstanceOther) { try { (void)obj; - jau::shared_ptr_ref<EInfoReport> ref_other_cpy(nativeInstanceOther); + shared_ptr_ref<EInfoReport> ref_other_cpy(nativeInstanceOther); return ref_other_cpy.release_to_jlong(); } catch(...) { rethrow_and_raise_java_exception(env); @@ -71,8 +72,8 @@ jlong Java_org_direct_1bt_EInfoReport_ctorImpl2(JNIEnv *env, jobject obj, jlong void Java_org_direct_1bt_EInfoReport_replace_nativeImpl(JNIEnv *env, jobject obj, jlong nativeInstanceOther) { try { - jau::shared_ptr_ref<EInfoReport> ref_other(nativeInstanceOther); - jau::shared_ptr_ref<EInfoReport> ref(env, obj); + shared_ptr_ref<EInfoReport> ref_other(nativeInstanceOther); + shared_ptr_ref<EInfoReport> ref(env, obj); // replace the shared managed object ref = ref_other.shared_ptr(); @@ -90,9 +91,9 @@ void Java_org_direct_1bt_EInfoReport_replace_nativeImpl(JNIEnv *env, jobject obj void Java_org_direct_1bt_EInfoReport_dtorImpl(JNIEnv *env, jclass clazz, jlong nativeInstance) { (void)clazz; try { - jau::shared_ptr_ref<EInfoReport> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done + shared_ptr_ref<EInfoReport> sref(nativeInstance, false /* throw_on_nullptr */); // hold copy until done if( nullptr != sref.pointer() ) { - std::shared_ptr<EInfoReport>* sref_ptr = jau::castInstance<EInfoReport>(nativeInstance); + std::shared_ptr<EInfoReport>* sref_ptr = castInstance<EInfoReport>(nativeInstance); delete sref_ptr; } } catch(...) { @@ -102,7 +103,7 @@ void Java_org_direct_1bt_EInfoReport_dtorImpl(JNIEnv *env, jclass clazz, jlong n void Java_org_direct_1bt_EInfoReport_clear(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done ref->clear(); } catch(...) { rethrow_and_raise_java_exception(env); @@ -111,8 +112,8 @@ void Java_org_direct_1bt_EInfoReport_clear(JNIEnv *env, jobject obj) { jint Java_org_direct_1bt_EInfoReport_setImpl(JNIEnv *env, jobject obj, jobject jeir_other) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done - jau::shared_ptr_ref<EInfoReport> ref_other(env, jeir_other); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref_other(env, jeir_other); // hold until done return static_cast<jint>( number( ref->set(*ref_other) ) ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -127,7 +128,7 @@ jint Java_org_direct_1bt_EInfoReport_setImpl(JNIEnv *env, jobject obj, jobject j */ void Java_org_direct_1bt_EInfoReport_setAddressTypeImpl(JNIEnv *env, jobject obj, jbyte jat) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done ref->setAddressType(static_cast<BDAddressType>(jat)); } catch(...) { rethrow_and_raise_java_exception(env); @@ -141,7 +142,7 @@ void Java_org_direct_1bt_EInfoReport_setAddressTypeImpl(JNIEnv *env, jobject obj */ void Java_org_direct_1bt_EInfoReport_setAddressImpl(JNIEnv *env, jobject obj, jbyteArray jaddress) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done if( nullptr == jaddress ) { throw jau::IllegalArgumentException("address null", E_FILE_LINE); @@ -150,7 +151,7 @@ void Java_org_direct_1bt_EInfoReport_setAddressImpl(JNIEnv *env, jobject obj, jb if( sizeof(EUI48) > address_size ) { throw jau::IllegalArgumentException("address byte size "+std::to_string(address_size)+" < "+std::to_string(sizeof(EUI48)), E_FILE_LINE); } - jau::JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release + JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * address_ptr = criticalArray.get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == address_ptr ) { throw jau::InternalError("GetPrimitiveArrayCritical(address byte array) is null", E_FILE_LINE); @@ -170,7 +171,7 @@ void Java_org_direct_1bt_EInfoReport_setAddressImpl(JNIEnv *env, jobject obj, jb */ void Java_org_direct_1bt_EInfoReport_setRSSI(JNIEnv *env, jobject obj, jbyte jrssi) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done ref->setRSSI(static_cast<int8_t>(jrssi)); } catch(...) { rethrow_and_raise_java_exception(env); @@ -184,7 +185,7 @@ void Java_org_direct_1bt_EInfoReport_setRSSI(JNIEnv *env, jobject obj, jbyte jrs */ void Java_org_direct_1bt_EInfoReport_setTxPower(JNIEnv *env, jobject obj, jbyte jtxp) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done ref->setTxPower(static_cast<int8_t>(jtxp)); } catch(...) { rethrow_and_raise_java_exception(env); @@ -198,7 +199,7 @@ void Java_org_direct_1bt_EInfoReport_setTxPower(JNIEnv *env, jobject obj, jbyte */ void Java_org_direct_1bt_EInfoReport_setFlagsImpl(JNIEnv *env, jobject obj, jbyte jf) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done ref->setFlags(static_cast<GAPFlags>(jf)); } catch(...) { rethrow_and_raise_java_exception(env); @@ -212,7 +213,7 @@ void Java_org_direct_1bt_EInfoReport_setFlagsImpl(JNIEnv *env, jobject obj, jbyt */ void Java_org_direct_1bt_EInfoReport_addFlagImpl(JNIEnv *env, jobject obj, jbyte jf) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done ref->addFlags(static_cast<GAPFlags>(jf)); } catch(...) { rethrow_and_raise_java_exception(env); @@ -226,8 +227,8 @@ void Java_org_direct_1bt_EInfoReport_addFlagImpl(JNIEnv *env, jobject obj, jbyte */ void Java_org_direct_1bt_EInfoReport_setName(JNIEnv *env, jobject obj, jstring jname) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done - std::string name = jau::from_jstring_to_string(env, jname); + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + std::string name = from_jstring_to_string(env, jname); ref->setName(name); } catch(...) { rethrow_and_raise_java_exception(env); @@ -241,8 +242,8 @@ void Java_org_direct_1bt_EInfoReport_setName(JNIEnv *env, jobject obj, jstring j */ void Java_org_direct_1bt_EInfoReport_setShortName(JNIEnv *env, jobject obj, jstring jsname) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done - std::string sname = jau::from_jstring_to_string(env, jsname); + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + std::string sname = from_jstring_to_string(env, jsname); ref->setShortName(sname); } catch(...) { rethrow_and_raise_java_exception(env); @@ -256,8 +257,8 @@ void Java_org_direct_1bt_EInfoReport_setShortName(JNIEnv *env, jobject obj, jstr */ void Java_org_direct_1bt_EInfoReport_addService(JNIEnv *env, jobject obj, jstring juuid) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done - std::string uuid_s = jau::from_jstring_to_string(env, juuid); + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + std::string uuid_s = from_jstring_to_string(env, juuid); std::shared_ptr<const jau::uuid_t> uuid = jau::uuid_t::create(uuid_s); ref->addService(uuid); } catch(...) { @@ -272,7 +273,7 @@ void Java_org_direct_1bt_EInfoReport_addService(JNIEnv *env, jobject obj, jstrin */ void Java_org_direct_1bt_EInfoReport_setServicesComplete(JNIEnv *env, jobject obj, jboolean jv) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done ref->setServicesComplete(JNI_TRUE==jv); } catch(...) { rethrow_and_raise_java_exception(env); @@ -286,7 +287,7 @@ void Java_org_direct_1bt_EInfoReport_setServicesComplete(JNIEnv *env, jobject ob */ void Java_org_direct_1bt_EInfoReport_setDeviceClass(JNIEnv *env, jobject obj, jint jv) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done ref->setDeviceClass(static_cast<uint32_t>(jv)); } catch(...) { rethrow_and_raise_java_exception(env); @@ -300,7 +301,7 @@ void Java_org_direct_1bt_EInfoReport_setDeviceClass(JNIEnv *env, jobject obj, ji */ void Java_org_direct_1bt_EInfoReport_setDeviceID(JNIEnv *env, jobject obj, jshort jsource, jshort jvendor, jshort jproduct, jshort jversion) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done ref->setDeviceID(static_cast<uint16_t>(jsource), static_cast<uint16_t>(jvendor), static_cast<uint16_t>(jproduct), static_cast<uint16_t>(jversion)); } catch(...) { rethrow_and_raise_java_exception(env); @@ -314,7 +315,7 @@ void Java_org_direct_1bt_EInfoReport_setDeviceID(JNIEnv *env, jobject obj, jshor */ void Java_org_direct_1bt_EInfoReport_setConnInterval(JNIEnv *env, jobject obj, jshort jmin, jshort jmax) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done ref->setConnInterval(static_cast<uint16_t>(jmin), static_cast<uint16_t>(jmax)); } catch(...) { rethrow_and_raise_java_exception(env); @@ -328,7 +329,7 @@ void Java_org_direct_1bt_EInfoReport_setConnInterval(JNIEnv *env, jobject obj, j */ jlong Java_org_direct_1bt_EInfoReport_getTimestamp(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done return static_cast<jlong>( ref->getTimestamp() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -343,7 +344,7 @@ jlong Java_org_direct_1bt_EInfoReport_getTimestamp(JNIEnv *env, jobject obj) { */ jint Java_org_direct_1bt_EInfoReport_getEIRDataMaskImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done return static_cast<jint>( number( ref->getEIRDataMask() ) ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -353,7 +354,7 @@ jint Java_org_direct_1bt_EInfoReport_getEIRDataMaskImpl(JNIEnv *env, jobject obj jint Java_org_direct_1bt_EInfoReport_getSourceImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done return static_cast<jint>( EInfoReport::number( ref->getSource() ) ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -368,7 +369,7 @@ jint Java_org_direct_1bt_EInfoReport_getSourceImpl(JNIEnv *env, jobject obj) { */ jbyte Java_org_direct_1bt_EInfoReport_getFlagsImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done return static_cast<jbyte>( number( ref->getFlags() ) ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -383,7 +384,7 @@ jbyte Java_org_direct_1bt_EInfoReport_getFlagsImpl(JNIEnv *env, jobject obj) { */ jbyte Java_org_direct_1bt_EInfoReport_getADAddressType(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done return static_cast<jbyte>( ref->getADAddressType() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -398,7 +399,7 @@ jbyte Java_org_direct_1bt_EInfoReport_getADAddressType(JNIEnv *env, jobject obj) */ jbyte Java_org_direct_1bt_EInfoReport_getAddressTypeImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done return static_cast<jbyte>( number( ref->getAddressType() ) ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -413,7 +414,7 @@ jbyte Java_org_direct_1bt_EInfoReport_getAddressTypeImpl(JNIEnv *env, jobject ob */ jbyteArray Java_org_direct_1bt_EInfoReport_getAddressImpl(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done const EUI48 & addr = ref->getAddress(); jbyteArray jaddr = env->NewByteArray(sizeof(addr)); env->SetByteArrayRegion(jaddr, 0, sizeof(addr), (const jbyte*)(addr.b)); @@ -431,8 +432,8 @@ jbyteArray Java_org_direct_1bt_EInfoReport_getAddressImpl(JNIEnv *env, jobject o */ jstring Java_org_direct_1bt_EInfoReport_getName(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done - return jau::from_string_to_jstring(env, ref->getName()); + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + return from_string_to_jstring(env, ref->getName()); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -446,8 +447,8 @@ jstring Java_org_direct_1bt_EInfoReport_getName(JNIEnv *env, jobject obj) { */ jstring Java_org_direct_1bt_EInfoReport_getShortName(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done - return jau::from_string_to_jstring(env, ref->getShortName()); + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + return from_string_to_jstring(env, ref->getShortName()); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -461,7 +462,7 @@ jstring Java_org_direct_1bt_EInfoReport_getShortName(JNIEnv *env, jobject obj) { */ jbyte Java_org_direct_1bt_EInfoReport_getRSSI(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done return static_cast<jbyte>( ref->getRSSI() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -476,7 +477,7 @@ jbyte Java_org_direct_1bt_EInfoReport_getRSSI(JNIEnv *env, jobject obj) { */ jbyte Java_org_direct_1bt_EInfoReport_getTxPower(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done return static_cast<jbyte>( ref->getTxPower() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -487,15 +488,15 @@ jbyte Java_org_direct_1bt_EInfoReport_getTxPower(JNIEnv *env, jobject obj) { jobject Java_org_direct_1bt_EInfoReport_getManufacturerData(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done std::shared_ptr<ManufactureSpecificData> mdata = ref->getManufactureSpecificData(); - jclass map_cls = jau::search_class(env, "java/util/HashMap"); - jmethodID map_ctor = jau::search_method(env, map_cls, "<init>", "(I)V", false); - jmethodID map_put = jau::search_method(env, map_cls, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", false); + jclass map_cls = search_class(env, "java/util/HashMap"); + jmethodID map_ctor = search_method(env, map_cls, "<init>", "(I)V", false); + jmethodID map_put = search_method(env, map_cls, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", false); - jclass short_cls = jau::search_class(env, "java/lang/Short"); - jmethodID short_ctor = jau::search_method(env, short_cls, "<init>", "(S)V", false); + jclass short_cls = search_class(env, "java/lang/Short"); + jmethodID short_ctor = search_method(env, short_cls, "<init>", "(S)V", false); jobject result = nullptr; if( nullptr != mdata ) { @@ -527,13 +528,13 @@ jobject Java_org_direct_1bt_EInfoReport_getManufacturerData(JNIEnv *env, jobject */ jobject Java_org_direct_1bt_EInfoReport_getServices(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done jau::darray<std::shared_ptr<const jau::uuid_t>> service_uuids = ref->getServices(); std::function<jobject(JNIEnv*, const std::shared_ptr<const jau::uuid_t>&)> ctor_uuid2string = [](JNIEnv *env_, const std::shared_ptr<const jau::uuid_t>& uuid_ptr)->jobject { - return jau::from_string_to_jstring(env_, uuid_ptr->toUUID128String()); + return from_string_to_jstring(env_, uuid_ptr->toUUID128String()); }; - return jau::convert_vector_sharedptr_to_jarraylist<jau::darray<std::shared_ptr<const jau::uuid_t>>, const jau::uuid_t>(env, service_uuids, ctor_uuid2string); + return convert_vector_sharedptr_to_jarraylist<jau::darray<std::shared_ptr<const jau::uuid_t>>, const jau::uuid_t>(env, service_uuids, ctor_uuid2string); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -547,7 +548,7 @@ jobject Java_org_direct_1bt_EInfoReport_getServices(JNIEnv *env, jobject obj) { */ jboolean Java_org_direct_1bt_EInfoReport_getServicesComplete(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done return ref->getServicesComplete() ? JNI_TRUE : JNI_FALSE; } catch(...) { rethrow_and_raise_java_exception(env); @@ -562,7 +563,7 @@ jboolean Java_org_direct_1bt_EInfoReport_getServicesComplete(JNIEnv *env, jobjec */ jint Java_org_direct_1bt_EInfoReport_getDeviceClass(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done return static_cast<jint>( ref->getDeviceClass() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -577,7 +578,7 @@ jint Java_org_direct_1bt_EInfoReport_getDeviceClass(JNIEnv *env, jobject obj) { */ jshort Java_org_direct_1bt_EInfoReport_getDeviceIDSource(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done return static_cast<jshort>( ref->getDeviceIDSource() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -592,7 +593,7 @@ jshort Java_org_direct_1bt_EInfoReport_getDeviceIDSource(JNIEnv *env, jobject ob */ jshort Java_org_direct_1bt_EInfoReport_getDeviceIDVendor(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done return static_cast<jshort>( ref->getDeviceIDVendor() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -607,7 +608,7 @@ jshort Java_org_direct_1bt_EInfoReport_getDeviceIDVendor(JNIEnv *env, jobject ob */ jshort Java_org_direct_1bt_EInfoReport_getDeviceIDProduct(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done return static_cast<jshort>( ref->getDeviceIDProduct() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -622,7 +623,7 @@ jshort Java_org_direct_1bt_EInfoReport_getDeviceIDProduct(JNIEnv *env, jobject o */ jshort Java_org_direct_1bt_EInfoReport_getDeviceIDVersion(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done return static_cast<jshort>( ref->getDeviceIDVersion() ); } catch(...) { rethrow_and_raise_java_exception(env); @@ -637,7 +638,7 @@ jshort Java_org_direct_1bt_EInfoReport_getDeviceIDVersion(JNIEnv *env, jobject o */ void Java_org_direct_1bt_EInfoReport_getConnInterval(JNIEnv *env, jobject obj, jshortArray jminmax) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done if( nullptr == jminmax ) { throw jau::IllegalArgumentException("address null", E_FILE_LINE); @@ -646,7 +647,7 @@ void Java_org_direct_1bt_EInfoReport_getConnInterval(JNIEnv *env, jobject obj, j if( 2 > array_size ) { throw jau::IllegalArgumentException("minmax array size "+std::to_string(array_size)+" < 2", E_FILE_LINE); } - jau::JNICriticalArray<uint16_t, jshortArray> criticalArray(env); // RAII - release + JNICriticalArray<uint16_t, jshortArray> criticalArray(env); // RAII - release uint16_t * array_ptr = criticalArray.get(jminmax, criticalArray.Mode::UPDATE_AND_RELEASE); if( NULL == array_ptr ) { throw jau::InternalError("GetPrimitiveArrayCritical(short array) is null", E_FILE_LINE); @@ -664,8 +665,8 @@ void Java_org_direct_1bt_EInfoReport_getConnInterval(JNIEnv *env, jobject obj, j */ jstring Java_org_direct_1bt_EInfoReport_getDeviceIDModalias(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done - return jau::from_string_to_jstring(env, ref->getDeviceIDModalias()); + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + return from_string_to_jstring(env, ref->getDeviceIDModalias()); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -679,8 +680,8 @@ jstring Java_org_direct_1bt_EInfoReport_getDeviceIDModalias(JNIEnv *env, jobject */ jstring Java_org_direct_1bt_EInfoReport_eirDataMaskToString(JNIEnv *env, jobject obj) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done - return jau::from_string_to_jstring(env, ref->eirDataMaskToString()); + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + return from_string_to_jstring(env, ref->eirDataMaskToString()); } catch(...) { rethrow_and_raise_java_exception(env); } @@ -694,8 +695,8 @@ jstring Java_org_direct_1bt_EInfoReport_eirDataMaskToString(JNIEnv *env, jobject */ jstring Java_org_direct_1bt_EInfoReport_toString(JNIEnv *env, jobject obj, jboolean includeServices) { try { - jau::shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done - return jau::from_string_to_jstring(env, ref->toString(JNI_TRUE==includeServices)); + shared_ptr_ref<EInfoReport> ref(env, obj); // hold until done + return from_string_to_jstring(env, ref->toString(JNI_TRUE==includeServices)); } catch(...) { rethrow_and_raise_java_exception(env); } diff --git a/java/jni/direct_bt/helper_dbt.cxx b/java/jni/direct_bt/helper_dbt.cxx index 7bc4d8af..d8cb2745 100644 --- a/java/jni/direct_bt/helper_dbt.cxx +++ b/java/jni/direct_bt/helper_dbt.cxx @@ -36,9 +36,9 @@ static std::string jStringEmpty(""); static std::string jAddressTypePublic("public"); static std::string jAddressTypeRandom("random"); -BDAddressType direct_bt::fromJavaAdressTypeToBDAddressType(JNIEnv *env, jstring jAddressType) { +BDAddressType direct_bt::jni::fromJavaAdressTypeToBDAddressType(JNIEnv *env, jstring jAddressType) { if( nullptr != jAddressType ) { - std::string saddressType = jau::from_jstring_to_string(env, jAddressType); + std::string saddressType = jau::jni::from_jstring_to_string(env, jAddressType); if( jAddressTypePublic == saddressType ) { return BDAddressType::BDADDR_LE_PUBLIC; } @@ -48,16 +48,16 @@ BDAddressType direct_bt::fromJavaAdressTypeToBDAddressType(JNIEnv *env, jstring } return BDAddressType::BDADDR_BREDR; } -jstring direct_bt::fromBDAddressTypeToJavaAddressType(JNIEnv *env, BDAddressType bdAddressType) { +jstring direct_bt::jni::fromBDAddressTypeToJavaAddressType(JNIEnv *env, BDAddressType bdAddressType) { switch( bdAddressType ) { case BDAddressType::BDADDR_LE_PUBLIC: - return jau::from_string_to_jstring(env, jAddressTypePublic); + return jau::jni::from_string_to_jstring(env, jAddressTypePublic); case BDAddressType::BDADDR_LE_RANDOM: - return jau::from_string_to_jstring(env, jAddressTypeRandom); + return jau::jni::from_string_to_jstring(env, jAddressTypeRandom); case BDAddressType::BDADDR_BREDR: // fall through intended default: - return jau::from_string_to_jstring(env, jStringEmpty); + return jau::jni::from_string_to_jstring(env, jStringEmpty); } } diff --git a/java/jni/direct_bt/helper_dbt.hpp b/java/jni/direct_bt/helper_dbt.hpp index 3fd4f0ac..2ffc5da0 100644 --- a/java/jni/direct_bt/helper_dbt.hpp +++ b/java/jni/direct_bt/helper_dbt.hpp @@ -30,7 +30,7 @@ #include "direct_bt/BTAddress.hpp" -namespace direct_bt { +namespace direct_bt::jni { BDAddressType fromJavaAdressTypeToBDAddressType(JNIEnv *env, jstring jAddressType); jstring fromBDAddressTypeToJavaAddressType(JNIEnv *env, BDAddressType bdAddressType); diff --git a/java/jni/helper_base.cxx b/java/jni/helper_base.cxx index 2bf072a3..945113f5 100644 --- a/java/jni/helper_base.cxx +++ b/java/jni/helper_base.cxx @@ -30,52 +30,52 @@ #include "helper_base.hpp" -void raise_java_exception(JNIEnv *env, const direct_bt::BTException &e, const char* file, int line) { - jau::print_native_caught_exception_fwd2java(e, file, line); +void direct_bt::jni::raise_java_exception(JNIEnv *env, const direct_bt::BTException &e, const char* file, int line) { + jau::jni::print_native_caught_exception_fwd2java(e, file, line); env->ThrowNew(env->FindClass("org/direct_bt/BTException"), e.what()); } static std::string _unknown_exception_type_msg("Unknown exception type"); -void rethrow_and_raise_java_exception_impl(JNIEnv *env, const char* file, int line) { +void direct_bt::jni::rethrow_and_raise_java_exception_impl(JNIEnv *env, const char* file, int line) { // std::exception_ptr e = std::current_exception(); try { // std::rethrow_exception(e); throw; // re-throw current exception } catch (const jau::OutOfMemoryError &e) { - jau::raise_java_exception(env, e, file, line); + jau::jni::raise_java_exception(env, e, file, line); } catch (const jau::InternalError &e) { - jau::raise_java_exception(env, e, file, line); + jau::jni::raise_java_exception(env, e, file, line); } catch (const jau::NullPointerException &e) { - jau::raise_java_exception(env, e, file, line); + jau::jni::raise_java_exception(env, e, file, line); } catch (const jau::IllegalArgumentException &e) { - jau::raise_java_exception(env, e, file, line); + jau::jni::raise_java_exception(env, e, file, line); } catch (const jau::IllegalStateException &e) { - jau::raise_java_exception(env, e, file, line); + jau::jni::raise_java_exception(env, e, file, line); } catch (const jau::UnsupportedOperationException &e) { - jau::raise_java_exception(env, e, file, line); + jau::jni::raise_java_exception(env, e, file, line); } catch (const jau::IndexOutOfBoundsException &e) { - jau::raise_java_exception(env, e, file, line); + jau::jni::raise_java_exception(env, e, file, line); } catch (const direct_bt::BTException &e) { raise_java_exception(env, e, file, line); } catch (const jau::RuntimeException &e) { - jau::raise_java_exception(env, e, file, line); + jau::jni::raise_java_exception(env, e, file, line); } catch (const std::bad_alloc &e) { - jau::raise_java_exception(env, e, file, line); + jau::jni::raise_java_exception(env, e, file, line); } catch (const std::runtime_error &e) { - jau::raise_java_exception(env, e, file, line); + jau::jni::raise_java_exception(env, e, file, line); } catch (const std::invalid_argument &e) { - jau::raise_java_exception(env, e, file, line); + jau::jni::raise_java_exception(env, e, file, line); } catch (const std::exception &e) { - jau::raise_java_exception(env, e, file, line); + jau::jni::raise_java_exception(env, e, file, line); } catch (const std::string &msg) { - jau::print_native_caught_exception_fwd2java(msg, file, line); + jau::jni::print_native_caught_exception_fwd2java(msg, file, line); env->ThrowNew(env->FindClass("java/lang/Error"), msg.c_str()); } catch (const char *msg) { - jau::print_native_caught_exception_fwd2java(msg, file, line); + jau::jni::print_native_caught_exception_fwd2java(msg, file, line); env->ThrowNew(env->FindClass("java/lang/Error"), msg); } catch (...) { - jau::print_native_caught_exception_fwd2java(_unknown_exception_type_msg, file, line); + jau::jni::print_native_caught_exception_fwd2java(_unknown_exception_type_msg, file, line); env->ThrowNew(env->FindClass("java/lang/Error"), _unknown_exception_type_msg.c_str()); } } diff --git a/java/jni/helper_base.hpp b/java/jni/helper_base.hpp index 629e3b78..b11efd22 100644 --- a/java/jni/helper_base.hpp +++ b/java/jni/helper_base.hpp @@ -35,19 +35,23 @@ #include "direct_bt/BTTypes0.hpp" -void raise_java_exception(JNIEnv *env, const direct_bt::BTException &e, const char* file, int line); +namespace direct_bt::jni { -/** - * Re-throw current exception and raise respective java exception - * using any matching function above. - */ -void rethrow_and_raise_java_exception_impl(JNIEnv *env, const char* file, int line); + void raise_java_exception(JNIEnv *env, const direct_bt::BTException &e, const char* file, int line); -/** - * Re-throw current exception and raise respective java exception - * using any matching function above. - */ -#define rethrow_and_raise_java_exception(E) rethrow_and_raise_java_exception_impl((E), __FILE__, __LINE__) -// inline void rethrow_and_raise_java_exception(JNIEnv *env) { rethrow_and_raise_java_exception_impl(env, __FILE__, __LINE__); } + /** + * Re-throw current exception and raise respective java exception + * using any matching function above. + */ + void rethrow_and_raise_java_exception_impl(JNIEnv *env, const char* file, int line); + + /** + * Re-throw current exception and raise respective java exception + * using any matching function above. + */ + #define rethrow_and_raise_java_exception(E) direct_bt::jni::rethrow_and_raise_java_exception_impl((E), __FILE__, __LINE__) + // inline void rethrow_and_raise_java_exception(JNIEnv *env) { direct_bt::jni::rethrow_and_raise_java_exception_impl(env, __FILE__, __LINE__); } + +} /* namespace direct_bt::jni */ #endif /* HELPER_BASE_HPP_ */ |