summaryrefslogtreecommitdiffstats
path: root/java/jni
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-06-24 06:06:46 +0200
committerSven Gothel <[email protected]>2020-06-24 06:06:46 +0200
commit50d04560b87f51a1dc2979b62cc48883c846d5bb (patch)
tree8e3423eacf9e28d42f2cc420727d7a7f5f9fe21e /java/jni
parent9900ef4b93c191c0ac4fa8f941e06a5a8045257c (diff)
HCIHandler: Use async event mechanism for delayed replies, commands shall return immediately (2/2)
Adjust using HCIHandler changes, see commit 9900ef4b93c191c0ac4fa8f941e06a5a8045257c - DBTAdapter listens to HCIHandler callbacks: *connected* and *disconnected* using same callback implementations as for DBTManager. - DBTDevice::notifyConnect receives the actual connection handler and will be called for all connected callbacks (DBTManager and HCIHandler) - DBTDevice adjusted return values for *connect* and *disconnect*, no more connection handle available immediately. Further changes:
Diffstat (limited to 'java/jni')
-rw-r--r--java/jni/direct_bt/DBTDevice.cxx22
1 files changed, 11 insertions, 11 deletions
diff --git a/java/jni/direct_bt/DBTDevice.cxx b/java/jni/direct_bt/DBTDevice.cxx
index 78fa8573..306e4156 100644
--- a/java/jni/direct_bt/DBTDevice.cxx
+++ b/java/jni/direct_bt/DBTDevice.cxx
@@ -262,11 +262,11 @@ jboolean Java_direct_1bt_tinyb_DBTDevice_disconnectImpl(JNIEnv *env, jobject obj
try {
DBTDevice *device = getInstance<DBTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
- device->disconnect();
+ return device->disconnect() ? JNI_TRUE : JNI_FALSE;
} catch(...) {
rethrow_and_raise_java_exception(env);
}
- return JNI_TRUE;
+ return JNI_FALSE;
}
jboolean Java_direct_1bt_tinyb_DBTDevice_remove(JNIEnv *env, jobject obj)
@@ -286,8 +286,8 @@ jboolean Java_direct_1bt_tinyb_DBTDevice_connectImpl__(JNIEnv *env, jobject obj)
try {
DBTDevice *device = getInstance<DBTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
- uint16_t hciHandle = device->connectDefault();
- return 0 != hciHandle ? JNI_TRUE : JNI_FALSE;
+ bool res = device->connectDefault();
+ return res ? JNI_TRUE : JNI_FALSE;
} catch(...) {
rethrow_and_raise_java_exception(env);
}
@@ -302,21 +302,21 @@ jboolean Java_direct_1bt_tinyb_DBTDevice_connectImpl__SSSSSS(JNIEnv *env, jobjec
try {
DBTDevice *device = getInstance<DBTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
- uint16_t hciHandle;
+ bool res;
switch( device->addressType ) {
case BDAddressType::BDADDR_LE_PUBLIC:
- hciHandle = device->connectLE(HCIAddressType::HCIADDR_LE_PUBLIC, HCIAddressType::HCIADDR_LE_PUBLIC,
- interval, window, min_interval, max_interval, latency, timeout);
+ res = device->connectLE(HCIAddressType::HCIADDR_LE_PUBLIC, HCIAddressType::HCIADDR_LE_PUBLIC,
+ interval, window, min_interval, max_interval, latency, timeout);
break;
case BDAddressType::BDADDR_LE_RANDOM:
- hciHandle = device->connectLE(HCIAddressType::HCIADDR_LE_RANDOM, HCIAddressType::HCIADDR_LE_PUBLIC,
- interval, window, min_interval, max_interval, latency, timeout);
+ res = device->connectLE(HCIAddressType::HCIADDR_LE_RANDOM, HCIAddressType::HCIADDR_LE_PUBLIC,
+ interval, window, min_interval, max_interval, latency, timeout);
break;
default:
- hciHandle = device->connectDefault();
+ res = device->connectDefault();
break;
}
- return 0 != hciHandle ? JNI_TRUE : JNI_FALSE;
+ return res ? JNI_TRUE : JNI_FALSE;
} catch(...) {
rethrow_and_raise_java_exception(env);
}