aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorVlad Kolotov <[email protected]>2017-10-13 22:49:52 +1300
committerpetreeftime <[email protected]>2017-10-14 17:18:12 +0300
commitfd4fdb0854d328f44bbf0f3ce2493c30e8587849 (patch)
treef50d40e5a0f25c8b57e28a171b3f9220620271fe /java
parent898f6ac604d6266292f74ce95d28ae8b7a7a3a2a (diff)
Adding support for setting RSSI discovery filter
Signed-off-by: Vlad Kolotov <[email protected]>
Diffstat (limited to 'java')
-rw-r--r--java/BluetoothAdapter.java8
-rw-r--r--java/jni/BluetoothAdapter.cxx21
2 files changed, 28 insertions, 1 deletions
diff --git a/java/BluetoothAdapter.java b/java/BluetoothAdapter.java
index e48909bc..0bbaecde 100644
--- a/java/BluetoothAdapter.java
+++ b/java/BluetoothAdapter.java
@@ -238,7 +238,13 @@ public class BluetoothAdapter extends BluetoothObject
* @return The local ID of the adapter.
*/
public native String getModalias();
-
+
+ /** This method sets RSSI device discovery filter for the caller. When this method is called
+ * with 0, filter is removed.
+ * @param rssi a rssi value
+ */
+ public native void setRssiDiscoveryFilter(int rssi);
+
/** Returns the interface name of the adapter.
* @return The interface name of the adapter.
*/
diff --git a/java/jni/BluetoothAdapter.cxx b/java/jni/BluetoothAdapter.cxx
index 1775da4e..0a15a4e1 100644
--- a/java/jni/BluetoothAdapter.cxx
+++ b/java/jni/BluetoothAdapter.cxx
@@ -787,3 +787,24 @@ void Java_tinyb_BluetoothAdapter_delete(JNIEnv *env, jobject obj)
}
}
+void Java_tinyb_BluetoothAdapter_setRssiDiscoveryFilter(JNIEnv *env, jobject obj, jint rssi)
+{
+ try {
+ BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
+
+ std::vector<BluetoothUUID> native_uuids;
+ native_uuids.reserve(0);
+
+ obj_adapter->set_discovery_filter(native_uuids, (int16_t) rssi, 0, TransportType::AUTO);
+ } 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);
+ }
+} \ No newline at end of file