diff options
-rw-r--r-- | api/direct_bt/DBTAdapter.hpp | 13 | ||||
-rw-r--r-- | api/direct_bt/DBTDevice.hpp | 16 | ||||
-rw-r--r-- | api/direct_bt/DBTManager.hpp | 13 | ||||
-rw-r--r-- | api/direct_bt/HCIComm.hpp | 6 | ||||
-rw-r--r-- | java/direct_bt/tinyb/DBTAdapter.java | 10 | ||||
-rw-r--r-- | java/direct_bt/tinyb/DBTDevice.java | 14 | ||||
-rw-r--r-- | java/org/tinyb/BluetoothAdapter.java | 12 | ||||
-rw-r--r-- | java/org/tinyb/BluetoothDevice.java | 18 | ||||
-rw-r--r-- | src/direct_bt/DBTAdapter.cpp | 8 | ||||
-rw-r--r-- | src/direct_bt/DBTDevice.cpp | 10 | ||||
-rw-r--r-- | src/direct_bt/HCIComm.cpp | 16 |
11 files changed, 82 insertions, 54 deletions
diff --git a/api/direct_bt/DBTAdapter.hpp b/api/direct_bt/DBTAdapter.hpp index 3813fd5d..cef32699 100644 --- a/api/direct_bt/DBTAdapter.hpp +++ b/api/direct_bt/DBTAdapter.hpp @@ -317,11 +317,20 @@ namespace direct_bt { * <p> * Method will reject duplicate devices, in which case it should be removed first. * </p> + * + * @param address + * @param address_type + * @param ctype + * @param conn_interval_min default value 0x000F + * @param conn_interval_max default value 0x000F + * @param conn_latency default value 0x0000 + * @param timeout in units of 10ms, default value 1000 for 10000ms or 10s. + * @return */ bool addDeviceToWhitelist(const EUI48 &address, const BDAddressType address_type, const HCIWhitelistConnectType ctype, - const uint16_t min_interval=0x000F, const uint16_t max_interval=0x000F, - const uint16_t latency=0x0000, const uint16_t timeout=HCI_LE_CONN_TIMEOUT_MS/10); + const uint16_t conn_interval_min=0x000F, const uint16_t conn_interval_max=0x000F, + const uint16_t conn_latency=0x0000, const uint16_t timeout=HCI_LE_CONN_TIMEOUT_MS/10); /** Remove the given device from the adapter's autoconnect whitelist. */ diff --git a/api/direct_bt/DBTDevice.hpp b/api/direct_bt/DBTDevice.hpp index e5f86818..724aa529 100644 --- a/api/direct_bt/DBTDevice.hpp +++ b/api/direct_bt/DBTDevice.hpp @@ -177,12 +177,22 @@ namespace direct_bt { * <p> * Set window to the same value as the interval, enables continuous scanning. * </p> + * + * @param peer_mac_type + * @param own_mac_type + * @param le_scan_interval default value 0x0004 + * @param le_scan_window default value 0x0004 + * @param conn_interval_min default value 0x000F + * @param conn_interval_max default value 0x000F + * @param conn_latency default value 0x0000 + * @param supervision_timeout in units of 10ms, default value 1000 for 10000ms or 10s. + * @return */ uint16_t connectLE(const HCIAddressType peer_mac_type=HCIAddressType::HCIADDR_LE_PUBLIC, const HCIAddressType own_mac_type=HCIAddressType::HCIADDR_LE_PUBLIC, - const uint16_t interval=0x0004, const uint16_t window=0x0004, - const uint16_t min_interval=0x000F, const uint16_t max_interval=0x000F, - const uint16_t latency=0x0000, const uint16_t supervision_timeout=HCI_LE_CONN_TIMEOUT_MS/10); + const uint16_t le_scan_interval=0x0004, const uint16_t le_scan_window=0x0004, + const uint16_t conn_interval_min=0x000F, const uint16_t conn_interval_max=0x000F, + const uint16_t conn_latency=0x0000, const uint16_t supervision_timeout=HCI_LE_CONN_TIMEOUT_MS/10); /** * Establish a HCI BDADDR_BREDR connection to this device. diff --git a/api/direct_bt/DBTManager.hpp b/api/direct_bt/DBTManager.hpp index 5ebcf925..15e46098 100644 --- a/api/direct_bt/DBTManager.hpp +++ b/api/direct_bt/DBTManager.hpp @@ -245,10 +245,19 @@ namespace direct_bt { /** * Uploads given connection parameter for given device to the kernel. + * + * @param dev_id + * @param address + * @param address_type + * @param conn_interval_min default value 0x000F + * @param conn_interval_max default value 0x000F + * @param conn_latency default value 0x0000 + * @param timeout in units of 10ms, default value 1000 for 10000ms or 10s. + * @return */ bool uploadConnParam(const int dev_id, const EUI48 &address, const BDAddressType address_type, - const uint16_t min_interval=0x000F, const uint16_t max_interval=0x000F, - const uint16_t latency=0x0000, const uint16_t timeout=HCI_LE_CONN_TIMEOUT_MS/10); + const uint16_t conn_interval_min=0x000F, const uint16_t conn_interval_max=0x000F, + const uint16_t conn_latency=0x0000, const uint16_t timeout=HCI_LE_CONN_TIMEOUT_MS/10); /** * Returns true, if the adapter's device is already whitelisted. diff --git a/api/direct_bt/HCIComm.hpp b/api/direct_bt/HCIComm.hpp index f437e9fc..2f5e4dc1 100644 --- a/api/direct_bt/HCIComm.hpp +++ b/api/direct_bt/HCIComm.hpp @@ -220,9 +220,9 @@ namespace direct_bt { HCIErrorCode le_create_conn(uint16_t * handle_return, const EUI48 &peer_bdaddr, const HCIAddressType peer_mac_type=HCIAddressType::HCIADDR_LE_PUBLIC, const HCIAddressType own_mac_type=HCIAddressType::HCIADDR_LE_PUBLIC, - const uint16_t interval=0x0004, const uint16_t window=0x0004, - const uint16_t min_interval=0x000F, const uint16_t max_interval=0x000F, - const uint16_t latency=0x0000, const uint16_t supervision_timeout=HCI_LE_CONN_TIMEOUT_MS/10); + const uint16_t le_scan_interval=0x0004, const uint16_t le_scan_window=0x0004, + const uint16_t conn_interval_min=0x000F, const uint16_t conn_interval_max=0x000F, + const uint16_t conn_latency=0x0000, const uint16_t supervision_timeout=HCI_LE_CONN_TIMEOUT_MS/10); /** * Establish a connection to the given BREDR (non LE). diff --git a/java/direct_bt/tinyb/DBTAdapter.java b/java/direct_bt/tinyb/DBTAdapter.java index e0d9aa02..d9f5f684 100644 --- a/java/direct_bt/tinyb/DBTAdapter.java +++ b/java/direct_bt/tinyb/DBTAdapter.java @@ -141,14 +141,14 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter @Override public boolean addDeviceToWhitelist(final String address, final BluetoothAddressType address_type, final HCIWhitelistConnectType ctype, - final short min_interval, final short max_interval, - final short latency, final short timeout) { + final short conn_interval_min, final short conn_interval_max, + final short conn_latency, final short timeout) { return addDeviceToWhitelist(address, address_type.value, ctype.value, - min_interval, max_interval, latency, timeout); + conn_interval_min, conn_interval_max, conn_latency, timeout); } private native boolean addDeviceToWhitelist(final String address, final int address_type, final int ctype, - final short min_interval, final short max_interval, - final short latency, final short timeout); + final short conn_interval_min, final short conn_interval_max, + final short conn_latency, final short timeout); @Override public boolean addDeviceToWhitelist(final String address, final BluetoothAddressType address_type, diff --git a/java/direct_bt/tinyb/DBTDevice.java b/java/direct_bt/tinyb/DBTDevice.java index fa749afe..5f122720 100644 --- a/java/direct_bt/tinyb/DBTDevice.java +++ b/java/direct_bt/tinyb/DBTDevice.java @@ -279,12 +279,12 @@ public class DBTDevice extends DBTObject implements BluetoothDevice private native boolean connectImpl() throws BluetoothException; @Override - public boolean connect(final short interval, final short window, - final short min_interval, final short max_interval, - final short latency, final short timeout) { + public boolean connect(final short le_scan_interval, final short le_scan_window, + final short conn_interval_min, final short conn_interval_max, + final short conn_latency, final short timeout) { boolean res = false; if( !connected ) { - res = connectImpl(interval, window, min_interval, max_interval, latency, timeout); + res = connectImpl(le_scan_interval, le_scan_window, conn_interval_min, conn_interval_max, conn_latency, timeout); if( res ) { connected = true; if( null != userConnectedNotificationsCB ) { @@ -301,9 +301,9 @@ public class DBTDevice extends DBTObject implements BluetoothDevice } return res; } - private native boolean connectImpl(final short interval, final short window, - final short min_interval, final short max_interval, - final short latency, final short timeout); + private native boolean connectImpl(final short le_scan_interval, final short le_scan_window, + final short conn_interval_min, final short conn_interval_max, + final short conn_latency, final short timeout); /* DBT Java callbacks */ diff --git a/java/org/tinyb/BluetoothAdapter.java b/java/org/tinyb/BluetoothAdapter.java index 16f3ef13..1261f28d 100644 --- a/java/org/tinyb/BluetoothAdapter.java +++ b/java/org/tinyb/BluetoothAdapter.java @@ -88,10 +88,10 @@ public interface BluetoothAdapter extends BluetoothObject * @param address * @param address_type * @param ctype - * @param min_interval default value 0x000F - * @param max_interval default value 0x000F - * @param latency default value 0x0000 - * @param timeout default value 0x0C80 + * @param conn_interval_min default value 0x000F + * @param conn_interval_max default value 0x000F + * @param conn_latency default value 0x0000 + * @param timeout in units of 10ms, default value 1000 for 10000ms or 10s. * @return {@code true} if successful, otherwise {@code false}. * * @see #addDeviceToWhitelist(String, BluetoothAddressType, HCIWhitelistConnectType) @@ -99,8 +99,8 @@ public interface BluetoothAdapter extends BluetoothObject */ public boolean addDeviceToWhitelist(final String address, final BluetoothAddressType address_type, final HCIWhitelistConnectType ctype, - final short min_interval, final short max_interval, - final short latency, final short timeout); + final short conn_interval_min, final short conn_interval_max, + final short conn_latency, final short timeout); /** * Add the given device to the adapter's autoconnect whitelist. diff --git a/java/org/tinyb/BluetoothDevice.java b/java/org/tinyb/BluetoothDevice.java index dbfb1d06..d4b03019 100644 --- a/java/org/tinyb/BluetoothDevice.java +++ b/java/org/tinyb/BluetoothDevice.java @@ -88,20 +88,20 @@ public interface BluetoothDevice extends BluetoothObject * Set window to the same value as the interval, enables continuous scanning. * </p> * - * @param interval default value 0x0004 - * @param window default value 0x0004 - * @param min_interval default value 0x000F - * @param max_interval default value 0x000F - * @param latency default value 0x0000 - * @param timeout default value 0x0C80 + * @param le_scan_interval default value 0x0004 + * @param le_scan_window default value 0x0004 + * @param conn_interval_min default value 0x000F + * @param conn_interval_max default value 0x000F + * @param conn_latency default value 0x0000 + * @param timeout in units of 10ms, default value 1000 for 10000ms or 10s. * @return {@code true} if successful, otherwise {@code false}. * * @see #connect() * @since 2.0.0 */ - public boolean connect(final short interval, final short window, - final short min_interval, final short max_interval, - final short latency, final short timeout); + public boolean connect(final short le_scan_interval, final short le_scan_window, + final short conn_interval_min, final short conn_interval_max, + final short conn_latency, final short timeout); /** Connects a specific profile available on the device, given by UUID diff --git a/src/direct_bt/DBTAdapter.cpp b/src/direct_bt/DBTAdapter.cpp index d29cbf71..f0c37433 100644 --- a/src/direct_bt/DBTAdapter.cpp +++ b/src/direct_bt/DBTAdapter.cpp @@ -227,16 +227,16 @@ bool DBTAdapter::isDeviceWhitelisted(const EUI48 &address) { } bool DBTAdapter::addDeviceToWhitelist(const EUI48 &address, const BDAddressType address_type, const HCIWhitelistConnectType ctype, - const uint16_t min_interval, const uint16_t max_interval, - const uint16_t latency, const uint16_t timeout) { + const uint16_t conn_interval_min, const uint16_t conn_interval_max, + const uint16_t conn_latency, const uint16_t timeout) { if( mgmt.isDeviceWhitelisted(dev_id, address) ) { ERR_PRINT("DBTAdapter::addDeviceToWhitelist: device already listed: dev_id %d, address %s", dev_id, address.toString().c_str()); return false; } - if( !mgmt.uploadConnParam(dev_id, address, address_type, min_interval, max_interval, latency, timeout) ) { + if( !mgmt.uploadConnParam(dev_id, address, address_type, conn_interval_min, conn_interval_max, conn_latency, timeout) ) { ERR_PRINT("DBTAdapter::addDeviceToWhitelist: uploadConnParam(dev_id %d, address %s, interval[%u..%u], latency %u, timeout %u): Failed", - dev_id, address.toString().c_str(), min_interval, max_interval, latency, timeout); + dev_id, address.toString().c_str(), conn_interval_min, conn_interval_max, conn_latency, timeout); } return mgmt.addDeviceToWhitelist(dev_id, address, address_type, ctype); } diff --git a/src/direct_bt/DBTDevice.cpp b/src/direct_bt/DBTDevice.cpp index bf843cd6..a0e772ba 100644 --- a/src/direct_bt/DBTDevice.cpp +++ b/src/direct_bt/DBTDevice.cpp @@ -240,9 +240,9 @@ std::shared_ptr<ConnectionInfo> DBTDevice::getConnectionInfo() { } uint16_t DBTDevice::connectLE(HCIAddressType peer_mac_type, HCIAddressType own_mac_type, - uint16_t interval, uint16_t window, - uint16_t min_interval, uint16_t max_interval, - uint16_t latency, uint16_t supervision_timeout) + uint16_t le_scan_interval, uint16_t le_scan_window, + uint16_t conn_interval_min, uint16_t conn_interval_max, + uint16_t conn_latency, uint16_t supervision_timeout) { if( 0 < hciConnHandle ) { ERR_PRINT("DBTDevice::connectLE: Already connected: %s", toString().c_str()); @@ -271,8 +271,8 @@ uint16_t DBTDevice::connectLE(HCIAddressType peer_mac_type, HCIAddressType own_m } HCIErrorCode status = hciComm->le_create_conn(&hciConnHandle, address, peer_mac_type, own_mac_type, - interval, window, min_interval, max_interval, - latency, supervision_timeout); + le_scan_interval, le_scan_window, conn_interval_min, conn_interval_max, + conn_latency, supervision_timeout); if( HCIErrorCode::COMMAND_DISALLOWED == status ) { WARN_PRINT("DBTDevice::connectLE: Could not yet create connection: status 0x%2.2X (%s), errno %d %s on %s", static_cast<uint8_t>(status), getHCIErrorCodeString(status).c_str(), errno, strerror(errno), toString().c_str()); diff --git a/src/direct_bt/HCIComm.cpp b/src/direct_bt/HCIComm.cpp index a76ac2fe..d1e8b2d2 100644 --- a/src/direct_bt/HCIComm.cpp +++ b/src/direct_bt/HCIComm.cpp @@ -659,9 +659,9 @@ bool HCIComm::le_enable_scan(const HCIAddressType own_type, HCIErrorCode HCIComm::le_create_conn(uint16_t * handle_return, const EUI48 &peer_bdaddr, const HCIAddressType peer_mac_type, const HCIAddressType own_mac_type, - const uint16_t interval, const uint16_t window, - const uint16_t min_interval, const uint16_t max_interval, - const uint16_t latency, const uint16_t supervision_timeout) + const uint16_t le_scan_interval, const uint16_t le_scan_window, + const uint16_t conn_interval_min, const uint16_t conn_interval_max, + const uint16_t conn_latency, const uint16_t supervision_timeout) { /** BT Core Spec v5.2: Vol 4, Part E HCI: 7.8.12 LE Create Connection command */ @@ -682,15 +682,15 @@ HCIErrorCode HCIComm::le_create_conn(uint16_t * handle_return, const EUI48 &peer const uint8_t initiator_filter = 0x00; // whitelist not used but peer_bdaddr* bzero((void*)&cp, sizeof(cp)); - cp.scan_interval = cpu_to_le(interval); - cp.scan_window = cpu_to_le(window); + cp.scan_interval = cpu_to_le(le_scan_interval); + cp.scan_window = cpu_to_le(le_scan_window); cp.filter_policy = initiator_filter; cp.peer_addr_type = peer_mac_type; cp.peer_addr = peer_bdaddr; cp.own_address_type = own_mac_type; - cp.conn_interval_min = cpu_to_le(min_interval); - cp.conn_interval_max = cpu_to_le(max_interval); - cp.conn_latency = cpu_to_le(latency); + cp.conn_interval_min = cpu_to_le(conn_interval_min); + cp.conn_interval_max = cpu_to_le(conn_interval_max); + cp.conn_latency = cpu_to_le(conn_latency); cp.supervision_timeout = cpu_to_le(supervision_timeout); cp.min_ce_len = cpu_to_le(min_ce_length); cp.max_ce_len = cpu_to_le(max_ce_length); |