#include <list>
#include <algorithm>
-#include "utils/logger.h"
#include "utils/timer_thread.h"
#include "transport_manager/common.h"
#include "transport_manager/transport_manager.h"
typedef utils::SharedPtr<TimerInternal> TimerInternalSharedPointer;
TimerInternalSharedPointer timer;
bool shutDown;
+ DeviceHandle device_handle_;
int messages_count;
ConnectionInternal(TransportManagerImpl* transport_manager,
TransportAdapter* transport_adapter,
const ConnectionUID& id, const DeviceUID& dev_id,
- const ApplicationHandle& app_id)
- : transport_manager(transport_manager),
- transport_adapter(transport_adapter),
- timer(new TimerInternal(this, &ConnectionInternal::DisconnectFailedRoutine)),
- shutDown(false),
- messages_count(0) {
- Connection::id = id;
- Connection::device = dev_id;
- Connection::application = app_id;
- }
-
- void DisconnectFailedRoutine() {
- LOG4CXX_INFO(logger_, "Disconnection failed");
- transport_manager->RaiseEvent(&TransportManagerListener::OnDisconnectFailed,
- transport_manager->converter_.UidToHandle(device),
- DisconnectDeviceError());
- shutDown = false;
- timer->stop();
- }
-
+ const ApplicationHandle& app_id,
+ const DeviceHandle& device_handle);
+ void DisconnectFailedRoutine();
};
public:
*
* @param observer - pointer to observer
*/
- virtual void SetTimeMetricObserver(TMMetricObserver* observer);
+ void SetTimeMetricObserver(TMMetricObserver* observer);
/**
* @brief Constructor.
void EventListenerThread(void);
/**
- * \brief For logging.
- */
-#ifdef ENABLE_LOG
- static log4cxx::LoggerPtr logger_;
-#endif // ENABLE_LOG
-
- /**
* @brief store messages
*
- * @param
- *
* @see @ref components_transportmanager_client_connection_management
**/
MessageQueue message_queue_;
/**
* @brief store events from comming device
*
- * @param
- *
* @see @ref components_transportmanager_client_connection_management
**/
EventQueue event_queue_;
* @brief Flag that TM is initialized
*/
bool is_initialized_;
-
+ TMMetricObserver* metric_observer_;
private:
/**
* @brief Structure that contains conversion functions (Device ID -> Device
* Device ID)
*/
Handle2GUIDConverter converter_;
- TMMetricObserver* metric_observer_;
explicit TransportManagerImpl(const TransportManagerImpl&);
int connection_id_counter_;
-/**
- * \file common.h
- * \brief TM USB adapter common definitions
- *
- * Copyright (c) 2013, Ford Motor Company
+/*
+ * Copyright (c) 2014, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_USB_COMMON_H_
#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_USB_COMMON_H_
-#include <cstdint>
+#include <stdint.h>
#include "utils/shared_ptr.h"
-#if defined(__QNX__) || (__QNXNTO__)
+#if defined(__QNXNTO__)
#include "transport_manager/usb/qnx/usb_handler.h"
#else
#include "transport_manager/usb/libusb/usb_handler.h"
static const uint16_t kAoaPid1 = 0x2d00;
static const uint16_t kAoaPid2 = 0x2d01;
static const uint8_t kAoaInterfaceSubclass = 0xff;
+
static const int kUsbConfiguration = 1;
typedef utils::SharedPtr<UsbHandler> UsbHandlerSptr;
UsbHandlerSptr usb_handler_;
};
+inline bool IsGoogleAccessory(const PlatformUsbDevice* device) {
+ return (kAoaVid == device->vendor_id()) &&
+ ((kAoaPid1 == device->product_id()) || (kAoaPid2 == device->product_id()));
+}
+
+inline bool IsAppleIAPDevice(const PlatformUsbDevice* device) {
+ return false;
+}
+
+inline bool IsAppleIAP2Device(const PlatformUsbDevice* device) {
+ return false;
+}
+
+inline bool IsAppleDevice(const PlatformUsbDevice* device) {
+ return IsAppleIAPDevice(device) || IsAppleIAP2Device(device);
+}
+
} // namespace
} // namespace
--- /dev/null
+/**
+ * \file usb_aoa_adapter.h
+ * \brief UsbAoaAdapter class header file.
+ *
+ * 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 SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_USB_USB_AOA_ADAPTER_H_
+#define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_USB_USB_AOA_ADAPTER_H_
+
+#include "transport_manager/transport_adapter/transport_adapter_impl.h"
+#include "transport_manager/usb/common.h"
+
+namespace transport_manager {
+namespace transport_adapter {
+
+class UsbAoaAdapter : public TransportAdapterImpl {
+ public:
+ UsbAoaAdapter();
+ virtual ~UsbAoaAdapter();
+
+ protected:
+ virtual DeviceType GetDeviceType() const;
+ virtual bool IsInitialised() const;
+ virtual TransportAdapter::Error Init();
+ virtual bool ToBeAutoConnected(DeviceSptr device) const;
+
+ private:
+ bool is_initialised_;
+ UsbHandlerSptr usb_handler_;
+};
+
+} // namespace transport_adapter
+} // namespace transport_manager
+
+#endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_USB_USB_AOA_ADAPTER
private:
void UpdateList();
void TurnIntoAccessoryMode(PlatformUsbDevice* device);
- void GoogleAccessoryFound(PlatformUsbDevice* device);
+ void SupportedDeviceFound(PlatformUsbDevice* device);
TransportAdapterController* controller_;