#include "transport_manager/usb/libusb/platform_usb_device.h"
#include "transport_manager/transport_adapter/transport_adapter_impl.h"
+#include "utils/logger.h"
+
namespace transport_manager {
namespace transport_adapter {
+CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager")
+
+
PlatformUsbDevice::PlatformUsbDevice(
uint8_t bus_number, uint8_t address,
const libusb_device_descriptor& device_descriptor,
#include <libusb/libusb.h>
+#include <sstream>
+
#include "transport_manager/usb/libusb/usb_connection.h"
#include "transport_manager/transport_adapter/transport_adapter_impl.h"
+#include "utils/logger.h"
+
namespace transport_manager {
namespace transport_adapter {
+CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager")
+
+
UsbConnection::UsbConnection(const DeviceUID& device_uid,
const ApplicationHandle& app_handle,
TransportAdapterController* controller,
#include "transport_manager/usb/common.h"
#include "transport_manager/transport_adapter/transport_adapter_impl.h"
+#include "utils/logger.h"
+
namespace transport_manager {
namespace transport_adapter {
+CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager")
+
class UsbHandler::ControlTransferSequenceState {
public:
ControlTransferSequenceState(class UsbHandler* usb_handler,
#include "transport_manager/usb/qnx/platform_usb_device.h"
#include "transport_manager/transport_adapter/transport_adapter_impl.h"
+#include "utils/logger.h"
+
namespace transport_manager {
namespace transport_adapter {
+CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager")
+
PlatformUsbDevice::PlatformUsbDevice(
usbd_device_instance_t* instance, usbd_device* device,
const usbd_device_descriptor_t& device_descriptor)
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <errno.h>
#include <sched.h>
#include <cstring>
#include "transport_manager/usb/qnx/usb_connection.h"
#include "transport_manager/transport_adapter/transport_adapter_impl.h"
+#include "utils/logger.h"
+
namespace transport_manager {
namespace transport_adapter {
+CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager")
+
UsbConnection::UsbConnection(const DeviceUID& device_uid,
const ApplicationHandle& app_handle,
TransportAdapterController* controller,
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <errno.h>
+
#include <cstring>
#include <cstdlib>
#include "transport_manager/usb/common.h"
#include "transport_manager/transport_adapter/transport_adapter_impl.h"
+#include "utils/logger.h"
+
namespace transport_manager {
namespace transport_adapter {
+CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager")
+
namespace {
UsbHandler* usb_handler;
}
--- /dev/null
+/**
+ * \file usb_aoa_adapter.cpp
+ * \brief UsbAoaAdapter class source 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.
+ */
+
+#include "transport_manager/usb/usb_aoa_adapter.h"
+#include "transport_manager/usb/usb_device_scanner.h"
+#include "transport_manager/usb/usb_connection_factory.h"
+#include "transport_manager/usb/common.h"
+
+namespace transport_manager {
+namespace transport_adapter {
+
+UsbAoaAdapter::UsbAoaAdapter()
+ : TransportAdapterImpl(new UsbDeviceScanner(this),
+ new UsbConnectionFactory(this), 0),
+ is_initialised_(false),
+ usb_handler_(new UsbHandler()) {
+ static_cast<UsbDeviceScanner*>(device_scanner_)->SetUsbHandler(usb_handler_);
+ static_cast<UsbConnectionFactory*>(server_connection_factory_)
+ ->SetUsbHandler(usb_handler_);
+}
+
+UsbAoaAdapter::~UsbAoaAdapter() {}
+
+DeviceType UsbAoaAdapter::GetDeviceType() const { return "sdl-usb-aoa"; }
+
+bool UsbAoaAdapter::IsInitialised() const {
+ return is_initialised_ && TransportAdapterImpl::IsInitialised();
+}
+
+TransportAdapter::Error UsbAoaAdapter::Init() {
+ TransportAdapter::Error error = usb_handler_->Init();
+ if (error != TransportAdapter::OK) {
+ return error;
+ }
+ error = TransportAdapterImpl::Init();
+ if (error != TransportAdapter::OK) {
+ return error;
+ }
+ is_initialised_ = true;
+ return TransportAdapter::OK;
+}
+
+bool UsbAoaAdapter::ToBeAutoConnected(DeviceSptr device) const {
+ return true;
+}
+
+} // namespace transport_adapter
+} // namespace transport_manager
-/**
- * \file usb_connection_factory.cc
- * \brief UsbConnectionFactory class source file.
- *
- * 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
#include "transport_manager/usb/usb_device.h"
#include "transport_manager/transport_adapter/transport_adapter_impl.h"
-#if defined(__QNX__) || defined(__QNXNTO__)
+#if defined(__QNXNTO__)
#include "transport_manager/usb/qnx/usb_connection.h"
#else
#include "transport_manager/usb/libusb/usb_connection.h"
#endif
+#include "utils/logger.h"
+
namespace transport_manager {
namespace transport_adapter {
+CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager")
+
UsbConnectionFactory::UsbConnectionFactory(
TransportAdapterController* controller)
: controller_(controller), usb_handler_() {}
UsbDevice* usb_device = static_cast<UsbDevice*>(device.get());
UsbConnection* usb_connection =
- new UsbConnection(device_uid, app_handle, controller_, usb_handler_,
- usb_device->usb_device());
+ new UsbConnection(device_uid, app_handle, controller_, usb_handler_,
+ usb_device->usb_device());
ConnectionSptr connection(usb_connection);
controller_->ConnectionCreated(connection, device_uid, app_handle);
- if (!usb_connection->Init()) {
+
+ if (usb_connection->Init()) {
+ LOG4CXX_INFO(logger_, "USB connection initialised");
+ return TransportAdapter::OK;
+ }
+ else {
return TransportAdapter::FAIL;
}
- LOG4CXX_INFO(logger_, "Usb connection initialised");
-
- return TransportAdapter::OK;
}
void UsbConnectionFactory::Terminate() {}
-/**
- * \file usb_device_scanner.cc
- * \brief UsbDeviceScanner class source file.
- *
- * 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
#include "transport_manager/usb/usb_device.h"
#include "transport_manager/usb/common.h"
+#include "utils/logger.h"
+
namespace transport_manager {
namespace transport_adapter {
+CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager")
+
class AoaInitSequence : public UsbControlTransferSequence {
public:
AoaInitSequence();
class AoaTurnIntoAccessoryMode;
};
-bool IsGoogleAccessory(uint16_t vid, uint16_t pid) {
- return (vid == kAoaVid) && (pid == kAoaPid1 || pid == kAoaPid2);
-}
-
void UsbDeviceScanner::OnDeviceArrived(PlatformUsbDevice* device) {
- if (IsGoogleAccessory(device->vendor_id(), device->product_id())) {
- GoogleAccessoryFound(device);
- } else {
- TurnIntoAccessoryMode(device);
+ if (IsAppleDevice(device)) {
+ SupportedDeviceFound(device);
+ }
+ else {
+ if (IsGoogleAccessory(device)) {
+ SupportedDeviceFound(device);
+ } else {
+ TurnIntoAccessoryMode(device);
+ }
}
}
GetUsbHandler()->StartControlTransferSequence(new AoaInitSequence, device);
}
-void UsbDeviceScanner::GoogleAccessoryFound(PlatformUsbDevice* device) {
- LOG4CXX_INFO(logger_, "Google accessory found");
+void UsbDeviceScanner::SupportedDeviceFound(PlatformUsbDevice* device) {
+ LOG4CXX_INFO(logger_, "Supported device found");
pthread_mutex_lock(&devices_mutex_);
devices_.push_back(device);
pthread_mutex_unlock(&devices_mutex_);
- LOG4CXX_INFO(logger_, "Google accessory (bus number "
+ LOG4CXX_INFO(logger_, "USB device (bus number "
<< static_cast<int>(device->bus_number())
<< ", address "
<< static_cast<int>(device->address())