aboutsummaryrefslogtreecommitdiffstats
path: root/java/jni/BluetoothManager.cxx
diff options
context:
space:
mode:
authorPetre Eftime <[email protected]>2016-03-07 18:05:17 +0200
committerPetre Eftime <[email protected]>2016-03-07 18:05:37 +0200
commit82f302d576d772277b6bcfb08d034047e10bb753 (patch)
tree4f5e9aad40614f8207cd089175aa09096ac8432a /java/jni/BluetoothManager.cxx
parentcfb4a5c26dbdd2cf37b99153b1ed26435aea21c9 (diff)
java: Add find methods to classes, add AsyncTinyB example
Signed-off-by: Petre Eftime <[email protected]>
Diffstat (limited to 'java/jni/BluetoothManager.cxx')
-rw-r--r--java/jni/BluetoothManager.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/java/jni/BluetoothManager.cxx b/java/jni/BluetoothManager.cxx
index 441dc50..a3257d8 100644
--- a/java/jni/BluetoothManager.cxx
+++ b/java/jni/BluetoothManager.cxx
@@ -73,6 +73,42 @@ static void getObject_setter(JNIEnv *env,
}
}
+jobject Java_tinyb_BluetoothManager_find(JNIEnv *env, jobject obj, jint type,
+ jstring name, jstring identifier, jobject parent,
+ jlong milliseconds)
+{
+ BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
+ BluetoothObject *b_parent;
+ BluetoothType b_type;
+ std::string *name_to_write;
+ std::string *identifier_to_write;
+
+ getObject_setter(env,
+ name, &name_to_write,
+ identifier, &identifier_to_write,
+ parent, &b_parent);
+
+ b_type = from_int_to_btype((int)type);
+ std::unique_ptr<BluetoothObject> b_object = manager->find(b_type, name_to_write,
+ identifier_to_write,
+ b_parent,
+ std::chrono::milliseconds(milliseconds));
+
+ BluetoothObject *b_object_naked = b_object.release();
+ if (!b_object_naked)
+ {
+ return nullptr;
+ }
+ jclass clazz = search_class(env, *b_object_naked);
+ jmethodID clazz_ctor = search_method(env, clazz, "<init>", "(J)V", false);
+
+ jobject result = env->NewObject(clazz, clazz_ctor, (long)b_object_naked);
+
+ return result;
+
+}
+
+
jobject Java_tinyb_BluetoothManager_getObject(JNIEnv *env, jobject obj, jint type,
jstring name, jstring identifier, jobject parent)
{