summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-09-26 11:25:55 +0200
committerSven Gothel <[email protected]>2020-09-26 11:25:55 +0200
commit0aacb220265e223d1e36635bc0517c3fa600ba8e (patch)
tree066a8eab0996d5d87bd98d17b0e5b5a66b7d9c5a /examples
parente5f17537344f09ffff7c072659f7e0ab9c8ff9e1 (diff)
DBTAdapter.adapterSettingsChanged(): Handle 'initialSetting' (0 == oldmask): Set all related states, skip all actions.
Also added notion of 'initialSetting' to dbt_scanner10 and DBTScanner10.
Diffstat (limited to 'examples')
-rw-r--r--examples/direct_bt_scanner10/dbt_scanner10.cpp12
-rw-r--r--examples/java/DBTScanner10.java7
2 files changed, 14 insertions, 5 deletions
diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp
index d8d87ac0..0653c4c5 100644
--- a/examples/direct_bt_scanner10/dbt_scanner10.cpp
+++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp
@@ -132,10 +132,14 @@ class MyAdapterStatusListener : public AdapterStatusListener {
void adapterSettingsChanged(DBTAdapter const &a, const AdapterSetting oldmask, const AdapterSetting newmask,
const AdapterSetting changedmask, const uint64_t timestamp) override {
- fprintf(stderr, "****** SETTINGS_CHANGED: %s -> %s, changed %s\n",
- getAdapterSettingsString(oldmask).c_str(),
- getAdapterSettingsString(newmask).c_str(),
- getAdapterSettingsString(changedmask).c_str());
+ const bool initialSetting = AdapterSetting::NONE == oldmask;
+ if( initialSetting ) {
+ fprintf(stderr, "****** SETTINGS_INITIAL: %s -> %s, changed %s\n", getAdapterSettingsString(oldmask).c_str(),
+ getAdapterSettingsString(newmask).c_str(), getAdapterSettingsString(changedmask).c_str());
+ } else {
+ fprintf(stderr, "****** SETTINGS_CHANGED: %s -> %s, changed %s\n", getAdapterSettingsString(oldmask).c_str(),
+ getAdapterSettingsString(newmask).c_str(), getAdapterSettingsString(changedmask).c_str());
+ }
fprintf(stderr, "Status DBTAdapter:\n");
fprintf(stderr, "%s\n", a.toString().c_str());
(void)timestamp;
diff --git a/examples/java/DBTScanner10.java b/examples/java/DBTScanner10.java
index 71528ad1..caa72def 100644
--- a/examples/java/DBTScanner10.java
+++ b/examples/java/DBTScanner10.java
@@ -106,7 +106,12 @@ public class DBTScanner10 {
@Override
public void adapterSettingsChanged(final BluetoothAdapter adapter, final AdapterSettings oldmask,
final AdapterSettings newmask, final AdapterSettings changedmask, final long timestamp) {
- println("****** SETTINGS: "+oldmask+" -> "+newmask+", changed "+changedmask);
+ final boolean initialSetting = oldmask.isEmpty();
+ if( initialSetting ) {
+ println("****** SETTINGS: "+oldmask+" -> "+newmask+", initial "+changedmask);
+ } else {
+ println("****** SETTINGS: "+oldmask+" -> "+newmask+", changed "+changedmask);
+ }
println("Status Adapter:");
println(adapter.toString());
if( changedmask.isSet(AdapterSettings.SettingType.POWERED) &&