diff options
author | Frank Ronneburg <fronneburg@xevo.com> | 2018-04-05 02:23:53 +0900 |
---|---|---|
committer | fronneburg <fronneburg@xevo.com> | 2018-04-04 14:21:54 -0700 |
commit | 926e8db70ceae88a4b11a028d9c37abbee9208e9 (patch) | |
tree | fb39df593691eb6638f5dbd8f3880326803b902b /src/components/connection_handler | |
parent | 7c88e20d4a6183e035a475def655c2aa0242187b (diff) | |
download | sdl_core-926e8db70ceae88a4b11a028d9c37abbee9208e9.tar.gz |
Merge pull request #231 in NAR/sdl-core from feat/config_for_secondary_transports to feature/Ford-WiFi
* commit '85f353fb31d336661fd34358f9e56d426626212a':
configuration for secondary transports
provide access to the connection device_type through the connection_handler
Diffstat (limited to 'src/components/connection_handler')
4 files changed, 57 insertions, 4 deletions
diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h index b6109b59c0..cd0efd9996 100644 --- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h +++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h @@ -275,6 +275,14 @@ class ConnectionHandlerImpl void OnMalformedMessageCallback(const uint32_t& connection_key) OVERRIDE; /** + * \brief Returns the device type associated with the connection handle + * \param connection_handle Handle of the connection being queried + * \return Device Type + */ + transport_manager::transport_adapter::DeviceType device_type( + transport_manager::ConnectionUID connection_handle) const; + + /** * \brief Creates unique identifier of session (can be used as hash) * from given connection identifier * within which session exists and session number. diff --git a/src/components/connection_handler/include/connection_handler/device.h b/src/components/connection_handler/include/connection_handler/device.h index 26376c1d8d..c2fb955f55 100644 --- a/src/components/connection_handler/include/connection_handler/device.h +++ b/src/components/connection_handler/include/connection_handler/device.h @@ -37,6 +37,7 @@ #include <map> #include <vector> #include "transport_manager/common.h" +#include "transport_manager/transport_adapter/transport_adapter.h" /** * \namespace connection_handler @@ -62,7 +63,8 @@ class Device { Device(DeviceHandle device_handle, const std::string& user_friendly_name, const std::string& mac_address = "", - const std::string& connection_type = ""); + const std::string& connection_type = "", + transport_manager::transport_adapter::DeviceType device_type = transport_manager::transport_adapter::DeviceType::UNKNOWN); /** * \brief Returns device handle @@ -88,6 +90,12 @@ class Device { */ std::string connection_type() const; + /** + * @brief The type of device. + * @return device type + */ + transport_manager::transport_adapter::DeviceType device_type() const; + private: /** * \brief Uniq device handle. @@ -108,6 +116,11 @@ class Device { * \brief The type of connection used by device. */ std::string connection_type_; + + /** + * \brief The DeviceType associated with the device + */ + transport_manager::transport_adapter::DeviceType device_type_; }; /** diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index f69ee0bd00..5cb9fd3f27 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -144,7 +144,8 @@ void ConnectionHandlerImpl::OnDeviceAdded( Device device(handle, device_info.name(), device_info.mac_address(), - device_info.connection_type()); + device_info.connection_type(), + device_info.device_type()); auto result = device_list_.insert(std::make_pair(handle, device)); @@ -816,6 +817,31 @@ void ConnectionHandlerImpl::OnSecondaryTransportEnded( } } +transport_manager::transport_adapter::DeviceType ConnectionHandlerImpl::device_type( + transport_manager::ConnectionUID connection_handle) const { + LOG4CXX_AUTO_TRACE(logger_); + + transport_manager::transport_adapter::DeviceType device_type = transport_manager::transport_adapter::DeviceType::UNKNOWN; + + sync_primitives::AutoReadLock lock(connection_list_lock_); + ConnectionList::const_iterator it = + connection_list_.find(connection_handle); + if (connection_list_.end() == it) { + LOG4CXX_WARN(logger_, + "Unknown connection " << connection_handle); + } else { + DeviceHandle device_handle = it->second->connection_device_handle(); + DeviceMap::const_iterator it = device_list_.find(device_handle); + if (device_list_.end() == it) { + LOG4CXX_ERROR(logger_, "Device not found!"); + } else { + device_type = it->second.device_type(); + } + } + + return device_type; +} + uint32_t ConnectionHandlerImpl::KeyFromPair( transport_manager::ConnectionUID connection_handle, uint8_t session_id) const { diff --git a/src/components/connection_handler/src/device.cc b/src/components/connection_handler/src/device.cc index 0ecb439172..6512848205 100644 --- a/src/components/connection_handler/src/device.cc +++ b/src/components/connection_handler/src/device.cc @@ -48,11 +48,13 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "ConnectionHandler") Device::Device(DeviceHandle device_handle, const std::string& user_friendly_name, const std::string& mac_address, - const std::string& connection_type) + const std::string& connection_type, + transport_manager::transport_adapter::DeviceType device_type) : device_handle_(device_handle) , user_friendly_name_(user_friendly_name) , mac_address_(mac_address) - , connection_type_(connection_type) { + , connection_type_(connection_type) + , device_type_(device_type) { mac_address_ = encryption::MakeHash(mac_address); LOG4CXX_DEBUG(logger_, "Device: MAC address - " << mac_address << ", hash - " @@ -75,4 +77,8 @@ std::string Device::connection_type() const { return connection_type_; } +transport_manager::transport_adapter::DeviceType Device::device_type() const { + return device_type_; +} + } // namespace connection_handler |