aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-05-25 21:34:38 +0200
committerSven Gothel <[email protected]>2020-05-25 21:34:38 +0200
commit3021035aa42a8d8075615e5159e9ebd2d70b58ae (patch)
treec67a827f4e10229665d793ebd93378ca023fdd74 /src
parent589e2718189a4501c3611cbceffc3a90d2ff7ef5 (diff)
DBTDevice/HCIComm: More 'snappy' connect method names and drop unused LE min/max ce_len,filter params
Show device on connection failure.
Diffstat (limited to 'src')
-rw-r--r--src/direct_bt/DBTDevice.cpp31
-rw-r--r--src/direct_bt/HCIComm.cpp9
2 files changed, 20 insertions, 20 deletions
diff --git a/src/direct_bt/DBTDevice.cpp b/src/direct_bt/DBTDevice.cpp
index 5fa9adfd..5e289bde 100644
--- a/src/direct_bt/DBTDevice.cpp
+++ b/src/direct_bt/DBTDevice.cpp
@@ -237,15 +237,13 @@ std::shared_ptr<ConnectionInfo> DBTDevice::getConnectionInfo() {
return connInfo;
}
-uint16_t DBTDevice::le_connectHCI(HCIAddressType peer_mac_type, HCIAddressType own_mac_type,
+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 min_ce_length, uint16_t max_ce_length,
- uint8_t initiator_filter )
+ uint16_t latency, uint16_t supervision_timeout)
{
if( 0 < hciConnHandle ) {
- ERR_PRINT("DBTDevice::le_connect: Already connected");
+ ERR_PRINT("DBTDevice::le_connect: Already connected: %s", toString().c_str());
return 0;
}
@@ -256,7 +254,7 @@ uint16_t DBTDevice::le_connectHCI(HCIAddressType peer_mac_type, HCIAddressType o
const std::lock_guard<std::recursive_mutex> lock(adapter.mtx_hci); // RAII-style acquire and relinquish via destructor
std::shared_ptr<HCIComm> hciComm = adapter.getHCI();
if( nullptr == hciComm || !hciComm->isOpen() ) {
- ERR_PRINT("DBTDevice::le_connect: Adapter's HCIComm not opened");
+ ERR_PRINT("DBTDevice::le_connect: Adapter's HCIComm not opened: %s", toString().c_str());
return 0;
}
if( !isLEAddressType() ) {
@@ -272,11 +270,10 @@ uint16_t DBTDevice::le_connectHCI(HCIAddressType peer_mac_type, HCIAddressType o
hciConnHandle = hciComm->le_create_conn(
address, peer_mac_type, own_mac_type,
- interval, window, min_interval, max_interval, latency, supervision_timeout,
- min_ce_length, max_ce_length, initiator_filter);
+ interval, window, min_interval, max_interval, latency, supervision_timeout);
if ( 0 == hciConnHandle ) {
- ERR_PRINT("DBTDevice::le_connect: Could not create connection");
+ ERR_PRINT("DBTDevice::le_connect: Could not create connection: %s", toString().c_str());
return 0;
}
adapter.addConnectedDevice(sharedInstance);
@@ -284,10 +281,10 @@ uint16_t DBTDevice::le_connectHCI(HCIAddressType peer_mac_type, HCIAddressType o
return hciConnHandle;
}
-uint16_t DBTDevice::connectHCI(const uint16_t pkt_type, const uint16_t clock_offset, const uint8_t role_switch)
+uint16_t DBTDevice::connectBREDR(const uint16_t pkt_type, const uint16_t clock_offset, const uint8_t role_switch)
{
if( 0 < hciConnHandle ) {
- ERR_PRINT("DBTDevice::connect: Already connected");
+ ERR_PRINT("DBTDevice::connect: Already connected: %s", toString().c_str());
return 0;
}
std::shared_ptr<DBTDevice> sharedInstance = getSharedInstance();
@@ -297,7 +294,7 @@ uint16_t DBTDevice::connectHCI(const uint16_t pkt_type, const uint16_t clock_off
const std::lock_guard<std::recursive_mutex> lock(adapter.mtx_hci); // RAII-style acquire and relinquish via destructor
std::shared_ptr<HCIComm> hciComm = adapter.getHCI();
if( nullptr == hciComm || !hciComm->isOpen() ) {
- ERR_PRINT("DBTDevice::le_connect: Adapter's HCIComm not opened");
+ ERR_PRINT("DBTDevice::le_connect: Adapter's HCIComm not opened: %s", toString().c_str());
return 0;
}
if( !isBREDRAddressType() ) {
@@ -314,7 +311,7 @@ uint16_t DBTDevice::connectHCI(const uint16_t pkt_type, const uint16_t clock_off
hciConnHandle = hciComm->create_conn(address, pkt_type, clock_offset, role_switch);
if ( 0 == hciConnHandle ) {
- ERR_PRINT("DBTDevice::connect: Could not create connection (yet)");
+ ERR_PRINT("DBTDevice::connect: Could not create connection: %s", toString().c_str());
return 0;
}
adapter.addConnectedDevice(sharedInstance);
@@ -322,15 +319,15 @@ uint16_t DBTDevice::connectHCI(const uint16_t pkt_type, const uint16_t clock_off
return hciConnHandle;
}
-uint16_t DBTDevice::connectHCIDefault()
+uint16_t DBTDevice::connectDefault()
{
switch( addressType ) {
case BDAddressType::BDADDR_LE_PUBLIC:
- return le_connectHCI(HCIAddressType::HCIADDR_LE_PUBLIC);
+ return connectLE(HCIAddressType::HCIADDR_LE_PUBLIC);
case BDAddressType::BDADDR_LE_RANDOM:
- return le_connectHCI(HCIAddressType::HCIADDR_LE_RANDOM);
+ return connectLE(HCIAddressType::HCIADDR_LE_RANDOM);
case BDAddressType::BDADDR_BREDR:
- return connectHCI();
+ return connectBREDR();
default:
ERR_PRINT("DBTDevice::defaultConnect: Not a valid address type: %s", toString().c_str());
return 0;
diff --git a/src/direct_bt/HCIComm.cpp b/src/direct_bt/HCIComm.cpp
index 1a89d853..3344830f 100644
--- a/src/direct_bt/HCIComm.cpp
+++ b/src/direct_bt/HCIComm.cpp
@@ -594,9 +594,7 @@ uint16_t HCIComm::le_create_conn(const EUI48 &peer_bdaddr,
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 min_ce_length, const uint16_t max_ce_length,
- const uint8_t initiator_filter)
+ const uint16_t latency, const uint16_t supervision_timeout)
{
const std::lock_guard<std::recursive_mutex> lock(mtx); // RAII-style acquire and relinquish via destructor
if( 0 > _dd ) {
@@ -606,6 +604,11 @@ uint16_t HCIComm::le_create_conn(const EUI48 &peer_bdaddr,
hci_cp_le_create_conn cp;
hci_ev_le_conn_complete rp;
+ const uint16_t min_ce_length = 0x0000; // 0x0001 ??
+ const uint16_t max_ce_length = 0x0000; // 0x0001 ??
+ const uint8_t initiator_filter = 0x00;
+
+
bzero((void*)&cp, sizeof(cp));
cp.scan_interval = cpu_to_le(interval);
cp.scan_window = cpu_to_le(window);