From a6791129fb1cfcd5dad96e4987b1c2664aafb61e Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Tue, 19 Sep 2017 16:51:35 +0300 Subject: Adds main logic and related bugfixes for transport switching --- .../transport_adapter/transport_adapter_impl.h | 4 ++++ .../transport_adapter/transport_adapter_listener.h | 3 +++ .../transport_adapter_listener_impl.h | 22 ++-------------------- 3 files changed, 9 insertions(+), 20 deletions(-) (limited to 'src/components/transport_manager/include/transport_manager/transport_adapter') diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index d4c97d5233..8d1b96bbfd 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -408,6 +408,10 @@ class TransportAdapterImpl : public TransportAdapter, */ std::string DeviceName(const DeviceUID& device_id) const OVERRIDE; + void StopDevice(const DeviceUID& device_id) const FINAL; + + void DeviceSwitched(const DeviceUID& device_handle) FINAL; + /** * @brief Allows to obtain connection type used by device. * @return connection type. diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h index 0a1eeb6b4a..3ac664fa29 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h @@ -84,6 +84,8 @@ class TransportAdapterListener { virtual void OnDeviceListUpdated( const TransportAdapter* transport_adapter) = 0; + virtual void OnDeviceAdded(DeviceUID device_uid) = 0; + /** * @brief Reaction to "Find new applications" request * @param adapter Current transport adapter @@ -146,6 +148,7 @@ class TransportAdapterListener { const DeviceUID& device_handle, const ApplicationHandle& app_handle, const CommunicationError& error) = 0; + /** * @brief Search specified device adapter in the container of shared pointers *to device adapters to be sure it is available, diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h index a7cd544563..5018549b86 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h @@ -48,26 +48,6 @@ using transport_manager::transport_adapter::TransportAdapter; class TransportAdapterListenerImpl : public transport_adapter::TransportAdapterListener { public: - /** - * @enum Available types of events. - */ - enum EventTypeEnum { - ON_SEARCH_DONE = 0, - ON_SEARCH_FAIL, - ON_DEVICE_LIST_UPDATED, - ON_FIND_NEW_APPLICATIONS_REQUEST, - ON_CONNECT_DONE, - ON_CONNECT_FAIL, - ON_DISCONNECT_DONE, - ON_DISCONNECT_FAIL, - ON_SEND_DONE, - ON_SEND_FAIL, - ON_RECEIVED_DONE, - ON_RECEIVED_FAIL, - ON_COMMUNICATION_ERROR, - ON_UNEXPECTED_DISCONNECT - }; - /** * @brief Constructor. * @@ -105,6 +85,8 @@ class TransportAdapterListenerImpl */ virtual void OnDeviceListUpdated(const TransportAdapter* adapter); + virtual void OnDeviceAdded(DeviceUID device_uid); + virtual void OnFindNewApplicationsRequest(const TransportAdapter* adapter); /** -- cgit v1.2.1 From 8fa4f3b498916b89552394d25f9482ce4b06de5a Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Thu, 21 Sep 2017 17:40:49 +0300 Subject: Adds descriptions, removes unused code --- .../transport_adapter/transport_adapter_impl.h | 12 ++++++++++++ .../transport_adapter/transport_adapter_listener.h | 5 +++++ .../transport_adapter/transport_adapter_listener_impl.h | 5 +++++ 3 files changed, 22 insertions(+) (limited to 'src/components/transport_manager/include/transport_manager/transport_adapter') diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index 8d1b96bbfd..e4d70d5b07 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -408,8 +408,20 @@ class TransportAdapterImpl : public TransportAdapter, */ std::string DeviceName(const DeviceUID& device_id) const OVERRIDE; + /** + * @brief StopDevice looks for specific device in devices list and calls + * Stop() interface of that device + * @param device_id unique device identifier that has to be stopped. + */ void StopDevice(const DeviceUID& device_id) const FINAL; + /** + * @brief DeviceSwitched is triggered for adapter to proceed with possible + * further switching steps required on device side. E.g. to notify device + * on end of switching so it can disconnect transport being switched from. + * This is default implemenation does nothing. Must be overloaded if needed. + * @param device_handle Device id to notify on event + */ void DeviceSwitched(const DeviceUID& device_handle) FINAL; /** diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h index 3ac664fa29..8cc812fc4d 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h @@ -84,6 +84,11 @@ class TransportAdapterListener { virtual void OnDeviceListUpdated( const TransportAdapter* transport_adapter) = 0; + /** + * @brief OnDeviceAdded is triggered by transport adapter on new device + * coming + * @param device_uid Device id of new device + */ virtual void OnDeviceAdded(DeviceUID device_uid) = 0; /** diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h index 5018549b86..4977547f97 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h @@ -85,6 +85,11 @@ class TransportAdapterListenerImpl */ virtual void OnDeviceListUpdated(const TransportAdapter* adapter); + /** + * @brief OnDeviceAdded is triggered by transport adapter on new device + * coming and sends ON_DEVICE_ADDED event to transport manager + * @param device_uid Device id of new device + */ virtual void OnDeviceAdded(DeviceUID device_uid); virtual void OnFindNewApplicationsRequest(const TransportAdapter* adapter); -- cgit v1.2.1 From a6eb294c8f1805d2b3e39fc71f31f461f2cb4a65 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Mon, 25 Sep 2017 16:32:45 +0300 Subject: Removes odd interface, updates TM unit tests --- .../transport_adapter/transport_adapter_listener.h | 7 ------- .../transport_adapter/transport_adapter_listener_impl.h | 7 ------- 2 files changed, 14 deletions(-) (limited to 'src/components/transport_manager/include/transport_manager/transport_adapter') diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h index 8cc812fc4d..db8ab4fce5 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h @@ -84,13 +84,6 @@ class TransportAdapterListener { virtual void OnDeviceListUpdated( const TransportAdapter* transport_adapter) = 0; - /** - * @brief OnDeviceAdded is triggered by transport adapter on new device - * coming - * @param device_uid Device id of new device - */ - virtual void OnDeviceAdded(DeviceUID device_uid) = 0; - /** * @brief Reaction to "Find new applications" request * @param adapter Current transport adapter diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h index 4977547f97..f5a7934ed6 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h @@ -85,13 +85,6 @@ class TransportAdapterListenerImpl */ virtual void OnDeviceListUpdated(const TransportAdapter* adapter); - /** - * @brief OnDeviceAdded is triggered by transport adapter on new device - * coming and sends ON_DEVICE_ADDED event to transport manager - * @param device_uid Device id of new device - */ - virtual void OnDeviceAdded(DeviceUID device_uid); - virtual void OnFindNewApplicationsRequest(const TransportAdapter* adapter); /** -- cgit v1.2.1 From 33b6a331bf7c22e662b995069e7106f09940eb1f Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Tue, 7 Nov 2017 08:50:53 +0200 Subject: Adds iAP2 BT/USB connection emulation over TCP transport To be able to check iAP2 transport switch feature these adapters are implemented. Implementation is done in the way of emulating iAP transport over TCP since there is no available iAP library for open source. Since it is just emulation not a real transport is will be built only with other unit tests i.e. with BUILD_TESTS = ON --- .../transport_manager/transport_adapter/transport_adapter_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/components/transport_manager/include/transport_manager/transport_adapter') diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index e4d70d5b07..df4c932260 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -413,7 +413,7 @@ class TransportAdapterImpl : public TransportAdapter, * Stop() interface of that device * @param device_id unique device identifier that has to be stopped. */ - void StopDevice(const DeviceUID& device_id) const FINAL; + void StopDevice(const DeviceUID& device_id) const OVERRIDE; /** * @brief DeviceSwitched is triggered for adapter to proceed with possible @@ -422,7 +422,7 @@ class TransportAdapterImpl : public TransportAdapter, * This is default implemenation does nothing. Must be overloaded if needed. * @param device_handle Device id to notify on event */ - void DeviceSwitched(const DeviceUID& device_handle) FINAL; + void DeviceSwitched(const DeviceUID& device_handle) OVERRIDE; /** * @brief Allows to obtain connection type used by device. -- cgit v1.2.1 From ee1d2d7677a7d94da43cc8b1e047bdd816e5fd83 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Wed, 29 Nov 2017 18:33:59 +0200 Subject: Changes iAP2 Bluetooth to USB switching flow These changes update switching flow so now instead of automatic switching start in case of same UUID is detected SDL will wait for external signal from the system to start this flow. Also due to UUID is reliable only while device remains connected (at least on certain systems) SDL now uses Bluetooth MAC and USB serial to manage devices and UUID is used only for detection of devices able to switch their transports. Currently only iAP2 Bluetooth to USB support is implemented. --- .../transport_adapter/transport_adapter_impl.h | 29 +++++++++++++++------- .../transport_adapter/transport_adapter_listener.h | 7 ++++++ .../transport_adapter_listener_impl.h | 9 ++++++- 3 files changed, 35 insertions(+), 10 deletions(-) (limited to 'src/components/transport_manager/include/transport_manager/transport_adapter') diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index df4c932260..2b1ada79ad 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -399,6 +399,26 @@ class TransportAdapterImpl : public TransportAdapter, ::protocol_handler::RawMessagePtr message, const DataSendError& error) OVERRIDE; + /** + * @brief DoTransportSwitch notifies listeners of transport adapter events + * that transport switching is requested by system + */ + void DoTransportSwitch() const OVERRIDE; + + /** + * @brief DeviceSwitched Notifies system on successful transport switch for + * particular device + * @param device_handle Device handle of switched device + */ + void DeviceSwitched(const DeviceUID& device_handle) OVERRIDE; + + /** + * @brief GetSwitchableDevices Provides list of devices able to switch their + * transport (e.g. iAP2 Bluetooth to iAP2 USB). + * @return + */ + SwitchableDevices GetSwitchableDevices() const OVERRIDE; + /** * @brief Return name of device. * @@ -415,15 +435,6 @@ class TransportAdapterImpl : public TransportAdapter, */ void StopDevice(const DeviceUID& device_id) const OVERRIDE; - /** - * @brief DeviceSwitched is triggered for adapter to proceed with possible - * further switching steps required on device side. E.g. to notify device - * on end of switching so it can disconnect transport being switched from. - * This is default implemenation does nothing. Must be overloaded if needed. - * @param device_handle Device id to notify on event - */ - void DeviceSwitched(const DeviceUID& device_handle) OVERRIDE; - /** * @brief Allows to obtain connection type used by device. * @return connection type. diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h index db8ab4fce5..424fa53dea 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener.h @@ -270,6 +270,13 @@ class TransportAdapterListener { virtual void OnCommunicationError(const TransportAdapter* transport_adapter, const DeviceUID& device_handle, const ApplicationHandle& app_handle) = 0; + /** + * @brief OnTransportSwitchRequested notifies on received signal to start + * transport switching flow (at the moment Bluetooth to USB only) + * @param transport_adapter Transport adapter who received the signal + */ + virtual void OnTransportSwitchRequested( + const TransportAdapter* transport_adapter) = 0; }; } // transport_adapter namespace diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h index f5a7934ed6..9b853d9610 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h @@ -263,7 +263,14 @@ class TransportAdapterListenerImpl */ virtual void OnCommunicationError(const TransportAdapter* adapter, const DeviceUID& device, - const ApplicationHandle& app_id); + const ApplicationHandle& app_id) OVERRIDE; + + /** + * @brief OnTransportSwitchRequested notifies on received signal to start + * transport switching flow (at the moment Bluetooth to USB only) + * @param transport_adapter Transport adapter who received the signal + */ + void OnTransportSwitchRequested(const TransportAdapter* adapter) OVERRIDE; private: TransportManager* transport_manager_; -- cgit v1.2.1 From c4e771fb7d402157c5cbb5159c41e0a4553b8492 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Wed, 6 Dec 2017 10:20:51 +0200 Subject: Fixes coding style --- .../transport_adapter/transport_adapter_listener_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/components/transport_manager/include/transport_manager/transport_adapter') diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h index 9b853d9610..8a8031c3cf 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_listener_impl.h @@ -263,7 +263,7 @@ class TransportAdapterListenerImpl */ virtual void OnCommunicationError(const TransportAdapter* adapter, const DeviceUID& device, - const ApplicationHandle& app_id) OVERRIDE; + const ApplicationHandle& app_id) OVERRIDE; /** * @brief OnTransportSwitchRequested notifies on received signal to start -- cgit v1.2.1