diff options
-rw-r--r-- | api/tinyb/BluetoothManager.hpp | 6 | ||||
-rw-r--r-- | java/BluetoothManager.java | 5 | ||||
-rw-r--r-- | java/jni/BluetoothManager.cxx | 19 | ||||
-rw-r--r-- | src/BluetoothManager.cpp | 8 |
4 files changed, 38 insertions, 0 deletions
diff --git a/api/tinyb/BluetoothManager.hpp b/api/tinyb/BluetoothManager.hpp index 75b1ed1f..fd833cfc 100644 --- a/api/tinyb/BluetoothManager.hpp +++ b/api/tinyb/BluetoothManager.hpp @@ -238,4 +238,10 @@ public: */ bool stop_discovery( ); + + /** Returns if the discovers is running or not. + * @return TRUE if discovery is running + */ + bool get_discovering( + ); }; diff --git a/java/BluetoothManager.java b/java/BluetoothManager.java index 222cf540..cc8f9d3a 100644 --- a/java/BluetoothManager.java +++ b/java/BluetoothManager.java @@ -205,6 +205,11 @@ public class BluetoothManager */ public native boolean stopDiscovery() throws BluetoothException; + /** Returns if the discovers is running or not. + * @return TRUE if discovery is running + */ + public native boolean getDiscovering() throws BluetoothException; + /** * When called, each new device found will fire an event to the passed * listener<p> diff --git a/java/jni/BluetoothManager.cxx b/java/jni/BluetoothManager.cxx index d5c652eb..dac0432c 100644 --- a/java/jni/BluetoothManager.cxx +++ b/java/jni/BluetoothManager.cxx @@ -370,6 +370,25 @@ jboolean Java_tinyb_BluetoothManager_stopDiscovery(JNIEnv *env, jobject obj) return JNI_FALSE; } +jboolean Java_tinyb_BluetoothManager_getDiscovering(JNIEnv *env, jobject obj) +{ + try { + BluetoothManager *manager = getInstance<BluetoothManager>(env, obj); + return manager->get_discovering() ? 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; +} + void Java_tinyb_BluetoothManager_init(JNIEnv *env, jobject obj) { try { diff --git a/src/BluetoothManager.cpp b/src/BluetoothManager.cpp index b4cdbd08..1a05776e 100644 --- a/src/BluetoothManager.cpp +++ b/src/BluetoothManager.cpp @@ -391,3 +391,11 @@ bool BluetoothManager::stop_discovery() else return false; } + +bool BluetoothManager::get_discovering() +{ + if (default_adapter != NULL) + return default_adapter->get_discovering(); + else + return false; +} |