summaryrefslogtreecommitdiffstats
path: root/examples/java/ScannerTinyB10.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-08-24 05:33:27 +0200
committerSven Gothel <[email protected]>2020-08-24 05:33:27 +0200
commitc1e543aacebd4c769abf4d6415c63d1a7ee6809d (patch)
tree7f7dc38fe61ca83406a2fda3956933e59cf32a64 /examples/java/ScannerTinyB10.java
parent790e705aa16f47effd1db6e58a84123b9e357c9f (diff)
BluetoothFactory/DBTEnv: Pass JVM properties to environment, access DEBUG, VERBOSE via lazy DBTEnv from C++ (
DEBUG := environment 'direct_bt_debug' or JVM property 'direct_bt.debug' VERBOSE := environment 'direct_bt_verbose' or JVM property 'direct_bt.verbose' This changes allows passing JVM properties as C++ environment variables, to be accessed via DBTEnv. JVM property names are renamed from 'foo.bar' to 'jvm_foo_bar' and can be queried via 'DBTEnv::getProperty("foo_bar")' as it will also attempt the 'jvm_' prefix if the plain name wasn't resolved. The singleton DBTEnv instance can be retrieved via DBTEnv::get(), which allows lazy initialization of DEBUG, VERBOSE from environment variables. This is required, as the JVM loads the native libraries first, initializes all native static variables and only then can pass the properties to the native environment via POSIX 'setenv(..)'. Hence users should never use static initialization from native code in such cases, otherwise they can't benefit from the unified JVM properties.
Diffstat (limited to 'examples/java/ScannerTinyB10.java')
-rw-r--r--examples/java/ScannerTinyB10.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/java/ScannerTinyB10.java b/examples/java/ScannerTinyB10.java
index 1815bf50..9e49c079 100644
--- a/examples/java/ScannerTinyB10.java
+++ b/examples/java/ScannerTinyB10.java
@@ -488,6 +488,10 @@ public class ScannerTinyB10 {
System.setProperty("org.tinyb.debug", "true");
} else if( arg.equals("-verbose") ) {
System.setProperty("org.tinyb.verbose", "true");
+ } else if( arg.equals("-dbt_debug") ) {
+ System.setProperty("direct_bt.debug", "true"); // 'direct_bt_debug' from C++
+ } else if( arg.equals("-dbt_verbose") ) {
+ System.setProperty("direct_bt.verbose", "true"); // 'direct_bt_verbose' from C++
} else if( arg.equals("-default_dev_id") && args.length > (i+1) ) {
final int default_dev_id = Integer.valueOf(args[++i]).intValue();
if( 0 <= default_dev_id ) {
@@ -536,7 +540,10 @@ public class ScannerTinyB10 {
test.MULTI_MEASUREMENTS = -1;
}
}
- println("Run with '[-default_dev_id <adapter-index>] [-dev_id <adapter-index>] (-mac <device_address>)* [-disconnect] [-count <number>] [-single] (-wl <device_address>)* (-char <uuid>)* [-show_update_events] [-bluetoothManager <BluetoothManager-Implementation-Class-Name>] [-verbose] [-debug] [-shutdown <int>]'");
+ println("Run with '[-default_dev_id <adapter-index>] [-dev_id <adapter-index>] (-mac <device_address>)* "+
+ "[-disconnect] [-count <number>] [-single] (-wl <device_address>)* (-char <uuid>)* [-show_update_events] "+
+ "[-bluetoothManager <BluetoothManager-Implementation-Class-Name>] "+
+ "[-verbose] [-debug] [-dbt_verbose] [-dbt_debug] [-shutdown <int>]'");
}
println("BluetoothManager "+bluetoothManagerClazzName);