summaryrefslogtreecommitdiffstats
path: root/java/jni
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-01-31 07:00:18 +0100
committerSven Gothel <[email protected]>2020-01-31 07:00:18 +0100
commitb88401a0bd3043e6ecf5bfdc5a99a10cf36b31d6 (patch)
tree5f7533a3b95c643a00dfbf5cf4e776667da78bcb /java/jni
parent031145ae81daa3583ddc2bb04b7b730d48cd67c8 (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.cxx39
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 {