summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2019-06-19 12:29:39 -0400
committerGitHub <noreply@github.com>2019-06-19 12:29:39 -0400
commit96ebd73b1dc80bf3746c70886b6b180e5f03c78d (patch)
tree05dcb4a178442fce1ee299d3f5997114827cec07
parent7a7c31b1ac64d6acd1796f5024472905b32ecf73 (diff)
parent5f353766c2ffc1dbef53a5594b9e64ba47cd7e88 (diff)
downloadsdl_core-96ebd73b1dc80bf3746c70886b6b180e5f03c78d.tar.gz
Merge pull request #2941 from smartdevicelink/feature/bt_uuid_ini_config
Configure BT UUID Via .INI Entry
-rw-r--r--src/appMain/smartDeviceLink.ini3
-rw-r--r--src/components/config_profile/include/config_profile/profile.h7
-rw-r--r--src/components/config_profile/src/profile.cc44
-rw-r--r--src/components/include/test/transport_manager/mock_transport_manager_settings.h1
-rw-r--r--src/components/include/transport_manager/transport_manager_settings.h2
-rw-r--r--src/components/transport_manager/include/transport_manager/bluetooth/bluetooth_device_scanner.h5
-rw-r--r--src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc22
-rw-r--r--src/components/transport_manager/src/bluetooth/bluetooth_transport_adapter.cc11
-rw-r--r--src/components/transport_manager/test/transport_manager_default_test.cc22
9 files changed, 111 insertions, 6 deletions
diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini
index 54c2395c47..40c1bf08a7 100644
--- a/src/appMain/smartDeviceLink.ini
+++ b/src/appMain/smartDeviceLink.ini
@@ -202,6 +202,9 @@ TCPAdapterPort = 12345
; If the name is omitted, Core will listen on all network interfaces by binding to INADDR_ANY.
TCPAdapterNetworkInterface =
+; 128 bit uuid for bluetooth device discovery. Please format as 16 seperate bytes.
+;BluetoothUUID = 0x93, 0x6D, 0xA0, 0x1F, 0x9A, 0xBD, 0x4D, 0x9D, 0x80, 0xC7, 0x02, 0xAF, 0x85, 0xC8, 0x22, 0xA8
+
[CloudAppConnections]
; Value in milliseconds for time between retry attempts on a failed websocket connection
CloudAppRetryTimeout = 1000
diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h
index 1d3766ca97..0a1e8b2c17 100644
--- a/src/components/config_profile/include/config_profile/profile.h
+++ b/src/components/config_profile/include/config_profile/profile.h
@@ -423,6 +423,8 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
*/
uint16_t cloud_app_max_retry_attempts() const OVERRIDE;
+ const uint8_t* bluetooth_uuid() const OVERRIDE;
+
// TransportManageMMESettings interface
const std::string& event_mq_name() const OVERRIDE;
@@ -610,6 +612,10 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
const char* const pKey,
bool* out_result) const;
+ std::vector<uint8_t> ReadUint8Container(const char* const pSection,
+ const char* const pKey,
+ bool* out_result) const;
+
/**
* @brief Returns delimiter for SDL-generated TTS chunks
* @return TTS delimiter
@@ -975,6 +981,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
std::string transport_manager_tcp_adapter_network_interface_;
uint32_t cloud_app_retry_timeout_;
uint16_t cloud_app_max_retry_attempts_;
+ std::vector<uint8_t> bluetooth_uuid_;
std::string tts_delimiter_;
uint32_t audio_data_stopped_timeout_;
uint32_t video_data_stopped_timeout_;
diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc
index a5b2daa130..c38b28db5f 100644
--- a/src/components/config_profile/src/profile.cc
+++ b/src/components/config_profile/src/profile.cc
@@ -184,6 +184,7 @@ const char* kAppHmiLevelNoneRequestsTimeScaleKey =
const char* kPendingRequestsAmoundKey = "PendingRequestsAmount";
const char* kSupportedDiagModesKey = "SupportedDiagModes";
const char* kTransportManagerDisconnectTimeoutKey = "DisconnectTimeout";
+const char* kBluetoothUUIDKey = "BluetoothUUID";
const char* kTTSDelimiterKey = "TTSDelimiter";
const char* kRecordingFileNameKey = "RecordingFileName";
const char* kRecordingFileSourceKey = "RecordingFileSource";
@@ -397,6 +398,22 @@ const bool kDefaultMultipleTransportsEnabled = false;
const char* kDefaultLowBandwidthResumptionLevel = "NONE";
const uint32_t kDefaultRpcPassThroughTimeout = 10000;
const char* kDefaultHMIOriginId = "HMI_ID";
+const std::vector<uint8_t> kDefaultBluetoothUUID = {0x93,
+ 0x6D,
+ 0xA0,
+ 0x1F,
+ 0x9A,
+ 0xBD,
+ 0x4D,
+ 0x9D,
+ 0x80,
+ 0xC7,
+ 0x02,
+ 0xAF,
+ 0x85,
+ 0xC8,
+ 0x22,
+ 0xA8};
} // namespace
namespace profile {
@@ -806,6 +823,10 @@ uint16_t Profile::cloud_app_max_retry_attempts() const {
return cloud_app_max_retry_attempts_;
}
+const uint8_t* Profile::bluetooth_uuid() const {
+ return bluetooth_uuid_.data();
+}
+
const std::string& Profile::tts_delimiter() const {
return tts_delimiter_;
}
@@ -1821,6 +1842,13 @@ void Profile::UpdateValues() {
kCloudAppMaxRetryAttemptsKey,
kCloudAppTransportSection);
+ bool read_result = true;
+ bluetooth_uuid_ = ReadUint8Container(
+ kTransportManagerSection, kBluetoothUUIDKey, &read_result);
+ if (!read_result || bluetooth_uuid_.size() != 16) {
+ bluetooth_uuid_ = kDefaultBluetoothUUID;
+ }
+
// Event MQ
ReadStringValue(
&event_mq_name_, kDefaultEventMQ, kTransportManagerSection, kEventMQKey);
@@ -2449,6 +2477,10 @@ int32_t hex_to_int(const std::string& value) {
return static_cast<int32_t>(strtol(value.c_str(), NULL, 16));
}
+uint8_t hex_to_uint8(const std::string& value) {
+ return static_cast<uint8_t>(strtol(value.c_str(), NULL, 16));
+}
+
std::string trim_string(const std::string& str) {
const char* delims = " \t";
@@ -2474,6 +2506,18 @@ std::vector<int> Profile::ReadIntContainer(const char* const pSection,
return value_list;
}
+std::vector<uint8_t> Profile::ReadUint8Container(const char* const pSection,
+ const char* const pKey,
+ bool* out_result) const {
+ const std::vector<std::string> string_list =
+ ReadStringContainer(pSection, pKey, out_result);
+ std::vector<uint8_t> value_list;
+ value_list.resize(string_list.size());
+ std::transform(
+ string_list.begin(), string_list.end(), value_list.begin(), hex_to_uint8);
+ return value_list;
+}
+
std::vector<std::string> Profile::ReadStringContainer(
const char* const pSection,
const char* const pKey,
diff --git a/src/components/include/test/transport_manager/mock_transport_manager_settings.h b/src/components/include/test/transport_manager/mock_transport_manager_settings.h
index 2d9f25a44c..eb12ce1b55 100644
--- a/src/components/include/test/transport_manager/mock_transport_manager_settings.h
+++ b/src/components/include/test/transport_manager/mock_transport_manager_settings.h
@@ -65,6 +65,7 @@ class MockTransportManagerSettings
std::string&());
MOCK_CONST_METHOD0(cloud_app_retry_timeout, uint32_t());
MOCK_CONST_METHOD0(cloud_app_max_retry_attempts, uint16_t());
+ MOCK_CONST_METHOD0(bluetooth_uuid, const uint8_t*());
};
} // namespace transport_manager_test
diff --git a/src/components/include/transport_manager/transport_manager_settings.h b/src/components/include/transport_manager/transport_manager_settings.h
index cbc1516c29..4a183ad22d 100644
--- a/src/components/include/transport_manager/transport_manager_settings.h
+++ b/src/components/include/transport_manager/transport_manager_settings.h
@@ -79,6 +79,8 @@ class TransportManagerSettings : public TransportManagerMMESettings {
* @brief Returns maximum retry attempts for cloud app connections
*/
virtual uint16_t cloud_app_max_retry_attempts() const = 0;
+
+ virtual const uint8_t* bluetooth_uuid() const = 0;
};
} // namespace transport_manager
#endif // SRC_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_SETTINGS_H_
diff --git a/src/components/transport_manager/include/transport_manager/bluetooth/bluetooth_device_scanner.h b/src/components/transport_manager/include/transport_manager/bluetooth/bluetooth_device_scanner.h
index 13fef1d017..768d9ebb54 100644
--- a/src/components/transport_manager/include/transport_manager/bluetooth/bluetooth_device_scanner.h
+++ b/src/components/transport_manager/include/transport_manager/bluetooth/bluetooth_device_scanner.h
@@ -70,6 +70,11 @@ class BluetoothDeviceScanner : public DeviceScanner {
BluetoothDeviceScanner(TransportAdapterController* controller,
bool auto_repeat_search,
int repeat_search_pause_sec);
+
+ BluetoothDeviceScanner(TransportAdapterController* controller,
+ bool auto_repeat_search,
+ int repeat_search_pause_sec,
+ const uint8_t* smart_device_link_service_uuid_data);
/**
* @brief Destructor.
*/
diff --git a/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc b/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc
index 7e9b4c1332..4759b2003a 100644
--- a/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc
+++ b/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc
@@ -133,7 +133,27 @@ BluetoothDeviceScanner::BluetoothDeviceScanner(
0xA8};
sdp_uuid128_create(&smart_device_link_service_uuid_,
smart_device_link_service_uuid_data);
- thread_ = threads::CreateThread("BT Device Scaner",
+ thread_ = threads::CreateThread("BT Device Scanner",
+ new BluetoothDeviceScannerDelegate(this));
+}
+
+BluetoothDeviceScanner::BluetoothDeviceScanner(
+ TransportAdapterController* controller,
+ bool auto_repeat_search,
+ int auto_repeat_pause_sec,
+ const uint8_t* smart_device_link_service_uuid_data)
+ : controller_(controller)
+ , thread_(NULL)
+ , shutdown_requested_(false)
+ , ready_(true)
+ , device_scan_requested_(false)
+ , device_scan_requested_lock_()
+ , device_scan_requested_cv_()
+ , auto_repeat_search_(auto_repeat_search)
+ , auto_repeat_pause_sec_(auto_repeat_pause_sec) {
+ sdp_uuid128_create(&smart_device_link_service_uuid_,
+ smart_device_link_service_uuid_data);
+ thread_ = threads::CreateThread("BT Device Scanner",
new BluetoothDeviceScannerDelegate(this));
}
diff --git a/src/components/transport_manager/src/bluetooth/bluetooth_transport_adapter.cc b/src/components/transport_manager/src/bluetooth/bluetooth_transport_adapter.cc
index 95265cad2e..911658bc56 100644
--- a/src/components/transport_manager/src/bluetooth/bluetooth_transport_adapter.cc
+++ b/src/components/transport_manager/src/bluetooth/bluetooth_transport_adapter.cc
@@ -58,11 +58,12 @@ BluetoothTransportAdapter::~BluetoothTransportAdapter() {}
BluetoothTransportAdapter::BluetoothTransportAdapter(
resumption::LastState& last_state, const TransportManagerSettings& settings)
- : TransportAdapterImpl(new BluetoothDeviceScanner(this, true, 0),
- new BluetoothConnectionFactory(this),
- NULL,
- last_state,
- settings) {}
+ : TransportAdapterImpl(
+ new BluetoothDeviceScanner(this, true, 0, settings.bluetooth_uuid()),
+ new BluetoothConnectionFactory(this),
+ NULL,
+ last_state,
+ settings) {}
DeviceType BluetoothTransportAdapter::GetDeviceType() const {
return BLUETOOTH;
diff --git a/src/components/transport_manager/test/transport_manager_default_test.cc b/src/components/transport_manager/test/transport_manager_default_test.cc
index d8bf51ef88..e102458b96 100644
--- a/src/components/transport_manager/test/transport_manager_default_test.cc
+++ b/src/components/transport_manager/test/transport_manager_default_test.cc
@@ -57,6 +57,22 @@ const std::string kTransportManager = "TransportManager";
const std::string kTcpAdapter = "TcpAdapter";
const std::string kBluetoothAdapter = "BluetoothAdapter";
const std::string kDevices = "devices";
+std::vector<uint8_t> kBTUUID = {0x93,
+ 0x6D,
+ 0xA0,
+ 0x1F,
+ 0x9A,
+ 0xBD,
+ 0x4D,
+ 0x9D,
+ 0x80,
+ 0xC7,
+ 0x02,
+ 0xAF,
+ 0x85,
+ 0xC8,
+ 0x22,
+ 0xA8};
} // namespace
TEST(TestTransportManagerDefault, Init_LastStateNotUsed) {
@@ -78,6 +94,8 @@ TEST(TestTransportManagerDefault, Init_LastStateNotUsed) {
EXPECT_CALL(transport_manager_settings,
transport_manager_tcp_adapter_network_interface())
.WillRepeatedly(ReturnRef(network_interface));
+ EXPECT_CALL(transport_manager_settings, bluetooth_uuid())
+ .WillRepeatedly(Return(kBTUUID.data()));
transport_manager.Init(mock_last_state);
transport_manager.Stop();
@@ -114,6 +132,8 @@ TEST(TestTransportManagerDefault, Init_LastStateUsed) {
EXPECT_CALL(transport_manager_settings,
transport_manager_tcp_adapter_network_interface())
.WillRepeatedly(ReturnRef(network_interface));
+ EXPECT_CALL(transport_manager_settings, bluetooth_uuid())
+ .WillRepeatedly(Return(kBTUUID.data()));
transport_manager.Init(mock_last_state);
transport_manager.Stop();
}
@@ -149,6 +169,8 @@ TEST(TestTransportManagerDefault, Init_LastStateUsed_InvalidPort) {
EXPECT_CALL(transport_manager_settings,
transport_manager_tcp_adapter_network_interface())
.WillRepeatedly(ReturnRef(network_interface));
+ EXPECT_CALL(transport_manager_settings, bluetooth_uuid())
+ .WillRepeatedly(Return(kBTUUID.data()));
transport_manager.Init(mock_last_state);
transport_manager.Stop();
}