From c6a2ca96156c32abdd65038aa5946f0fb1d9cb41 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 7 Jun 2019 11:50:12 -0400 Subject: Configure bt uuid via ini entry --- .../include/config_profile/profile.h | 7 +++++++ src/components/config_profile/src/profile.cc | 24 ++++++++++++++++++++++ .../application_manager_settings.h | 1 + .../transport_manager/transport_manager_settings.h | 2 ++ .../bluetooth/bluetooth_device_scanner.h | 5 +++++ .../src/bluetooth/bluetooth_device_scanner.cc | 20 ++++++++++++++++++ .../src/bluetooth/bluetooth_transport_adapter.cc | 11 +++++----- 7 files changed, 65 insertions(+), 5 deletions(-) (limited to 'src/components') 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 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 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(strtol(value.c_str(), NULL, 16)); } +int32_t hex_to_uint8(const std::string& value) { + return static_cast(strtol(value.c_str(), NULL, 16)); +} + std::string trim_string(const std::string& str) { const char* delims = " \t"; @@ -2474,6 +2486,18 @@ std::vector Profile::ReadIntContainer(const char* const pSection, return value_list; } +std::vector Profile::ReadUint8Container(const char* const pSection, + const char* const pKey, + bool* out_result) const { + const std::vector string_list = + ReadStringContainer(pSection, pKey, out_result); + std::vector 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 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; -- cgit v1.2.1