diff options
author | Sven Gothel <[email protected]> | 2022-04-14 05:29:31 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-04-14 05:29:31 +0200 |
commit | b0cf6cee7adb38d0e8a64d9c22f44083d2a79e4d (patch) | |
tree | 63f88c27721fcd78ae35911ac563efce3a5445b8 | |
parent | 48221cbcae5ab772f418e77b7fe3320f7f3d0f2e (diff) |
Fix and document default connection paramter, leaning to higher performance side - add documentation file
-rw-r--r-- | api/direct_bt/BTAdapter.hpp | 12 | ||||
-rw-r--r-- | api/direct_bt/HCIHandler.hpp | 6 | ||||
-rw-r--r-- | doc/Connection_Parameter.txt | 46 | ||||
-rw-r--r-- | examples/dbt_peripheral00.cpp | 6 | ||||
-rw-r--r-- | examples/dbt_scanner10.cpp | 4 | ||||
-rw-r--r-- | examples/java/DBTPeripheral00.java | 6 | ||||
-rw-r--r-- | examples/java/DBTScanner10.java | 4 | ||||
-rw-r--r-- | java/org/direct_bt/BTAdapter.java | 8 | ||||
-rw-r--r-- | trial/java/trial/org/direct_bt/BaseDBTClientServer.java | 2 | ||||
-rw-r--r-- | trial/java/trial/org/direct_bt/DBTClient00.java | 8 | ||||
-rw-r--r-- | trial/java/trial/org/direct_bt/DBTServer00.java | 6 |
11 files changed, 77 insertions, 31 deletions
diff --git a/api/direct_bt/BTAdapter.hpp b/api/direct_bt/BTAdapter.hpp index 3e0f82ac..f6bf2748 100644 --- a/api/direct_bt/BTAdapter.hpp +++ b/api/direct_bt/BTAdapter.hpp @@ -1180,8 +1180,8 @@ namespace direct_bt { * @param eir Full ADV EIR EInfoReport, will be updated with getName() and at least GAPFlags::LE_Gen_Disc set. * @param adv_mask EIRDataType mask for EInfoReport to select advertisement EIR PDU data, defaults to EIRDataType::FLAGS | EIRDataType::SERVICE_UUID * @param scanrsp_mask EIRDataType mask for EInfoReport to select scan-response (active scanning) EIR PDU data, defaults to EIRDataType::NAME | EIRDataType::CONN_IVAL - * @param adv_interval_min in units of 0.625ms, default value 640 for 400ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] - * @param adv_interval_max in units of 0.625ms, default value 640 for 400ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] + * @param adv_interval_min in units of 0.625ms, default value 160 for 100ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] + * @param adv_interval_max in units of 0.625ms, default value 480 for 300ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] * @param adv_type see AD_PDU_Type, default ::AD_PDU_Type::ADV_IND * @param adv_chan_map bit 0: chan 37, bit 1: chan 38, bit 2: chan 39, default is 0x07 (all 3 channels enabled) * @param filter_policy 0x00 accepts all PDUs (default), 0x01 only of whitelisted, ... @@ -1197,7 +1197,7 @@ namespace direct_bt { EInfoReport& eir, EIRDataType adv_mask = EIRDataType::FLAGS | EIRDataType::SERVICE_UUID, EIRDataType scanrsp_mask = EIRDataType::NAME | EIRDataType::CONN_IVAL, - const uint16_t adv_interval_min=640, const uint16_t adv_interval_max=640, + const uint16_t adv_interval_min=160, const uint16_t adv_interval_max=480, const AD_PDU_Type adv_type=AD_PDU_Type::ADV_IND, const uint8_t adv_chan_map=0x07, const uint8_t filter_policy=0x00) noexcept; @@ -1232,8 +1232,8 @@ namespace direct_bt { * @param gattServerData_ the DBGattServer data to be advertised and offered via GattHandler as ::GATTRole::Server. * Its handles will be setup via DBGattServer::setServicesHandles(). * Reference is held until next disconnect. - * @param adv_interval_min in units of 0.625ms, default value 640 for 400ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] - * @param adv_interval_max in units of 0.625ms, default value 640 for 400ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] + * @param adv_interval_min in units of 0.625ms, default value 160 for 100ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] + * @param adv_interval_max in units of 0.625ms, default value 480 for 300ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] * @param adv_type see AD_PDU_Type, default ::AD_PDU_Type::ADV_IND * @param adv_chan_map bit 0: chan 37, bit 1: chan 38, bit 2: chan 39, default is 0x07 (all 3 channels enabled) * @param filter_policy 0x00 accepts all PDUs (default), 0x01 only of whitelisted, ... @@ -1246,7 +1246,7 @@ namespace direct_bt { * @since 2.4.0 */ HCIStatusCode startAdvertising(DBGattServerRef gattServerData_, - const uint16_t adv_interval_min=640, const uint16_t adv_interval_max=640, + const uint16_t adv_interval_min=160, const uint16_t adv_interval_max=480, const AD_PDU_Type adv_type=AD_PDU_Type::ADV_IND, const uint8_t adv_chan_map=0x07, const uint8_t filter_policy=0x00) noexcept; diff --git a/api/direct_bt/HCIHandler.hpp b/api/direct_bt/HCIHandler.hpp index ad37724d..883ee55e 100644 --- a/api/direct_bt/HCIHandler.hpp +++ b/api/direct_bt/HCIHandler.hpp @@ -852,8 +852,8 @@ namespace direct_bt { * @param peer_bdaddr EUI48 of directed peer, defaults to EUI48::ANY_DEVICE (zero address) * @param own_mac_type HCILEOwnAddressType::PUBLIC (default) or random/private. * @param peer_mac_type HCILEOwnAddressType::PUBLIC (default) or random/private. - * @param adv_interval_min in units of 0.625ms, default value 640 for 400ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] - * @param adv_interval_max in units of 0.625ms, default value 640 for 400ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] + * @param adv_interval_min in units of 0.625ms, default value 160 for 100ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] + * @param adv_interval_max in units of 0.625ms, default value 480 for 300ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] * @param adv_type see AD_PDU_Type, default ::AD_PDU_Type::ADV_IND * @param adv_chan_map bit 0: chan 37, bit 1: chan 38, bit 2: chan 39, default is 0x07 (all 3 channels enabled) * @param filter_policy 0x00 accepts all PDUs (default), 0x01 only of whitelisted, ... @@ -866,7 +866,7 @@ namespace direct_bt { const EUI48 &peer_bdaddr=EUI48::ANY_DEVICE, const HCILEOwnAddressType own_mac_type=HCILEOwnAddressType::PUBLIC, const HCILEOwnAddressType peer_mac_type=HCILEOwnAddressType::PUBLIC, - const uint16_t adv_interval_min=640, const uint16_t adv_interval_max=640, + const uint16_t adv_interval_min=160, const uint16_t adv_interval_max=480, const AD_PDU_Type adv_type=AD_PDU_Type::ADV_IND, const uint8_t adv_chan_map=0x07, const uint8_t filter_policy=0x00) noexcept; diff --git a/doc/Connection_Parameter.txt b/doc/Connection_Parameter.txt new file mode 100644 index 00000000..d9233e88 --- /dev/null +++ b/doc/Connection_Parameter.txt @@ -0,0 +1,46 @@ +Server: +======== + +BTAdapter::setDefaultConnParam(): + 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); + +BTAdapter::startAdvertising() + static const uint16_t adv_interval_min=160; // x0.625 = 100ms - default is 640 -> 400ms + static const uint16_t adv_interval_max=480; // x0.625 = 300ms - default is 640 -> 400ms + static const AD_PDU_Type adv_type=AD_PDU_Type::ADV_IND; + static const uint8_t adv_chan_map=0x07; + static const uint8_t filter_policy=0x00; + + eir.setConnInterval(8, 12); // 10ms - 15ms + + +Client: +======== + +BTAdapter::startDiscovery(): + static DiscoveryPolicy discoveryPolicy = DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_READY; // default value + static bool le_scan_active = true; // default value + static const uint16_t le_scan_interval = 24; // 15ms, default value + static const uint16_t le_scan_window = 24; // 15ms, default value + static const uint8_t filter_policy = 0; // default value + + adapter->startDiscovery( discoveryPolicy, le_scan_active, le_scan_interval, le_scan_window, filter_policy ); + + +BTDevice::connectLE(): + static const uint16_t le_scan_interval = 24; // 15ms, default value + static const uint16_t le_scan_window = 24; // 15ms, default value + + uint16_t conn_interval_min = (uint16_t)8; // 10ms + uint16_t conn_interval_max = (uint16_t)12; // 15ms + const uint16_t conn_latency = (uint16_t)0; + + const uint16_t supervision_timeout = (uint16_t) getHCIConnSupervisorTimeout(conn_latency, (int) ( conn_interval_max * 1.25 ) /* ms */); + device->connectLE(le_scan_interval, le_scan_window, conn_interval_min, conn_interval_max, conn_latency, supervision_timeout); + + + diff --git a/examples/dbt_peripheral00.cpp b/examples/dbt_peripheral00.cpp index 9c55cbf9..9d12f5a6 100644 --- a/examples/dbt_peripheral00.cpp +++ b/examples/dbt_peripheral00.cpp @@ -519,8 +519,8 @@ class MyGATTServerListener : public DBGattServer::Listener { } }; -static const uint16_t adv_interval_min=640; -static const uint16_t adv_interval_max=640; +static const uint16_t adv_interval_min=160; // x0.625 = 100ms +static const uint16_t adv_interval_max=480; // x0.625 = 300ms static const AD_PDU_Type adv_type=AD_PDU_Type::ADV_IND; static const uint8_t adv_chan_map=0x07; static const uint8_t filter_policy=0x00; @@ -541,7 +541,7 @@ static bool startAdvertising(BTAdapter *a, std::string msg) { eir.setServicesComplete(false); eir.setName(a->getName()); - eir.setConnInterval(8, 24); // 10ms - 30ms + eir.setConnInterval(8, 12); // 10ms - 15ms DBGattCharRef gattDevNameChar = dbGattServer->findGattChar( jau::uuid16_t(GattServiceType::GENERIC_ACCESS), jau::uuid16_t(GattCharacteristicType::DEVICE_NAME) ); diff --git a/examples/dbt_scanner10.cpp b/examples/dbt_scanner10.cpp index 6e76a5e2..a4d61020 100644 --- a/examples/dbt_scanner10.cpp +++ b/examples/dbt_scanner10.cpp @@ -400,8 +400,8 @@ static void connectDiscoveredDevice(BTDeviceRef device) { std::shared_ptr<const EInfoReport> eir = device->getEIR(); fprintf_td(stderr, "Using EIR %s\n", eir->toString().c_str()); - uint16_t conn_interval_min = (uint16_t)12; - uint16_t conn_interval_max = (uint16_t)12; + uint16_t conn_interval_min = (uint16_t)8; // 10ms + uint16_t conn_interval_max = (uint16_t)12; // 15ms const uint16_t conn_latency = (uint16_t)0; if( eir->isSet(EIRDataType::CONN_IVAL) ) { eir->getConnInterval(conn_interval_min, conn_interval_max); diff --git a/examples/java/DBTPeripheral00.java b/examples/java/DBTPeripheral00.java index ae64c58d..a09e6fc6 100644 --- a/examples/java/DBTPeripheral00.java +++ b/examples/java/DBTPeripheral00.java @@ -559,8 +559,8 @@ public class DBTPeripheral00 { } } } - static final short adv_interval_min=(short)640; - static final short adv_interval_max=(short)640; + static final short adv_interval_min=(short)160; // x0.625 = 100ms + static final short adv_interval_max=(short)480; // x0.625 = 300ms static final byte adv_type=(byte)0; // AD_PDU_Type::ADV_IND; static final byte adv_chan_map=(byte)0x07; static final byte filter_policy=(byte)0x00; @@ -597,7 +597,7 @@ public class DBTPeripheral00 { eir.setServicesComplete(false); eir.setName(adapter.getName()); - eir.setConnInterval((short)8, (short)24); // 10ms - 30ms + eir.setConnInterval((short)8, (short)12); // 10ms - 15ms final DBGattChar gattDevNameChar = dbGattServer.findGattChar(DBGattService.UUID16.GENERIC_ACCESS, DBGattChar.UUID16.DEVICE_NAME); if( null != gattDevNameChar ) { diff --git a/examples/java/DBTScanner10.java b/examples/java/DBTScanner10.java index 8711fd78..3d81900e 100644 --- a/examples/java/DBTScanner10.java +++ b/examples/java/DBTScanner10.java @@ -369,8 +369,8 @@ public class DBTScanner10 { final EInfoReport eir = device.getEIR(); BTUtils.println(System.err, "Using EIR "+eir.toString()); - short conn_interval_min = (short)12; - short conn_interval_max = (short)12; + short conn_interval_min = (short)8; // 10ms + short conn_interval_max = (short)12; // 15ms final short conn_latency = (short)0; if( eir.isSet(EIRDataTypeSet.DataType.CONN_IVAL) ) { final short[] minmax = new short[2]; diff --git a/java/org/direct_bt/BTAdapter.java b/java/org/direct_bt/BTAdapter.java index adf1aa00..1a0c9732 100644 --- a/java/org/direct_bt/BTAdapter.java +++ b/java/org/direct_bt/BTAdapter.java @@ -316,8 +316,8 @@ public interface BTAdapter extends BTObject * @param eir Full ADV EIR {@link EInfoReport}, will be updated with {@link #getName()} and at least {@link GAPFlags.Bit#LE_Gen_Disc} set. * @param adv_mask {@link EIRDataTypeSet} mask for {@link EInfoReport} to select advertisement EIR PDU data, defaults to {@link EIRDataTypeSet.DataType#FLAGS} | {@link EIRDataTypeSet.DataType#SERVICE_UUID} * @param scanrsp_mask {@link EIRDataTypeSet} mask for {@link EInfoReport} to select scan-response (active scanning) EIR PDU data, defaults to {@link EIRDataTypeSet.DataType#NAME} | {@link EIRDataTypeSet.DataType#CONN_IVAL} - * @param adv_interval_min in units of 0.625ms, default value 640 for 400ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] - * @param adv_interval_max in units of 0.625ms, default value 640 for 400ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] + * @param adv_interval_min in units of 0.625ms, default value 160 for 100ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] + * @param adv_interval_max in units of 0.625ms, default value 480 for 300ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] * @param adv_type see AD_PDU_Type, default 0x00, i.e. ::AD_PDU_Type::ADV_IND * @param adv_chan_map bit 0: chan 37, bit 1: chan 38, bit 2: chan 39, default is 0x07 (all 3 channels enabled) * @param filter_policy 0x00 accepts all PDUs (default), 0x01 only of whitelisted, ... @@ -363,8 +363,8 @@ public interface BTAdapter extends BTObject * @param gattServerData_ the {@link DBGattServer} data to be advertised and offered via GattHandler as ::GATTRole::Server. * Its handles will be setup via DBGattServer::setServicesHandles(). * Reference is held until next disconnect. - * @param adv_interval_min in units of 0.625ms, default value 640 for 400ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] - * @param adv_interval_max in units of 0.625ms, default value 640 for 400ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] + * @param adv_interval_min in units of 0.625ms, default value 160 for 100ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] + * @param adv_interval_max in units of 0.625ms, default value 480 for 300ms; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s] * @param adv_type see AD_PDU_Type, default 0x00, i.e. ::AD_PDU_Type::ADV_IND * @param adv_chan_map bit 0: chan 37, bit 1: chan 38, bit 2: chan 39, default is 0x07 (all 3 channels enabled) * @param filter_policy 0x00 accepts all PDUs (default), 0x01 only of whitelisted, ... diff --git a/trial/java/trial/org/direct_bt/BaseDBTClientServer.java b/trial/java/trial/org/direct_bt/BaseDBTClientServer.java index 9a4fee03..4351c464 100644 --- a/trial/java/trial/org/direct_bt/BaseDBTClientServer.java +++ b/trial/java/trial/org/direct_bt/BaseDBTClientServer.java @@ -47,7 +47,7 @@ import jau.test.junit.util.SingletonJunitCase; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public abstract class BaseDBTClientServer extends SingletonJunitCase { - static boolean DEBUG = false; + static boolean DEBUG = true; @BeforeClass public static final void setupAll() { diff --git a/trial/java/trial/org/direct_bt/DBTClient00.java b/trial/java/trial/org/direct_bt/DBTClient00.java index 987799b4..0d8cdeb3 100644 --- a/trial/java/trial/org/direct_bt/DBTClient00.java +++ b/trial/java/trial/org/direct_bt/DBTClient00.java @@ -360,8 +360,8 @@ public class DBTClient00 implements DBTClientTest { final EInfoReport eir = device.getEIR(); BTUtils.println(System.err, "Using EIR "+eir.toString()); - short conn_interval_min = (short)12; - short conn_interval_max = (short)12; + short conn_interval_min = (short)8; // 10ms + short conn_interval_max = (short)12; // 15ms final short conn_latency = (short)0; if( eir.isSet(EIRDataTypeSet.DataType.CONN_IVAL) ) { final short[] minmax = new short[2]; @@ -583,8 +583,8 @@ public class DBTClient00 implements DBTClientTest { DiscoveryPolicy discoveryPolicy = DiscoveryPolicy.PAUSE_CONNECTED_UNTIL_READY; // default value boolean le_scan_active = true; // default value - static final short le_scan_interval = (short)24; // default value - static final short le_scan_window = (short)24; // default value + static final short le_scan_interval = (short)24; // 15ms, default value + static final short le_scan_window = (short)24; // 15ms, default value static final byte filter_policy = (byte)0; // default value static final boolean filter_dup = true; // default value diff --git a/trial/java/trial/org/direct_bt/DBTServer00.java b/trial/java/trial/org/direct_bt/DBTServer00.java index 548b6033..a47e8984 100644 --- a/trial/java/trial/org/direct_bt/DBTServer00.java +++ b/trial/java/trial/org/direct_bt/DBTServer00.java @@ -601,8 +601,8 @@ public class DBTServer00 implements DBTServerTest { } } } - static final short adv_interval_min=(short)640; - static final short adv_interval_max=(short)640; + static final short adv_interval_min=(short)160; // x0.625 = 100ms + static final short adv_interval_max=(short)480; // x0.625 = 300ms static final byte adv_type=(byte)0; // AD_PDU_Type::ADV_IND; static final byte adv_chan_map=(byte)0x07; static final byte filter_policy=(byte)0x00; @@ -641,7 +641,7 @@ public class DBTServer00 implements DBTServerTest { eir.setServicesComplete(false); eir.setName(adapter.getName()); - eir.setConnInterval((short)8, (short)24); // 10ms - 30ms + eir.setConnInterval((short)8, (short)12); // 10ms - 15ms final DBGattChar gattDevNameChar = dbGattServer.findGattChar(DBGattService.UUID16.GENERIC_ACCESS, DBGattChar.UUID16.DEVICE_NAME); if( null != gattDevNameChar ) { |