summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-02-09 08:50:22 +0100
committerSven Gothel <[email protected]>2020-02-09 08:50:22 +0100
commit4f99bad3abcabb2c37ef6543ec5ed8467914cd53 (patch)
tree5848e3fdaa3ebc2acc6f6ca0abae517b0b6253a2
parent0c76e289ad011f1c616176a896da02e9b255275e (diff)
Java Refactory: Expose intefaces via org.tinyb.* and D-Bus implementation via tinyb.dbus.*
Allows alternative interface implementations and delegated wrapper implementations for debug and tracing. Original D-Bus implementation can be retrieved via: 'BluetoothManager org.tinyb.BluetoothFactory.getDBusBluetoothManager()' A HCI native implementation will follow up w/o use of D-Bus. Otherwise the Java API is unchanged and this tinyb can replace previous implementation. Due to the major API change (despite interface is unchanged but BluetoothManager instantiation) the jar file has been renamed from 'tinyb.jar' to 'tinyb2.jar'. Same goes with the version number, which will be set to 'v2.0.0'. The native library and class definition is kept unchanged using the original names so far.
-rw-r--r--CMakeLists.txt6
-rw-r--r--api/tinyb/BluetoothAdapter.hpp2
-rw-r--r--api/tinyb/BluetoothDevice.hpp2
-rw-r--r--api/tinyb/BluetoothGattCharacteristic.hpp2
-rw-r--r--api/tinyb/BluetoothGattDescriptor.hpp2
-rw-r--r--api/tinyb/BluetoothGattService.hpp2
-rw-r--r--api/tinyb/BluetoothManager.hpp2
-rw-r--r--api/tinyb/BluetoothObject.hpp5
-rw-r--r--examples/java/AsyncTinyB.java51
-rw-r--r--examples/java/CMakeLists.txt6
-rw-r--r--examples/java/HelloTinyB.java73
-rw-r--r--examples/java/Notification.java58
-rw-r--r--examples/java/ScannerTinyB.java251
-rw-r--r--java/CMakeLists.txt38
-rw-r--r--java/jni/DBusAdapter.cxx (renamed from java/jni/BluetoothAdapter.cxx)72
-rw-r--r--java/jni/DBusDevice.cxx (renamed from java/jni/BluetoothDevice.cxx)104
-rw-r--r--java/jni/DBusEvent.cxx (renamed from java/jni/BluetoothEvent.cxx)16
-rw-r--r--java/jni/DBusGattCharacteristic.cxx (renamed from java/jni/BluetoothGattCharacteristic.cxx)28
-rw-r--r--java/jni/DBusGattDescriptor.cxx (renamed from java/jni/BluetoothGattDescriptor.cxx)22
-rw-r--r--java/jni/DBusGattService.cxx (renamed from java/jni/BluetoothGattService.cxx)16
-rw-r--r--java/jni/DBusManager.cxx (renamed from java/jni/BluetoothManager.cxx)32
-rw-r--r--java/jni/DBusObject.cxx (renamed from java/jni/BluetoothObject.cxx)12
-rw-r--r--java/jni/helper.cxx4
-rw-r--r--java/org/tinyb/BluetoothAdapter.java (renamed from java/tinyb/BluetoothAdapter.java)139
-rw-r--r--java/org/tinyb/BluetoothCallback.java (renamed from java/tinyb/BluetoothCallback.java)6
-rw-r--r--java/org/tinyb/BluetoothDevice.java (renamed from java/tinyb/BluetoothDevice.java)175
-rw-r--r--java/org/tinyb/BluetoothEvent.java39
-rw-r--r--java/org/tinyb/BluetoothException.java (renamed from java/tinyb/BluetoothException.java)11
-rw-r--r--java/org/tinyb/BluetoothFactory.java32
-rw-r--r--java/org/tinyb/BluetoothGattCharacteristic.java (renamed from java/tinyb/BluetoothGattCharacteristic.java)63
-rw-r--r--java/org/tinyb/BluetoothGattDescriptor.java (renamed from java/tinyb/BluetoothGattDescriptor.java)41
-rw-r--r--java/org/tinyb/BluetoothGattService.java (renamed from java/tinyb/BluetoothGattService.java)46
-rw-r--r--java/org/tinyb/BluetoothManager.java (renamed from java/tinyb/BluetoothManager.java)203
-rw-r--r--java/org/tinyb/BluetoothNotification.java (renamed from java/tinyb/BluetoothNotification.java)6
-rw-r--r--java/org/tinyb/BluetoothObject.java54
-rw-r--r--java/org/tinyb/BluetoothType.java (renamed from java/tinyb/BluetoothType.java)4
-rw-r--r--java/org/tinyb/ObjectArgCallback.java (renamed from java/tinyb/ObjectArgCallback.java)11
-rw-r--r--java/org/tinyb/ObjectArrayArgCallback.java (renamed from java/tinyb/ObjectArrayArgCallback.java)7
-rw-r--r--java/org/tinyb/TransportType.java (renamed from java/tinyb/TransportType.java)2
-rw-r--r--java/tinyb/dbus/DBusAdapter.java189
-rw-r--r--java/tinyb/dbus/DBusDevice.java216
-rw-r--r--java/tinyb/dbus/DBusEvent.java (renamed from java/tinyb/BluetoothEvent.java)20
-rw-r--r--java/tinyb/dbus/DBusGattCharacteristic.java104
-rw-r--r--java/tinyb/dbus/DBusGattDescriptor.java76
-rw-r--r--java/tinyb/dbus/DBusGattService.java80
-rw-r--r--java/tinyb/dbus/DBusManager.java165
-rw-r--r--java/tinyb/dbus/DBusObject.java (renamed from java/tinyb/BluetoothObject.java)42
-rw-r--r--src/BluetoothAdapter.cpp2
-rw-r--r--src/BluetoothDevice.cpp2
-rw-r--r--src/BluetoothGattCharacteristic.cpp2
-rw-r--r--src/BluetoothGattDescriptor.cpp2
-rw-r--r--src/BluetoothGattService.cpp2
-rw-r--r--src/BluetoothManager.cpp2
-rw-r--r--src/BluetoothObject.cpp2
-rw-r--r--src/org.bluez.xml53
55 files changed, 1841 insertions, 763 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index daf8bbb7..ec9542c9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,11 +23,11 @@ include (GetGitRevisionDescription)
git_describe (VERSION "--tags")
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_HEAD-HASH-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_-128-NOTFOUND")
- message (WARNING " - Install git to compile a production libtinyb!")
- set (VERSION "v0.5.0-dirty")
+ message (WARNING " - Install git to compile a production libtinyb2!")
+ set (VERSION "v2.0.0-dirty")
endif ()
-message (INFO " - libtinyb Version ${VERSION}")
+message (INFO " - libtinyb2 Version ${VERSION}")
#parse the version information into pieces.
string (REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
diff --git a/api/tinyb/BluetoothAdapter.hpp b/api/tinyb/BluetoothAdapter.hpp
index e11ab28d..ef9981de 100644
--- a/api/tinyb/BluetoothAdapter.hpp
+++ b/api/tinyb/BluetoothAdapter.hpp
@@ -66,7 +66,7 @@ protected:
public:
static std::string java_class() {
- return std::string(JAVA_PACKAGE "/BluetoothAdapter");
+ return std::string(JAVA_DBUS_PACKAGE "/DBusAdapter");
}
static BluetoothType class_type() { return BluetoothType::ADAPTER; }
diff --git a/api/tinyb/BluetoothDevice.hpp b/api/tinyb/BluetoothDevice.hpp
index e3300b56..72e1b834 100644
--- a/api/tinyb/BluetoothDevice.hpp
+++ b/api/tinyb/BluetoothDevice.hpp
@@ -75,7 +75,7 @@ protected:
public:
static std::string java_class() {
- return std::string(JAVA_PACKAGE "/BluetoothDevice");
+ return std::string(JAVA_DBUS_PACKAGE "/DBusDevice");
}
static BluetoothType class_type() { return BluetoothType::DEVICE; }
diff --git a/api/tinyb/BluetoothGattCharacteristic.hpp b/api/tinyb/BluetoothGattCharacteristic.hpp
index 9e3c2697..52e91c90 100644
--- a/api/tinyb/BluetoothGattCharacteristic.hpp
+++ b/api/tinyb/BluetoothGattCharacteristic.hpp
@@ -70,7 +70,7 @@ protected:
public:
static std::string java_class() {
- return std::string(JAVA_PACKAGE "/BluetoothGattCharacteristic");
+ return std::string(JAVA_DBUS_PACKAGE "/DBusGattCharacteristic");
}
static BluetoothType class_type() { return BluetoothType::GATT_CHARACTERISTIC; }
diff --git a/api/tinyb/BluetoothGattDescriptor.hpp b/api/tinyb/BluetoothGattDescriptor.hpp
index 669e60d1..4e973dca 100644
--- a/api/tinyb/BluetoothGattDescriptor.hpp
+++ b/api/tinyb/BluetoothGattDescriptor.hpp
@@ -63,7 +63,7 @@ protected:
public:
static std::string java_class() {
- return std::string(JAVA_PACKAGE "/BluetoothGattDescriptor");
+ return std::string(JAVA_DBUS_PACKAGE "/DBusGattDescriptor");
}
static BluetoothType class_type() { return BluetoothType::GATT_DESCRIPTOR; }
diff --git a/api/tinyb/BluetoothGattService.hpp b/api/tinyb/BluetoothGattService.hpp
index 3418750f..bcc1e525 100644
--- a/api/tinyb/BluetoothGattService.hpp
+++ b/api/tinyb/BluetoothGattService.hpp
@@ -61,7 +61,7 @@ protected:
public:
static std::string java_class() {
- return std::string(JAVA_PACKAGE "/BluetoothGattService");
+ return std::string(JAVA_DBUS_PACKAGE "/DBusGattService");
}
static BluetoothType class_type() { return BluetoothType::GATT_SERVICE; }
diff --git a/api/tinyb/BluetoothManager.hpp b/api/tinyb/BluetoothManager.hpp
index fd833cfc..7c54bd3b 100644
--- a/api/tinyb/BluetoothManager.hpp
+++ b/api/tinyb/BluetoothManager.hpp
@@ -53,7 +53,7 @@ protected:
public:
static std::string java_class() {
- return std::string(JAVA_PACKAGE "/BluetoothManager");
+ return std::string(JAVA_DBUS_PACKAGE "/DBusManager");
}
static std::string get_api_version();
diff --git a/api/tinyb/BluetoothObject.hpp b/api/tinyb/BluetoothObject.hpp
index 549229fd..9502e8f7 100644
--- a/api/tinyb/BluetoothObject.hpp
+++ b/api/tinyb/BluetoothObject.hpp
@@ -27,7 +27,8 @@
#include <mutex>
#include <atomic>
-#define JAVA_PACKAGE "tinyb"
+#define JAVA_MAIN_PACKAGE "org/tinyb"
+#define JAVA_DBUS_PACKAGE "tinyb/dbus"
namespace tinyb {
enum class BluetoothType {
@@ -83,7 +84,7 @@ public:
static BluetoothType class_type() { return BluetoothType::NONE; }
static std::string java_class() {
- return std::string(JAVA_PACKAGE "/BluetoothObject");
+ return std::string(JAVA_DBUS_PACKAGE "/DBusObject");
}
/** Returns the complete Java class of this object
diff --git a/examples/java/AsyncTinyB.java b/examples/java/AsyncTinyB.java
index 99deecca..28c492b5 100644
--- a/examples/java/AsyncTinyB.java
+++ b/examples/java/AsyncTinyB.java
@@ -1,21 +1,26 @@
-import tinyb.*;
-import java.util.*;
-import java.time.*;
import java.util.concurrent.locks.*;
+
+import org.tinyb.BluetoothDevice;
+import org.tinyb.BluetoothException;
+import org.tinyb.BluetoothFactory;
+import org.tinyb.BluetoothGattCharacteristic;
+import org.tinyb.BluetoothGattService;
+import org.tinyb.BluetoothManager;
+
import java.util.concurrent.TimeUnit;
public class AsyncTinyB {
private static final float SCALE_LSB = 0.03125f;
static boolean running = true;
- static void printDevice(BluetoothDevice device) {
+ static void printDevice(final BluetoothDevice device) {
System.out.print("Address = " + device.getAddress());
System.out.print(" Name = " + device.getName());
System.out.print(" Connected = " + device.getConnected());
System.out.println();
}
- static float convertCelsius(int raw) {
+ static float convertCelsius(final int raw) {
return raw / 128f;
}
@@ -28,7 +33,7 @@ public class AsyncTinyB {
* The API used in this example is based on TinyB v0.3, which only supports polling, but v0.4 will introduce a
* simplied API for discovering devices and services.
*/
- public static void main(String[] args) throws InterruptedException {
+ public static void main(final String[] args) throws InterruptedException {
if (args.length < 1) {
System.err.println("Run with <device_address> argument");
@@ -40,13 +45,13 @@ public class AsyncTinyB {
* library is through the BluetoothManager. There can be only one BluetoothManager at one time, and the
* reference to it is obtained through the getBluetoothManager method.
*/
- BluetoothManager manager = BluetoothManager.getBluetoothManager();
+ final BluetoothManager manager = BluetoothFactory.getDBusBluetoothManager();
/*
* The manager will try to initialize a BluetoothAdapter if any adapter is present in the system. To initialize
* discovery we can call startDiscovery, which will put the default adapter in discovery mode.
*/
- boolean discoveryStarted = manager.startDiscovery();
+ final boolean discoveryStarted = manager.startDiscovery();
System.out.println("The discovery started: " + (discoveryStarted ? "true" : "false"));
@@ -54,14 +59,14 @@ public class AsyncTinyB {
* After discovery is started, new devices will be detected. We can find the device we are interested in
* through the manager's find method.
*/
- BluetoothDevice sensor = manager.find(null, args[0], null, Duration.ofSeconds(10));
+ final BluetoothDevice sensor = manager.find(null, args[0], null, 10000);
/*
* After we find the device we can stop looking for other devices.
*/
try {
manager.stopDiscovery();
- } catch (BluetoothException e) {
+ } catch (final BluetoothException e) {
System.err.println("Discovery could not be stopped right now");
}
@@ -80,8 +85,8 @@ public class AsyncTinyB {
System.exit(-1);
}
- Lock lock = new ReentrantLock();
- Condition cv = lock.newCondition();
+ final Lock lock = new ReentrantLock();
+ final Condition cv = lock.newCondition();
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
@@ -101,7 +106,7 @@ public class AsyncTinyB {
* http://processors.wiki.ti.com/images/a/a8/BLE_SensorTag_GATT_Server.pdf. The service we are looking for has the
* short UUID AA00 which we insert into the TI Base UUID: f000XXXX-0451-4000-b000-000000000000
*/
- BluetoothGattService tempService = sensor.find( "f000aa00-0451-4000-b000-000000000000");
+ final BluetoothGattService tempService = sensor.find( "f000aa00-0451-4000-b000-000000000000");
if (tempService == null) {
System.err.println("This device does not have the temperature service we are looking for.");
@@ -110,9 +115,9 @@ public class AsyncTinyB {
}
System.out.println("Found service " + tempService.getUUID());
- BluetoothGattCharacteristic tempValue = tempService.find("f000aa01-0451-4000-b000-000000000000");
- BluetoothGattCharacteristic tempConfig = tempService.find("f000aa02-0451-4000-b000-000000000000");
- BluetoothGattCharacteristic tempPeriod = tempService.find("f000aa03-0451-4000-b000-000000000000");
+ final BluetoothGattCharacteristic tempValue = tempService.find("f000aa01-0451-4000-b000-000000000000");
+ final BluetoothGattCharacteristic tempConfig = tempService.find("f000aa02-0451-4000-b000-000000000000");
+ final BluetoothGattCharacteristic tempPeriod = tempService.find("f000aa03-0451-4000-b000-000000000000");
if (tempValue == null || tempConfig == null || tempPeriod == null) {
System.err.println("Could not find the correct characteristics.");
@@ -127,16 +132,16 @@ public class AsyncTinyB {
* mentioned above. We could also modify the update interval, by writing in the period characteristic, but the
* default 1s is good enough for our purposes.
*/
- byte[] config = { 0x01 };
+ final byte[] config = { 0x01 };
tempConfig.writeValue(config);
/*
* Each second read the value characteristic and display it in a human readable format.
*/
while (running) {
- byte[] tempRaw = tempValue.readValue();
+ final byte[] tempRaw = tempValue.readValue();
System.out.print("Temp raw = {");
- for (byte b : tempRaw) {
+ for (final byte b : tempRaw) {
System.out.print(String.format("%02x,", b));
}
System.out.print("}");
@@ -146,11 +151,11 @@ public class AsyncTinyB {
* raw temperature format to celsius and print it. Conversion for object temperature depends on ambient
* according to wiki, but assume result is good enough for our purposes without conversion.
*/
- int objectTempRaw = (tempRaw[0] & 0xff) | (tempRaw[1] << 8);
- int ambientTempRaw = (tempRaw[2] & 0xff) | (tempRaw[3] << 8);
+ final int objectTempRaw = (tempRaw[0] & 0xff) | (tempRaw[1] << 8);
+ final int ambientTempRaw = (tempRaw[2] & 0xff) | (tempRaw[3] << 8);
- float objectTempCelsius = convertCelsius(objectTempRaw);
- float ambientTempCelsius = convertCelsius(ambientTempRaw);
+ final float objectTempCelsius = convertCelsius(objectTempRaw);
+ final float ambientTempCelsius = convertCelsius(ambientTempRaw);
System.out.println(
String.format(" Temp: Object = %fC, Ambient = %fC", objectTempCelsius, ambientTempCelsius));
diff --git a/examples/java/CMakeLists.txt b/examples/java/CMakeLists.txt
index 4bfa5c58..07dbe4be 100644
--- a/examples/java/CMakeLists.txt
+++ b/examples/java/CMakeLists.txt
@@ -1,21 +1,21 @@
find_package(Java REQUIRED)
include(UseJava)
-add_jar(HelloTinyB SOURCES HelloTinyB.java INCLUDE_JARS "${CMAKE_CURRENT_BINARY_DIR}/../../java/tinyb.jar" ENTRY_POINT HelloTinyB)
+add_jar(HelloTinyB SOURCES HelloTinyB.java INCLUDE_JARS "${CMAKE_CURRENT_BINARY_DIR}/../../java/tinyb2.jar" ENTRY_POINT HelloTinyB)
add_custom_command(TARGET HelloTinyB
POST_BUILD
COMMAND cp "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/HelloTinyB.dir/HelloTinyB.class" "${CMAKE_CURRENT_BINARY_DIR}"
)
-add_jar(AsyncTinyB SOURCES AsyncTinyB.java INCLUDE_JARS "${CMAKE_CURRENT_BINARY_DIR}/../../java/tinyb.jar" ENTRY_POINT AsyncTinyB)
+add_jar(AsyncTinyB SOURCES AsyncTinyB.java INCLUDE_JARS "${CMAKE_CURRENT_BINARY_DIR}/../../java/tinyb2.jar" ENTRY_POINT AsyncTinyB)
add_custom_command(TARGET AsyncTinyB
POST_BUILD
COMMAND cp "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/AsyncTinyB.dir/AsyncTinyB.class" "${CMAKE_CURRENT_BINARY_DIR}"
)
-add_jar(Notification SOURCES Notification.java INCLUDE_JARS "${CMAKE_CURRENT_BINARY_DIR}/../../java/tinyb.jar" ENTRY_POINT Notification)
+add_jar(Notification SOURCES Notification.java INCLUDE_JARS "${CMAKE_CURRENT_BINARY_DIR}/../../java/tinyb2.jar" ENTRY_POINT Notification)
add_custom_command(TARGET Notification
POST_BUILD
diff --git a/examples/java/HelloTinyB.java b/examples/java/HelloTinyB.java
index b3d2c934..4e8a2d0d 100644
--- a/examples/java/HelloTinyB.java
+++ b/examples/java/HelloTinyB.java
@@ -1,20 +1,27 @@
-import tinyb.*;
-import java.util.*;
-import java.util.concurrent.locks.*;
+import java.util.List;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.tinyb.BluetoothDevice;
+import org.tinyb.BluetoothException;
+import org.tinyb.BluetoothFactory;
+import org.tinyb.BluetoothGattCharacteristic;
+import org.tinyb.BluetoothGattService;
+import org.tinyb.BluetoothManager;
public class HelloTinyB {
- private static final float SCALE_LSB = 0.03125f;
static boolean running = true;
- static void printDevice(BluetoothDevice device) {
+ static void printDevice(final BluetoothDevice device) {
System.out.print("Address = " + device.getAddress());
System.out.print(" Name = " + device.getName());
System.out.print(" Connected = " + device.getConnected());
System.out.println();
}
- static float convertCelsius(int raw) {
+ static float convertCelsius(final int raw) {
return raw / 128f;
}
@@ -23,15 +30,15 @@ public class HelloTinyB {
* getDevices method. We can the look through the list of devices to find the device with the MAC which we provided
* as a parameter. We continue looking until we find it, or we try 15 times (1 minutes).
*/
- static BluetoothDevice getDevice(String address) throws InterruptedException {
- BluetoothManager manager = BluetoothManager.getBluetoothManager();
+ static BluetoothDevice getDevice(final String address) throws InterruptedException {
+ final BluetoothManager manager = BluetoothFactory.getDBusBluetoothManager();
BluetoothDevice sensor = null;
for (int i = 0; (i < 15) && running; ++i) {
- List<BluetoothDevice> list = manager.getDevices();
+ final List<BluetoothDevice> list = manager.getDevices();
if (list == null)
return null;
- for (BluetoothDevice device : list) {
+ for (final BluetoothDevice device : list) {
printDevice(device);
/*
* Here we check if the address matches.
@@ -54,7 +61,7 @@ public class HelloTinyB {
* http://processors.wiki.ti.com/images/a/a8/BLE_SensorTag_GATT_Server.pdf. The service we are looking for has the
* short UUID AA00 which we insert into the TI Base UUID: f000XXXX-0451-4000-b000-000000000000
*/
- static BluetoothGattService getService(BluetoothDevice device, String UUID) throws InterruptedException {
+ static BluetoothGattService getService(final BluetoothDevice device, final String UUID) throws InterruptedException {
System.out.println("Services exposed by device:");
BluetoothGattService tempService = null;
List<BluetoothGattService> bluetoothServices = null;
@@ -63,7 +70,7 @@ public class HelloTinyB {
if (bluetoothServices == null)
return null;
- for (BluetoothGattService service : bluetoothServices) {
+ for (final BluetoothGattService service : bluetoothServices) {
System.out.println("UUID: " + service.getUUID());
if (service.getUUID().equals(UUID))
tempService = service;
@@ -73,12 +80,12 @@ public class HelloTinyB {
return tempService;
}
- static BluetoothGattCharacteristic getCharacteristic(BluetoothGattService service, String UUID) {
- List<BluetoothGattCharacteristic> characteristics = service.getCharacteristics();
+ static BluetoothGattCharacteristic getCharacteristic(final BluetoothGattService service, final String UUID) {
+ final List<BluetoothGattCharacteristic> characteristics = service.getCharacteristics();
if (characteristics == null)
return null;
- for (BluetoothGattCharacteristic characteristic : characteristics) {
+ for (final BluetoothGattCharacteristic characteristic : characteristics) {
if (characteristic.getUUID().equals(UUID))
return characteristic;
}
@@ -94,7 +101,7 @@ public class HelloTinyB {
* The API used in this example is based on TinyB v0.3, which only supports polling, but v0.4 will introduce a
* simplied API for discovering devices and services.
*/
- public static void main(String[] args) throws InterruptedException {
+ public static void main(final String[] args) throws InterruptedException {
if (args.length < 1) {
System.err.println("Run with <device_address> argument");
@@ -106,23 +113,23 @@ public class HelloTinyB {
* library is through the BluetoothManager. There can be only one BluetoothManager at one time, and the
* reference to it is obtained through the getBluetoothManager method.
*/
- BluetoothManager manager = BluetoothManager.getBluetoothManager();
+ final BluetoothManager manager = BluetoothFactory.getDBusBluetoothManager();
/*
* The manager will try to initialize a BluetoothAdapter if any adapter is present in the system. To initialize
* discovery we can call startDiscovery, which will put the default adapter in discovery mode.
*/
- boolean discoveryStarted = manager.startDiscovery();
+ final boolean discoveryStarted = manager.startDiscovery();
System.out.println("The discovery started: " + (discoveryStarted ? "true" : "false"));
- BluetoothDevice sensor = getDevice(args[0]);
+ final BluetoothDevice sensor = getDevice(args[0]);
/*
* After we find the device we can stop looking for other devices.
*/
try {
manager.stopDiscovery();
- } catch (BluetoothException e) {
+ } catch (final BluetoothException e) {
System.err.println("Discovery could not be stopped.");
}
@@ -141,8 +148,8 @@ public class HelloTinyB {
System.exit(-1);
}
- Lock lock = new ReentrantLock();
- Condition cv = lock.newCondition();
+ final Lock lock = new ReentrantLock();
+ final Condition cv = lock.newCondition();
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
@@ -158,7 +165,7 @@ public class HelloTinyB {
});
- BluetoothGattService tempService = getService(sensor, "f000aa00-0451-4000-b000-000000000000");
+ final BluetoothGattService tempService = getService(sensor, "f000aa00-0451-4000-b000-000000000000");
if (tempService == null) {
System.err.println("This device does not have the temperature service we are looking for.");
@@ -167,9 +174,9 @@ public class HelloTinyB {
}
System.out.println("Found service " + tempService.getUUID());
- BluetoothGattCharacteristic tempValue = getCharacteristic(tempService, "f000aa01-0451-4000-b000-000000000000");
- BluetoothGattCharacteristic tempConfig = getCharacteristic(tempService, "f000aa02-0451-4000-b000-000000000000");
- BluetoothGattCharacteristic tempPeriod = getCharacteristic(tempService, "f000aa03-0451-4000-b000-000000000000");
+ final BluetoothGattCharacteristic tempValue = getCharacteristic(tempService, "f000aa01-0451-4000-b000-000000000000");
+ final BluetoothGattCharacteristic tempConfig = getCharacteristic(tempService, "f000aa02-0451-4000-b000-000000000000");
+ final BluetoothGattCharacteristic tempPeriod = getCharacteristic(tempService, "f000aa03-0451-4000-b000-000000000000");
if (tempValue == null || tempConfig == null || tempPeriod == null) {
System.err.println("Could not find the correct characteristics.");
@@ -184,16 +191,16 @@ public class HelloTinyB {
* mentioned above. We could also modify the update interval, by writing in the period characteristic, but the
* default 1s is good enough for our purposes.
*/
- byte[] config = { 0x01 };
+ final byte[] config = { 0x01 };
tempConfig.writeValue(config);
/*
* Each second read the value characteristic and display it in a human readable format.
*/
while (running) {
- byte[] tempRaw = tempValue.readValue();
+ final byte[] tempRaw = tempValue.readValue();
System.out.print("Temp raw = {");
- for (byte b : tempRaw) {
+ for (final byte b : tempRaw) {
System.out.print(String.format("%02x,", b));
}
System.out.print("}");
@@ -203,11 +210,11 @@ public class HelloTinyB {
* raw temperature format to celsius and print it. Conversion for object temperature depends on ambient
* according to wiki, but assume result is good enough for our purposes without conversion.
*/
- int objectTempRaw = (tempRaw[0] & 0xff) | (tempRaw[1] << 8);
- int ambientTempRaw = (tempRaw[2] & 0xff) | (tempRaw[3] << 8);
+ final int objectTempRaw = (tempRaw[0] & 0xff) | (tempRaw[1] << 8);
+ final int ambientTempRaw = (tempRaw[2] & 0xff) | (tempRaw[3] << 8);
- float objectTempCelsius = convertCelsius(objectTempRaw);
- float ambientTempCelsius = convertCelsius(ambientTempRaw);
+ final float objectTempCelsius = convertCelsius(objectTempRaw);
+ final float ambientTempCelsius = convertCelsius(ambientTempRaw);
System.out.println(
String.format(" Temp: Object = %fC, Ambient = %fC", objectTempCelsius, ambientTempCelsius));
diff --git a/examples/java/Notification.java b/examples/java/Notification.java
index ffb7bee1..069e013d 100644
--- a/examples/java/Notification.java
+++ b/examples/java/Notification.java
@@ -22,16 +22,22 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-import tinyb.*;
-import java.util.*;
-import java.time.*;
-import java.util.concurrent.locks.*;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.tinyb.BluetoothDevice;
+import org.tinyb.BluetoothFactory;
+import org.tinyb.BluetoothGattCharacteristic;
+import org.tinyb.BluetoothGattService;
+import org.tinyb.BluetoothManager;
+import org.tinyb.BluetoothNotification;
class ValueNotification implements BluetoothNotification<byte[]> {
- public void run(byte[] tempRaw) {
+ public void run(final byte[] tempRaw) {
System.out.print("Temp raw = {");
- for (byte b : tempRaw) {
+ for (final byte b : tempRaw) {
System.out.print(String.format("%02x,", b));
}
System.out.print("}");
@@ -41,11 +47,11 @@ class ValueNotification implements BluetoothNotification<byte[]> {
* raw temperature format to celsius and print it. Conversion for object temperature depends on ambient
* according to wiki, but assume result is good enough for our purposes without conversion.
*/
- int objectTempRaw = (tempRaw[0] & 0xff) | (tempRaw[1] << 8);
- int ambientTempRaw = (tempRaw[2] & 0xff) | (tempRaw[3] << 8);
+ final int objectTempRaw = (tempRaw[0] & 0xff) | (tempRaw[1] << 8);
+ final int ambientTempRaw = (tempRaw[2] & 0xff) | (tempRaw[3] << 8);
- float objectTempCelsius = Notification.convertCelsius(objectTempRaw);
- float ambientTempCelsius = Notification.convertCelsius(ambientTempRaw);
+ final float objectTempCelsius = Notification.convertCelsius(objectTempRaw);
+ final float ambientTempCelsius = Notification.convertCelsius(ambientTempRaw);
System.out.println(
String.format(" Temp: Object = %fC, Ambient = %fC", objectTempCelsius, ambientTempCelsius));
@@ -57,7 +63,7 @@ class ValueNotification implements BluetoothNotification<byte[]> {
class ConnectedNotification implements BluetoothNotification<Boolean> {
- public void run(Boolean connected) {
+ public void run(final Boolean connected) {
System.out.println("Connected");
}
@@ -67,14 +73,14 @@ public class Notification {
private static final float SCALE_LSB = 0.03125f;
static boolean running = true;
- static void printDevice(BluetoothDevice device) {
+ static void printDevice(final BluetoothDevice device) {
System.out.print("Address = " + device.getAddress());
System.out.print(" Name = " + device.getName());
System.out.print(" Connected = " + device.getConnected());
System.out.println();
}
- static float convertCelsius(int raw) {
+ static float convertCelsius(final int raw) {
return raw / 128f;
}
@@ -87,7 +93,7 @@ public class Notification {
* The API used in this example is based on TinyB v0.3, which only supports polling, but v0.4 will introduce a
* simplied API for discovering devices and services.
*/
- public static void main(String[] args) throws InterruptedException {
+ public static void main(final String[] args) throws InterruptedException {
if (args.length < 1) {
System.err.println("Run with <device_address> argument");
@@ -99,13 +105,13 @@ public class Notification {
* library is through the BluetoothManager. There can be only one BluetoothManager at one time, and the
* reference to it is obtained through the getBluetoothManager method.
*/
- BluetoothManager manager = BluetoothManager.getBluetoothManager();
+ final BluetoothManager manager = BluetoothFactory.getDBusBluetoothManager();
/*
* The manager will try to initialize a BluetoothAdapter if any adapter is present in the system. To initialize
* discovery we can call startDiscovery, which will put the default adapter in discovery mode.
*/
- boolean discoveryStarted = manager.startDiscovery();
+ final boolean discoveryStarted = manager.startDiscovery();
System.out.println("The discovery started: " + (discoveryStarted ? "true" : "false"));
@@ -113,7 +119,7 @@ public class Notification {
* After discovery is started, new devices will be detected. We can find the device we are interested in
* through the manager's find method.
*/
- BluetoothDevice sensor = manager.find(null, args[0], null, Duration.ofSeconds(10));
+ final BluetoothDevice sensor = manager.find(null, args[0], null, 10000);
if (sensor == null) {
System.err.println("No sensor found with the provided address.");
@@ -137,8 +143,8 @@ public class Notification {
*/
//manager.stopDiscovery();
- Lock lock = new ReentrantLock();
- Condition cv = lock.newCondition();
+ final Lock lock = new ReentrantLock();
+ final Condition cv = lock.newCondition();
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
@@ -158,7 +164,7 @@ public class Notification {
* http://processors.wiki.ti.com/images/a/a8/BLE_SensorTag_GATT_Server.pdf. The service we are looking for has the
* short UUID AA00 which we insert into the TI Base UUID: f000XXXX-0451-4000-b000-000000000000
*/
- BluetoothGattService tempService = sensor.find( "f000aa00-0451-4000-b000-000000000000");
+ final BluetoothGattService tempService = sensor.find( "f000aa00-0451-4000-b000-000000000000");
if (tempService == null) {
System.err.println("This device does not have the temperature service we are looking for.");
@@ -167,9 +173,9 @@ public class Notification {
}
System.out.println("Found service " + tempService.getUUID());
- BluetoothGattCharacteristic tempValue = tempService.find("f000aa01-0451-4000-b000-000000000000");
- BluetoothGattCharacteristic tempConfig = tempService.find("f000aa02-0451-4000-b000-000000000000");
- BluetoothGattCharacteristic tempPeriod = tempService.find("f000aa03-0451-4000-b000-000000000000");
+ final BluetoothGattCharacteristic tempValue = tempService.find("f000aa01-0451-4000-b000-000000000000");
+ final BluetoothGattCharacteristic tempConfig = tempService.find("f000aa02-0451-4000-b000-000000000000");
+ final BluetoothGattCharacteristic tempPeriod = tempService.find("f000aa03-0451-4000-b000-000000000000");
if (tempValue == null || tempConfig == null || tempPeriod == null) {
System.err.println("Could not find the correct characteristics.");
@@ -184,10 +190,10 @@ public class Notification {
* mentioned above. We could also modify the update interval, by writing in the period characteristic, but the
* default 1s is good enough for our purposes.
*/
- byte[] config = { 0x01 };
+ final byte[] config = { 0x01 };
tempConfig.writeValue(config);
-
- byte[] period = { 100 };
+
+ final byte[] period = { 100 };
tempPeriod.writeValue(period);
tempValue.enableValueNotifications(new ValueNotification());
diff --git a/examples/java/ScannerTinyB.java b/examples/java/ScannerTinyB.java
new file mode 100644
index 00000000..c01f7123
--- /dev/null
+++ b/examples/java/ScannerTinyB.java
@@ -0,0 +1,251 @@
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.tinyb.BluetoothAdapter;
+import org.tinyb.BluetoothDevice;
+import org.tinyb.BluetoothFactory;
+import org.tinyb.BluetoothGattCharacteristic;
+import org.tinyb.BluetoothGattDescriptor;
+import org.tinyb.BluetoothGattService;
+import org.tinyb.BluetoothManager;
+import org.tinyb.BluetoothNotification;
+
+public class ScannerTinyB {
+ /** 60,000 milliseconds */
+ static long TO_DISCOVER = 60000;
+
+ public static void main(final String[] args) throws InterruptedException {
+ String mac = null;
+ int mode = 0;
+
+ for(int i=0; i< args.length; i++) {
+ final String arg = args[i];
+
+ if( arg.equals("-mac") ) {
+ mac = args[++i];
+ } else if( arg.equals("-mode") ) {
+ mode = Integer.valueOf(args[++i]).intValue();
+ }
+ }
+
+ if ( null == mac ) {
+ System.err.println("Run with '-mac <device_address>' argument");
+ System.exit(-1);
+ }
+
+ final boolean useAdapter = mode/10 > 0;
+ mode = mode %10;
+
+ /*
+ * To start looking of the device, we first must initialize the TinyB library. The way of interacting with the
+ * library is through the BluetoothManager. There can be only one BluetoothManager at one time, and the
+ * reference to it is obtained through the getBluetoothManager method.
+ */
+ final BluetoothManager manager = BluetoothFactory.getDBusBluetoothManager();
+ final BluetoothAdapter adapter = manager.getDefaultAdapter();
+
+ final long t0 = System.currentTimeMillis();;
+
+ if( useAdapter ) {
+ adapter.removeDevices();
+ }
+ final boolean discoveryStarted = useAdapter ? adapter.startDiscovery() : manager.startDiscovery();
+
+ System.err.println("The discovery started: " + (discoveryStarted ? "true" : "false") + " for mac "+mac+", mode "+mode+", useAdapter "+useAdapter);
+ BluetoothDevice sensor = null;
+
+ if( 0 == mode ) {
+ if( useAdapter ) {
+ sensor = adapter.find(null, mac, TO_DISCOVER);
+ } else {
+ sensor = manager.find(null, mac, null, TO_DISCOVER);
+ }
+ } else {
+ boolean timeout = false;
+ while( null == sensor && !timeout ) {
+ final List<BluetoothDevice> devices = useAdapter ? adapter.getDevices() : manager.getDevices();
+ for(final Iterator<BluetoothDevice> id = devices.iterator(); id.hasNext() && !timeout; ) {
+ final BluetoothDevice d = id.next();
+ if(d.getAddress().equals(mac)) {
+ sensor = d;
+ break;
+ }
+ final long tn = System.currentTimeMillis();
+ timeout = ( tn - t0 ) > TO_DISCOVER;
+ }
+ }
+ }
+ final long t1 = System.currentTimeMillis();
+ if (sensor == null) {
+ System.err.println("No sensor found within "+(t1-t0)+" ms");
+ System.exit(-1);
+ }
+ System.err.println("Found device in "+(t1-t0)+" ms: ");
+ printDevice(sensor);
+
+ final BooleanNotification connectedNotification = new BooleanNotification("Connected", t1);
+ final BooleanNotification servicesResolvedNotification = new BooleanNotification("ServicesResolved", t1);
+ sensor.enableConnectedNotifications(connectedNotification);
+ sensor.enableServicesResolvedNotifications(servicesResolvedNotification);
+
+ final long t2;
+ if ( sensor.connect() ) {
+ t2 = System.currentTimeMillis();
+ System.err.println("Sensor connected in "+(t2-t1)+" ms");
+ System.err.println("Sensor connectedNotification: "+connectedNotification.getValue());
+ } else {
+ t2=0;
+ System.out.println("Could not connect device.");
+ System.exit(-1);
+ }
+
+ synchronized( servicesResolvedNotification ) {
+ while( !servicesResolvedNotification.getValue() ) {
+ final long tn = System.currentTimeMillis();
+ if( tn - t2 > 20000 ) {
+ break; // 20s TO
+ }
+ servicesResolvedNotification.wait();
+ }
+ }
+ final long t3;
+ if ( servicesResolvedNotification.getValue() ) {
+ t3 = System.currentTimeMillis();
+ System.err.println("Sensor servicesResolved in "+(t3-t2)+" ms, total "+(t3-t1)+" ms");
+ } else {
+ t3=0;
+ System.out.println("Could not connect device.");
+ System.exit(-1);
+ }
+ // Will shut down everything .. ??
+ //adapter.stopDiscovery();
+
+ final List<BluetoothGattService> allBluetoothServices = sensor.getServices();
+ if (allBluetoothServices.isEmpty()) {
+ System.err.println("No BluetoothGattService found!");
+ System.exit(1);
+ }
+ printAllServiceInfo(allBluetoothServices);
+
+ sensor.disconnect();
+ }
+ private static void printDevice(final BluetoothDevice device) {
+ System.err.println("Address = " + device.getAddress());
+ System.err.println(" Name = " + device.getName());
+ System.err.println(" Connected = " + device.getConnected());
+ System.err.println();
+ }
+ private static void printAllServiceInfo(final List<BluetoothGattService> allBluetoothServices) {
+ try {
+ for (final BluetoothGattService service : allBluetoothServices) {
+ System.err.println("Service UUID: " + service.getUUID());
+ final List<BluetoothGattCharacteristic> v = service.getCharacteristics();
+ for (final BluetoothGattCharacteristic c : v) {
+ System.err.println(" Characteristic UUID: " + c.getUUID());
+
+ final List<BluetoothGattDescriptor> descriptors = c.getDescriptors();
+
+ for (final BluetoothGattDescriptor d : descriptors) {
+ System.err.println(" Descriptor UUID: " + d.getUUID());
+ }
+ if (c.getUUID().contains("2a29-")) {
+ final byte[] tempRaw = c.readValue();
+ System.err.println(" Manufacturer: " + new String(tempRaw));
+ }
+
+ if (c.getUUID().contains("2a28-")) {
+ final byte[] tempRaw = c.readValue();
+ System.err.println(" Software: " + new String(tempRaw));
+ }
+
+ if (c.getUUID().contains("2a27-")) {
+ final byte[] tempRaw = c.readValue();
+ System.err.println(" Hardware: " + new String(tempRaw));
+ }
+
+ if (c.getUUID().contains("2a26-")) {
+ final byte[] tempRaw = c.readValue();
+ System.err.println(" Firmware: " + new String(tempRaw));
+ }
+
+ if (c.getUUID().contains("2a25-")) {
+ final byte[] tempRaw = c.readValue();
+ System.err.println(" Serial: " + new String(tempRaw));
+ }
+
+ if (c.getUUID().contains("2a24-")) {
+ final byte[] tempRaw = c.readValue();
+ System.err.println(" Model: " + new String(tempRaw));
+ }
+
+ if (c.getUUID().contains("2a23-")) {
+ final byte[] tempRaw = c.readValue();
+ System.err.println(" System ID: " + bytesToHex(tempRaw));
+ }
+ }
+ }
+ } catch (final RuntimeException e) {
+ }
+ }
+ private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
+ public static String bytesToHex(final byte[] bytes) {
+ final char[] hexChars = new char[bytes.length * 2];
+ for (int j = 0; j < bytes.length; j++) {
+ final int v = bytes[j] & 0xFF;
+ hexChars[j * 2] = HEX_ARRAY[v >>> 4];
+ hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
+ }
+ return new String(hexChars);
+ }
+ static class BooleanNotification implements BluetoothNotification<Boolean> {
+ private final long t0;
+ private final String name;
+ private boolean v;
+
+ public BooleanNotification(final String name, final long t0) {
+ this.t0 = t0;
+ this.name = name;
+ this.v = false;
+ }
+
+ @Override
+ public void run(final Boolean v) {
+ synchronized(this) {
+ final long t1 = System.currentTimeMillis();
+ this.v = v.booleanValue();
+ System.out.println("#### "+name+": "+v+" in td "+(t1-t0)+" ms!");
+ this.notifyAll();
+ }
+ }
+ public boolean getValue() {
+ synchronized(this) {
+ return v;
+ }
+ }
+ }
+}
diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt
index 33581bcf..4a17f8c5 100644
--- a/java/CMakeLists.txt
+++ b/java/CMakeLists.txt
@@ -17,25 +17,33 @@ if(NOT Java_JAVAH_EXECUTABLE)
endif(NOT Java_JAVAH_EXECUTABLE)
set(CMAKE_JNI_TARGET TRUE)
-file(GLOB JAVA_SOURCES "*.java")
+file(GLOB_RECURSE JAVA_SOURCES "*.java")
add_jar(tinybjar ${JAVA_SOURCES}
MANIFEST ${CMAKE_CURRENT_BINARY_DIR}/manifest.txt
- OUTPUT_NAME tinyb
+ OUTPUT_NAME tinyb2
)
-set(JAVA_CLASSES tinyb.BluetoothAdapter
- tinyb.BluetoothCallback
- tinyb.BluetoothDevice
- tinyb.BluetoothEvent
- tinyb.BluetoothGattCharacteristic
- tinyb.BluetoothGattService
- tinyb.BluetoothGattDescriptor
- tinyb.BluetoothManager
- tinyb.BluetoothObject
- tinyb.BluetoothType
- tinyb.BluetoothException
- tinyb.ObjectArgCallback
- tinyb.ObjectArrayArgCallback)
+set(JAVA_CLASSES org.tinyb.BluetoothAdapter
+ org.tinyb.BluetoothCallback
+ org.tinyb.BluetoothDevice
+ org.tinyb.BluetoothEvent
+ org.tinyb.BluetoothGattCharacteristic
+ org.tinyb.BluetoothGattService
+ org.tinyb.BluetoothGattDescriptor
+ org.tinyb.BluetoothManager
+ org.tinyb.BluetoothObject
+ org.tinyb.BluetoothType
+ org.tinyb.BluetoothException
+ org.tinyb.ObjectArgCallback
+ org.tinyb.ObjectArrayArgCallback
+ tinyb.dbus.DBusAdapter
+ tinyb.dbus.DBusDevice
+ tinyb.dbus.DBusEvent
+ tinyb.dbus.DBusGattCharacteristic
+ tinyb.dbus.DBusGattDescriptor
+ tinyb.dbus.DBusGattService
+ tinyb.dbus.DBusManager
+ tinyb.dbus.DBusObject)
add_custom_command (TARGET tinybjar
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating JNI headers.."
diff --git a/java/jni/BluetoothAdapter.cxx b/java/jni/DBusAdapter.cxx
index ffc72576..0c73a94f 100644
--- a/java/jni/BluetoothAdapter.cxx
+++ b/java/jni/DBusAdapter.cxx
@@ -26,14 +26,14 @@
#include "tinyb/BluetoothDevice.hpp"
#include "tinyb/BluetoothObject.hpp"
-#include "tinyb_BluetoothAdapter.h"
+#include "tinyb_dbus_DBusAdapter.h"
#include "JNIMem.hpp"
#include "helper.hpp"
using namespace tinyb;
-jobject Java_tinyb_BluetoothAdapter_getBluetoothType(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusAdapter_getBluetoothType(JNIEnv *env, jobject obj)
{
try {
(void)obj;
@@ -53,7 +53,7 @@ jobject Java_tinyb_BluetoothAdapter_getBluetoothType(JNIEnv *env, jobject obj)
return nullptr;
}
-jobject Java_tinyb_BluetoothAdapter_clone(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusAdapter_clone(JNIEnv *env, jobject obj)
{
try {
return generic_clone<BluetoothAdapter>(env, obj);
@@ -71,7 +71,7 @@ jobject Java_tinyb_BluetoothAdapter_clone(JNIEnv *env, jobject obj)
return nullptr;
}
-jboolean Java_tinyb_BluetoothAdapter_startDiscovery(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusAdapter_startDiscovery(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -91,7 +91,7 @@ jboolean Java_tinyb_BluetoothAdapter_startDiscovery(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jboolean Java_tinyb_BluetoothAdapter_stopDiscovery(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusAdapter_stopDiscovery(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -111,7 +111,7 @@ jboolean Java_tinyb_BluetoothAdapter_stopDiscovery(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jobject Java_tinyb_BluetoothAdapter_getDevices(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusAdapter_getDevices(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -134,7 +134,7 @@ jobject Java_tinyb_BluetoothAdapter_getDevices(JNIEnv *env, jobject obj)
return nullptr;
}
-jint Java_tinyb_BluetoothAdapter_removeDevices(JNIEnv *env, jobject obj)
+jint Java_tinyb_dbus_DBusAdapter_removeDevices(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -164,7 +164,7 @@ jint Java_tinyb_BluetoothAdapter_removeDevices(JNIEnv *env, jobject obj)
return 0;
}
-jstring Java_tinyb_BluetoothAdapter_getAddress(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusAdapter_getAddress(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -185,7 +185,7 @@ jstring Java_tinyb_BluetoothAdapter_getAddress(JNIEnv *env, jobject obj)
return nullptr;
}
-jstring Java_tinyb_BluetoothAdapter_getName(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusAdapter_getName(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -206,7 +206,7 @@ jstring Java_tinyb_BluetoothAdapter_getName(JNIEnv *env, jobject obj)
return nullptr;
}
-jstring Java_tinyb_BluetoothAdapter_getAlias(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusAdapter_getAlias(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -227,7 +227,7 @@ jstring Java_tinyb_BluetoothAdapter_getAlias(JNIEnv *env, jobject obj)
return nullptr;
}
-void Java_tinyb_BluetoothAdapter_setAlias(JNIEnv *env, jobject obj, jstring str)
+void Java_tinyb_dbus_DBusAdapter_setAlias(JNIEnv *env, jobject obj, jstring str)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -248,7 +248,7 @@ void Java_tinyb_BluetoothAdapter_setAlias(JNIEnv *env, jobject obj, jstring str)
}
}
-jlong Java_tinyb_BluetoothAdapter_getBluetoothClass(JNIEnv *env, jobject obj)
+jlong Java_tinyb_dbus_DBusAdapter_getBluetoothClass(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -268,7 +268,7 @@ jlong Java_tinyb_BluetoothAdapter_getBluetoothClass(JNIEnv *env, jobject obj)
return 0;
}
-jboolean Java_tinyb_BluetoothAdapter_getPowered(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusAdapter_getPowered(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -288,7 +288,7 @@ jboolean Java_tinyb_BluetoothAdapter_getPowered(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-void Java_tinyb_BluetoothAdapter_setPowered(JNIEnv *env, jobject obj, jboolean val)
+void Java_tinyb_dbus_DBusAdapter_setPowered(JNIEnv *env, jobject obj, jboolean val)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -308,7 +308,7 @@ void Java_tinyb_BluetoothAdapter_setPowered(JNIEnv *env, jobject obj, jboolean v
}
}
-void Java_tinyb_BluetoothAdapter_enablePoweredNotifications(JNIEnv *env, jobject obj, jobject callback)
+void Java_tinyb_dbus_DBusAdapter_enablePoweredNotifications(JNIEnv *env, jobject obj, jobject callback)
{
try {
BluetoothAdapter *obj_adapter =
@@ -343,7 +343,7 @@ void Java_tinyb_BluetoothAdapter_enablePoweredNotifications(JNIEnv *env, jobject
}
}
-void Java_tinyb_BluetoothAdapter_disablePoweredNotifications(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusAdapter_disablePoweredNotifications(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter =
@@ -362,7 +362,7 @@ void Java_tinyb_BluetoothAdapter_disablePoweredNotifications(JNIEnv *env, jobjec
}
}
-jboolean Java_tinyb_BluetoothAdapter_getDiscoverable(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusAdapter_getDiscoverable(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -382,7 +382,7 @@ jboolean Java_tinyb_BluetoothAdapter_getDiscoverable(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-void Java_tinyb_BluetoothAdapter_setDiscoverable(JNIEnv *env, jobject obj, jboolean val)
+void Java_tinyb_dbus_DBusAdapter_setDiscoverable(JNIEnv *env, jobject obj, jboolean val)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -402,7 +402,7 @@ void Java_tinyb_BluetoothAdapter_setDiscoverable(JNIEnv *env, jobject obj, jbool
}
}
-void Java_tinyb_BluetoothAdapter_enableDiscoverableNotifications(JNIEnv *env, jobject obj, jobject callback)
+void Java_tinyb_dbus_DBusAdapter_enableDiscoverableNotifications(JNIEnv *env, jobject obj, jobject callback)
{
try {
BluetoothAdapter *obj_adapter =
@@ -437,7 +437,7 @@ void Java_tinyb_BluetoothAdapter_enableDiscoverableNotifications(JNIEnv *env, jo
}
}
-void Java_tinyb_BluetoothAdapter_disableDiscoverableNotifications(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusAdapter_disableDiscoverableNotifications(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter =
@@ -456,7 +456,7 @@ void Java_tinyb_BluetoothAdapter_disableDiscoverableNotifications(JNIEnv *env, j
}
}
-jlong Java_tinyb_BluetoothAdapter_getDiscoverableTimeout(JNIEnv *env, jobject obj)
+jlong Java_tinyb_dbus_DBusAdapter_getDiscoverableTimeout(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -476,7 +476,7 @@ jlong Java_tinyb_BluetoothAdapter_getDiscoverableTimeout(JNIEnv *env, jobject ob
return 0;
}
-void Java_tinyb_BluetoothAdapter_setDiscoverableTimout(JNIEnv *env, jobject obj, jlong timeout)
+void Java_tinyb_dbus_DBusAdapter_setDiscoverableTimout(JNIEnv *env, jobject obj, jlong timeout)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -499,7 +499,7 @@ void Java_tinyb_BluetoothAdapter_setDiscoverableTimout(JNIEnv *env, jobject obj,
}
}
-jboolean Java_tinyb_BluetoothAdapter_getPairable(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusAdapter_getPairable(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -519,7 +519,7 @@ jboolean Java_tinyb_BluetoothAdapter_getPairable(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-void Java_tinyb_BluetoothAdapter_enablePairableNotifications(JNIEnv *env, jobject obj, jobject callback)
+void Java_tinyb_dbus_DBusAdapter_enablePairableNotifications(JNIEnv *env, jobject obj, jobject callback)
{
try {
BluetoothAdapter *obj_adapter =
@@ -554,7 +554,7 @@ void Java_tinyb_BluetoothAdapter_enablePairableNotifications(JNIEnv *env, jobjec
}
}
-void Java_tinyb_BluetoothAdapter_disablePairableNotifications(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusAdapter_disablePairableNotifications(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter =
@@ -573,7 +573,7 @@ void Java_tinyb_BluetoothAdapter_disablePairableNotifications(JNIEnv *env, jobje
}
}
-void Java_tinyb_BluetoothAdapter_setPairable(JNIEnv *env, jobject obj, jboolean val)
+void Java_tinyb_dbus_DBusAdapter_setPairable(JNIEnv *env, jobject obj, jboolean val)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -593,7 +593,7 @@ void Java_tinyb_BluetoothAdapter_setPairable(JNIEnv *env, jobject obj, jboolean
}
}
-jlong Java_tinyb_BluetoothAdapter_getPairableTimeout(JNIEnv *env, jobject obj)
+jlong Java_tinyb_dbus_DBusAdapter_getPairableTimeout(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -613,7 +613,7 @@ jlong Java_tinyb_BluetoothAdapter_getPairableTimeout(JNIEnv *env, jobject obj)
return 0;
}
-void Java_tinyb_BluetoothAdapter_setPairableTimeout(JNIEnv *env, jobject obj, jlong timeout)
+void Java_tinyb_dbus_DBusAdapter_setPairableTimeout(JNIEnv *env, jobject obj, jlong timeout)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -636,7 +636,7 @@ void Java_tinyb_BluetoothAdapter_setPairableTimeout(JNIEnv *env, jobject obj, jl
}
}
-jboolean Java_tinyb_BluetoothAdapter_getDiscovering(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusAdapter_getDiscovering(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -656,7 +656,7 @@ jboolean Java_tinyb_BluetoothAdapter_getDiscovering(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-void Java_tinyb_BluetoothAdapter_enableDiscoveringNotifications(JNIEnv *env, jobject obj, jobject callback)
+void Java_tinyb_dbus_DBusAdapter_enableDiscoveringNotifications(JNIEnv *env, jobject obj, jobject callback)
{
try {
BluetoothAdapter *obj_adapter =
@@ -691,7 +691,7 @@ void Java_tinyb_BluetoothAdapter_enableDiscoveringNotifications(JNIEnv *env, job
}
}
-void Java_tinyb_BluetoothAdapter_disableDiscoveringNotifications(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusAdapter_disableDiscoveringNotifications(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter =
@@ -710,7 +710,7 @@ void Java_tinyb_BluetoothAdapter_disableDiscoveringNotifications(JNIEnv *env, jo
}
}
-jobjectArray Java_tinyb_BluetoothAdapter_getUUIDs(JNIEnv *env, jobject obj)
+jobjectArray Java_tinyb_dbus_DBusAdapter_getUUIDs(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -746,7 +746,7 @@ jobjectArray Java_tinyb_BluetoothAdapter_getUUIDs(JNIEnv *env, jobject obj)
return nullptr;
}
-jstring Java_tinyb_BluetoothAdapter_getModalias(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusAdapter_getModalias(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -769,7 +769,7 @@ jstring Java_tinyb_BluetoothAdapter_getModalias(JNIEnv *env, jobject obj)
return nullptr;
}
-void Java_tinyb_BluetoothAdapter_delete(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusAdapter_delete(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -787,7 +787,7 @@ void Java_tinyb_BluetoothAdapter_delete(JNIEnv *env, jobject obj)
}
}
-void Java_tinyb_BluetoothAdapter_setDiscoveryFilter(JNIEnv *env, jobject obj, jobject uuids, jint rssi, jint pathloss, jint transportType)
+void Java_tinyb_dbus_DBusAdapter_setDiscoveryFilter(JNIEnv *env, jobject obj, jobject uuids, jint rssi, jint pathloss, jint transportType)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -824,7 +824,7 @@ void Java_tinyb_BluetoothAdapter_setDiscoveryFilter(JNIEnv *env, jobject obj, jo
}
}
-jobject Java_tinyb_BluetoothAdapter_connectDevice(JNIEnv *env, jobject obj, jstring jaddress, jstring jaddressType)
+jobject Java_tinyb_dbus_DBusAdapter_connectDevice(JNIEnv *env, jobject obj, jstring jaddress, jstring jaddressType)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
diff --git a/java/jni/BluetoothDevice.cxx b/java/jni/DBusDevice.cxx
index 5f9dcf41..896f1544 100644
--- a/java/jni/BluetoothDevice.cxx
+++ b/java/jni/DBusDevice.cxx
@@ -27,14 +27,14 @@
#include "tinyb/BluetoothGattService.hpp"
#include "tinyb/BluetoothObject.hpp"
-#include "tinyb_BluetoothDevice.h"
+#include "tinyb_dbus_DBusDevice.h"
#include "JNIMem.hpp"
#include "helper.hpp"
using namespace tinyb;
-jobject Java_tinyb_BluetoothDevice_getBluetoothType(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusDevice_getBluetoothType(JNIEnv *env, jobject obj)
{
try {
(void)obj;
@@ -54,7 +54,7 @@ jobject Java_tinyb_BluetoothDevice_getBluetoothType(JNIEnv *env, jobject obj)
return nullptr;
}
-jobject Java_tinyb_BluetoothDevice_clone(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusDevice_clone(JNIEnv *env, jobject obj)
{
try {
return generic_clone<BluetoothDevice>(env, obj);
@@ -72,7 +72,7 @@ jobject Java_tinyb_BluetoothDevice_clone(JNIEnv *env, jobject obj)
return nullptr;
}
-jboolean Java_tinyb_BluetoothDevice_disconnect(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusDevice_disconnect(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -92,7 +92,7 @@ jboolean Java_tinyb_BluetoothDevice_disconnect(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-void Java_tinyb_BluetoothDevice_connectAsyncStart(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusDevice_connectAsyncStart(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -111,7 +111,7 @@ void Java_tinyb_BluetoothDevice_connectAsyncStart(JNIEnv *env, jobject obj)
}
}
-jboolean Java_tinyb_BluetoothDevice_connectAsyncFinish(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusDevice_connectAsyncFinish(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -131,7 +131,7 @@ jboolean Java_tinyb_BluetoothDevice_connectAsyncFinish(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jboolean Java_tinyb_BluetoothDevice_connect(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusDevice_connect(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -151,7 +151,7 @@ jboolean Java_tinyb_BluetoothDevice_connect(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jboolean Java_tinyb_BluetoothDevice_connectProfile(JNIEnv *env, jobject obj, jstring str)
+jboolean Java_tinyb_dbus_DBusDevice_connectProfile(JNIEnv *env, jobject obj, jstring str)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -173,7 +173,7 @@ jboolean Java_tinyb_BluetoothDevice_connectProfile(JNIEnv *env, jobject obj, jst
return JNI_FALSE;
}
-jboolean Java_tinyb_BluetoothDevice_disconnectProfile(JNIEnv *env, jobject obj, jstring str)
+jboolean Java_tinyb_dbus_DBusDevice_disconnectProfile(JNIEnv *env, jobject obj, jstring str)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -195,7 +195,7 @@ jboolean Java_tinyb_BluetoothDevice_disconnectProfile(JNIEnv *env, jobject obj,
return JNI_FALSE;
}
-jboolean Java_tinyb_BluetoothDevice_pair(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusDevice_pair(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -215,7 +215,7 @@ jboolean Java_tinyb_BluetoothDevice_pair(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jboolean Java_tinyb_BluetoothDevice_remove(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusDevice_remove(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -235,7 +235,7 @@ jboolean Java_tinyb_BluetoothDevice_remove(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jboolean Java_tinyb_BluetoothDevice_cancelPairing(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusDevice_cancelPairing(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -255,7 +255,7 @@ jboolean Java_tinyb_BluetoothDevice_cancelPairing(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jobject Java_tinyb_BluetoothDevice_getServices(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusDevice_getServices(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -278,7 +278,7 @@ jobject Java_tinyb_BluetoothDevice_getServices(JNIEnv *env, jobject obj)
return nullptr;
}
-jstring Java_tinyb_BluetoothDevice_getAddress(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusDevice_getAddress(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -299,7 +299,7 @@ jstring Java_tinyb_BluetoothDevice_getAddress(JNIEnv *env, jobject obj)
return nullptr;
}
-jstring Java_tinyb_BluetoothDevice_getName(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusDevice_getName(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -320,7 +320,7 @@ jstring Java_tinyb_BluetoothDevice_getName(JNIEnv *env, jobject obj)
return nullptr;
}
-jstring Java_tinyb_BluetoothDevice_getAlias(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusDevice_getAlias(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -341,7 +341,7 @@ jstring Java_tinyb_BluetoothDevice_getAlias(JNIEnv *env, jobject obj)
return nullptr;
}
-void Java_tinyb_BluetoothDevice_setAlias(JNIEnv *env, jobject obj, jstring str)
+void Java_tinyb_dbus_DBusDevice_setAlias(JNIEnv *env, jobject obj, jstring str)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -362,7 +362,7 @@ void Java_tinyb_BluetoothDevice_setAlias(JNIEnv *env, jobject obj, jstring str)
}
}
-jint Java_tinyb_BluetoothDevice_getBluetoothClass(JNIEnv *env, jobject obj)
+jint Java_tinyb_dbus_DBusDevice_getBluetoothClass(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -382,7 +382,7 @@ jint Java_tinyb_BluetoothDevice_getBluetoothClass(JNIEnv *env, jobject obj)
return 0;
}
-jshort Java_tinyb_BluetoothDevice_getAppearance(JNIEnv *env, jobject obj)
+jshort Java_tinyb_dbus_DBusDevice_getAppearance(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -402,7 +402,7 @@ jshort Java_tinyb_BluetoothDevice_getAppearance(JNIEnv *env, jobject obj)
return 0;
}
-jstring Java_tinyb_BluetoothDevice_getIcon(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusDevice_getIcon(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -425,7 +425,7 @@ jstring Java_tinyb_BluetoothDevice_getIcon(JNIEnv *env, jobject obj)
return nullptr;
}
-jboolean Java_tinyb_BluetoothDevice_getPaired(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusDevice_getPaired(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -445,7 +445,7 @@ jboolean Java_tinyb_BluetoothDevice_getPaired(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-void Java_tinyb_BluetoothDevice_enablePairedNotifications(JNIEnv *env, jobject obj, jobject callback)
+void Java_tinyb_dbus_DBusDevice_enablePairedNotifications(JNIEnv *env, jobject obj, jobject callback)
{
try {
BluetoothDevice *obj_device =
@@ -480,7 +480,7 @@ void Java_tinyb_BluetoothDevice_enablePairedNotifications(JNIEnv *env, jobject o
}
}
-void Java_tinyb_BluetoothDevice_disablePairedNotifications(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusDevice_disablePairedNotifications(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device =
@@ -499,7 +499,7 @@ void Java_tinyb_BluetoothDevice_disablePairedNotifications(JNIEnv *env, jobject
}
}
-jboolean Java_tinyb_BluetoothDevice_getTrusted(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusDevice_getTrusted(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -519,7 +519,7 @@ jboolean Java_tinyb_BluetoothDevice_getTrusted(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-void Java_tinyb_BluetoothDevice_setTrusted(JNIEnv *env, jobject obj, jboolean val)
+void Java_tinyb_dbus_DBusDevice_setTrusted(JNIEnv *env, jobject obj, jboolean val)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -539,7 +539,7 @@ void Java_tinyb_BluetoothDevice_setTrusted(JNIEnv *env, jobject obj, jboolean va
}
}
-void Java_tinyb_BluetoothDevice_enableTrustedNotifications(JNIEnv *env, jobject obj, jobject callback)
+void Java_tinyb_dbus_DBusDevice_enableTrustedNotifications(JNIEnv *env, jobject obj, jobject callback)
{
try {
BluetoothDevice *obj_device =
@@ -574,7 +574,7 @@ void Java_tinyb_BluetoothDevice_enableTrustedNotifications(JNIEnv *env, jobject
}
}
-void Java_tinyb_BluetoothDevice_disableTrustedNotifications(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusDevice_disableTrustedNotifications(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device =
@@ -593,7 +593,7 @@ void Java_tinyb_BluetoothDevice_disableTrustedNotifications(JNIEnv *env, jobject
}
}
-jboolean Java_tinyb_BluetoothDevice_getBlocked(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusDevice_getBlocked(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -613,7 +613,7 @@ jboolean Java_tinyb_BluetoothDevice_getBlocked(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-void Java_tinyb_BluetoothDevice_setBlocked(JNIEnv *env, jobject obj, jboolean val)
+void Java_tinyb_dbus_DBusDevice_setBlocked(JNIEnv *env, jobject obj, jboolean val)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -633,7 +633,7 @@ void Java_tinyb_BluetoothDevice_setBlocked(JNIEnv *env, jobject obj, jboolean va
}
}
-void Java_tinyb_BluetoothDevice_enableBlockedNotifications(JNIEnv *env, jobject obj, jobject callback)
+void Java_tinyb_dbus_DBusDevice_enableBlockedNotifications(JNIEnv *env, jobject obj, jobject callback)
{
try {
BluetoothDevice *obj_device =
@@ -668,7 +668,7 @@ void Java_tinyb_BluetoothDevice_enableBlockedNotifications(JNIEnv *env, jobject
}
}
-void Java_tinyb_BluetoothDevice_disableBlockedNotifications(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusDevice_disableBlockedNotifications(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device =
@@ -687,7 +687,7 @@ void Java_tinyb_BluetoothDevice_disableBlockedNotifications(JNIEnv *env, jobject
}
}
-jboolean Java_tinyb_BluetoothDevice_getLegacyPairing(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusDevice_getLegacyPairing(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -707,7 +707,7 @@ jboolean Java_tinyb_BluetoothDevice_getLegacyPairing(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jshort Java_tinyb_BluetoothDevice_getRSSI(JNIEnv *env, jobject obj)
+jshort Java_tinyb_dbus_DBusDevice_getRSSI(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -727,7 +727,7 @@ jshort Java_tinyb_BluetoothDevice_getRSSI(JNIEnv *env, jobject obj)
return 0;
}
-void Java_tinyb_BluetoothDevice_enableRSSINotifications(JNIEnv *env, jobject obj, jobject callback)
+void Java_tinyb_dbus_DBusDevice_enableRSSINotifications(JNIEnv *env, jobject obj, jobject callback)
{
try {
BluetoothDevice *obj_device =
@@ -762,7 +762,7 @@ void Java_tinyb_BluetoothDevice_enableRSSINotifications(JNIEnv *env, jobject obj
}
}
-void Java_tinyb_BluetoothDevice_disableRSSINotifications(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusDevice_disableRSSINotifications(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device =
@@ -781,7 +781,7 @@ void Java_tinyb_BluetoothDevice_disableRSSINotifications(JNIEnv *env, jobject ob
}
}
-jboolean Java_tinyb_BluetoothDevice_getConnected(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusDevice_getConnected(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -801,7 +801,7 @@ jboolean Java_tinyb_BluetoothDevice_getConnected(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-void Java_tinyb_BluetoothDevice_enableConnectedNotifications(JNIEnv *env, jobject obj, jobject callback)
+void Java_tinyb_dbus_DBusDevice_enableConnectedNotifications(JNIEnv *env, jobject obj, jobject callback)
{
try {
BluetoothDevice *obj_device =
@@ -836,7 +836,7 @@ void Java_tinyb_BluetoothDevice_enableConnectedNotifications(JNIEnv *env, jobjec
}
}
-void Java_tinyb_BluetoothDevice_disableConnectedNotifications(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusDevice_disableConnectedNotifications(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device =
@@ -855,7 +855,7 @@ void Java_tinyb_BluetoothDevice_disableConnectedNotifications(JNIEnv *env, jobje
}
}
-jobjectArray Java_tinyb_BluetoothDevice_getUUIDs(JNIEnv *env, jobject obj)
+jobjectArray Java_tinyb_dbus_DBusDevice_getUUIDs(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -887,7 +887,7 @@ jobjectArray Java_tinyb_BluetoothDevice_getUUIDs(JNIEnv *env, jobject obj)
return nullptr;
}
-jstring Java_tinyb_BluetoothDevice_getModalias(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusDevice_getModalias(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -910,7 +910,7 @@ jstring Java_tinyb_BluetoothDevice_getModalias(JNIEnv *env, jobject obj)
return nullptr;
}
-jobject Java_tinyb_BluetoothDevice_getAdapter(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusDevice_getAdapter(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -940,7 +940,7 @@ jobject Java_tinyb_BluetoothDevice_getAdapter(JNIEnv *env, jobject obj)
return nullptr;
}
-jobject Java_tinyb_BluetoothDevice_getManufacturerData(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusDevice_getManufacturerData(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -989,7 +989,7 @@ jobject Java_tinyb_BluetoothDevice_getManufacturerData(JNIEnv *env, jobject obj)
return nullptr;
}
-void Java_tinyb_BluetoothDevice_enableManufacturerDataNotifications(JNIEnv *env, jobject obj, jobject callback)
+void Java_tinyb_dbus_DBusDevice_enableManufacturerDataNotifications(JNIEnv *env, jobject obj, jobject callback)
{
try {
BluetoothDevice *obj_device =
@@ -1042,7 +1042,7 @@ void Java_tinyb_BluetoothDevice_enableManufacturerDataNotifications(JNIEnv *env,
}
}
-void Java_tinyb_BluetoothDevice_disableManufacturerDataNotifications(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusDevice_disableManufacturerDataNotifications(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device =
@@ -1061,7 +1061,7 @@ void Java_tinyb_BluetoothDevice_disableManufacturerDataNotifications(JNIEnv *env
}
}
-jobject Java_tinyb_BluetoothDevice_getServiceData(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusDevice_getServiceData(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -1106,7 +1106,7 @@ jobject Java_tinyb_BluetoothDevice_getServiceData(JNIEnv *env, jobject obj)
return nullptr;
}
-void Java_tinyb_BluetoothDevice_enableServiceDataNotifications(JNIEnv *env, jobject obj, jobject callback)
+void Java_tinyb_dbus_DBusDevice_enableServiceDataNotifications(JNIEnv *env, jobject obj, jobject callback)
{
try {
BluetoothDevice *obj_device =
@@ -1154,7 +1154,7 @@ void Java_tinyb_BluetoothDevice_enableServiceDataNotifications(JNIEnv *env, jobj
}
}
-void Java_tinyb_BluetoothDevice_disableServiceDataNotifications(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusDevice_disableServiceDataNotifications(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device =
@@ -1175,7 +1175,7 @@ void Java_tinyb_BluetoothDevice_disableServiceDataNotifications(JNIEnv *env, job
-jshort Java_tinyb_BluetoothDevice_getTxPower(JNIEnv *env, jobject obj)
+jshort Java_tinyb_dbus_DBusDevice_getTxPower(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -1195,7 +1195,7 @@ jshort Java_tinyb_BluetoothDevice_getTxPower(JNIEnv *env, jobject obj)
return 0;
}
-jboolean Java_tinyb_BluetoothDevice_getServicesResolved(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusDevice_getServicesResolved(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
@@ -1215,7 +1215,7 @@ jboolean Java_tinyb_BluetoothDevice_getServicesResolved(JNIEnv *env, jobject obj
return JNI_FALSE;
}
-void Java_tinyb_BluetoothDevice_enableServicesResolvedNotifications(JNIEnv *env, jobject obj, jobject callback)
+void Java_tinyb_dbus_DBusDevice_enableServicesResolvedNotifications(JNIEnv *env, jobject obj, jobject callback)
{
try {
BluetoothDevice *obj_device =
@@ -1250,7 +1250,7 @@ void Java_tinyb_BluetoothDevice_enableServicesResolvedNotifications(JNIEnv *env,
}
}
-void Java_tinyb_BluetoothDevice_disableServicesResolvedNotifications(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusDevice_disableServicesResolvedNotifications(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *obj_device =
@@ -1271,7 +1271,7 @@ void Java_tinyb_BluetoothDevice_disableServicesResolvedNotifications(JNIEnv *env
-void Java_tinyb_BluetoothDevice_delete(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusDevice_delete(JNIEnv *env, jobject obj)
{
try {
BluetoothDevice *b_device = getInstance<BluetoothDevice>(env, obj);
diff --git a/java/jni/BluetoothEvent.cxx b/java/jni/DBusEvent.cxx
index b3acd349..14b6431c 100644
--- a/java/jni/BluetoothEvent.cxx
+++ b/java/jni/DBusEvent.cxx
@@ -22,9 +22,9 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "tinyb_BluetoothEvent.h"
+#include "tinyb_dbus_DBusEvent.h"
-jobject Java_tinyb_BluetoothEvent_getType(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusEvent_getType(JNIEnv *env, jobject obj)
{
(void)env;
(void)obj;
@@ -32,7 +32,7 @@ jobject Java_tinyb_BluetoothEvent_getType(JNIEnv *env, jobject obj)
return NULL;
}
-jstring Java_tinyb_BluetoothEvent_getName(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusEvent_getName(JNIEnv *env, jobject obj)
{
(void)env;
(void)obj;
@@ -40,7 +40,7 @@ jstring Java_tinyb_BluetoothEvent_getName(JNIEnv *env, jobject obj)
return NULL;
}
-jstring Java_tinyb_BluetoothEvent_getIdentifier(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusEvent_getIdentifier(JNIEnv *env, jobject obj)
{
(void)env;
(void)obj;
@@ -48,7 +48,7 @@ jstring Java_tinyb_BluetoothEvent_getIdentifier(JNIEnv *env, jobject obj)
return NULL;
}
-jboolean Java_tinyb_BluetoothEvent_executeCallback(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusEvent_executeCallback(JNIEnv *env, jobject obj)
{
(void)env;
(void)obj;
@@ -56,7 +56,7 @@ jboolean Java_tinyb_BluetoothEvent_executeCallback(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jboolean Java_tinyb_BluetoothEvent_hasCallback(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusEvent_hasCallback(JNIEnv *env, jobject obj)
{
(void)env;
(void)obj;
@@ -64,7 +64,7 @@ jboolean Java_tinyb_BluetoothEvent_hasCallback(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-void Java_tinyb_BluetoothEvent_init(JNIEnv *env, jobject obj, jobject type, jstring name,
+void Java_tinyb_dbus_DBusEvent_init(JNIEnv *env, jobject obj, jobject type, jstring name,
jstring identifier, jobject parent, jobject callback,
jobject arg_data)
{
@@ -78,7 +78,7 @@ void Java_tinyb_BluetoothEvent_init(JNIEnv *env, jobject obj, jobject type, jstr
(void)arg_data;
}
-void Java_tinyb_BluetoothEvent_delete(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusEvent_delete(JNIEnv *env, jobject obj)
{
(void)env;
(void)obj;
diff --git a/java/jni/BluetoothGattCharacteristic.cxx b/java/jni/DBusGattCharacteristic.cxx
index 0a62b516..a3e9428f 100644
--- a/java/jni/BluetoothGattCharacteristic.cxx
+++ b/java/jni/DBusGattCharacteristic.cxx
@@ -27,14 +27,14 @@
#include "tinyb/BluetoothGattService.hpp"
#include "tinyb/BluetoothObject.hpp"
-#include "tinyb_BluetoothGattCharacteristic.h"
+#include "tinyb_dbus_DBusGattCharacteristic.h"
#include "JNIMem.hpp"
#include "helper.hpp"
using namespace tinyb;
-jobject Java_tinyb_BluetoothGattCharacteristic_getBluetoothType(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusGattCharacteristic_getBluetoothType(JNIEnv *env, jobject obj)
{
try {
(void)obj;
@@ -54,7 +54,7 @@ jobject Java_tinyb_BluetoothGattCharacteristic_getBluetoothType(JNIEnv *env, job
return nullptr;
}
-jobject Java_tinyb_BluetoothGattCharacteristic_clone(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusGattCharacteristic_clone(JNIEnv *env, jobject obj)
{
try {
return generic_clone<BluetoothGattCharacteristic>(env, obj);
@@ -72,7 +72,7 @@ jobject Java_tinyb_BluetoothGattCharacteristic_clone(JNIEnv *env, jobject obj)
return nullptr;
}
-jbyteArray Java_tinyb_BluetoothGattCharacteristic_readValue(JNIEnv *env, jobject obj)
+jbyteArray Java_tinyb_dbus_DBusGattCharacteristic_readValue(JNIEnv *env, jobject obj)
{
try {
BluetoothGattCharacteristic *obj_gatt_char =
@@ -98,7 +98,7 @@ jbyteArray Java_tinyb_BluetoothGattCharacteristic_readValue(JNIEnv *env, jobject
return nullptr;
}
-jboolean Java_tinyb_BluetoothGattCharacteristic_writeValue(JNIEnv *env, jobject obj, jbyteArray argValue)
+jboolean Java_tinyb_dbus_DBusGattCharacteristic_writeValue(JNIEnv *env, jobject obj, jbyteArray argValue)
{
try {
if (!argValue)
@@ -131,7 +131,7 @@ jboolean Java_tinyb_BluetoothGattCharacteristic_writeValue(JNIEnv *env, jobject
return JNI_FALSE;
}
-void Java_tinyb_BluetoothGattCharacteristic_enableValueNotifications(JNIEnv *env, jobject obj, jobject callback)
+void Java_tinyb_dbus_DBusGattCharacteristic_enableValueNotifications(JNIEnv *env, jobject obj, jobject callback)
{
try {
BluetoothGattCharacteristic *obj_gatt_char =
@@ -164,7 +164,7 @@ void Java_tinyb_BluetoothGattCharacteristic_enableValueNotifications(JNIEnv *env
}
}
-void Java_tinyb_BluetoothGattCharacteristic_disableValueNotifications(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusGattCharacteristic_disableValueNotifications(JNIEnv *env, jobject obj)
{
try {
BluetoothGattCharacteristic *obj_gatt_char =
@@ -183,7 +183,7 @@ void Java_tinyb_BluetoothGattCharacteristic_disableValueNotifications(JNIEnv *en
}
}
-jstring Java_tinyb_BluetoothGattCharacteristic_getUUID(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusGattCharacteristic_getUUID(JNIEnv *env, jobject obj)
{
try {
BluetoothGattCharacteristic *obj_gatt_char =
@@ -205,7 +205,7 @@ jstring Java_tinyb_BluetoothGattCharacteristic_getUUID(JNIEnv *env, jobject obj)
return nullptr;
}
-jobject Java_tinyb_BluetoothGattCharacteristic_getService(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusGattCharacteristic_getService(JNIEnv *env, jobject obj)
{
try {
BluetoothGattCharacteristic *obj_gatt_char =
@@ -236,7 +236,7 @@ jobject Java_tinyb_BluetoothGattCharacteristic_getService(JNIEnv *env, jobject o
return nullptr;
}
-jbyteArray Java_tinyb_BluetoothGattCharacteristic_getValue(JNIEnv *env, jobject obj)
+jbyteArray Java_tinyb_dbus_DBusGattCharacteristic_getValue(JNIEnv *env, jobject obj)
{
try {
BluetoothGattCharacteristic *obj_gatt_char =
@@ -262,7 +262,7 @@ jbyteArray Java_tinyb_BluetoothGattCharacteristic_getValue(JNIEnv *env, jobject
return nullptr;
}
-jboolean Java_tinyb_BluetoothGattCharacteristic_getNotifying(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusGattCharacteristic_getNotifying(JNIEnv *env, jobject obj)
{
try {
BluetoothGattCharacteristic *obj_gatt_char =
@@ -282,7 +282,7 @@ jboolean Java_tinyb_BluetoothGattCharacteristic_getNotifying(JNIEnv *env, jobjec
return JNI_FALSE;
}
-jobjectArray Java_tinyb_BluetoothGattCharacteristic_getFlags(JNIEnv *env, jobject obj)
+jobjectArray Java_tinyb_dbus_DBusGattCharacteristic_getFlags(JNIEnv *env, jobject obj)
{
try {
BluetoothGattCharacteristic *obj_gatt_char =
@@ -315,7 +315,7 @@ jobjectArray Java_tinyb_BluetoothGattCharacteristic_getFlags(JNIEnv *env, jobjec
return nullptr;
}
-jobject Java_tinyb_BluetoothGattCharacteristic_getDescriptors(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusGattCharacteristic_getDescriptors(JNIEnv *env, jobject obj)
{
try {
BluetoothGattCharacteristic *obj_gatt_char =
@@ -339,7 +339,7 @@ jobject Java_tinyb_BluetoothGattCharacteristic_getDescriptors(JNIEnv *env, jobje
return nullptr;
}
-void Java_tinyb_BluetoothGattCharacteristic_delete(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusGattCharacteristic_delete(JNIEnv *env, jobject obj)
{
try {
BluetoothGattCharacteristic *obj_gatt_char =
diff --git a/java/jni/BluetoothGattDescriptor.cxx b/java/jni/DBusGattDescriptor.cxx
index e43b8db1..bdb83fc0 100644
--- a/java/jni/BluetoothGattDescriptor.cxx
+++ b/java/jni/DBusGattDescriptor.cxx
@@ -26,14 +26,14 @@
#include "tinyb/BluetoothGattDescriptor.hpp"
#include "tinyb/BluetoothObject.hpp"
-#include "tinyb_BluetoothGattDescriptor.h"
+#include "tinyb_dbus_DBusGattDescriptor.h"
#include "JNIMem.hpp"
#include "helper.hpp"
using namespace tinyb;
-jobject Java_tinyb_BluetoothGattDescriptor_getBluetoothType(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusGattDescriptor_getBluetoothType(JNIEnv *env, jobject obj)
{
try {
(void)obj;
@@ -53,7 +53,7 @@ jobject Java_tinyb_BluetoothGattDescriptor_getBluetoothType(JNIEnv *env, jobject
return nullptr;
}
-jobject Java_tinyb_BluetoothGattDescriptor_clone(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusGattDescriptor_clone(JNIEnv *env, jobject obj)
{
try {
return generic_clone<BluetoothGattDescriptor>(env, obj);
@@ -71,7 +71,7 @@ jobject Java_tinyb_BluetoothGattDescriptor_clone(JNIEnv *env, jobject obj)
return nullptr;
}
-jbyteArray Java_tinyb_BluetoothGattDescriptor_readValue(JNIEnv *env, jobject obj)
+jbyteArray Java_tinyb_dbus_DBusGattDescriptor_readValue(JNIEnv *env, jobject obj)
{
try {
BluetoothGattDescriptor *obj_gatt_desc = getInstance<BluetoothGattDescriptor>(env, obj);
@@ -96,7 +96,7 @@ jbyteArray Java_tinyb_BluetoothGattDescriptor_readValue(JNIEnv *env, jobject obj
return nullptr;
}
-jboolean Java_tinyb_BluetoothGattDescriptor_writeValue(JNIEnv *env, jobject obj, jbyteArray argValue)
+jboolean Java_tinyb_dbus_DBusGattDescriptor_writeValue(JNIEnv *env, jobject obj, jbyteArray argValue)
{
try {
if (!argValue)
@@ -127,7 +127,7 @@ jboolean Java_tinyb_BluetoothGattDescriptor_writeValue(JNIEnv *env, jobject obj,
return JNI_FALSE;
}
-jstring Java_tinyb_BluetoothGattDescriptor_getUUID(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusGattDescriptor_getUUID(JNIEnv *env, jobject obj)
{
try {
BluetoothGattDescriptor *obj_gatt_desc = getInstance<BluetoothGattDescriptor>(env, obj);
@@ -148,7 +148,7 @@ jstring Java_tinyb_BluetoothGattDescriptor_getUUID(JNIEnv *env, jobject obj)
return nullptr;
}
-jobject Java_tinyb_BluetoothGattDescriptor_getCharacteristic(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusGattDescriptor_getCharacteristic(JNIEnv *env, jobject obj)
{
try {
BluetoothGattDescriptor *obj_gatt_desc = getInstance<BluetoothGattDescriptor>(env, obj);
@@ -178,7 +178,7 @@ jobject Java_tinyb_BluetoothGattDescriptor_getCharacteristic(JNIEnv *env, jobjec
return nullptr;
}
-jbyteArray Java_tinyb_BluetoothGattDescriptor_getValue(JNIEnv *env, jobject obj)
+jbyteArray Java_tinyb_dbus_DBusGattDescriptor_getValue(JNIEnv *env, jobject obj)
{
try {
BluetoothGattDescriptor *obj_gatt_desc = getInstance<BluetoothGattDescriptor>(env, obj);
@@ -204,7 +204,7 @@ jbyteArray Java_tinyb_BluetoothGattDescriptor_getValue(JNIEnv *env, jobject obj)
return nullptr;
}
-void Java_tinyb_BluetoothGattDescriptor_enableValueNotifications(JNIEnv *env, jobject obj, jobject callback)
+void Java_tinyb_dbus_DBusGattDescriptor_enableValueNotifications(JNIEnv *env, jobject obj, jobject callback)
{
try {
BluetoothGattDescriptor *obj_gatt_desc =
@@ -237,7 +237,7 @@ void Java_tinyb_BluetoothGattDescriptor_enableValueNotifications(JNIEnv *env, jo
}
}
-void Java_tinyb_BluetoothGattDescriptor_disableValueNotifications(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusGattDescriptor_disableValueNotifications(JNIEnv *env, jobject obj)
{
try {
BluetoothGattDescriptor *obj_gatt_desc =
@@ -257,7 +257,7 @@ void Java_tinyb_BluetoothGattDescriptor_disableValueNotifications(JNIEnv *env, j
}
-void Java_tinyb_BluetoothGattDescriptor_delete(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusGattDescriptor_delete(JNIEnv *env, jobject obj)
{
try {
BluetoothGattDescriptor *obj_gatt_desc = getInstance<BluetoothGattDescriptor>(env, obj);
diff --git a/java/jni/BluetoothGattService.cxx b/java/jni/DBusGattService.cxx
index 2f1c922b..6ac0963f 100644
--- a/java/jni/BluetoothGattService.cxx
+++ b/java/jni/DBusGattService.cxx
@@ -27,13 +27,13 @@
#include "tinyb/BluetoothGattCharacteristic.hpp"
#include "tinyb/BluetoothObject.hpp"
-#include "tinyb_BluetoothGattService.h"
+#include "tinyb_dbus_DBusGattService.h"
#include "helper.hpp"
using namespace tinyb;
-jobject Java_tinyb_BluetoothGattService_getBluetoothType(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusGattService_getBluetoothType(JNIEnv *env, jobject obj)
{
try {
(void)obj;
@@ -53,7 +53,7 @@ jobject Java_tinyb_BluetoothGattService_getBluetoothType(JNIEnv *env, jobject ob
return nullptr;
}
-jobject Java_tinyb_BluetoothGattService_clone(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusGattService_clone(JNIEnv *env, jobject obj)
{
try {
return generic_clone<BluetoothGattService>(env, obj);
@@ -71,7 +71,7 @@ jobject Java_tinyb_BluetoothGattService_clone(JNIEnv *env, jobject obj)
return nullptr;
}
-jstring Java_tinyb_BluetoothGattService_getUUID(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusGattService_getUUID(JNIEnv *env, jobject obj)
{
try {
BluetoothGattService *obj_gatt_serv = getInstance<BluetoothGattService>(env, obj);
@@ -92,7 +92,7 @@ jstring Java_tinyb_BluetoothGattService_getUUID(JNIEnv *env, jobject obj)
return nullptr;
}
-jobject Java_tinyb_BluetoothGattService_getDevice(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusGattService_getDevice(JNIEnv *env, jobject obj)
{
try {
BluetoothGattService *obj_gatt_serv = getInstance<BluetoothGattService>(env, obj);
@@ -122,7 +122,7 @@ jobject Java_tinyb_BluetoothGattService_getDevice(JNIEnv *env, jobject obj)
return nullptr;
}
-jboolean Java_tinyb_BluetoothGattService_getPrimary(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusGattService_getPrimary(JNIEnv *env, jobject obj)
{
try {
BluetoothGattService *obj_gatt_serv = getInstance<BluetoothGattService>(env, obj);
@@ -142,7 +142,7 @@ jboolean Java_tinyb_BluetoothGattService_getPrimary(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jobject Java_tinyb_BluetoothGattService_getCharacteristics(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusGattService_getCharacteristics(JNIEnv *env, jobject obj)
{
try {
BluetoothGattService *obj_gatt_serv = getInstance<BluetoothGattService>(env, obj);
@@ -165,7 +165,7 @@ jobject Java_tinyb_BluetoothGattService_getCharacteristics(JNIEnv *env, jobject
return nullptr;
}
-void Java_tinyb_BluetoothGattService_delete(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusGattService_delete(JNIEnv *env, jobject obj)
{
try {
BluetoothGattService *obj_gatt_serv = getInstance<BluetoothGattService>(env, obj);
diff --git a/java/jni/BluetoothManager.cxx b/java/jni/DBusManager.cxx
index dc6b038a..85f7fd75 100644
--- a/java/jni/BluetoothManager.cxx
+++ b/java/jni/DBusManager.cxx
@@ -27,13 +27,13 @@
#include "tinyb/BluetoothGattService.hpp"
#include "tinyb/BluetoothManager.hpp"
-#include "tinyb_BluetoothManager.h"
+#include "tinyb_dbus_DBusManager.h"
#include "helper.hpp"
using namespace tinyb;
-jobject Java_tinyb_BluetoothManager_getBluetoothType(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusManager_getBluetoothType(JNIEnv *env, jobject obj)
{
try {
(void)obj;
@@ -107,7 +107,7 @@ static void getObject_cleaner(std::string *name_to_write, std::string *identifie
delete identifier_to_write;
}
-jobject Java_tinyb_BluetoothManager_find(JNIEnv *env, jobject obj, jint type,
+jobject Java_tinyb_dbus_DBusManager_find(JNIEnv *env, jobject obj, jint type,
jstring name, jstring identifier, jobject parent,
jlong milliseconds)
{
@@ -157,7 +157,7 @@ jobject Java_tinyb_BluetoothManager_find(JNIEnv *env, jobject obj, jint type,
}
-jobject Java_tinyb_BluetoothManager_getObject(JNIEnv *env, jobject obj, jint type,
+jobject Java_tinyb_dbus_DBusManager_getObject(JNIEnv *env, jobject obj, jint type,
jstring name, jstring identifier, jobject parent)
{
try {
@@ -202,7 +202,7 @@ jobject Java_tinyb_BluetoothManager_getObject(JNIEnv *env, jobject obj, jint typ
return nullptr;
}
-jobject Java_tinyb_BluetoothManager_getObjects(JNIEnv *env, jobject obj, jint type,
+jobject Java_tinyb_dbus_DBusManager_getObjects(JNIEnv *env, jobject obj, jint type,
jstring name, jstring identifier, jobject parent)
{
try {
@@ -239,7 +239,7 @@ jobject Java_tinyb_BluetoothManager_getObjects(JNIEnv *env, jobject obj, jint ty
return nullptr;
}
-jobject Java_tinyb_BluetoothManager_getAdapters(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusManager_getAdapters(JNIEnv *env, jobject obj)
{
try {
BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
@@ -262,7 +262,7 @@ jobject Java_tinyb_BluetoothManager_getAdapters(JNIEnv *env, jobject obj)
return nullptr;
}
-jobject Java_tinyb_BluetoothManager_getDevices(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusManager_getDevices(JNIEnv *env, jobject obj)
{
try {
BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
@@ -285,7 +285,7 @@ jobject Java_tinyb_BluetoothManager_getDevices(JNIEnv *env, jobject obj)
return nullptr;
}
-jobject Java_tinyb_BluetoothManager_getServices(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusManager_getServices(JNIEnv *env, jobject obj)
{
try {
BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
@@ -308,7 +308,7 @@ jobject Java_tinyb_BluetoothManager_getServices(JNIEnv *env, jobject obj)
return nullptr;
}
-jboolean Java_tinyb_BluetoothManager_setDefaultAdapter(JNIEnv *env, jobject obj, jobject adapter)
+jboolean Java_tinyb_dbus_DBusManager_setDefaultAdapter(JNIEnv *env, jobject obj, jobject adapter)
{
try {
if (adapter == nullptr)
@@ -332,7 +332,7 @@ jboolean Java_tinyb_BluetoothManager_setDefaultAdapter(JNIEnv *env, jobject obj,
return JNI_FALSE;
}
-jobject Java_tinyb_BluetoothManager_getDefaultAdapter(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusManager_getDefaultAdapter(JNIEnv *env, jobject obj)
{
try {
BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
@@ -362,7 +362,7 @@ jobject Java_tinyb_BluetoothManager_getDefaultAdapter(JNIEnv *env, jobject obj)
return NULL;
}
-jboolean Java_tinyb_BluetoothManager_startDiscovery(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusManager_startDiscovery(JNIEnv *env, jobject obj)
{
try {
BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
@@ -381,7 +381,7 @@ jboolean Java_tinyb_BluetoothManager_startDiscovery(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jboolean Java_tinyb_BluetoothManager_stopDiscovery(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusManager_stopDiscovery(JNIEnv *env, jobject obj)
{
try {
BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
@@ -400,7 +400,7 @@ jboolean Java_tinyb_BluetoothManager_stopDiscovery(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jboolean Java_tinyb_BluetoothManager_getDiscovering(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusManager_getDiscovering(JNIEnv *env, jobject obj)
{
try {
BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
@@ -419,7 +419,7 @@ jboolean Java_tinyb_BluetoothManager_getDiscovering(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-void Java_tinyb_BluetoothManager_init(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusManager_init(JNIEnv *env, jobject obj)
{
try {
BluetoothManager *manager = BluetoothManager::get_bluetooth_manager();
@@ -437,7 +437,7 @@ void Java_tinyb_BluetoothManager_init(JNIEnv *env, jobject obj)
}
}
-void Java_tinyb_BluetoothManager_delete(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusManager_delete(JNIEnv *env, jobject obj)
{
try {
BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
@@ -455,7 +455,7 @@ void Java_tinyb_BluetoothManager_delete(JNIEnv *env, jobject obj)
}
}
-jstring Java_tinyb_BluetoothManager_getNativeAPIVersion(JNIEnv *env, jclass clazz)
+jstring Java_tinyb_dbus_DBusManager_getNativeAPIVersion(JNIEnv *env, jclass clazz)
{
try {
(void) clazz;
diff --git a/java/jni/BluetoothObject.cxx b/java/jni/DBusObject.cxx
index 0f1e3909..623ab26e 100644
--- a/java/jni/BluetoothObject.cxx
+++ b/java/jni/DBusObject.cxx
@@ -24,32 +24,32 @@
#include "tinyb/BluetoothObject.hpp"
-#include "tinyb_BluetoothObject.h"
+#include "tinyb_dbus_DBusObject.h"
#include "helper.hpp"
using namespace tinyb;
-jobject Java_tinyb_BluetoothObject_getBluetoothType(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusObject_getBluetoothType(JNIEnv *env, jobject obj)
{
(void)obj;
return get_bluetooth_type(env, "NONE");
}
-jobject Java_tinyb_BluetoothObject_clone(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusObject_clone(JNIEnv *env, jobject obj)
{
return generic_clone<BluetoothObject>(env, obj);
}
-void Java_tinyb_BluetoothObject_delete(JNIEnv *env, jobject obj)
+void Java_tinyb_dbus_DBusObject_delete(JNIEnv *env, jobject obj)
{
BluetoothObject *obj_b = getInstance<BluetoothObject>(env, obj);
delete obj_b;
}
-jboolean Java_tinyb_BluetoothObject_operatorEqual(JNIEnv *env, jobject obj, jobject other)
+jboolean Java_tinyb_dbus_DBusObject_operatorEqual(JNIEnv *env, jobject obj, jobject other)
{
if (!other)
{
@@ -61,7 +61,7 @@ jboolean Java_tinyb_BluetoothObject_operatorEqual(JNIEnv *env, jobject obj, jobj
return (*obj_b) == (*obj_other);
}
-jstring Java_tinyb_BluetoothObject_getObjectPath(JNIEnv *env, jobject obj)
+jstring Java_tinyb_dbus_DBusObject_getObjectPath(JNIEnv *env, jobject obj)
{
BluetoothObject *obj_b = getInstance<BluetoothObject>(env, obj);
diff --git a/java/jni/helper.cxx b/java/jni/helper.cxx
index 9987ae3e..dda3c136 100644
--- a/java/jni/helper.cxx
+++ b/java/jni/helper.cxx
@@ -211,9 +211,9 @@ tinyb::TransportType from_int_to_transport_type(int type)
jobject get_bluetooth_type(JNIEnv *env, const char *field_name)
{
- jclass b_type_enum = search_class(env, JAVA_PACKAGE "/BluetoothType");
+ jclass b_type_enum = search_class(env, JAVA_MAIN_PACKAGE "/BluetoothType");
- jfieldID b_type_field = search_field(env, b_type_enum, field_name, "L" JAVA_PACKAGE "/BluetoothType;", true);
+ jfieldID b_type_field = search_field(env, b_type_enum, field_name, "L" JAVA_MAIN_PACKAGE "/BluetoothType;", true);
jobject result = env->GetStaticObjectField(b_type_enum, b_type_field);
env->DeleteLocalRef(b_type_enum);
diff --git a/java/tinyb/BluetoothAdapter.java b/java/org/tinyb/BluetoothAdapter.java
index 8094ff23..95d2e6d0 100644
--- a/java/tinyb/BluetoothAdapter.java
+++ b/java/org/tinyb/BluetoothAdapter.java
@@ -1,4 +1,8 @@
-/*
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
* Author: Andrei Vasiliu <[email protected]>
* Copyright (c) 2016 Intel Corporation.
*
@@ -20,23 +24,21 @@
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
*/
+package org.tinyb;
-package tinyb;
-
-import java.util.*;
-import java.time.Duration;
+import java.util.List;
+import java.util.UUID;
/**
* Provides access to Bluetooth adapters. Follows the BlueZ adapter API
* available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/adapter-api.txt
*/
-public class BluetoothAdapter extends BluetoothObject
+public interface BluetoothAdapter extends BluetoothObject
{
- public native BluetoothType getBluetoothType();
- public native BluetoothAdapter clone();
-
- static BluetoothType class_type() { return BluetoothType.ADAPTER; }
+ @Override
+ public BluetoothAdapter clone();
/** Find a BluetoothDevice. If parameters name and address are not null,
* the returned object will have to match them.
@@ -46,15 +48,12 @@ public class BluetoothAdapter extends BluetoothObject
* waiting for
* @parameter address optionally specify the MAC address of the device you are
* waiting for
- * @parameter timeout the function will return after timeout time, a
+ * @parameter timeoutMS the function will return after timeout time in milliseconds, a
* value of zero means wait forever. If object is not found during this time null will be returned.
* @return An object matching the name and address or null if not found before
* timeout expires.
*/
- public BluetoothDevice find(String name, String address, Duration duration) {
- BluetoothManager manager = BluetoothManager.getBluetoothManager();
- return (BluetoothDevice) manager.find(BluetoothType.DEVICE, name, address, this, duration);
- }
+ public BluetoothDevice find(String name, String address, long timeoutMS);
/** Find a BluetoothDevice. If parameters name and address are not null,
* the returned object will have to match them.
@@ -66,64 +65,63 @@ public class BluetoothAdapter extends BluetoothObject
* waiting for
* @return An object matching the name and address.
*/
- public BluetoothDevice find(String name, String address) {
- return find(name, address, Duration.ZERO);
- }
+ public BluetoothDevice find(String name, String address);
+
+ /* D-Bus specified API */
- /* D-Bus method calls: */
/** Turns on device discovery if it is disabled.
* @return TRUE if discovery was successfully enabled
*/
- public native boolean startDiscovery() throws BluetoothException;
+ public boolean startDiscovery() throws BluetoothException;
/** Turns off device discovery if it is enabled.
* @return TRUE if discovery was successfully disabled
*/
- public native boolean stopDiscovery() throws BluetoothException;
+ public boolean stopDiscovery() throws BluetoothException;
/** Returns a list of BluetoothDevices visible from this adapter.
* @return A list of BluetoothDevices visible on this adapter,
* NULL if an error occurred
*/
- public native List<BluetoothDevice> getDevices();
+ public List<BluetoothDevice> getDevices();
/**
* Remove all the known devices
- *
+ *
* @return The number of devices removed from internal list
- * @throws BluetoothException
+ * @throws BluetoothException
*/
- public native int removeDevices() throws BluetoothException;
-
+ public int removeDevices() throws BluetoothException;
+
/* D-Bus property accessors: */
/** Returns the hardware address of this adapter.
* @return The hardware address of this adapter.
*/
- public native String getAddress();
+ public String getAddress();
/** Returns the system name of this adapter.
* @return The system name of this adapter.
*/
- public native String getName();
+ public String getName();
/** Returns the friendly name of this adapter.
* @return The friendly name of this adapter, or NULL if not set.
*/
- public native String getAlias();
+ public String getAlias();
/** Sets the friendly name of this adapter.
*/
- public native void setAlias(String value);
+ public void setAlias(String value);
/** Returns the Bluetooth class of the adapter.
* @return The Bluetooth class of the adapter.
*/
- public native long getBluetoothClass();
+ public long getBluetoothClass();
/** Returns the power state the adapter.
* @return The power state of the adapter.
*/
- public native boolean getPowered();
+ public boolean getPowered();
/**
* Enables notifications for the powered property and calls run function of the
@@ -132,21 +130,22 @@ public class BluetoothAdapter extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the powered
* property.
*/
- public native void enablePoweredNotifications(BluetoothNotification<Boolean> callback);
+ public void enablePoweredNotifications(BluetoothNotification<Boolean> callback);
+
/**
* Disables notifications of the powered property and unregisters the callback
* object passed through the corresponding enable method.
*/
- public native void disablePoweredNotifications();
+ public void disablePoweredNotifications();
/** Sets the power state the adapter.
*/
- public native void setPowered(boolean value);
+ public void setPowered(boolean value);
/** Returns the discoverable state the adapter.
* @return The discoverable state of the adapter.
*/
- public native boolean getDiscoverable();
+ public boolean getDiscoverable();
/**
* Enables notifications for the discoverable property and calls run function of the
@@ -155,26 +154,26 @@ public class BluetoothAdapter extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the discoverable
* property.
*/
- public native void enableDiscoverableNotifications(BluetoothNotification<Boolean> callback);
+ public void enableDiscoverableNotifications(BluetoothNotification<Boolean> callback);
/**
* Disables notifications of the discoverable property and unregisters the callback
* object passed through the corresponding enable method.
*/
- public native void disableDiscoverableNotifications();
+ public void disableDiscoverableNotifications();
/** Sets the discoverable state the adapter.
*/
- public native void setDiscoverable(boolean value);
+ public void setDiscoverable(boolean value);
/** Returns the discoverable timeout the adapter.
* @return The discoverable timeout of the adapter.
*/
- public native long getDiscoverableTimeout();
+ public long getDiscoverableTimeout();
/** Sets the discoverable timeout the adapter. A value of 0 disables
* the timeout.
*/
- public native void setDiscoverableTimout(long value);
+ public void setDiscoverableTimout(long value);
/**
* This method connects to device without need of
@@ -187,7 +186,7 @@ public class BluetoothAdapter extends BluetoothObject
* Connect on Device1 after this call. If connection was
* successful this method returns object path to created
* device object.
- *
+ *
* @param address The Bluetooth device address of the remote
* device. This parameter is mandatory.
* @param addressType The Bluetooth device Address Type. This is
@@ -200,12 +199,12 @@ public class BluetoothAdapter extends BluetoothObject
* <li>{@code random} - Random address</li>
* </ul>
*/
- public native BluetoothDevice connectDevice(String address, String addressType);
+ public BluetoothDevice connectDevice(String address, String addressType);
/** Returns the pairable state the adapter.
* @return The pairable state of the adapter.
*/
- public native boolean getPairable();
+ public boolean getPairable();
/**
* Enables notifications for the pairable property and calls run function of the
@@ -214,32 +213,33 @@ public class BluetoothAdapter extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the pairable
* property.
*/
- public native void enablePairableNotifications(BluetoothNotification<Boolean> callback);
+ public void enablePairableNotifications(BluetoothNotification<Boolean> callback);
+
/**
* Disables notifications of the pairable property and unregisters the callback
* object passed through the corresponding enable method.
*/
- public native void disablePairableNotifications();
+ public void disablePairableNotifications();
/** Sets the discoverable state the adapter.
*/
- public native void setPairable(boolean value);
+ public void setPairable(boolean value);
/** Returns the timeout in seconds after which pairable state turns off
* automatically, 0 means never.
* @return The pairable timeout of the adapter.
*/
- public native long getPairableTimeout();
+ public long getPairableTimeout();
/** Sets the timeout after which pairable state turns off automatically, 0 means never.
*/
- public native void setPairableTimeout(long value);
+ public void setPairableTimeout(long value);
/** Returns the discovering state the adapter. It can be modified through
* start_discovery/stop_discovery functions.
* @return The discovering state of the adapter.
*/
- public native boolean getDiscovering();
+ public boolean getDiscovering();
/**
* Enables notifications for the discovering property and calls run function of the
@@ -248,22 +248,23 @@ public class BluetoothAdapter extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the discovering
* property.
*/
- public native void enableDiscoveringNotifications(BluetoothNotification<Boolean> callback);
+ public void enableDiscoveringNotifications(BluetoothNotification<Boolean> callback);
+
/**
* Disables notifications of the discovering property and unregisters the discovering
* object passed through the corresponding enable method.
*/
- public native void disableDiscoveringNotifications();
+ public void disableDiscoveringNotifications();
/** Returns the UUIDs of the adapter.
* @return Array containing the UUIDs of the adapter, ends with NULL.
*/
- public native String[] getUUIDs();
+ public String[] getUUIDs();
/** Returns the local ID of the adapter.
* @return The local ID of the adapter.
*/
- public native String getModalias();
+ public String getModalias();
/** This method sets the device discovery filter for the caller. When this method is called
* with no filter parameter, filter is removed.
@@ -284,36 +285,10 @@ public class BluetoothAdapter extends BluetoothObject
* @param rssi a rssi value
* @param pathloss a pathloss value
*/
- public void setDiscoveryFilter(List<UUID> uuids, int rssi, int pathloss, TransportType transportType) {
- List<String> uuidsFmt = new ArrayList<>(uuids.size());
- for (UUID uuid : uuids) {
- uuidsFmt.add(uuid.toString());
- }
- setDiscoveryFilter(uuidsFmt, rssi, pathloss, transportType.ordinal());
- }
-
- /** 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 void setRssiDiscoveryFilter(int rssi) {
- setDiscoveryFilter(Collections.EMPTY_LIST, rssi, 0, TransportType.AUTO);
- }
+ public void setDiscoveryFilter(List<UUID> uuids, int rssi, int pathloss, TransportType transportType);
/** Returns the interface name of the adapter.
* @return The interface name of the adapter.
*/
- public String getInterfaceName() {
- String[] path = getObjectPath().split("/");
- return path[path.length-1];
- }
-
- private native void delete();
-
- private native void setDiscoveryFilter(List<String> uuids, int rssi, int pathloss, int transportType);
-
- private BluetoothAdapter(long instance)
- {
- super(instance);
- }
+ public String getInterfaceName();
}
diff --git a/java/tinyb/BluetoothCallback.java b/java/org/tinyb/BluetoothCallback.java
index 0cbe0ed0..d2f59c35 100644
--- a/java/tinyb/BluetoothCallback.java
+++ b/java/org/tinyb/BluetoothCallback.java
@@ -22,11 +22,13 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-package tinyb;
+package org.tinyb;
+
+import tinyb.dbus.DBusObject;
public abstract class BluetoothCallback implements Runnable
{
- protected BluetoothObject bObj;
+ protected DBusObject bObj;
/*
* public void run() is missing because it will be implemented
diff --git a/java/tinyb/BluetoothDevice.java b/java/org/tinyb/BluetoothDevice.java
index da077117..a8764cfc 100644
--- a/java/tinyb/BluetoothDevice.java
+++ b/java/org/tinyb/BluetoothDevice.java
@@ -1,4 +1,8 @@
-/*
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
* Author: Andrei Vasiliu <[email protected]>
* Copyright (c) 2016 Intel Corporation.
*
@@ -20,23 +24,17 @@
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
*/
+package org.tinyb;
-package tinyb;
-
-import java.util.*;
-import java.time.Duration;
+import java.util.List;
+import java.util.Map;
-/**
- * Provides access to Bluetooth devices. Follows the BlueZ adapter API
- * available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/device-api.txt
- */
-public class BluetoothDevice extends BluetoothObject
+public interface BluetoothDevice extends BluetoothObject
{
- public native BluetoothType getBluetoothType();
- public native BluetoothDevice clone();
-
- static BluetoothType class_type() { return BluetoothType.DEVICE; }
+ @Override
+ public BluetoothDevice clone();
/** Find a BluetoothGattService. If parameter UUID is not null,
* the returned object will have to match it.
@@ -44,16 +42,12 @@ public class BluetoothDevice extends BluetoothObject
* or connect to devices.
* @parameter UUID optionally specify the UUID of the BluetoothGattService you are
* waiting for
- * @parameter timeout the function will return after timeout time, a
+ * @parameter timeoutMS the function will return after timeout time in milliseconds, a
* value of zero means wait forever. If object is not found during this time null will be returned.
* @return An object matching the UUID or null if not found before
* timeout expires or event is canceled.
*/
- public BluetoothGattService find(String UUID, Duration duration) {
- BluetoothManager manager = BluetoothManager.getBluetoothManager();
- return (BluetoothGattService) manager.find(BluetoothType.GATT_SERVICE,
- null, UUID, this, duration);
- }
+ BluetoothGattService find(String UUID, long timeoutMS);
/** Find a BluetoothGattService. If parameter UUID is not null,
* the returned object will have to match it.
@@ -64,107 +58,95 @@ public class BluetoothDevice extends BluetoothObject
* @return An object matching the UUID or null if not found before
* timeout expires or event is canceled.
*/
- public BluetoothGattService find(String UUID) {
- return find(UUID, Duration.ZERO);
- }
+ BluetoothGattService find(String UUID);
/* D-Bus method calls: */
/** The connection to this device is removed, removing all connected
* profiles.
* @return TRUE if the device disconnected
*/
- public native boolean disconnect() throws BluetoothException;
-
- /** An asynchronous connection to this device is initiated,
- * connecting each profile flagged as auto-connectable.
- */
- public native void connectAsyncStart() throws BluetoothException;
-
- /** Completion of the initiated asynchronous connection.
- * @return TRUE if the device connected
- */
- public native boolean connectAsyncFinish() throws BluetoothException;
+ boolean disconnect() throws BluetoothException;
/** A connection to this device is established, connecting each profile
* flagged as auto-connectable.
* @return TRUE if the device connected
*/
- public native boolean connect() throws BluetoothException;
+ boolean connect() throws BluetoothException;
- /** Connects a specific profile available on the device, given by UUID
+ /** Connects a specific profile available on the device, given by UUID
* @param arg_UUID The UUID of the profile to be connected
* @return TRUE if the profile connected successfully
*/
- public native boolean connectProfile(String arg_UUID) throws BluetoothException;
+ boolean connectProfile(String arg_UUID) throws BluetoothException;
/** Disconnects a specific profile available on the device, given by UUID
* @param arg_UUID The UUID of the profile to be disconnected
* @return TRUE if the profile disconnected successfully
*/
- public native boolean disconnectProfile(String arg_UUID) throws BluetoothException;
+ boolean disconnectProfile(String arg_UUID) throws BluetoothException;
/** A connection to this device is established, and the device is then
* paired.
* @return TRUE if the device connected and paired
*/
- public native boolean pair() throws BluetoothException;
-
- /** Remove this device from the system (like an unpair).
- * @return TRUE if the device has been removed
- * @throws BluetoothException
+ boolean pair() throws BluetoothException;
+
+ /** Remove this device from the system (like an unpair).
+ * @return TRUE if the device has been removed
+ * @throws BluetoothException
*/
- public native boolean remove() throws BluetoothException;
+ boolean remove() throws BluetoothException;
/** Cancels an initiated pairing operation
* @return TRUE if the paring is cancelled successfully
*/
- public native boolean cancelPairing() throws BluetoothException;
+ boolean cancelPairing() throws BluetoothException;
/** Returns a list of BluetoothGattServices available on this device.
* @return A list of BluetoothGattServices available on this device,
* NULL if an error occurred
*/
- public native List<BluetoothGattService> getServices();
+ List<BluetoothGattService> getServices();
/* D-Bus property accessors: */
/** Returns the hardware address of this device.
* @return The hardware address of this device.
*/
- public native String getAddress();
+ String getAddress();
/** Returns the remote friendly name of this device.
* @return The remote friendly name of this device, or NULL if not set.
*/
- public native String getName();
+ String getName();
/** Returns an alternative friendly name of this device.
* @return The alternative friendly name of this device, or NULL if not set.
*/
- public native String getAlias();
+ String getAlias();
/** Sets an alternative friendly name of this device.
*/
- public native void setAlias(String value);
+ void setAlias(String value);
/** Returns the Bluetooth class of the device.
* @return The Bluetooth class of the device.
*/
- public native int getBluetoothClass();
+ int getBluetoothClass();
/** Returns the appearance of the device, as found by GAP service.
* @return The appearance of the device, as found by GAP service.
*/
- public native short getAppearance();
+ short getAppearance();
/** Returns the proposed icon name of the device.
* @return The proposed icon name, or NULL if not set.
*/
- public native String getIcon();
+ String getIcon();
/** Returns the paired state the device.
* @return The paired state of the device.
*/
- public native boolean getPaired();
+ boolean getPaired();
/**
* Enables notifications for the paired property and calls run function of the
@@ -173,17 +155,18 @@ public class BluetoothDevice extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the paired
* property.
*/
- public native void enablePairedNotifications(BluetoothNotification<Boolean> callback);
+ void enablePairedNotifications(BluetoothNotification<Boolean> callback);
+
/**
* Disables notifications of the paired property and unregisters the callback
* object passed through the corresponding enable method.
*/
- public native void disablePairedNotifications();
+ void disablePairedNotifications();
/** Returns the trusted state the device.
* @return The trusted state of the device.
*/
- public native boolean getTrusted();
+ boolean getTrusted();
/**
* Enables notifications for the trusted property and calls run function of the
@@ -192,21 +175,22 @@ public class BluetoothDevice extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the trusted
* property.
*/
- public native void enableTrustedNotifications(BluetoothNotification<Boolean> callback);
+ void enableTrustedNotifications(BluetoothNotification<Boolean> callback);
+
/**
* Disables notifications of the trusted property and unregisters the callback
* object passed through the corresponding enable method.
*/
- public native void disableTrustedNotifications();
+ void disableTrustedNotifications();
/** Sets the trusted state the device.
*/
- public native void setTrusted(boolean value);
+ void setTrusted(boolean value);
/** Returns the blocked state the device.
* @return The blocked state of the device.
*/
- public native boolean getBlocked();
+ boolean getBlocked();
/**
* Enables notifications for the blocked property and calls run function of the
@@ -215,26 +199,27 @@ public class BluetoothDevice extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the blocked
* property.
*/
- public native void enableBlockedNotifications(BluetoothNotification<Boolean> callback);
+ void enableBlockedNotifications(BluetoothNotification<Boolean> callback);
+
/**
* Disables notifications of the blocked property and unregisters the callback
* object passed through the corresponding enable method.
*/
- public native void disableBlockedNotifications();
+ void disableBlockedNotifications();
/** Sets the blocked state the device.
*/
- public native void setBlocked(boolean value);
+ void setBlocked(boolean value);
/** Returns if device uses only pre-Bluetooth 2.1 pairing mechanism.
* @return True if device uses only pre-Bluetooth 2.1 pairing mechanism.
*/
- public native boolean getLegacyPairing();
+ boolean getLegacyPairing();
/** Returns the Received Signal Strength Indicator of the device.
* @return The Received Signal Strength Indicator of the device.
*/
- public native short getRSSI();
+ short getRSSI();
/**
* Enables notifications for the RSSI property and calls run function of the
@@ -243,17 +228,18 @@ public class BluetoothDevice extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the RSSI
* property.
*/
- public native void enableRSSINotifications(BluetoothNotification<Short> callback);
+ void enableRSSINotifications(BluetoothNotification<Short> callback);
+
/**
* Disables notifications of the RSSI property and unregisters the callback
* object passed through the corresponding enable method.
*/
- public native void disableRSSINotifications();
+ void disableRSSINotifications();
/** Returns the connected state of the device.
* @return The connected state of the device.
*/
- public native boolean getConnected();
+ boolean getConnected();
/**
* Enables notifications for the connected property and calls run function of the
@@ -262,34 +248,35 @@ public class BluetoothDevice extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the connected
* property.
*/
- public native void enableConnectedNotifications(BluetoothNotification<Boolean> callback);
+ void enableConnectedNotifications(BluetoothNotification<Boolean> callback);
+
/**
* Disables notifications of the connected property and unregisters the callback
* object passed through the corresponding enable method.
*/
- public native void disableConnectedNotifications();
+ void disableConnectedNotifications();
/** Returns the UUIDs of the device.
* @return Array containing the UUIDs of the device, ends with NULL.
*/
- public native String[] getUUIDs();
+ String[] getUUIDs();
/** Returns the local ID of the adapter.
* @return The local ID of the adapter.
*/
- public native String getModalias();
+ String getModalias();
/** Returns the adapter on which this device was discovered or
* connected.
* @return The adapter.
*/
- public native BluetoothAdapter getAdapter();
+ BluetoothAdapter getAdapter();
/** Returns a map containing manufacturer specific advertisement data.
* An entry has a uint16_t key and an array of bytes.
* @return manufacturer specific advertisement data.
*/
- public native Map<Short, byte[]> getManufacturerData();
+ Map<Short, byte[]> getManufacturerData();
/**
* Enables notifications for the manufacturer data property and calls run function of the
@@ -298,19 +285,20 @@ public class BluetoothDevice extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the manufacturer data
* property.
*/
- public native void enableManufacturerDataNotifications(BluetoothNotification<Map<Short, byte[]> > callback);
+ void enableManufacturerDataNotifications(
+ BluetoothNotification<Map<Short, byte[]>> callback);
+
/**
* Disables notifications of the manufacturer data property and unregisters the callback
* object passed through the corresponding enable method.
*/
- public native void disableManufacturerDataNotifications();
-
+ void disableManufacturerDataNotifications();
/** Returns a map containing service advertisement data.
* An entry has a UUID string key and an array of bytes.
* @return service advertisement data.
*/
- public native Map<String, byte[]> getServiceData();
+ Map<String, byte[]> getServiceData();
/**
* Enables notifications for the service data property and calls run function of the
@@ -319,23 +307,24 @@ public class BluetoothDevice extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the service data
* property.
*/
- public native void enableServiceDataNotifications(BluetoothNotification<Map<String, byte[]> > callback);
+ void enableServiceDataNotifications(
+ BluetoothNotification<Map<String, byte[]>> callback);
+
/**
* Disables notifications of the service data property and unregisters the callback
* object passed through the corresponding enable method.
*/
- public native void disableServiceDataNotifications();
-
+ void disableServiceDataNotifications();
- /** Returns the transmission power level (0 means unknown).
+ /** Returns the transmission power level (0 means unknown).
* @return the transmission power level (0 means unknown).
*/
- public native short getTxPower ();
+ short getTxPower();
- /** Returns true if service discovery has ended.
+ /** Returns true if service discovery has ended.
* @return true if the service discovery has ended.
*/
- public native boolean getServicesResolved ();
+ boolean getServicesResolved();
/**
* Enables notifications for the services resolved property and calls run function of the
@@ -344,18 +333,12 @@ public class BluetoothDevice extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the services resolved
* property.
*/
- public native void enableServicesResolvedNotifications(BluetoothNotification<Boolean> callback);
+ void enableServicesResolvedNotifications(
+ BluetoothNotification<Boolean> callback);
+
/**
* Disables notifications of the services resolved property and unregisters the callback
* object passed through the corresponding enable method.
*/
- public native void disableServicesResolvedNotifications();
-
- private native void delete();
-
- private BluetoothDevice(long instance)
- {
- super(instance);
- }
-
+ void disableServicesResolvedNotifications();
}
diff --git a/java/org/tinyb/BluetoothEvent.java b/java/org/tinyb/BluetoothEvent.java
new file mode 100644
index 00000000..620ab0ad
--- /dev/null
+++ b/java/org/tinyb/BluetoothEvent.java
@@ -0,0 +1,39 @@
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
+ * Author: Andrei Vasiliu <[email protected]>
+ * Copyright (c) 2016 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package org.tinyb;
+
+public interface BluetoothEvent
+{
+ public BluetoothType getType();
+ public String getName();
+ public String getIdentifier();
+ public boolean executeCallback();
+ public boolean hasCallback();
+
+}
diff --git a/java/tinyb/BluetoothException.java b/java/org/tinyb/BluetoothException.java
index d14b4903..c0caa8aa 100644
--- a/java/tinyb/BluetoothException.java
+++ b/java/org/tinyb/BluetoothException.java
@@ -1,4 +1,8 @@
-/*
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
* Author: Petre Eftime <[email protected]>
* Copyright (c) 2016 Intel Corporation.
*
@@ -22,10 +26,11 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-package tinyb;
+package org.tinyb;
+@SuppressWarnings("serial")
public class BluetoothException extends RuntimeException {
- BluetoothException(String msg) {
+ BluetoothException(final String msg) {
super(msg);
}
}
diff --git a/java/org/tinyb/BluetoothFactory.java b/java/org/tinyb/BluetoothFactory.java
new file mode 100644
index 00000000..08df1c43
--- /dev/null
+++ b/java/org/tinyb/BluetoothFactory.java
@@ -0,0 +1,32 @@
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.tinyb;
+
+public class BluetoothFactory {
+ public static BluetoothManager getDBusBluetoothManager() throws BluetoothException
+ {
+ return tinyb.dbus.DBusManager.getBluetoothManager();
+ }
+}
diff --git a/java/tinyb/BluetoothGattCharacteristic.java b/java/org/tinyb/BluetoothGattCharacteristic.java
index 9e20fffc..327fde69 100644
--- a/java/tinyb/BluetoothGattCharacteristic.java
+++ b/java/org/tinyb/BluetoothGattCharacteristic.java
@@ -1,4 +1,8 @@
-/*
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
* Author: Andrei Vasiliu <[email protected]>
* Copyright (c) 2016 Intel Corporation.
*
@@ -22,21 +26,18 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-package tinyb;
+package org.tinyb;
-import java.util.*;
-import java.time.Duration;
+import java.util.List;
/**
* Provides access to Bluetooth GATT characteristic. Follows the BlueZ adapter API
* available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt
*/
-public class BluetoothGattCharacteristic extends BluetoothObject
+public interface BluetoothGattCharacteristic extends BluetoothObject
{
- public native BluetoothType getBluetoothType();
- public native BluetoothGattCharacteristic clone();
-
- static BluetoothType class_type() { return BluetoothType.GATT_CHARACTERISTIC; }
+ @Override
+ public BluetoothGattCharacteristic clone();
/** Find a BluetoothGattDescriptor. If parameter UUID is not null,
* the returned object will have to match it.
@@ -44,16 +45,12 @@ public class BluetoothGattCharacteristic extends BluetoothObject
* or connect to devices.
* @parameter UUID optionally specify the UUID of the BluetoothGattDescriptor you are
* waiting for
- * @parameter timeout the function will return after timeout time, a
+ * @parameter timeoutMS the function will return after timeout time in milliseconds, a
* value of zero means wait forever. If object is not found during this time null will be returned.
* @return An object matching the UUID or null if not found before
* timeout expires or event is canceled.
*/
- public BluetoothGattDescriptor find(String UUID, Duration duration) {
- BluetoothManager manager = BluetoothManager.getBluetoothManager();
- return (BluetoothGattDescriptor) manager.find(BluetoothType.GATT_DESCRIPTOR,
- null, UUID, this, duration);
- }
+ public BluetoothGattDescriptor find(final String UUID, final long timeoutMS);
/** Find a BluetoothGattDescriptor. If parameter UUID is not null,
* the returned object will have to match it.
@@ -64,15 +61,14 @@ public class BluetoothGattCharacteristic extends BluetoothObject
* @return An object matching the UUID or null if not found before
* timeout expires or event is canceled.
*/
- public BluetoothGattDescriptor find(String UUID) {
- return find(UUID, Duration.ZERO);
- }
+ public BluetoothGattDescriptor find(final String UUID);
/* D-Bus method calls: */
+
/** Reads the value of this characteristic.
* @return A std::vector<unsgined char> containing the value of this characteristic.
*/
- public native byte[] readValue() throws BluetoothException;
+ public byte[] readValue() throws BluetoothException;
/**
* Enables notifications for the value and calls run function of the BluetoothNotification
@@ -81,61 +77,54 @@ public class BluetoothGattCharacteristic extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the value
* property.
*/
- public native void enableValueNotifications(BluetoothNotification<byte[]> callback);
+ public void enableValueNotifications(BluetoothNotification<byte[]> callback);
+
/**
* Disables notifications of the value and unregisters the callback object
* passed through the corresponding enable method. It disables notications
* at BLE level for this characteristic.
*/
- public native void disableValueNotifications();
+ public void disableValueNotifications();
/** Writes the value of this characteristic.
* @param[in] arg_value The data as vector<uchar>
* to be written packed in a GBytes struct
* @return TRUE if value was written succesfully
*/
- public native boolean writeValue(byte[] argValue) throws BluetoothException;
+ public boolean writeValue(byte[] argValue) throws BluetoothException;
/* D-Bus property accessors: */
+
/** Get the UUID of this characteristic.
* @return The 128 byte UUID of this characteristic, NULL if an error occurred
*/
- public native String getUUID();
+ public String getUUID();
/** Returns the service to which this characteristic belongs to.
* @return The service.
*/
- public native BluetoothGattService getService();
+ public BluetoothGattService getService();
/** Returns the cached value of this characteristic, if any.
* @return The cached value of this characteristic.
*/
- public native byte[] getValue();
+ public byte[] getValue();
/** Returns true if notification for changes of this characteristic are
* activated.
* @return True if notificatios are activated.
*/
- public native boolean getNotifying();
+ public boolean getNotifying();
/** Returns the flags this characterstic has.
* @return A list of flags for this characteristic.
*/
- public native String[] getFlags();
+ public String[] getFlags();
/** Returns a list of BluetoothGattDescriptors this characteristic exposes.
* @return A list of BluetoothGattDescriptors exposed by this characteristic
* NULL if an error occurred
*/
- public native List<BluetoothGattDescriptor> getDescriptors();
-
- private native void init(BluetoothGattCharacteristic obj);
-
- private native void delete();
-
- private BluetoothGattCharacteristic(long instance)
- {
- super(instance);
- }
+ public List<BluetoothGattDescriptor> getDescriptors();
}
diff --git a/java/tinyb/BluetoothGattDescriptor.java b/java/org/tinyb/BluetoothGattDescriptor.java
index d5911d23..4ccdf2d6 100644
--- a/java/tinyb/BluetoothGattDescriptor.java
+++ b/java/org/tinyb/BluetoothGattDescriptor.java
@@ -1,4 +1,8 @@
-/*
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
* Author: Andrei Vasiliu <[email protected]>
* Copyright (c) 2016 Intel Corporation.
*
@@ -22,33 +26,30 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-package tinyb;
-
-import java.util.*;
+package org.tinyb;
/**
* Provides access to Bluetooth GATT descriptor. Follows the BlueZ adapter API
* available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt
*/
-public class BluetoothGattDescriptor extends BluetoothObject
+public interface BluetoothGattDescriptor extends BluetoothObject
{
- public native BluetoothType getBluetoothType();
- public native BluetoothAdapter clone();
-
- static BluetoothType class_type() { return BluetoothType.GATT_DESCRIPTOR; }
+ @Override
+ public BluetoothGattDescriptor clone();
/* D-Bus method calls: */
+
/** Reads the value of this descriptor
* @return A vector<uchar> containing data from this descriptor
*/
- public native byte[] readValue();
+ public byte[] readValue();
/** Writes the value of this descriptor.
* @param[in] arg_value The data as vector<uchar>
* to be written packed in a GBytes struct
* @return TRUE if value was written succesfully
*/
- public native boolean writeValue(byte[] argValue) throws BluetoothException;
+ public boolean writeValue(byte[] argValue) throws BluetoothException;
/**
* Enables notifications for the value and calls run function of the BluetoothNotification
@@ -57,33 +58,27 @@ public class BluetoothGattDescriptor extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the value
* property.
*/
- public native void enableValueNotifications(BluetoothNotification<byte[]> callback);
+ public void enableValueNotifications(BluetoothNotification<byte[]> callback);
/**
* Disables notifications of the value and unregisters the callback object
* passed through the corresponding enable method.
*/
- public native void disableValueNotifications();
+ public void disableValueNotifications();
/* D-Bus property accessors: */
+
/** Get the UUID of this descriptor.
* @return The 128 byte UUID of this descriptor, NULL if an error occurred
*/
- public native String getUUID();
+ public String getUUID();
/** Returns the characteristic to which this descriptor belongs to.
* @return The characteristic.
*/
- public native BluetoothGattCharacteristic getCharacteristic();
+ public BluetoothGattCharacteristic getCharacteristic();
/** Returns the cached value of this descriptor, if any.
* @return The cached value of this descriptor.
*/
- public native byte[] getValue();
-
- private native void delete();
-
- private BluetoothGattDescriptor(long instance)
- {
- super(instance);
- }
+ public byte[] getValue();
}
diff --git a/java/tinyb/BluetoothGattService.java b/java/org/tinyb/BluetoothGattService.java
index 49b18739..38b91d26 100644
--- a/java/tinyb/BluetoothGattService.java
+++ b/java/org/tinyb/BluetoothGattService.java
@@ -1,4 +1,8 @@
-/*
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
* Author: Andrei Vasiliu <[email protected]>
* Copyright (c) 2016 Intel Corporation.
*
@@ -22,21 +26,18 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-package tinyb;
+package org.tinyb;
-import java.util.*;
-import java.time.Duration;
+import java.util.List;
/**
* Provides access to Bluetooth GATT characteristic. Follows the BlueZ adapter API
* available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt
*/
-public class BluetoothGattService extends BluetoothObject
+public interface BluetoothGattService extends BluetoothObject
{
- public native BluetoothType getBluetoothType();
- public native BluetoothAdapter clone();
-
- static BluetoothType class_type() { return BluetoothType.GATT_SERVICE; }
+ @Override
+ public BluetoothGattService clone();
/** Find a BluetoothGattCharacteristic. If parameter UUID is not null,
* the returned object will have to match it.
@@ -44,16 +45,12 @@ public class BluetoothGattService extends BluetoothObject
* or connect to devices.
* @parameter UUID optionally specify the UUID of the BluetoothGattCharacteristic you are
* waiting for
- * @parameter timeout the function will return after timeout time, a
+ * @parameter timeoutMS the function will return after timeout time in milliseconds, a
* value of zero means wait forever. If object is not found during this time null will be returned.
* @return An object matching the UUID or null if not found before
* timeout expires or event is canceled.
*/
- public BluetoothGattCharacteristic find(String UUID, Duration duration) {
- BluetoothManager manager = BluetoothManager.getBluetoothManager();
- return (BluetoothGattCharacteristic) manager.find(BluetoothType.GATT_CHARACTERISTIC,
- null, UUID, this, duration);
- }
+ public BluetoothGattCharacteristic find(String UUID, long timeoutMS);
/** Find a BluetoothGattCharacteristic. If parameter UUID is not null,
* the returned object will have to match it.
@@ -64,36 +61,27 @@ public class BluetoothGattService extends BluetoothObject
* @return An object matching the UUID or null if not found before
* timeout expires or event is canceled.
*/
- public BluetoothGattCharacteristic find(String UUID) {
- return find(UUID, Duration.ZERO);
- }
+ public BluetoothGattCharacteristic find(String UUID);
/* D-Bus property accessors: */
/** Get the UUID of this service
* @return The 128 byte UUID of this service, NULL if an error occurred
*/
- public native String getUUID();
+ public String getUUID();
/** Returns the device to which this service belongs to.
* @return The device.
*/
- public native BluetoothDevice getDevice();
+ public BluetoothDevice getDevice();
/** Returns true if this service is a primary service, false if secondary.
* @return true if this service is a primary service, false if secondary.
*/
- public native boolean getPrimary();
+ public boolean getPrimary();
/** Returns a list of BluetoothGattCharacteristics this service exposes.
* @return A list of BluetoothGattCharacteristics exposed by this service
*/
- public native List<BluetoothGattCharacteristic> getCharacteristics();
-
- private native void delete();
-
- private BluetoothGattService(long instance)
- {
- super(instance);
- }
+ public List<BluetoothGattCharacteristic> getCharacteristics();
}
diff --git a/java/tinyb/BluetoothManager.java b/java/org/tinyb/BluetoothManager.java
index 489ac3eb..ec1de2d7 100644
--- a/java/tinyb/BluetoothManager.java
+++ b/java/org/tinyb/BluetoothManager.java
@@ -1,4 +1,8 @@
-/*
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
* Author: Andrei Vasiliu <[email protected]>
* Copyright (c) 2016 Intel Corporation.
*
@@ -22,36 +26,12 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-package tinyb;
+package org.tinyb;
-import java.util.*;
-import java.time.Duration;
+import java.util.List;
-public class BluetoothManager
+public interface BluetoothManager
{
- private long nativeInstance;
- private static BluetoothManager inst;
-
- /**
- * The thread to watch for nearby devices
- */
- private Thread nearbyThread = null;
-
- static {
- try {
- System.loadLibrary("tinyb");
- System.loadLibrary("javatinyb");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load.\n" + e);
- }
- }
-
- private native static String getNativeAPIVersion();
-
- public native BluetoothType getBluetoothType();
-
- private native BluetoothObject find(int type, String name, String identifier, BluetoothObject parent, long milliseconds);
-
/** Find a BluetoothObject of a type matching type. If parameters name,
* identifier and parent are not null, the returned object will have to
* match them.
@@ -66,14 +46,12 @@ public class BluetoothManager
* for Adapter or Device)
* @parameter parent optionally specify the parent of the object you are
* waiting for
- * @parameter timeout the function will return after timeout time, a
+ * @parameter timeoutMS the function will return after timeout time in milliseconds, a
* value of zero means wait forever. If object is not found during this time null will be returned.
* @return An object matching the name, identifier, parent or null if not found before
* timeout expires or event is canceled.
*/
- public BluetoothObject find(BluetoothType type, String name, String identifier, BluetoothObject parent, Duration timeout) {
- return find(type.ordinal(), name, identifier, parent, timeout.toNanos() / 1000000);
- }
+ public BluetoothObject find(BluetoothType type, String name, String identifier, BluetoothObject parent, long timeoutMS);
/** Find a BluetoothObject of a type matching type. If parameters name,
@@ -92,9 +70,7 @@ public class BluetoothManager
* waiting for
* @return An object matching the name, identifier and parent.
*/
- public BluetoothObject find(BluetoothType type, String name, String identifier, BluetoothObject parent) {
- return find(type, name, identifier, parent, Duration.ZERO);
- }
+ public BluetoothObject find(BluetoothType type, String name, String identifier, BluetoothObject parent);
/** Find a BluetoothObject of type T. If parameters name, identifier and
* parent are not null, the returned object will have to match them.
@@ -107,14 +83,12 @@ public class BluetoothManager
* for Adapter or Device)
* @parameter parent optionally specify the parent of the object you are
* waiting for
- * @parameter timeout the function will return after timeout time, a
+ * @parameter timeoutMS the function will return after timeout time in milliseconds, a
* value of zero means wait forever. If object is not found during this time null will be returned.
* @return An object matching the name, identifier, parent or null if not found before
* timeout expires or event is canceled.
*/
- public <T extends BluetoothObject> T find(String name, String identifier, BluetoothObject parent, Duration timeout) {
- return (T) find(T.class_type().ordinal(), name, identifier, parent, timeout.toNanos() / 1000000);
- }
+ public <T extends BluetoothObject> T find(String name, String identifier, BluetoothObject parent, long timeoutMS);
/** Find a BluetoothObject of type T. If parameters name, identifier and
* parent are not null, the returned object will have to match them.
@@ -129,9 +103,7 @@ public class BluetoothManager
* waiting for
* @return An object matching the name, identifier and parent.
*/
- public <T extends BluetoothObject> T find(String name, String identifier, BluetoothObject parent) {
- return (T) find(name, identifier, parent, Duration.ZERO);
- }
+ public <T extends BluetoothObject> T find(String name, String identifier, BluetoothObject parent);
/** Return a BluetoothObject of a type matching type. If parameters name,
* identifier and parent are not null, the returned object will have to
@@ -148,11 +120,7 @@ public class BluetoothManager
* @return An object matching the name, identifier, parent or null if not found.
*/
public BluetoothObject getObject(BluetoothType type, String name,
- String identifier, BluetoothObject parent) {
- return getObject(type.ordinal(), name, identifier, parent);
- }
- private native BluetoothObject getObject(int type, String name,
- String identifier, BluetoothObject parent);
+ String identifier, BluetoothObject parent);
/** Return a List of BluetoothObject of a type matching type. If parameters name,
* identifier and parent are not null, the returned object will have to
@@ -169,31 +137,27 @@ public class BluetoothManager
* @return A vector of object matching the name, identifier, parent.
*/
public List<BluetoothObject> getObjects(BluetoothType type, String name,
- String identifier, BluetoothObject parent) {
- return getObjects(type.ordinal(), name, identifier, parent);
- }
- private native List<BluetoothObject> getObjects(int type, String name,
String identifier, BluetoothObject parent);
/** Returns a list of BluetoothAdapters available in the system
* @return A list of BluetoothAdapters available in the system
*/
- public native List<BluetoothAdapter> getAdapters();
+ public List<BluetoothAdapter> getAdapters();
/** Returns a list of discovered BluetoothDevices
* @return A list of discovered BluetoothDevices
*/
- public native List<BluetoothDevice> getDevices();
+ public List<BluetoothDevice> getDevices();
/** Returns a list of available BluetoothGattServices
* @return A list of available BluetoothGattServices
*/
- public native List<BluetoothGattService> getServices();
+ public List<BluetoothGattService> getServices();
/** Sets a default adapter to use for discovery.
* @return TRUE if the device was set
*/
- public native boolean setDefaultAdapter(BluetoothAdapter adapter);
+ public boolean setDefaultAdapter(BluetoothAdapter adapter);
/** Gets the default adapter to use for discovery.
* <p>
@@ -201,141 +165,20 @@ public class BluetoothManager
* </p>
* @return the used default adapter
*/
- public native BluetoothAdapter getDefaultAdapter();
+ public BluetoothAdapter getDefaultAdapter();
/** Turns on device discovery on the default adapter if it is disabled.
* @return TRUE if discovery was successfully enabled
*/
- public native boolean startDiscovery() throws BluetoothException;
+ public boolean startDiscovery() throws BluetoothException;
/** Turns off device discovery on the default adapter if it is enabled.
* @return TRUE if discovery was successfully disabled
*/
- public native boolean stopDiscovery() throws BluetoothException;
+ public 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>
- *
- * This method will create a new thread to handle the discovery process
- * which is a simple polling of the current list (getDevices)
- * <p>
- *
- * The thread is stopped when the nearbyStopDiscovery is called<p>
- *
- * @param listener
- * @param pollingRate The polling rate is miliseconds (1000 = 1s)
- * @param onlyManufacturerFilled If true, then only if the manufacturer data is filled, the event will be fired
- */
- public void startNearbyDiscovery(final BluetoothDeviceDiscoveryListener listener, final int pollingRate, final boolean onlyManufacturerFilled) {
- //--- If alreay started, does nothing
- if ((nearbyThread != null) && nearbyThread.isAlive()) return;
-
- //--- Remove all devices to have a clean start
- getAdapters().get(0).removeDevices();
-
- //--- Start the bluez discovery
- startDiscovery();
-
- //--- Thread to poll the devices list
- nearbyThread = new Thread() {
- public void run() {
- //--- The key is the address
- HashMap<String, BluetoothDevice> discovered = new HashMap<String, BluetoothDevice>();
- try {
- while (Thread.interrupted() == false) {
- List<BluetoothDevice> list = getDevices();
- for (BluetoothDevice d:list) {
- if (!discovered.containsKey(d.getAddress())) {
- if (onlyManufacturerFilled) {
- if (!d.getManufacturerData().isEmpty()) {
- discovered.put(d.getAddress(), d);
- if (listener != null) listener.bluetoothDeviceDiscovered(d);
- }
-
- } else {
- discovered.put(d.getAddress(), d);
- if (listener != null) listener.bluetoothDeviceDiscovered(d);
- }
- }
- }
- //--- Polling rate of 1 second
- sleep(pollingRate);
- }
-
- } catch (InterruptedException ex) {
- //--- Stopped by user or jvm
- }
- stopDiscovery();
-
- }
- };
- nearbyThread.start();
-
- }
-
- /**
- * Stop the nearby thread
- */
- public void stopNearbyDiscovery() {
- if ((nearbyThread != null) && nearbyThread.isAlive()) nearbyThread.interrupt();
-
- }
-
- /**
- * Interface to implement to receive the device discovery event
- */
- public interface BluetoothDeviceDiscoveryListener {
-
- public void bluetoothDeviceDiscovered(BluetoothDevice device);
- }
-
- private native void init() throws BluetoothException;
- private native void delete();
- private BluetoothManager()
- {
- init();
- }
-
- /** Returns an instance of BluetoothManager, to be used instead of constructor.
- * @return An initialized BluetoothManager instance.
- */
- public static synchronized BluetoothManager getBluetoothManager() throws RuntimeException, BluetoothException
- {
- if (inst == null)
- {
- String nativeAPIVersion = getNativeAPIVersion();
- String APIVersion = BluetoothManager.class.getPackage().getSpecificationVersion();
- if ( null != APIVersion && APIVersion.equals(nativeAPIVersion) == false) {
- String[] nativeAPIVersionCode = nativeAPIVersion.split("\\D");
- String[] APIVersionCode = APIVersion.split("\\D");
- if (APIVersionCode[0].equals(nativeAPIVersionCode[0]) == false) {
- if (Integer.valueOf(APIVersionCode[0]) < Integer.valueOf(nativeAPIVersionCode[0]))
- throw new RuntimeException("Java library is out of date. Please update the Java library.");
- else throw new RuntimeException("Native library is out of date. Please update the native library.");
- }
- else if (APIVersionCode[0].equals("0") == true) {
- if (Integer.valueOf(APIVersionCode[1]) < Integer.valueOf(nativeAPIVersionCode[1]))
- throw new RuntimeException("Java library is out of date. Please update the Java library.");
- else throw new RuntimeException("Native library is out of date. Please update the native library.");
- }
- else if (Integer.valueOf(APIVersionCode[1]) < Integer.valueOf(nativeAPIVersionCode[1]))
- System.err.println("Java library is out of date. Please update the Java library.");
- else System.err.println("Native library is out of date. Please update the native library.");
- }
- inst = new BluetoothManager();
- inst.init();
- }
- return inst;
- }
-
- protected void finalize()
- {
- delete();
- }
+ public boolean getDiscovering() throws BluetoothException;
}
diff --git a/java/tinyb/BluetoothNotification.java b/java/org/tinyb/BluetoothNotification.java
index 79fe800c..abc90259 100644
--- a/java/tinyb/BluetoothNotification.java
+++ b/java/org/tinyb/BluetoothNotification.java
@@ -1,4 +1,4 @@
-/*
+/**
* Author: Petre Eftime <[email protected]>
* Copyright (c) 2016 Intel Corporation.
*
@@ -22,9 +22,9 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-package tinyb;
+package org.tinyb;
-/*
+/**
* This interface is used by notifications.
* Implement a class inheriting BluetoothNotification and pass an object of that type
* to the enable*Notifications function. When a notification of that type is received,
diff --git a/java/org/tinyb/BluetoothObject.java b/java/org/tinyb/BluetoothObject.java
new file mode 100644
index 00000000..906f116e
--- /dev/null
+++ b/java/org/tinyb/BluetoothObject.java
@@ -0,0 +1,54 @@
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
+ * Author: Andrei Vasiliu <[email protected]>
+ * Copyright (c) 2016 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package org.tinyb;
+
+public interface BluetoothObject extends Cloneable, AutoCloseable
+{
+ /** Returns the BluetoothType of this object
+ * @return The BluetoothType of this object
+ */
+ public BluetoothType getBluetoothType();
+
+ /** Returns a clone of the BluetoothObject
+ * @return A clone of the BluetoothObject
+ */
+ public BluetoothObject clone();
+
+ @Override
+ public boolean equals(Object obj);
+
+ @Override
+ public int hashCode();
+
+ /**
+ * Release the native memory associated with this object
+ * The object should not be used following a call to close
+ */
+ @Override
+ public void close();
+}
diff --git a/java/tinyb/BluetoothType.java b/java/org/tinyb/BluetoothType.java
index ac2fb02e..c05ace73 100644
--- a/java/tinyb/BluetoothType.java
+++ b/java/org/tinyb/BluetoothType.java
@@ -22,13 +22,11 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-package tinyb;
+package org.tinyb;
public enum BluetoothType
{
NONE, ADAPTER, DEVICE,
GATT_SERVICE, GATT_CHARACTERISTIC,
GATT_DESCRIPTOR;
-
- private long nativeInstance;
}
diff --git a/java/tinyb/ObjectArgCallback.java b/java/org/tinyb/ObjectArgCallback.java
index 898c9cbc..2ada8731 100644
--- a/java/tinyb/ObjectArgCallback.java
+++ b/java/org/tinyb/ObjectArgCallback.java
@@ -1,4 +1,4 @@
-/*
+/**
* Author: Andrei Vasiliu <[email protected]>
* Copyright (c) 2016 Intel Corporation.
*
@@ -22,18 +22,21 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-package tinyb;
+package org.tinyb;
+
+import tinyb.dbus.DBusObject;
public class ObjectArgCallback extends BluetoothCallback
{
- private Object callbackArg;
+ private final Object callbackArg;
- public ObjectArgCallback(BluetoothObject bObj, Object callbackArg)
+ public ObjectArgCallback(final DBusObject bObj, final Object callbackArg)
{
this.bObj = bObj;
this.callbackArg = callbackArg;
}
+ @Override
public void run()
{
}
diff --git a/java/tinyb/ObjectArrayArgCallback.java b/java/org/tinyb/ObjectArrayArgCallback.java
index b0d83410..4cb40e1c 100644
--- a/java/tinyb/ObjectArrayArgCallback.java
+++ b/java/org/tinyb/ObjectArrayArgCallback.java
@@ -22,18 +22,21 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-package tinyb;
+package org.tinyb;
+
+import tinyb.dbus.DBusObject;
public class ObjectArrayArgCallback extends BluetoothCallback
{
private Object[] callbackArg;
- public ObjectArrayArgCallback(BluetoothObject bObj, Object[] callbackArg)
+ public ObjectArrayArgCallback(DBusObject bObj, Object[] callbackArg)
{
this.bObj = bObj;
this.callbackArg = callbackArg;
}
+ @Override
public void run()
{
}
diff --git a/java/tinyb/TransportType.java b/java/org/tinyb/TransportType.java
index ab71a1cb..7c79d240 100644
--- a/java/tinyb/TransportType.java
+++ b/java/org/tinyb/TransportType.java
@@ -1,4 +1,4 @@
-package tinyb;
+package org.tinyb;
/**
* TransportType determines type of bluetooth scan.
diff --git a/java/tinyb/dbus/DBusAdapter.java b/java/tinyb/dbus/DBusAdapter.java
new file mode 100644
index 00000000..695677fe
--- /dev/null
+++ b/java/tinyb/dbus/DBusAdapter.java
@@ -0,0 +1,189 @@
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
+ * Author: Andrei Vasiliu <[email protected]>
+ * Copyright (c) 2016 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package tinyb.dbus;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+
+import org.tinyb.BluetoothAdapter;
+import org.tinyb.BluetoothDevice;
+import org.tinyb.BluetoothException;
+import org.tinyb.BluetoothManager;
+import org.tinyb.BluetoothNotification;
+import org.tinyb.BluetoothType;
+import org.tinyb.TransportType;
+
+public class DBusAdapter extends DBusObject implements BluetoothAdapter
+{
+ @Override
+ public native BluetoothType getBluetoothType();
+
+ @Override
+ public native BluetoothAdapter clone();
+
+ static BluetoothType class_type() { return BluetoothType.ADAPTER; }
+
+ @Override
+ public BluetoothDevice find(final String name, final String address, final long timeoutMS) {
+ final BluetoothManager manager = DBusManager.getBluetoothManager();
+ return (BluetoothDevice) manager.find(BluetoothType.DEVICE, name, address, this, timeoutMS);
+ }
+
+ @Override
+ public BluetoothDevice find(final String name, final String address) {
+ return find(name, address, 0);
+ }
+
+ /* D-Bus method calls: */
+
+ @Override
+ public native boolean startDiscovery() throws BluetoothException;
+
+ @Override
+ public native boolean stopDiscovery() throws BluetoothException;
+
+ @Override
+ public native List<BluetoothDevice> getDevices();
+
+ @Override
+ public native int removeDevices() throws BluetoothException;
+
+ /* D-Bus property accessors: */
+
+ @Override
+ public native String getAddress();
+
+ @Override
+ public native String getName();
+
+ @Override
+ public native String getAlias();
+
+ @Override
+ public native void setAlias(String value);
+
+ @Override
+ public native long getBluetoothClass();
+
+ @Override
+ public native boolean getPowered();
+
+ @Override
+ public native void enablePoweredNotifications(BluetoothNotification<Boolean> callback);
+
+ @Override
+ public native void disablePoweredNotifications();
+
+ @Override
+ public native void setPowered(boolean value);
+
+ @Override
+ public native boolean getDiscoverable();
+
+ @Override
+ public native void enableDiscoverableNotifications(BluetoothNotification<Boolean> callback);
+
+ @Override
+ public native void disableDiscoverableNotifications();
+
+ @Override
+ public native void setDiscoverable(boolean value);
+
+ @Override
+ public native long getDiscoverableTimeout();
+
+ @Override
+ public native void setDiscoverableTimout(long value);
+
+ @Override
+ public native BluetoothDevice connectDevice(String address, String addressType);
+
+ @Override
+ public native boolean getPairable();
+
+ @Override
+ public native void enablePairableNotifications(BluetoothNotification<Boolean> callback);
+
+ @Override
+ public native void disablePairableNotifications();
+
+ @Override
+ public native void setPairable(boolean value);
+
+ @Override
+ public native long getPairableTimeout();
+
+ @Override
+ public native void setPairableTimeout(long value);
+
+ @Override
+ public native boolean getDiscovering();
+
+ @Override
+ public native void enableDiscoveringNotifications(BluetoothNotification<Boolean> callback);
+
+ @Override
+ public native void disableDiscoveringNotifications();
+
+ @Override
+ public native String[] getUUIDs();
+
+ @Override
+ public native String getModalias();
+
+ @Override
+ public void setDiscoveryFilter(final List<UUID> uuids, final int rssi, final int pathloss, final TransportType transportType) {
+ final List<String> uuidsFmt = new ArrayList<>(uuids.size());
+ for (final UUID uuid : uuids) {
+ uuidsFmt.add(uuid.toString());
+ }
+ setDiscoveryFilter(uuidsFmt, rssi, pathloss, transportType.ordinal());
+ }
+
+ public void setRssiDiscoveryFilter(final int rssi) {
+ setDiscoveryFilter(Collections.EMPTY_LIST, rssi, 0, TransportType.AUTO);
+ }
+
+ @Override
+ public String getInterfaceName() {
+ final String[] path = getObjectPath().split("/");
+ return path[path.length-1];
+ }
+
+ private native void delete();
+
+ private native void setDiscoveryFilter(List<String> uuids, int rssi, int pathloss, int transportType);
+
+ private DBusAdapter(final long instance)
+ {
+ super(instance);
+ }
+}
diff --git a/java/tinyb/dbus/DBusDevice.java b/java/tinyb/dbus/DBusDevice.java
new file mode 100644
index 00000000..bb1919b9
--- /dev/null
+++ b/java/tinyb/dbus/DBusDevice.java
@@ -0,0 +1,216 @@
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
+ * Author: Andrei Vasiliu <[email protected]>
+ * Copyright (c) 2016 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package tinyb.dbus;
+
+import java.util.List;
+import java.util.Map;
+
+import org.tinyb.BluetoothDevice;
+import org.tinyb.BluetoothException;
+import org.tinyb.BluetoothGattService;
+import org.tinyb.BluetoothManager;
+import org.tinyb.BluetoothNotification;
+import org.tinyb.BluetoothType;
+
+public class DBusDevice extends DBusObject implements BluetoothDevice
+{
+ @Override
+ public native BluetoothType getBluetoothType();
+ @Override
+ public native DBusDevice clone();
+
+ static BluetoothType class_type() { return BluetoothType.DEVICE; }
+
+ @Override
+ public BluetoothGattService find(final String UUID, final long timeoutMS) {
+ final BluetoothManager manager = DBusManager.getBluetoothManager();
+ return (BluetoothGattService) manager.find(BluetoothType.GATT_SERVICE,
+ null, UUID, this, timeoutMS);
+ }
+
+ @Override
+ public BluetoothGattService find(final String UUID) {
+ return find(UUID, 0);
+ }
+
+ /* D-Bus method calls: */
+
+ @Override
+ public native boolean disconnect() throws BluetoothException;
+
+ public native void connectAsyncStart() throws BluetoothException;
+
+ public native boolean connectAsyncFinish() throws BluetoothException;
+
+ @Override
+ public native boolean connect() throws BluetoothException;
+
+ @Override
+ public native boolean connectProfile(String arg_UUID) throws BluetoothException;
+
+ @Override
+ public native boolean disconnectProfile(String arg_UUID) throws BluetoothException;
+
+ @Override
+ public native boolean pair() throws BluetoothException;
+
+ @Override
+ public native boolean remove() throws BluetoothException;
+
+ @Override
+ public native boolean cancelPairing() throws BluetoothException;
+
+ @Override
+ public native List<BluetoothGattService> getServices();
+
+ /* D-Bus property accessors: */
+
+ @Override
+ public native String getAddress();
+
+ @Override
+ public native String getName();
+
+ @Override
+ public native String getAlias();
+
+ @Override
+ public native void setAlias(String value);
+
+ @Override
+ public native int getBluetoothClass();
+
+ @Override
+ public native short getAppearance();
+
+ @Override
+ public native String getIcon();
+
+ @Override
+ public native boolean getPaired();
+
+ @Override
+ public native void enablePairedNotifications(BluetoothNotification<Boolean> callback);
+
+ @Override
+ public native void disablePairedNotifications();
+
+ @Override
+ public native boolean getTrusted();
+
+ @Override
+ public native void enableTrustedNotifications(BluetoothNotification<Boolean> callback);
+
+ @Override
+ public native void disableTrustedNotifications();
+
+ @Override
+ public native void setTrusted(boolean value);
+
+ @Override
+ public native boolean getBlocked();
+
+ @Override
+ public native void enableBlockedNotifications(BluetoothNotification<Boolean> callback);
+
+ @Override
+ public native void disableBlockedNotifications();
+
+ @Override
+ public native void setBlocked(boolean value);
+
+ @Override
+ public native boolean getLegacyPairing();
+
+ @Override
+ public native short getRSSI();
+
+ @Override
+ public native void enableRSSINotifications(BluetoothNotification<Short> callback);
+
+ @Override
+ public native void disableRSSINotifications();
+
+ @Override
+ public native boolean getConnected();
+
+ @Override
+ public native void enableConnectedNotifications(BluetoothNotification<Boolean> callback);
+
+ @Override
+ public native void disableConnectedNotifications();
+
+ @Override
+ public native String[] getUUIDs();
+
+ @Override
+ public native String getModalias();
+
+ @Override
+ public native DBusAdapter getAdapter();
+
+ @Override
+ public native Map<Short, byte[]> getManufacturerData();
+
+ @Override
+ public native void enableManufacturerDataNotifications(BluetoothNotification<Map<Short, byte[]> > callback);
+
+ @Override
+ public native void disableManufacturerDataNotifications();
+
+
+ @Override
+ public native Map<String, byte[]> getServiceData();
+
+ @Override
+ public native void enableServiceDataNotifications(BluetoothNotification<Map<String, byte[]> > callback);
+
+ @Override
+ public native void disableServiceDataNotifications();
+
+ @Override
+ public native short getTxPower ();
+
+ @Override
+ public native boolean getServicesResolved ();
+
+ @Override
+ public native void enableServicesResolvedNotifications(BluetoothNotification<Boolean> callback);
+
+ @Override
+ public native void disableServicesResolvedNotifications();
+
+ private native void delete();
+
+ private DBusDevice(final long instance)
+ {
+ super(instance);
+ }
+
+}
diff --git a/java/tinyb/BluetoothEvent.java b/java/tinyb/dbus/DBusEvent.java
index b2141131..fe6d4c40 100644
--- a/java/tinyb/BluetoothEvent.java
+++ b/java/tinyb/dbus/DBusEvent.java
@@ -22,30 +22,38 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-package tinyb;
+package tinyb.dbus;
-import java.util.*;
+import org.tinyb.BluetoothCallback;
+import org.tinyb.BluetoothEvent;
+import org.tinyb.BluetoothType;
-public class BluetoothEvent
+public class DBusEvent implements BluetoothEvent
{
private long nativeInstance;
+ @Override
public native BluetoothType getType();
+ @Override
public native String getName();
+ @Override
public native String getIdentifier();
+ @Override
public native boolean executeCallback();
+ @Override
public native boolean hasCallback();
private native void init(BluetoothType type, String name, String identifier,
- BluetoothObject parent, BluetoothCallback cb, Object data);
+ DBusObject parent, BluetoothCallback cb, Object data);
private native void delete();
- public BluetoothEvent(BluetoothType type, String name, String identifier,
- BluetoothObject parent, BluetoothCallback cb, Object data)
+ public DBusEvent(final BluetoothType type, final String name, final String identifier,
+ final DBusObject parent, final BluetoothCallback cb, final Object data)
{
init(type, name, identifier, parent, cb, data);
}
+ @Override
protected void finalize()
{
delete();
diff --git a/java/tinyb/dbus/DBusGattCharacteristic.java b/java/tinyb/dbus/DBusGattCharacteristic.java
new file mode 100644
index 00000000..3ca5ab93
--- /dev/null
+++ b/java/tinyb/dbus/DBusGattCharacteristic.java
@@ -0,0 +1,104 @@
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
+ * Author: Andrei Vasiliu <[email protected]>
+ * Copyright (c) 2016 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package tinyb.dbus;
+
+import java.util.List;
+
+import org.tinyb.BluetoothException;
+import org.tinyb.BluetoothGattCharacteristic;
+import org.tinyb.BluetoothGattDescriptor;
+import org.tinyb.BluetoothGattService;
+import org.tinyb.BluetoothManager;
+import org.tinyb.BluetoothNotification;
+import org.tinyb.BluetoothType;
+
+public class DBusGattCharacteristic extends DBusObject implements BluetoothGattCharacteristic
+{
+ @Override
+ public native BluetoothType getBluetoothType();
+ @Override
+ public native DBusGattCharacteristic clone();
+
+ static BluetoothType class_type() { return BluetoothType.GATT_CHARACTERISTIC; }
+
+ @Override
+ public BluetoothGattDescriptor find(final String UUID, final long timeoutMS) {
+ final BluetoothManager manager = DBusManager.getBluetoothManager();
+ return (BluetoothGattDescriptor) manager.find(BluetoothType.GATT_DESCRIPTOR,
+ null, UUID, this, timeoutMS);
+ }
+
+ @Override
+ public BluetoothGattDescriptor find(final String UUID) {
+ return find(UUID, 0);
+ }
+
+ /* D-Bus method calls: */
+
+ @Override
+ public native byte[] readValue() throws BluetoothException;
+
+ @Override
+ public native void enableValueNotifications(BluetoothNotification<byte[]> callback);
+
+ @Override
+ public native void disableValueNotifications();
+
+ @Override
+ public native boolean writeValue(byte[] argValue) throws BluetoothException;
+
+ /* D-Bus property accessors: */
+
+ @Override
+ public native String getUUID();
+
+ @Override
+ public native BluetoothGattService getService();
+
+ @Override
+ public native byte[] getValue();
+
+ @Override
+ public native boolean getNotifying();
+
+ @Override
+ public native String[] getFlags();
+
+ @Override
+ public native List<BluetoothGattDescriptor> getDescriptors();
+
+ private native void init(DBusGattCharacteristic obj);
+
+ private native void delete();
+
+ private DBusGattCharacteristic(final long instance)
+ {
+ super(instance);
+ }
+}
diff --git a/java/tinyb/dbus/DBusGattDescriptor.java b/java/tinyb/dbus/DBusGattDescriptor.java
new file mode 100644
index 00000000..5c59ea8c
--- /dev/null
+++ b/java/tinyb/dbus/DBusGattDescriptor.java
@@ -0,0 +1,76 @@
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
+ * Author: Andrei Vasiliu <[email protected]>
+ * Copyright (c) 2016 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package tinyb.dbus;
+
+import org.tinyb.BluetoothException;
+import org.tinyb.BluetoothGattDescriptor;
+import org.tinyb.BluetoothNotification;
+import org.tinyb.BluetoothType;
+
+public class DBusGattDescriptor extends DBusObject implements BluetoothGattDescriptor
+{
+ @Override
+ public native BluetoothType getBluetoothType();
+ @Override
+ public native BluetoothGattDescriptor clone();
+
+ static BluetoothType class_type() { return BluetoothType.GATT_DESCRIPTOR; }
+
+ /* D-Bus method calls: */
+
+ @Override
+ public native byte[] readValue();
+
+ @Override
+ public native boolean writeValue(byte[] argValue) throws BluetoothException;
+
+ @Override
+ public native void enableValueNotifications(BluetoothNotification<byte[]> callback);
+
+ @Override
+ public native void disableValueNotifications();
+
+ /* D-Bus property accessors: */
+
+ @Override
+ public native String getUUID();
+
+ @Override
+ public native DBusGattCharacteristic getCharacteristic();
+
+ @Override
+ public native byte[] getValue();
+
+ private native void delete();
+
+ private DBusGattDescriptor(final long instance)
+ {
+ super(instance);
+ }
+}
diff --git a/java/tinyb/dbus/DBusGattService.java b/java/tinyb/dbus/DBusGattService.java
new file mode 100644
index 00000000..092662a8
--- /dev/null
+++ b/java/tinyb/dbus/DBusGattService.java
@@ -0,0 +1,80 @@
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
+ * Author: Andrei Vasiliu <[email protected]>
+ * Copyright (c) 2016 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package tinyb.dbus;
+
+import java.util.List;
+
+import org.tinyb.BluetoothGattCharacteristic;
+import org.tinyb.BluetoothGattService;
+import org.tinyb.BluetoothManager;
+import org.tinyb.BluetoothType;
+
+public class DBusGattService extends DBusObject implements BluetoothGattService
+{
+ @Override
+ public native BluetoothType getBluetoothType();
+
+ @Override
+ public native BluetoothGattService clone();
+
+ static BluetoothType class_type() { return BluetoothType.GATT_SERVICE; }
+
+ @Override
+ public BluetoothGattCharacteristic find(final String UUID, final long timeoutMS) {
+ final BluetoothManager manager = DBusManager.getBluetoothManager();
+ return (DBusGattCharacteristic) manager.find(BluetoothType.GATT_CHARACTERISTIC,
+ null, UUID, this, timeoutMS);
+ }
+
+ @Override
+ public BluetoothGattCharacteristic find(final String UUID) {
+ return find(UUID, 0);
+ }
+
+ /* D-Bus property accessors: */
+
+ @Override
+ public native String getUUID();
+
+ @Override
+ public native DBusDevice getDevice();
+
+ @Override
+ public native boolean getPrimary();
+
+ @Override
+ public native List<BluetoothGattCharacteristic> getCharacteristics();
+
+ private native void delete();
+
+ private DBusGattService(final long instance)
+ {
+ super(instance);
+ }
+}
diff --git a/java/tinyb/dbus/DBusManager.java b/java/tinyb/dbus/DBusManager.java
new file mode 100644
index 00000000..e3e86ab6
--- /dev/null
+++ b/java/tinyb/dbus/DBusManager.java
@@ -0,0 +1,165 @@
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
+ * Author: Andrei Vasiliu <[email protected]>
+ * Copyright (c) 2016 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package tinyb.dbus;
+
+import java.util.List;
+
+import org.tinyb.BluetoothAdapter;
+import org.tinyb.BluetoothDevice;
+import org.tinyb.BluetoothException;
+import org.tinyb.BluetoothGattService;
+import org.tinyb.BluetoothObject;
+import org.tinyb.BluetoothManager;
+import org.tinyb.BluetoothType;
+
+public class DBusManager implements BluetoothManager
+{
+ private long nativeInstance;
+ private static DBusManager inst;
+
+ static {
+ try {
+ System.loadLibrary("tinyb");
+ System.loadLibrary("javatinyb");
+ } catch (final UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load.\n" + e);
+ }
+ }
+
+ private native static String getNativeAPIVersion();
+
+ public native BluetoothType getBluetoothType();
+
+ private native DBusObject find(int type, String name, String identifier, BluetoothObject parent, long milliseconds);
+
+ @Override
+ public DBusObject find(final BluetoothType type, final String name, final String identifier, final BluetoothObject parent, final long timeoutMS) {
+ return find(type.ordinal(), name, identifier, parent, timeoutMS);
+ }
+
+ @Override
+ public DBusObject find(final BluetoothType type, final String name, final String identifier, final BluetoothObject parent) {
+ return find(type, name, identifier, parent, 0);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T extends BluetoothObject> T find(final String name, final String identifier, final BluetoothObject parent, final long timeoutMS) {
+ return (T) find(DBusObject.class_type().ordinal(), name, identifier, parent, timeoutMS);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T extends BluetoothObject> T find(final String name, final String identifier, final BluetoothObject parent) {
+ return (T) find(name, identifier, parent, 0);
+ }
+
+ @Override
+ public BluetoothObject getObject(final BluetoothType type, final String name,
+ final String identifier, final BluetoothObject parent) {
+ return getObject(type.ordinal(), name, identifier, parent);
+ }
+ private native BluetoothObject getObject(int type, String name, String identifier, BluetoothObject parent);
+
+ @Override
+ public List<BluetoothObject> getObjects(final BluetoothType type, final String name,
+ final String identifier, final BluetoothObject parent) {
+ return getObjects(type.ordinal(), name, identifier, parent);
+ }
+ private native List<BluetoothObject> getObjects(int type, String name, String identifier, BluetoothObject parent);
+
+ @Override
+ public native List<BluetoothAdapter> getAdapters();
+
+ @Override
+ public native List<BluetoothDevice> getDevices();
+
+ @Override
+ public native List<BluetoothGattService> getServices();
+
+ @Override
+ public native boolean setDefaultAdapter(BluetoothAdapter adapter);
+
+ @Override
+ public native BluetoothAdapter getDefaultAdapter();
+
+ @Override
+ public native boolean startDiscovery() throws BluetoothException;
+
+ @Override
+ public native boolean stopDiscovery() throws BluetoothException;
+
+ @Override
+ public native boolean getDiscovering() throws BluetoothException;
+
+ private native void init() throws BluetoothException;
+ private native void delete();
+ private DBusManager()
+ {
+ init();
+ }
+
+ /** Returns an instance of BluetoothManager, to be used instead of constructor.
+ * @return An initialized BluetoothManager instance.
+ */
+ public static synchronized BluetoothManager getBluetoothManager() throws RuntimeException, BluetoothException
+ {
+ if (inst == null)
+ {
+ final String nativeAPIVersion = getNativeAPIVersion();
+ final String APIVersion = DBusManager.class.getPackage().getSpecificationVersion();
+ if ( null != APIVersion && APIVersion.equals(nativeAPIVersion) == false) {
+ final String[] nativeAPIVersionCode = nativeAPIVersion.split("\\D");
+ final String[] APIVersionCode = APIVersion.split("\\D");
+ if (APIVersionCode[0].equals(nativeAPIVersionCode[0]) == false) {
+ if (Integer.valueOf(APIVersionCode[0]) < Integer.valueOf(nativeAPIVersionCode[0]))
+ throw new RuntimeException("Java library is out of date. Please update the Java library.");
+ else throw new RuntimeException("Native library is out of date. Please update the native library.");
+ }
+ else if (APIVersionCode[0].equals("0") == true) {
+ if (Integer.valueOf(APIVersionCode[1]) < Integer.valueOf(nativeAPIVersionCode[1]))
+ throw new RuntimeException("Java library is out of date. Please update the Java library.");
+ else throw new RuntimeException("Native library is out of date. Please update the native library.");
+ }
+ else if (Integer.valueOf(APIVersionCode[1]) < Integer.valueOf(nativeAPIVersionCode[1]))
+ System.err.println("Java library is out of date. Please update the Java library.");
+ else System.err.println("Native library is out of date. Please update the native library.");
+ }
+ inst = new DBusManager();
+ inst.init();
+ }
+ return inst;
+ }
+
+ @Override
+ protected void finalize()
+ {
+ delete();
+ }
+}
diff --git a/java/tinyb/BluetoothObject.java b/java/tinyb/dbus/DBusObject.java
index 2afb8c3c..a9095d1a 100644
--- a/java/tinyb/BluetoothObject.java
+++ b/java/tinyb/dbus/DBusObject.java
@@ -1,4 +1,8 @@
-/*
+/**
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
* Author: Andrei Vasiliu <[email protected]>
* Copyright (c) 2016 Intel Corporation.
*
@@ -22,11 +26,12 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-package tinyb;
+package tinyb.dbus;
-import java.util.*;
+import org.tinyb.BluetoothObject;
+import org.tinyb.BluetoothType;
-public abstract class BluetoothObject implements Cloneable,AutoCloseable
+public class DBusObject implements BluetoothObject
{
protected long nativeInstance;
private boolean isValid;
@@ -34,55 +39,50 @@ public abstract class BluetoothObject implements Cloneable,AutoCloseable
static {
try {
System.loadLibrary("javatinyb");
- } catch (UnsatisfiedLinkError e) {
+ } catch (final UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
}
}
static BluetoothType class_type() { return BluetoothType.NONE; }
- /** Returns the BluetoothType of this object
- * @return The BluetoothType of this object
- */
+ @Override
public native BluetoothType getBluetoothType();
- /** Returns a clone of the BluetoothObject
- * @return A clone of the BluetoothObject
- */
+ @Override
public native BluetoothObject clone();
private native void delete();
- private native boolean operatorEqual(BluetoothObject obj);
+ private native boolean operatorEqual(DBusObject obj);
- protected BluetoothObject(long instance)
+ protected DBusObject(final long instance)
{
nativeInstance = instance;
isValid = true;
}
+ @Override
protected void finalize()
{
close();
}
- public boolean equals(Object obj)
+ @Override
+ public boolean equals(final Object obj)
{
- if (obj == null || !(obj instanceof BluetoothObject))
+ if (obj == null || !(obj instanceof DBusObject))
return false;
- return operatorEqual((BluetoothObject)obj);
+ return operatorEqual((DBusObject)obj);
}
protected native String getObjectPath();
+ @Override
public int hashCode() {
- String objectPath = getObjectPath();
+ final String objectPath = getObjectPath();
return objectPath.hashCode();
}
- /**
- * Release the native memory associated with this object
- * The object should not be used following a call to close
- */
@Override
public synchronized void close() {
if (!isValid)
diff --git a/src/BluetoothAdapter.cpp b/src/BluetoothAdapter.cpp
index ba8873ba..eab4eacd 100644
--- a/src/BluetoothAdapter.cpp
+++ b/src/BluetoothAdapter.cpp
@@ -88,7 +88,7 @@ std::string BluetoothAdapter::get_class_name() const
std::string BluetoothAdapter::get_java_class() const
{
- return std::string(JAVA_PACKAGE "/BluetoothAdapter");
+ return std::string(JAVA_DBUS_PACKAGE "/DBusAdapter");
}
std::string BluetoothAdapter::get_object_path() const
diff --git a/src/BluetoothDevice.cpp b/src/BluetoothDevice.cpp
index 1565941e..97538cd4 100644
--- a/src/BluetoothDevice.cpp
+++ b/src/BluetoothDevice.cpp
@@ -148,7 +148,7 @@ std::string BluetoothDevice::get_class_name() const
std::string BluetoothDevice::get_java_class() const
{
- return std::string(JAVA_PACKAGE "/BluetoothDevice");
+ return std::string(JAVA_DBUS_PACKAGE "/DBusDevice");
}
std::string BluetoothDevice::get_object_path() const
diff --git a/src/BluetoothGattCharacteristic.cpp b/src/BluetoothGattCharacteristic.cpp
index a087ae68..30914e9e 100644
--- a/src/BluetoothGattCharacteristic.cpp
+++ b/src/BluetoothGattCharacteristic.cpp
@@ -60,7 +60,7 @@ std::string BluetoothGattCharacteristic::get_class_name() const
std::string BluetoothGattCharacteristic::get_java_class() const
{
- return std::string(JAVA_PACKAGE "/BluetoothGattCharacteristic");
+ return std::string(JAVA_DBUS_PACKAGE "/DBusGattCharacteristic");
}
std::string BluetoothGattCharacteristic::get_object_path() const
diff --git a/src/BluetoothGattDescriptor.cpp b/src/BluetoothGattDescriptor.cpp
index ff5f804d..72acdd37 100644
--- a/src/BluetoothGattDescriptor.cpp
+++ b/src/BluetoothGattDescriptor.cpp
@@ -59,7 +59,7 @@ std::string BluetoothGattDescriptor::get_class_name() const
std::string BluetoothGattDescriptor::get_java_class() const
{
- return std::string(JAVA_PACKAGE "/BluetoothGattDescriptor");
+ return std::string(JAVA_DBUS_PACKAGE "/DBusGattDescriptor");
}
std::string BluetoothGattDescriptor::get_object_path() const
diff --git a/src/BluetoothGattService.cpp b/src/BluetoothGattService.cpp
index bc3fd534..d63893eb 100644
--- a/src/BluetoothGattService.cpp
+++ b/src/BluetoothGattService.cpp
@@ -38,7 +38,7 @@ std::string BluetoothGattService::get_class_name() const
std::string BluetoothGattService::get_java_class() const
{
- return std::string(JAVA_PACKAGE "/BluetoothGattService");
+ return std::string(JAVA_DBUS_PACKAGE "/DBusGattService");
}
std::string BluetoothGattService::get_object_path() const
diff --git a/src/BluetoothManager.cpp b/src/BluetoothManager.cpp
index 5c6c82ad..b6868d09 100644
--- a/src/BluetoothManager.cpp
+++ b/src/BluetoothManager.cpp
@@ -109,7 +109,7 @@ std::string BluetoothManager::get_class_name() const
std::string BluetoothManager::get_java_class() const
{
- return std::string(JAVA_PACKAGE "/BluetoothManager");
+ return std::string(JAVA_DBUS_PACKAGE "/DBusManager");
}
std::string BluetoothManager::get_object_path() const
diff --git a/src/BluetoothObject.cpp b/src/BluetoothObject.cpp
index 79c8b6e4..2e8ddaf4 100644
--- a/src/BluetoothObject.cpp
+++ b/src/BluetoothObject.cpp
@@ -29,7 +29,7 @@ using namespace tinyb;
std::string BluetoothObject::get_java_class() const
{
- return std::string(JAVA_PACKAGE "/BluetoothObject");
+ return std::string(JAVA_DBUS_PACKAGE "/DBusObject");
}
std::string BluetoothObject::get_class_name() const
diff --git a/src/org.bluez.xml b/src/org.bluez.xml
index c87384b5..da200c6b 100644
--- a/src/org.bluez.xml
+++ b/src/org.bluez.xml
@@ -20,6 +20,12 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+
+Author: Sven Gothel <[email protected]>
+Copyright (c) 2020 Gothel Software e.K.
+
+Permission / License unchanged BSD style.
+
-->
<node>
<interface name="org.bluez.Adapter1">
@@ -139,4 +145,51 @@ THE SOFTWARE.
<property name="ServiceData" type="a{sv}" access="read"/>
<property name="IncludeTxPower" type="b" access="read"/>
</interface>
+
+ <interface name="org.bluez.AgentManager1">
+ <method name="RegisterAgent">
+ <arg name="agent" type="o" direction="in" />
+ <arg name="capability" type="s" direction="in" />
+ </method>
+ <method name="UnregisterAgent">
+ <arg name="agent" type="o" direction="in" />
+ </method>
+ <method name="RequestDefaultAgent">
+ <arg name="agent" type="o" direction="in" />
+ </method>
+ </interface>
+
+ <interface name="org.bluez.Agent1">
+ <method name="Release"/>
+ <method name="RequestPinCode">
+ <arg name="pincode" type="s" direction="out" />
+ <arg name="device" type="o" direction="in" />
+ </method>
+ <method name="DisplayPinCode">
+ <arg name="device" type="o" direction="in" />
+ <arg name="pincode" type="s" direction="in" />
+ </method>
+ <method name="RequestPasskey">
+ <arg name="passkey" type="u" direction="out" />
+ <arg name="device" type="o" direction="in" />
+ </method>
+ <method name="DisplayPasskey">
+ <arg name="device" type="o" direction="in" />
+ <arg name="passkey" type="u" direction="in" />
+ <arg name="entered" type="q" direction="in" />
+ </method>
+ <method name="RequestConfirmation">
+ <arg name="device" type="o" direction="in" />
+ <arg name="passkey" type="u" direction="in" />
+ </method>
+ <method name="RequestAuthorization">
+ <arg name="device" type="o" direction="in" />
+ </method>
+ <method name="AuthorizeService">
+ <arg name="device" type="o" direction="in" />
+ <arg name="uuid" type="s" direction="in" />
+ </method>
+ <method name="Cancel"/>
+ </interface>
+
</node>