summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-10-25 02:19:34 +0100
committerSven Gothel <[email protected]>2020-10-25 02:19:34 +0100
commit2565b396380f1dc0c30161439c2dde30df083a0d (patch)
treeda80840edca85529b8eb5d546c2da35f2a07debb /examples
parent5d3d7df23b1f499e27f1956e885f1a40d7a0de3b (diff)
Refine/add state queries in [DBT|Bluetooth]Adapter, BluetoothManager
[DBT|Bluetooth]Adapter: C++ and Java: Redefine/add state queries: - isValid(): true if this adapter references are valid and hasn't been DBTAdapter::close() 'ed - isPowered(): true if DBTAdapter::isValid(), HCIHandler::isOpen() and AdapterSetting::POWERED state is set - isSuspended(): true if DBTAdapter::isValid(), HCIHandler::isOpen() and AdapterSetting::POWERED state is not set - dev_id / getDevID(): Added definition, added method + implementation to Java BluetoothAdapter: Java - getPowered() -> getPoweredState() - to differentiate with isPowered() BluetoothManager: Java - getAdapter(dev_id) added - setDefaultAdapter(..) implementation removed in DBTManager -> nonsense - getDefaultAdapter(): DBT: Return 1st isPowered() adapter (redfinition, aligned with C++)
Diffstat (limited to 'examples')
-rw-r--r--examples/direct_bt_scanner00/dbt_scanner00.cpp4
-rw-r--r--examples/direct_bt_scanner01/dbt_scanner01.cpp4
-rw-r--r--examples/java/DBTScanner10.java6
-rw-r--r--examples/java/ScannerTinyB00.java2
-rw-r--r--examples/java/ScannerTinyB01.java2
-rw-r--r--examples/java/ScannerTinyB02.java2
6 files changed, 7 insertions, 13 deletions
diff --git a/examples/direct_bt_scanner00/dbt_scanner00.cpp b/examples/direct_bt_scanner00/dbt_scanner00.cpp
index ede0ea95..be56e35d 100644
--- a/examples/direct_bt_scanner00/dbt_scanner00.cpp
+++ b/examples/direct_bt_scanner00/dbt_scanner00.cpp
@@ -194,8 +194,8 @@ int main(int argc, char *argv[])
fprintf(stderr, "Adapter invalid.\n");
exit(1);
}
- if( !adapter.isEnabled() ) {
- fprintf(stderr, "Adapter not enabled: device %s, address %s: %s\n",
+ if( !adapter.isPowered() ) {
+ fprintf(stderr, "Adapter not powered: device %s, address %s: %s\n",
adapter.getName().c_str(), adapter.getAddressString().c_str(), adapter.toString().c_str());
exit(1);
}
diff --git a/examples/direct_bt_scanner01/dbt_scanner01.cpp b/examples/direct_bt_scanner01/dbt_scanner01.cpp
index 9759faa6..e7933ad2 100644
--- a/examples/direct_bt_scanner01/dbt_scanner01.cpp
+++ b/examples/direct_bt_scanner01/dbt_scanner01.cpp
@@ -192,8 +192,8 @@ int main(int argc, char *argv[])
fprintf(stderr, "Adapter invalid.\n");
exit(1);
}
- if( !adapter.isEnabled() ) {
- fprintf(stderr, "Adapter not enabled: device %s, address %s: %s\n",
+ if( !adapter.isPowered() ) {
+ fprintf(stderr, "Adapter not powered: device %s, address %s: %s\n",
adapter.getName().c_str(), adapter.getAddressString().c_str(), adapter.toString().c_str());
exit(1);
}
diff --git a/examples/java/DBTScanner10.java b/examples/java/DBTScanner10.java
index 59affe46..5988f5d6 100644
--- a/examples/java/DBTScanner10.java
+++ b/examples/java/DBTScanner10.java
@@ -615,12 +615,6 @@ public class DBTScanner10 {
System.setProperty("direct_bt.hci", args[++i]);
} else if( arg.equals("-dbt_mgmt") && args.length > (i+1) ) {
System.setProperty("direct_bt.mgmt", args[++i]);
- } 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 ) {
- System.setProperty("org.tinyb.default_adapter", String.valueOf(default_dev_id));
- System.err.println("Setting 'org.tinyb.default_adapter' to "+default_dev_id);
- }
} else if( arg.equals("-btmode") && args.length > (i+1) ) {
final BTMode btmode = BTMode.get(args[++i]);
System.setProperty("org.tinyb.btmode", btmode.toString());
diff --git a/examples/java/ScannerTinyB00.java b/examples/java/ScannerTinyB00.java
index fe7f2475..ec088670 100644
--- a/examples/java/ScannerTinyB00.java
+++ b/examples/java/ScannerTinyB00.java
@@ -125,7 +125,7 @@ public class ScannerTinyB00 {
System.exit(-1);
}
adapter = adapters.get(dev_id);
- if( !adapter.isEnabled() ) {
+ if( !adapter.isPowered() ) {
System.err.println("Adapter not enabled: device "+adapter.getName()+", address "+adapter.getAddress()+": "+adapter.toString());
System.exit(-1);
}
diff --git a/examples/java/ScannerTinyB01.java b/examples/java/ScannerTinyB01.java
index e431f610..b1266a9e 100644
--- a/examples/java/ScannerTinyB01.java
+++ b/examples/java/ScannerTinyB01.java
@@ -150,7 +150,7 @@ public class ScannerTinyB01 {
System.exit(-1);
}
adapter = adapters.get(dev_id);
- if( !adapter.isEnabled() ) {
+ if( !adapter.isPowered() ) {
System.err.println("Adapter not enabled: device "+adapter.getName()+", address "+adapter.getAddress()+": "+adapter.toString());
System.exit(-1);
}
diff --git a/examples/java/ScannerTinyB02.java b/examples/java/ScannerTinyB02.java
index e40052a9..c300431a 100644
--- a/examples/java/ScannerTinyB02.java
+++ b/examples/java/ScannerTinyB02.java
@@ -130,7 +130,7 @@ public class ScannerTinyB02 {
System.exit(-1);
}
adapter = adapters.get(dev_id);
- if( !adapter.isEnabled() ) {
+ if( !adapter.isPowered() ) {
System.err.println("Adapter not enabled: device "+adapter.getName()+", address "+adapter.getAddress()+": "+adapter.toString());
System.exit(-1);
}