aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/java/AsyncTinyB.java4
-rw-r--r--examples/java/CMakeLists.txt1
-rw-r--r--examples/java/HelloTinyB.java2
-rw-r--r--examples/java/Notification.java6
-rw-r--r--examples/java/ScannerTinyB01.java2
-rw-r--r--examples/java/ScannerTinyB02.java73
-rw-r--r--java/CMakeLists.txt1
-rw-r--r--java/direct_bt/tinyb/DBTDevice.java1
-rw-r--r--java/direct_bt/tinyb/DBTGattService.java1
-rw-r--r--java/direct_bt/tinyb/DBTManager.java2
-rw-r--r--java/org/tinyb/ObjectArgCallback.java1
-rw-r--r--java/org/tinyb/ObjectArrayArgCallback.java5
12 files changed, 28 insertions, 71 deletions
diff --git a/examples/java/AsyncTinyB.java b/examples/java/AsyncTinyB.java
index cb9a305c..ed0d49be 100644
--- a/examples/java/AsyncTinyB.java
+++ b/examples/java/AsyncTinyB.java
@@ -12,7 +12,7 @@ import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.TimeUnit;
public class AsyncTinyB {
- private static final float SCALE_LSB = 0.03125f;
+ // private static final float SCALE_LSB = 0.03125f;
static boolean running = true;
static void printDevice(final BluetoothDevice device) {
@@ -61,6 +61,7 @@ public class AsyncTinyB {
* 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.
*/
+ @SuppressWarnings("deprecation")
final boolean discoveryStarted = manager.startDiscovery();
System.out.println("The discovery started: " + (discoveryStarted ? "true" : "false"));
@@ -99,6 +100,7 @@ public class AsyncTinyB {
final Condition cv = lock.newCondition();
Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
public void run() {
running = false;
lock.lock();
diff --git a/examples/java/CMakeLists.txt b/examples/java/CMakeLists.txt
index d7a374aa..e6cee8b2 100644
--- a/examples/java/CMakeLists.txt
+++ b/examples/java/CMakeLists.txt
@@ -1,3 +1,4 @@
+# examples/java/CMakeLists.txt
find_package(Java REQUIRED)
include(UseJava)
diff --git a/examples/java/HelloTinyB.java b/examples/java/HelloTinyB.java
index 6008e721..6ea6a493 100644
--- a/examples/java/HelloTinyB.java
+++ b/examples/java/HelloTinyB.java
@@ -128,6 +128,7 @@ public class HelloTinyB {
* 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.
*/
+ @SuppressWarnings("deprecation")
final boolean discoveryStarted = manager.startDiscovery();
System.out.println("The discovery started: " + (discoveryStarted ? "true" : "false"));
@@ -161,6 +162,7 @@ public class HelloTinyB {
final Condition cv = lock.newCondition();
Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
public void run() {
running = false;
lock.lock();
diff --git a/examples/java/Notification.java b/examples/java/Notification.java
index 68e2a1b1..8d54017d 100644
--- a/examples/java/Notification.java
+++ b/examples/java/Notification.java
@@ -38,6 +38,7 @@ import org.tinyb.HCIStatusCode;
class ValueNotification implements BluetoothNotification<byte[]> {
+ @Override
public void run(final byte[] tempRaw) {
System.out.print("Temp raw = {");
for (final byte b : tempRaw) {
@@ -66,6 +67,7 @@ class ValueNotification implements BluetoothNotification<byte[]> {
class ConnectedNotification implements BluetoothNotification<Boolean> {
+ @Override
public void run(final Boolean connected) {
System.out.println("Connected");
}
@@ -73,7 +75,7 @@ class ConnectedNotification implements BluetoothNotification<Boolean> {
}
public class Notification {
- private static final float SCALE_LSB = 0.03125f;
+ // private static final float SCALE_LSB = 0.03125f;
static boolean running = true;
static void printDevice(final BluetoothDevice device) {
@@ -122,6 +124,7 @@ public class Notification {
* 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.
*/
+ @SuppressWarnings("deprecation")
final boolean discoveryStarted = manager.startDiscovery();
System.out.println("The discovery started: " + (discoveryStarted ? "true" : "false"));
@@ -158,6 +161,7 @@ public class Notification {
final Condition cv = lock.newCondition();
Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
public void run() {
running = false;
lock.lock();
diff --git a/examples/java/ScannerTinyB01.java b/examples/java/ScannerTinyB01.java
index d2a03ffb..cfd45ec9 100644
--- a/examples/java/ScannerTinyB01.java
+++ b/examples/java/ScannerTinyB01.java
@@ -332,7 +332,7 @@ public class ScannerTinyB01 {
final BluetoothGattCharacteristic char2 = (BluetoothGattCharacteristic)
manager.find(BluetoothType.GATT_CHARACTERISTIC, null, characteristic, sensor, 1000);
System.err.println("Char UUID "+characteristic);
- //System.err.println(" over manager: "+char0);
+ System.err.println(" over manager: "+char0);
System.err.println(" over adapter: "+char1);
System.err.println(" over device : "+char2);
}
diff --git a/examples/java/ScannerTinyB02.java b/examples/java/ScannerTinyB02.java
index 75245920..815d5876 100644
--- a/examples/java/ScannerTinyB02.java
+++ b/examples/java/ScannerTinyB02.java
@@ -316,70 +316,19 @@ public class ScannerTinyB02 {
// System.exit(-1);
}
- if( true ) {
- final BluetoothDevice _sensor = sensor;
- final Thread lalaTask = new Thread( new Runnable() {
- @Override
- public void run() {
- _sensor.disconnect();
- }
- }, "lala");
- lalaTask.setDaemon(true); // detach thread
- lalaTask.start();
-
- // Thread.sleep(60);
- // sensor.connect();
- continue;
- } else {
- final List<BluetoothGattService> primServices = sensor.getServices();
- if ( null == primServices || primServices.isEmpty() ) {
- System.err.println("No BluetoothGattService found!");
- } else {
- final GATTCharacteristicListener myCharacteristicListener = new GATTCharacteristicListener(null) {
- @Override
- public void notificationReceived(final BluetoothGattCharacteristic charDecl,
- final byte[] value, final long timestamp) {
- System.err.println("****** GATT notificationReceived: "+charDecl+
- ", value "+BluetoothUtils.bytesHexString(value, true, true));
- }
-
- @Override
- public void indicationReceived(final BluetoothGattCharacteristic charDecl,
- final byte[] value, final long timestamp, final boolean confirmationSent) {
- System.err.println("****** GATT indicationReceived: "+charDecl+
- ", value "+BluetoothUtils.bytesHexString(value, true, true));
- }
- };
- final boolean addedCharacteristicListenerRes =
- BluetoothGattService.addCharacteristicListenerToAll(sensor, primServices, myCharacteristicListener);
- System.err.println("Added GATTCharacteristicListener: "+addedCharacteristicListenerRes);
-
- int i=0, j=0;
- for(final Iterator<BluetoothGattService> srvIter = primServices.iterator(); srvIter.hasNext(); i++) {
- final BluetoothGattService primService = srvIter.next();
- System.err.printf(" [%02d] Service %s\n", i, primService.toString());
- System.err.printf(" [%02d] Service Characteristics\n", i);
- final List<BluetoothGattCharacteristic> serviceCharacteristics = primService.getCharacteristics();
- for(final Iterator<BluetoothGattCharacteristic> charIter = serviceCharacteristics.iterator(); charIter.hasNext(); j++) {
- final BluetoothGattCharacteristic serviceChar = charIter.next();
- System.err.printf(" [%02d.%02d] Decla: %s\n", i, j, serviceChar.toString());
- final List<String> properties = Arrays.asList(serviceChar.getFlags());
- if( properties.contains("read") ) {
- final byte[] value = serviceChar.readValue();
- final String svalue = BluetoothUtils.decodeUTF8String(value, 0, value.length);
- System.err.printf(" [%02d.%02d] Value: %s ('%s')\n",
- i, j, BluetoothUtils.bytesHexString(value, true, true), svalue);
- }
- }
+ final BluetoothDevice _sensor = sensor;
+ final Thread lalaTask = new Thread( new Runnable() {
+ @Override
+ public void run() {
+ _sensor.disconnect();
}
- Thread.sleep(1000); // FIXME: Wait for notifications
+ }, "lala");
+ lalaTask.setDaemon(true); // detach thread
+ lalaTask.start();
- final boolean remRes = BluetoothGattService.removeCharacteristicListenerFromAll(sensor, primServices, myCharacteristicListener);
- System.err.println("Removed GATTCharacteristicListener: "+remRes);
- }
- sensor.disconnect();
- System.err.println("ScannerTinyB01 04 ...: "+adapter);
- }
+ // Thread.sleep(60);
+ // sensor.connect();
+ continue;
}
} catch (final Throwable t) {
System.err.println("Caught: "+t.getMessage());
diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt
index ccb33756..52272909 100644
--- a/java/CMakeLists.txt
+++ b/java/CMakeLists.txt
@@ -1,3 +1,4 @@
+# java/CMakeLists.txt
find_package(Java REQUIRED)
find_package(JNI REQUIRED)
include(UseJava)
diff --git a/java/direct_bt/tinyb/DBTDevice.java b/java/direct_bt/tinyb/DBTDevice.java
index 7e01b122..6d3d2b7d 100644
--- a/java/direct_bt/tinyb/DBTDevice.java
+++ b/java/direct_bt/tinyb/DBTDevice.java
@@ -39,7 +39,6 @@ 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.BluetoothObject;
import org.tinyb.BluetoothType;
diff --git a/java/direct_bt/tinyb/DBTGattService.java b/java/direct_bt/tinyb/DBTGattService.java
index a319a894..eca6ddf1 100644
--- a/java/direct_bt/tinyb/DBTGattService.java
+++ b/java/direct_bt/tinyb/DBTGattService.java
@@ -32,7 +32,6 @@ import org.tinyb.BluetoothDevice;
import org.tinyb.BluetoothGattCharacteristic;
import org.tinyb.BluetoothGattDescriptor;
import org.tinyb.BluetoothGattService;
-import org.tinyb.BluetoothManager;
import org.tinyb.BluetoothObject;
import org.tinyb.BluetoothType;
diff --git a/java/direct_bt/tinyb/DBTManager.java b/java/direct_bt/tinyb/DBTManager.java
index 82b25166..3dd83c2f 100644
--- a/java/direct_bt/tinyb/DBTManager.java
+++ b/java/direct_bt/tinyb/DBTManager.java
@@ -174,7 +174,6 @@ public class DBTManager implements BluetoothManager
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) {
// Due to generic type erasure, we cannot determine the matching BluetoothType for the return parameter,
@@ -183,7 +182,6 @@ public class DBTManager implements BluetoothManager
// return (T) find(BluetoothType.NONE, name, identifier, parent, timeoutMS);
}
- @SuppressWarnings("unchecked")
@Override
public <T extends BluetoothObject> T find(final String name, final String identifier, final BluetoothObject parent) {
// Due to generic type erasure, we cannot determine the matching BluetoothType for the return parameter,
diff --git a/java/org/tinyb/ObjectArgCallback.java b/java/org/tinyb/ObjectArgCallback.java
index 2ada8731..c201c8fb 100644
--- a/java/org/tinyb/ObjectArgCallback.java
+++ b/java/org/tinyb/ObjectArgCallback.java
@@ -28,6 +28,7 @@ import tinyb.dbus.DBusObject;
public class ObjectArgCallback extends BluetoothCallback
{
+ @SuppressWarnings("unused")
private final Object callbackArg;
public ObjectArgCallback(final DBusObject bObj, final Object callbackArg)
diff --git a/java/org/tinyb/ObjectArrayArgCallback.java b/java/org/tinyb/ObjectArrayArgCallback.java
index 4cb40e1c..91bb6e50 100644
--- a/java/org/tinyb/ObjectArrayArgCallback.java
+++ b/java/org/tinyb/ObjectArrayArgCallback.java
@@ -28,9 +28,10 @@ import tinyb.dbus.DBusObject;
public class ObjectArrayArgCallback extends BluetoothCallback
{
- private Object[] callbackArg;
+ @SuppressWarnings("unused")
+ private final Object[] callbackArg;
- public ObjectArrayArgCallback(DBusObject bObj, Object[] callbackArg)
+ public ObjectArrayArgCallback(final DBusObject bObj, final Object[] callbackArg)
{
this.bObj = bObj;
this.callbackArg = callbackArg;