summaryrefslogtreecommitdiff
path: root/SDL_Core/src/components/TransportManager/include
diff options
context:
space:
mode:
Diffstat (limited to 'SDL_Core/src/components/TransportManager/include')
-rw-r--r--SDL_Core/src/components/TransportManager/include/TransportManager/ITransportManager.hpp168
-rw-r--r--SDL_Core/src/components/TransportManager/include/TransportManager/ITransportManagerDataListener.hpp129
-rw-r--r--SDL_Core/src/components/TransportManager/include/TransportManager/ITransportManagerDeviceListener.hpp102
-rw-r--r--SDL_Core/src/components/TransportManager/include/TransportManager/SDeviceInfo.hpp140
4 files changed, 539 insertions, 0 deletions
diff --git a/SDL_Core/src/components/TransportManager/include/TransportManager/ITransportManager.hpp b/SDL_Core/src/components/TransportManager/include/TransportManager/ITransportManager.hpp
new file mode 100644
index 000000000..301493c9c
--- /dev/null
+++ b/SDL_Core/src/components/TransportManager/include/TransportManager/ITransportManager.hpp
@@ -0,0 +1,168 @@
+/**
+ * \file ITransportManager.hpp
+ * \brief Class ITransportManager header.
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __TRANSPORTMANAGER_ITRANSPORTMANAGER_HPP__
+#define __TRANSPORTMANAGER_ITRANSPORTMANAGER_HPP__
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <vector>
+
+#include "TransportManager/SDeviceInfo.hpp"
+
+namespace NsSmartDeviceLink
+{
+ namespace NsTransportManager
+ {
+ class ITransportManagerDeviceListener;
+ class ITransportManagerDataListener;
+
+ /**
+ * @brief Connection handle.
+ **/
+ typedef int tConnectionHandle;
+
+ /**
+ * @brief Special value of connection handle for indicating invalid connection handle.
+ **/
+ const tConnectionHandle InvalidConnectionHandle = static_cast<tConnectionHandle>(-1);
+
+ /**
+ * @brief Interface of transport manager.
+ * @interface ITransportManager
+ **/
+ class ITransportManager
+ {
+ public:
+ /**
+ * @brief Destructor.
+ **/
+ virtual ~ITransportManager(void);
+
+ /**
+ * @brief Create trasport manager.
+ *
+ * @return Pointer to created transport manager instance.
+ **/
+ static ITransportManager * create(void);
+
+ /**
+ * @brief Run transport manager.
+ *
+ * Must be called from startup after all references to
+ * external components are initialized to start trasport manager.
+ **/
+ virtual void run(void) = 0;
+
+ /**
+ * @brief Start scanning for new devices.
+ *
+ * List of new devices will be supplied in onDeviceListUpdated callback.
+ *
+ * @see @ref components_transportmanager_client_device_management
+ **/
+ virtual void scanForNewDevices(void) = 0;
+
+ /**
+ * @brief Connect to all applications discovered on device.
+ *
+ * @param DeviceHandle Handle of device to connect to.
+ *
+ * @see @ref components_transportmanager_client_connection_management
+ **/
+ virtual void connectDevice(const tDeviceHandle DeviceHandle) = 0;
+
+ /**
+ * @brief Disconnect from all applications connected on device.
+ *
+ * @param DeviceHandle Handle of device to disconnect from.
+ *
+ * @see @ref components_transportmanager_client_connection_management
+ **/
+ virtual void disconnectDevice(const tDeviceHandle DeviceHandle) = 0;
+
+ /**
+ * @brief Add listener to the data-related events
+ *
+ * @param Listener Pointer to listener.
+ *
+ * @see @ref components_transportmanager_client_data_transfer
+ **/
+ virtual void addDataListener(ITransportManagerDataListener * Listener) = 0;
+
+ /**
+ * @brief Remove listener to the data-related events.
+ *
+ * @param Listener Pointer to listener.
+ *
+ * @see @ref components_transportmanager_client_data_transfer
+ **/
+ virtual void removeDataListener(ITransportManagerDataListener * Listener) = 0;
+
+ /**
+ * @brief Add listener to the device-related events.
+ *
+ * @param Listener Pointer to listener.
+ *
+ * @see @ref components_transportmanager_client_device_management
+ * @see @ref components_transportmanager_client_connection_management
+ **/
+ virtual void addDeviceListener(ITransportManagerDeviceListener * Listener) = 0;
+
+ /**
+ * @brief Remove listenerto the device-related events.
+ *
+ * @param Listener Pointer to listener.
+ *
+ * @see @ref components_transportmanager_client_device_management
+ * @see @ref components_transportmanager_client_connection_management
+ **/
+ virtual void removeDeviceListener(ITransportManagerDeviceListener * Listener) = 0;
+
+ /**
+ * @brief Send frame.
+ *
+ * @param ConnectionHandle Connection handle.
+ * @param Data Frame payload data.
+ * @param DataSize Size of data in bytes.
+ * @param UserData Any user data. Will be returned as is in ITransportManagerDataListener::onFrameSendCompleted
+ *
+ * @see @ref components_transportmanager_client_data_transfer
+ **/
+ virtual void sendFrame(tConnectionHandle ConnectionHandle, const uint8_t * Data, size_t DataSize, const int UserData) = 0;
+ };
+ }
+}
+
+#endif
diff --git a/SDL_Core/src/components/TransportManager/include/TransportManager/ITransportManagerDataListener.hpp b/SDL_Core/src/components/TransportManager/include/TransportManager/ITransportManagerDataListener.hpp
new file mode 100644
index 000000000..b1770b8db
--- /dev/null
+++ b/SDL_Core/src/components/TransportManager/include/TransportManager/ITransportManagerDataListener.hpp
@@ -0,0 +1,129 @@
+/**
+ * \file ITransportManagerDataListener.hpp
+ * \brief Class ITransportManagerDataListener header.
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __TRANSPORTMANAGER_ITRANSPORTMANAGERDATALISTENER_HPP__
+#define __TRANSPORTMANAGER_ITRANSPORTMANAGERDATALISTENER_HPP__
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include "TransportManager/ITransportManager.hpp"
+
+namespace NsSmartDeviceLink
+{
+ namespace NsTransportManager
+ {
+ /**
+ * @brief Enumeration of send status.
+ **/
+ enum ESendStatus
+ {
+ /**
+ * @brief Sending frame has succeeded.
+ **/
+ SendStatusOK,
+
+ /**
+ * @brief Timeout occured.
+ **/
+ SendStatusTimeout,
+
+ /**
+ * @brief Sending frame has failed.
+ **/
+ SendStatusFailed,
+
+ /**
+ * @brief Transport manager internal error.
+ **/
+ SendStatusInternalError,
+
+ /**
+ * @brief Invalid incoming parameters.
+ **/
+ SendStatusInvalidParametersError,
+
+ /**
+ * @brief Unknown error.
+ **/
+ SendStatusUnknownError
+ };
+
+ /**
+ * @brief Interface of transport manager listener related to data information.
+ *
+ * Clients of transport manager must inherit this interface
+ * in order to register as listener to receive callbacks about data information
+ *
+ * @interface ITransportManagerDataListener
+ *
+ * @see @ref components_transportmanager_client_data_transfer
+ **/
+ class ITransportManagerDataListener
+ {
+ public:
+ /**
+ * @brief Destructor
+ *
+ **/
+ virtual ~ITransportManagerDataListener();
+
+ /**
+ * @brief Frame received callbacks.
+ *
+ * @param ConnectionHandle Connection handle.
+ * @param Data Received frame payload data.
+ * @param DataSize Size of data in bytes.
+ *
+ * @see @ref components_transportmanager_client_data_transfer
+ **/
+ virtual void onFrameReceived(tConnectionHandle ConnectionHandle, const uint8_t * Data, size_t DataSize);
+
+ /**
+ * @brief Frame send completed callback.
+ *
+ * @param ConnectionHandle Connection handle.
+ * @param UserData User data that was previously passed to ITransportManager::sendFrame.
+ * @param SendStatus Result status.
+ *
+ * @see @ref components_transportmanager_client_data_transfer
+ **/
+ virtual void onFrameSendCompleted(tConnectionHandle ConnectionHandle, int UserData, ESendStatus SendStatus);
+ };
+ }
+}
+
+
+
+#endif // __TRANSPORTMANAGER_ITRANSPORTMANAGERDATALISTENER_HPP__
diff --git a/SDL_Core/src/components/TransportManager/include/TransportManager/ITransportManagerDeviceListener.hpp b/SDL_Core/src/components/TransportManager/include/TransportManager/ITransportManagerDeviceListener.hpp
new file mode 100644
index 000000000..0bb40e947
--- /dev/null
+++ b/SDL_Core/src/components/TransportManager/include/TransportManager/ITransportManagerDeviceListener.hpp
@@ -0,0 +1,102 @@
+/**
+ * \file ITransportManagerDeviceListener.hpp
+ * \brief Class ITransportManagerDeviceListener header.
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __TRANSPORTMANAGER_ITRANSPORTMANAGERDEVICELISTENER_HPP__
+#define __TRANSPORTMANAGER_ITRANSPORTMANAGERDEVICELISTENER_HPP__
+
+#include "TransportManager/SDeviceInfo.hpp"
+#include "TransportManager/ITransportManager.hpp"
+
+namespace NsSmartDeviceLink
+{
+ namespace NsTransportManager
+ {
+ /**
+ * @brief Interface of transport manager listener related to device information.
+ *
+ * Clients of transport manager must inherit this interface
+ * in order to register as listener to receive callbacks about device information
+ *
+ * @interface ITransportManagerDeviceListener
+ *
+ * @see @ref components_transportmanager_client_device_management
+ * @see @ref components_transportmanager_client_connection_management
+ **/
+ class ITransportManagerDeviceListener
+ {
+ public:
+ /**
+ * @brief Destructor
+ *
+ **/
+ virtual ~ITransportManagerDeviceListener();
+
+ /**
+ * @brief Available devices list updated.
+ *
+ * Called when device scanning initiated with scanForNewDevices
+ * is completed.
+ *
+ * @param DeviceList New list of available devices.
+ *
+ * @see @ref components_transportmanager_client_device_management
+ **/
+ virtual void onDeviceListUpdated(const tDeviceList & DeviceList);
+
+ /**
+ * @brief Application connected.
+ *
+ * @param ConnectedDevice DeviceInfo of connected device.
+ * @param Connection Connection handle.
+ *
+ * @see @ref components_transportmanager_client_connection_management
+ **/
+ virtual void onApplicationConnected(const SDeviceInfo & ConnectedDevice, const tConnectionHandle Connection);
+
+ /**
+ * @brief Application disconnected.
+ *
+ * @param DisconnectedDevice DeviceInfo of disconnected device.
+ * @param Connection Connection handle.
+ *
+ * @see @ref components_transportmanager_client_connection_management
+ **/
+ virtual void onApplicationDisconnected(const SDeviceInfo & DisconnectedDevice, const tConnectionHandle Connection);
+ };
+ }
+}
+
+
+
+#endif // __TRANSPORTMANAGER_ITRANSPORTMANAGERDEVICELISTENER_HPP__
diff --git a/SDL_Core/src/components/TransportManager/include/TransportManager/SDeviceInfo.hpp b/SDL_Core/src/components/TransportManager/include/TransportManager/SDeviceInfo.hpp
new file mode 100644
index 000000000..42f6a50fb
--- /dev/null
+++ b/SDL_Core/src/components/TransportManager/include/TransportManager/SDeviceInfo.hpp
@@ -0,0 +1,140 @@
+/**
+ * \file SDeviceInfo.hpp
+ * \brief Structure SDeviceInfo header.
+ * Copyright (c) 2013, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __TRANSPORTMANAGER_SDEVICEINFO_HPP__
+#define __TRANSPORTMANAGER_SDEVICEINFO_HPP__
+
+#include <string>
+#include <vector>
+
+namespace NsSmartDeviceLink
+{
+ namespace NsTransportManager
+ {
+ /**
+ * @brief Handle to device.
+ **/
+ typedef int tDeviceHandle;
+
+ /**
+ * @brief Special value of device handle for indicating invalid device handle.
+ **/
+ const tDeviceHandle InvalidDeviceHandle = static_cast<tDeviceHandle>(-1);
+
+ /**
+ * @brief Enumeration for device type.
+ **/
+ enum EDeviceType
+ {
+ /**
+ * @brief Bluetooth device.
+ **/
+ DeviceBluetooth,
+
+ /**
+ * @brief USB device.
+ **/
+ DeviceUSB,
+
+ /**
+ * @brief WiFi device.
+ **/
+ DeviceWiFi
+ };
+
+ /**
+ * @brief Device information.
+ **/
+ struct SDeviceInfo
+ {
+ /**
+ * @brief Constructor for creating empty struct
+ *
+ **/
+ SDeviceInfo();
+
+ /**
+ * @brief Constructor for creating struct with predefined values
+ *
+ * @param DeviceHandle DeviceHandle
+ * @param DeviceType DeviceType
+ * @param UserFriendlyName User-friendly name
+ * @param UniqueDeviceId Unique device id
+ **/
+ SDeviceInfo(tDeviceHandle DeviceHandle, EDeviceType DeviceType, std::string UserFriendlyName, std::string UniqueDeviceId);
+
+ /**
+ * @brief Copy constructor
+ *
+ * @param other Reference to object to be copied
+ **/
+ SDeviceInfo(const SDeviceInfo& other);
+
+ /**
+ * @brief Comparison operator.
+ *
+ * @param i_other Reference to the object to be compared with
+ * @return bool
+ **/
+ bool operator==( const SDeviceInfo& i_other ) const;
+
+ /**
+ * @brief Device handle.
+ **/
+ tDeviceHandle mDeviceHandle;
+
+ /**
+ * @brief Device type.
+ **/
+ EDeviceType mDeviceType;
+
+ /**
+ * @brief User-friendly device name.
+ **/
+ std::string mUserFriendlyName;
+
+ /**
+ * @brief Unique device identifier across all devices
+ **/
+ std::string mUniqueDeviceId;
+ };
+
+ /**
+ * @brief Device list.
+ **/
+ typedef std::vector<SDeviceInfo> tDeviceList;
+ }
+}
+
+#endif