diff options
author | Sven Gothel <[email protected]> | 2020-01-31 07:00:18 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-01-31 07:00:18 +0100 |
commit | b88401a0bd3043e6ecf5bfdc5a99a10cf36b31d6 (patch) | |
tree | 5f7533a3b95c643a00dfbf5cf4e776667da78bcb /java/jni | |
parent | 031145ae81daa3583ddc2bb04b7b730d48cd67c8 (diff) |
Expose BluetoothDevice async calls: device1_call_connect(..) / device1_call_connect_finish via Java connectAsyncStart() and connectAsyncFinish()
Diffstat (limited to 'java/jni')
-rw-r--r-- | java/jni/BluetoothDevice.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/java/jni/BluetoothDevice.cxx b/java/jni/BluetoothDevice.cxx index 387c9559..5f9dcf41 100644 --- a/java/jni/BluetoothDevice.cxx +++ b/java/jni/BluetoothDevice.cxx @@ -92,6 +92,45 @@ jboolean Java_tinyb_BluetoothDevice_disconnect(JNIEnv *env, jobject obj) return JNI_FALSE; } +void Java_tinyb_BluetoothDevice_connectAsyncStart(JNIEnv *env, jobject obj) +{ + try { + BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj); + + obj_device->connect_async_start(); + } catch (std::bad_alloc &e) { + raise_java_oom_exception(env, e); + } catch (BluetoothException &e) { + raise_java_bluetooth_exception(env, e); + } catch (std::runtime_error &e) { + raise_java_runtime_exception(env, e); + } catch (std::invalid_argument &e) { + raise_java_invalid_arg_exception(env, e); + } catch (std::exception &e) { + raise_java_exception(env, e); + } +} + +jboolean Java_tinyb_BluetoothDevice_connectAsyncFinish(JNIEnv *env, jobject obj) +{ + try { + BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj); + + return obj_device->connect_async_finish() ? JNI_TRUE : JNI_FALSE; + } catch (std::bad_alloc &e) { + raise_java_oom_exception(env, e); + } catch (BluetoothException &e) { + raise_java_bluetooth_exception(env, e); + } catch (std::runtime_error &e) { + raise_java_runtime_exception(env, e); + } catch (std::invalid_argument &e) { + raise_java_invalid_arg_exception(env, e); + } catch (std::exception &e) { + raise_java_exception(env, e); + } + return JNI_FALSE; +} + jboolean Java_tinyb_BluetoothDevice_connect(JNIEnv *env, jobject obj) { try { |