Skip to content

AccessoryModeQueryFactory_8cpp

github-actions edited this page Mar 15, 2026 · 3 revisions

title: src/USB/AccessoryModeQueryFactory.cpp


src/USB/AccessoryModeQueryFactory.cpp

Namespaces

Name
aasdk
aasdk::usb

Source code

// This file is part of aasdk library project.
// Copyright (C) 2018 f1x.studio (Michal Szwaj)
// Copyright (C) 2024 CubeOne (Simon Dean - simon.dean@cubeone.co.uk)
// Copyright (C) 2026 OpenCarDev (Matthew Hilton - matthilton2005@gmail.com)
//
// aasdk is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// aasdk is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with aasdk. If not, see <http://www.gnu.org/licenses/>.

#include <aasdk/USB/AccessoryModeQueryFactory.hpp>
#include <aasdk/USB/AccessoryModeSendStringQuery.hpp>
#include <aasdk/USB/AccessoryModeStartQuery.hpp>
#include <aasdk/USB/AccessoryModeProtocolVersionQuery.hpp>
#include <aasdk/USB/AccessoryModeSendStringType.hpp>


namespace aasdk {
  namespace usb {

    AccessoryModeQueryFactory::AccessoryModeQueryFactory(usb::IUSBWrapper &usbWrapper,
                                                         boost::asio::io_service &ioService)
        : usbWrapper_(usbWrapper), ioService_(ioService) {

    }

    IAccessoryModeQuery::Pointer
    AccessoryModeQueryFactory::createQuery(AccessoryModeQueryType queryType, IUSBEndpoint::Pointer usbEndpoint) {
      switch (queryType) {
        case AccessoryModeQueryType::PROTOCOL_VERSION:
          return std::make_shared<AccessoryModeProtocolVersionQuery>(ioService_, usbWrapper_, std::move(usbEndpoint));

        case AccessoryModeQueryType::SEND_DESCRIPTION:
          return std::make_shared<AccessoryModeSendStringQuery>(ioService_, usbWrapper_, std::move(usbEndpoint),
                                                                AccessoryModeSendStringType::DESCRIPTION,
                                                                "Android Auto");

        case AccessoryModeQueryType::SEND_MANUFACTURER:
          return std::make_shared<AccessoryModeSendStringQuery>(ioService_, usbWrapper_, std::move(usbEndpoint),
                                                                AccessoryModeSendStringType::MANUFACTURER, "Android");

        case AccessoryModeQueryType::SEND_MODEL:
          return std::make_shared<AccessoryModeSendStringQuery>(ioService_, usbWrapper_, std::move(usbEndpoint),
                                                                AccessoryModeSendStringType::MODEL, "Android Auto");

        case AccessoryModeQueryType::SEND_SERIAL:
          return std::make_shared<AccessoryModeSendStringQuery>(ioService_, usbWrapper_, std::move(usbEndpoint),
                                                                AccessoryModeSendStringType::SERIAL, "HU-AAAAAA001");

        case AccessoryModeQueryType::SEND_URI:
          return std::make_shared<AccessoryModeSendStringQuery>(ioService_, usbWrapper_, std::move(usbEndpoint),
                                                                AccessoryModeSendStringType::URI,
                                                                "https://f1xstudio.com");

        case AccessoryModeQueryType::SEND_VERSION:
          return std::make_shared<AccessoryModeSendStringQuery>(ioService_, usbWrapper_, std::move(usbEndpoint),
                                                                AccessoryModeSendStringType::VERSION, "2.0.1");

        case AccessoryModeQueryType::START:
          return std::make_shared<AccessoryModeStartQuery>(ioService_, usbWrapper_, std::move(usbEndpoint));

        default:
          return nullptr;
      }
    }

  }
}

Updated on 2026-03-15 at 09:02:41 +0000

Clone this wiki locally