summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2019-06-07 11:50:12 -0400
committerJackLivio <jack@livio.io>2019-06-07 11:50:12 -0400
commitc6a2ca96156c32abdd65038aa5946f0fb1d9cb41 (patch)
treebf355165035ac34ee50def6ddf9b6bf6a2e0aa9e
parent7a7c31b1ac64d6acd1796f5024472905b32ecf73 (diff)
downloadsdl_core-c6a2ca96156c32abdd65038aa5946f0fb1d9cb41.tar.gz
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.cc24
-rw-r--r--src/components/include/application_manager/application_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.cc20
-rw-r--r--src/components/transport_manager/src/bluetooth/bluetooth_transport_adapter.cc11
8 files changed, 68 insertions, 5 deletions
diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini
index 54c2395c47..1bf7c92924 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..336bd9a2d1 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";
@@ -806,6 +807,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 +1826,9 @@ void Profile::UpdateValues() {
kCloudAppMaxRetryAttemptsKey,
kCloudAppTransportSection);
+ bluetooth_uuid_ =
+ ReadUint8Container(kTransportManagerSection, kBluetoothUUIDKey, NULL);
+
// Event MQ
ReadStringValue(
&event_mq_name_, kDefaultEventMQ, kTransportManagerSection, kEventMQKey);
@@ -2449,6 +2457,10 @@ int32_t hex_to_int(const std::string& value) {
return static_cast<int32_t>(strtol(value.c_str(), NULL, 16));
}
+int32_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 +2486,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/application_manager/application_manager_settings.h b/src/components/include/application_manager/application_manager_settings.h
index 0f73ea94ed..cf8669d8d8 100644
--- a/src/components/include/application_manager/application_manager_settings.h
+++ b/src/components/include/application_manager/application_manager_settings.h
@@ -88,6 +88,7 @@ class ApplicationManagerSettings : public RequestControlerSettings,
virtual uint32_t rpc_pass_through_timeout() const = 0;
virtual uint32_t cloud_app_retry_timeout() const = 0;
virtual uint16_t cloud_app_max_retry_attempts() const = 0;
+ virtual const uint8_t* bluetooth_uuid() const = 0;
virtual bool use_db_for_resumption() const = 0;
virtual const uint32_t& app_resumption_save_persistent_data_timeout()
const = 0;
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..083943e61f 100644
--- a/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc
+++ b/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc
@@ -137,6 +137,26 @@ BluetoothDeviceScanner::BluetoothDeviceScanner(
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 Scaner",
+ new BluetoothDeviceScannerDelegate(this));
+}
+
BluetoothDeviceScanner::~BluetoothDeviceScanner() {
thread_->join();
delete thread_->delegate();
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;