USB Headers
authorJustin Dickow <jjdickow@gmail.com>
Tue, 15 Jul 2014 19:58:15 +0000 (15:58 -0400)
committerJustin Dickow <jjdickow@gmail.com>
Tue, 15 Jul 2014 19:58:15 +0000 (15:58 -0400)
Signed-off-by: Justin Dickow <jjdickow@gmail.com>
src/components/transport_manager/include/transport_manager/transport_manager_impl.h
src/components/transport_manager/include/transport_manager/usb/common.h
src/components/transport_manager/include/transport_manager/usb/usb_aoa_adapter.h [new file with mode: 0644]
src/components/transport_manager/include/transport_manager/usb/usb_device_scanner.h

index 53e62f2..d7c55e2 100755 (executable)
@@ -49,7 +49,6 @@
 #include <list>
 #include <algorithm>
 
-#include "utils/logger.h"
 #include "utils/timer_thread.h"
 #include "transport_manager/common.h"
 #include "transport_manager/transport_manager.h"
@@ -100,31 +99,15 @@ class TransportManagerImpl : public TransportManager {
     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:
 
@@ -250,7 +233,7 @@ class TransportManagerImpl : public TransportManager {
    *
    * @param observer - pointer to observer
    */
-  virtual void SetTimeMetricObserver(TMMetricObserver* observer);
+  void SetTimeMetricObserver(TMMetricObserver* observer);
 
   /**
    * @brief Constructor.
@@ -337,17 +320,8 @@ class TransportManagerImpl : public TransportManager {
   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_;
@@ -365,8 +339,6 @@ class TransportManagerImpl : public TransportManager {
   /**
    * @brief store events from comming device
    *
-   * @param
-   *
    * @see @ref components_transportmanager_client_connection_management
    **/
   EventQueue event_queue_;
@@ -410,7 +382,7 @@ class TransportManagerImpl : public TransportManager {
    * @brief Flag that TM is initialized
    */
   bool is_initialized_;
-
+  TMMetricObserver* metric_observer_;
  private:
   /**
    * @brief Structure that contains conversion functions (Device ID -> Device
@@ -452,7 +424,6 @@ class TransportManagerImpl : public TransportManager {
    * Device ID)
    */
   Handle2GUIDConverter converter_;
-  TMMetricObserver* metric_observer_;
 
   explicit TransportManagerImpl(const TransportManagerImpl&);
   int connection_id_counter_;
index 31ef25a..05b52c5 100644 (file)
@@ -1,8 +1,5 @@
-/**
- * \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"
@@ -54,6 +51,7 @@ static const uint16_t kAoaVid = 0x18d1;
 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;
@@ -76,6 +74,23 @@ class UsbDeviceListener {
   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
 
diff --git a/src/components/transport_manager/include/transport_manager/usb/usb_aoa_adapter.h b/src/components/transport_manager/include/transport_manager/usb/usb_aoa_adapter.h
new file mode 100644 (file)
index 0000000..55fb028
--- /dev/null
@@ -0,0 +1,64 @@
+/**
+ * \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
index 6cae522..0937222 100644 (file)
@@ -63,7 +63,7 @@ class UsbDeviceScanner : public DeviceScanner, public UsbDeviceListener {
  private:
   void UpdateList();
   void TurnIntoAccessoryMode(PlatformUsbDevice* device);
-  void GoogleAccessoryFound(PlatformUsbDevice* device);
+  void SupportedDeviceFound(PlatformUsbDevice* device);
 
   TransportAdapterController* controller_;