diff options
author | Sven Gothel <[email protected]> | 2022-01-25 18:25:23 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-01-25 18:25:23 +0100 |
commit | fed5a977d7d9f2a26b5ef462d13146de1bfaffec (patch) | |
tree | 14f260a7094f1cf768a505ea81bd21cedf187180 /examples | |
parent | 4ceee4cb4d2d34e7d24db33f12c05bb617f288ca (diff) |
Expose BTManager::setDefaultConnParam(..) via BTAdapter::setDefaultConnParam(..), essential in server mode
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dbt_peripheral00.cpp | 15 | ||||
-rw-r--r-- | examples/java/DBTPeripheral00.java | 15 |
2 files changed, 30 insertions, 0 deletions
diff --git a/examples/dbt_peripheral00.cpp b/examples/dbt_peripheral00.cpp index a6a13373..383a6e74 100644 --- a/examples/dbt_peripheral00.cpp +++ b/examples/dbt_peripheral00.cpp @@ -589,6 +589,7 @@ static bool initAdapter(std::shared_ptr<BTAdapter>& adapter) { fprintf_td(stderr, "initAdapter: setLocalName OK: %s\n", adapter->toString().c_str()); } else { fprintf_td(stderr, "initAdapter: setLocalName failed: %s\n", adapter->toString().c_str()); + return false; } status = adapter->setSecureConnections( use_SC ); @@ -596,7 +597,21 @@ static bool initAdapter(std::shared_ptr<BTAdapter>& adapter) { fprintf_td(stderr, "initAdapter: setSecureConnections OK: %s\n", adapter->toString().c_str()); } else { fprintf_td(stderr, "initAdapter: setSecureConnections failed: %s\n", adapter->toString().c_str()); + return false; + } + + const uint16_t conn_min_interval = 8; // 10ms + const uint16_t conn_max_interval = 40; // 50ms + const uint16_t conn_latency = 0; + const uint16_t supervision_timeout = 50; // 500ms + status = adapter->setDefaultConnParam(conn_min_interval, conn_max_interval, conn_latency, supervision_timeout); + if( HCIStatusCode::SUCCESS == status ) { + fprintf_td(stderr, "initAdapter: setDefaultConnParam OK: %s\n", adapter->toString().c_str()); + } else { + fprintf_td(stderr, "initAdapter: setDefaultConnParam failed: %s\n", adapter->toString().c_str()); + return false; } + if( !adapter->setPowered( true ) ) { fprintf_td(stderr, "initAdapter: setPower.2 on failed: %s\n", adapter->toString().c_str()); return false; diff --git a/examples/java/DBTPeripheral00.java b/examples/java/DBTPeripheral00.java index 97cb8f12..6cde923a 100644 --- a/examples/java/DBTPeripheral00.java +++ b/examples/java/DBTPeripheral00.java @@ -637,6 +637,7 @@ public class DBTPeripheral00 { BTUtils.fprintf_td(System.err, "initAdapter: setLocalName OK: %s\n", adapter.toString()); } else { BTUtils.fprintf_td(System.err, "initAdapter: setLocalName failed: %s\n", adapter.toString()); + return false; } status = adapter.setSecureConnections( use_SC ); @@ -644,7 +645,21 @@ public class DBTPeripheral00 { BTUtils.fprintf_td(System.err, "initAdapter: setSecureConnections OK: %s\n", adapter.toString()); } else { BTUtils.fprintf_td(System.err, "initAdapter: setSecureConnections failed: %s\n", adapter.toString()); + return false; + } + + final short conn_min_interval = 8; // 10ms + final short conn_max_interval = 40; // 50ms + final short conn_latency = 0; + final short supervision_timeout = 50; // 500ms + status = adapter.setDefaultConnParam(conn_min_interval, conn_max_interval, conn_latency, supervision_timeout); + if( HCIStatusCode.SUCCESS == status ) { + BTUtils.fprintf_td(System.err, "initAdapter: setDefaultConnParam OK: %s\n", adapter.toString()); + } else { + BTUtils.fprintf_td(System.err, "initAdapter: setDefaultConnParam failed: %s\n", adapter.toString()); + return false; } + if( !adapter.setPowered( true ) ) { BTUtils.fprintf_td(System.err, "initAdapter: setPower.2 on failed: %s\n", adapter.toString()); return false; |