diff options
author | Andrei Vasiliu <[email protected]> | 2015-12-18 20:09:25 +0200 |
---|---|---|
committer | Andrei Vasiliu <[email protected]> | 2016-01-12 00:03:19 +0200 |
commit | 6cb00d4068ff288f8dad76164c1b03b5672099ef (patch) | |
tree | de11c49d5f06668fc4efc01fed83f016595fb4c7 /java/jni/BluetoothManager.cxx | |
parent | de993184be455b65a3dd43d77ca917afe2aa85a9 (diff) |
Java: Added Java API
Signed-off-by: Andrei Vasiliu <[email protected]>
Diffstat (limited to 'java/jni/BluetoothManager.cxx')
-rw-r--r-- | java/jni/BluetoothManager.cxx | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/java/jni/BluetoothManager.cxx b/java/jni/BluetoothManager.cxx new file mode 100644 index 0000000..749eac7 --- /dev/null +++ b/java/jni/BluetoothManager.cxx @@ -0,0 +1,110 @@ +#include "tinyb/BluetoothAdapter.hpp" +#include "tinyb/BluetoothDevice.hpp" +#include "tinyb/BluetoothGattService.hpp" +#include "tinyb/BluetoothManager.hpp" + +#include "BluetoothManager.h" + +#include "helper.h" + +using namespace tinyb; + +jobject Java_BluetoothManager_getBluetoothType(JNIEnv *env, jobject obj) +{ + (void)obj; + + return get_bluetooth_type(env, "NONE"); +} + +jobject Java_BluetoothManager_getObject(JNIEnv *env, jobject obj, jobject type, + jstring name, jstring identifier, jobject parent) +{ + (void)env; + (void)obj; + (void)type; + (void)name; + (void)identifier; + (void)parent; + + return nullptr; +} + +jobject Java_BluetoothManager_getObjects(JNIEnv *env, jobject obj, jobject type, + jstring name, jstring identifier, jobject parent) +{ + (void)env; + (void)obj; + (void)type; + (void)name; + (void)identifier; + (void)parent; + + return nullptr; +} + +jobject Java_BluetoothManager_getAdapters(JNIEnv *env, jobject obj) +{ + BluetoothManager *manager = getInstance<BluetoothManager>(env, obj); + + std::vector<std::unique_ptr<BluetoothAdapter>> array = manager->get_adapters(); + jobject result = convert_vector_to_jobject<BluetoothAdapter>(env, array, + "BluetoothAdapter", + "(J)V"); + return result; +} + +jobject Java_BluetoothManager_getDevices(JNIEnv *env, jobject obj) +{ + BluetoothManager *manager = getInstance<BluetoothManager>(env, obj); + + std::vector<std::unique_ptr<BluetoothDevice>> array = manager->get_devices(); + jobject result = convert_vector_to_jobject<BluetoothDevice>(env, array, + "BluetoothDevice", + "(J)V"); + return result; + +} + +jobject Java_BluetoothManager_getServices(JNIEnv *env, jobject obj) +{ + BluetoothManager *manager = getInstance<BluetoothManager>(env, obj); + + std::vector<std::unique_ptr<BluetoothGattService>> array = manager->get_services(); + jobject result = convert_vector_to_jobject<BluetoothGattService>(env, array, + "BluetoothGattService", + "(J)V"); + return result; +} + +jboolean Java_BluetoothManager_setDefaultAdapter(JNIEnv *env, jobject obj, jobject adapter) +{ + BluetoothManager *manager = getInstance<BluetoothManager>(env, obj); + BluetoothAdapter *b_adapter = getInstance<BluetoothAdapter>(env, adapter); + + return manager->set_default_adapter(b_adapter); +} + +jboolean Java_BluetoothManager_startDiscovery(JNIEnv *env, jobject obj) +{ + BluetoothManager *manager = getInstance<BluetoothManager>(env, obj); + return manager->start_discovery() ? JNI_TRUE : JNI_FALSE; +} + +jboolean Java_BluetoothManager_stopDiscovery(JNIEnv *env, jobject obj) +{ + BluetoothManager *manager = getInstance<BluetoothManager>(env, obj); + return manager->start_discovery() ? JNI_TRUE : JNI_FALSE; +} + +void Java_BluetoothManager_init(JNIEnv *env, jobject obj) +{ + BluetoothManager *manager = BluetoothManager::get_bluetooth_manager(); + setInstance<BluetoothManager>(env, obj, manager); +} + +void Java_BluetoothManager_delete(JNIEnv *env, jobject obj) +{ + BluetoothManager *manager = getInstance<BluetoothManager>(env, obj); + delete manager; +} + |