Reformat Code

This commit is contained in:
Simon Dean 2024-11-27 09:53:07 +00:00
parent 7f38e16983
commit 478526b953
27 changed files with 2598 additions and 2717 deletions

View File

@ -18,17 +18,10 @@
#pragma once
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace configuration
{
enum class BluetoothAdapterType
{
namespace f1x::openauto::autoapp::configuration {
enum class BluetoothAdapterType {
NONE,
LOCAL,
REMOTE
@ -37,4 +30,6 @@ enum class BluetoothAdapterType
}
}
}
}

View File

@ -23,13 +23,7 @@
#pragma once
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
namespace f1x::openauto::autoapp::projection
{
class LocalBluetoothDevice: public QObject, public IBluetoothDevice
@ -37,7 +31,7 @@ class LocalBluetoothDevice: public QObject, public IBluetoothDevice
Q_OBJECT
public:
LocalBluetoothDevice();
LocalBluetoothDevice(const QString &adapterAddress = QString(), QObject *parent = nullptr);
void stop() override;
bool isPaired(const std::string& address) const override;
@ -68,6 +62,6 @@ private:
};
}
}
}
}

View File

@ -24,32 +24,29 @@
#include <aap_protobuf/service/control/message/ServiceDiscoveryResponse.pb.h>
#include <aap_protobuf/shared/MessageStatus.pb.h>
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
class IService
{
namespace f1x::openauto::autoapp::service {
class IService {
public:
typedef std::shared_ptr<IService> Pointer;
virtual ~IService() = default;
virtual void start() = 0;
virtual void stop() = 0;
virtual void pause() = 0;
virtual void resume() = 0;
virtual void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) = 0;
};
typedef std::vector<IService::Pointer> ServiceList;
}
}
}
}

View File

@ -26,11 +26,8 @@
#include <boost/asio/io_service.hpp>
#include <aasdk/Messenger/IMessenger.hpp>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace sensor {
namespace f1x::openauto::autoapp::service::sensor {
class SensorService :
public aasdk::channel::sensorsource::ISensorSourceServiceEventHandler,
public IService,
@ -44,9 +41,13 @@ namespace f1x {
bool stopPolling = false;
void start() override;
void stop() override;
void pause() override;
void resume() override;
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
@ -79,7 +80,6 @@ namespace f1x {
};
}
}
}
}
}

View File

@ -22,10 +22,7 @@
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace f1x::openauto::autoapp::service {
class Service
: public IService {
@ -48,7 +45,3 @@ namespace f1x {
};
}
}
}
}
}

View File

@ -23,11 +23,8 @@
#include <boost/asio/io_service.hpp>
#include <aasdk/Messenger/IMessenger.hpp>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace vendorextension {
namespace f1x::openauto::autoapp::service::vendorextension {
class VendorExtensionService :
public aasdk::channel::vendorextension::IVendorExtensionServiceEventHandler,
@ -37,9 +34,13 @@ namespace f1x {
VendorExtensionService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger);
void start() override;
void stop() override;
void pause() override;
void resume() override;
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
@ -55,7 +56,6 @@ namespace f1x {
};
}
}
}
}
}

View File

@ -23,11 +23,8 @@
#include <boost/asio/io_service.hpp>
#include <aasdk/Messenger/IMessenger.hpp>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace wifiprojection {
namespace f1x::openauto::autoapp::service::wifiprojection {
class WifiProjectionService :
public aasdk::channel::wifiprojection::IWifiProjectionServiceEventHandler,
@ -37,9 +34,13 @@ namespace f1x {
WifiProjectionService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger);
void start() override;
void stop() override;
void pause() override;
void resume() override;
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
@ -47,7 +48,8 @@ namespace f1x {
void onChannelError(const aasdk::error::Error &e) override;
void
onWifiCredentialsRequest(const aap_protobuf::service::wifiprojection::message::WifiCredentialsRequest &request) override;
onWifiCredentialsRequest(
const aap_protobuf::service::wifiprojection::message::WifiCredentialsRequest &request) override;
private:
using std::enable_shared_from_this<WifiProjectionService>::shared_from_this;
@ -57,7 +59,6 @@ namespace f1x {
};
}
}
}
}
}

View File

@ -35,13 +35,7 @@ namespace Ui
class SettingsWindow;
}
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace ui
namespace f1x::openauto::autoapp::ui
{
class SettingsWindow : public QWidget
@ -112,6 +106,6 @@ private:
};
}
}
}
}

View File

@ -22,57 +22,41 @@
#include <f1x/openauto/autoapp/App.hpp>
#include <f1x/openauto/Common/Log.hpp>
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace f1x::openauto::autoapp {
App::App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper, aasdk::tcp::ITCPWrapper& tcpWrapper, service::IAndroidAutoEntityFactory& androidAutoEntityFactory,
aasdk::usb::IUSBHub::Pointer usbHub, aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator)
: ioService_(ioService)
, usbWrapper_(usbWrapper)
, tcpWrapper_(tcpWrapper)
, strand_(ioService_)
, androidAutoEntityFactory_(androidAutoEntityFactory)
, usbHub_(std::move(usbHub))
, connectedAccessoriesEnumerator_(std::move(connectedAccessoriesEnumerator))
, acceptor_(ioService, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 5000 ))
, isStopped_(false)
{
App::App(boost::asio::io_service &ioService, aasdk::usb::USBWrapper &usbWrapper, aasdk::tcp::ITCPWrapper &tcpWrapper,
service::IAndroidAutoEntityFactory &androidAutoEntityFactory,
aasdk::usb::IUSBHub::Pointer usbHub,
aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator)
: ioService_(ioService), usbWrapper_(usbWrapper), tcpWrapper_(tcpWrapper), strand_(ioService_),
androidAutoEntityFactory_(androidAutoEntityFactory), usbHub_(std::move(usbHub)),
connectedAccessoriesEnumerator_(std::move(connectedAccessoriesEnumerator)),
acceptor_(ioService, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 5000)), isStopped_(false) {
}
void App::waitForUSBDevice()
{
void App::waitForUSBDevice() {
strand_.dispatch([this, self = this->shared_from_this()]() {
try
{
try {
this->waitForDevice();
}
catch(...)
{
catch (...) {
OPENAUTO_LOG(error) << "[App] waitForUSBDevice() -exception caused by this->waitForDevice();";
}
try
{
try {
this->enumerateDevices();
}
catch(...)
{
catch (...) {
OPENAUTO_LOG(error) << "[App] waitForUSBDevice() exception caused by this->enumerateDevices()";
}
});
}
void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket)
{
void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket) {
strand_.dispatch([this, self = this->shared_from_this(), socket = std::move(socket)]() mutable {
OPENAUTO_LOG(info) << "Start from socket";
if(androidAutoEntity_ != nullptr)
{
if (androidAutoEntity_ != nullptr) {
// tcpWrapper_.close(*socket);
// OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
// return;
@ -88,8 +72,7 @@ void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket)
}
}
try
{
try {
// usbHub_->cancel();
// connectedAccessoriesEnumerator_->cancel();
@ -97,8 +80,7 @@ void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket)
androidAutoEntity_ = androidAutoEntityFactory_.create(std::move(tcpEndpoint));
androidAutoEntity_->start(*this);
}
catch(const aasdk::error::Error& error)
{
catch (const aasdk::error::Error &error) {
OPENAUTO_LOG(error) << "[App] TCP AndroidAutoEntity create error: " << error.what();
//androidAutoEntity_.reset();
@ -107,8 +89,7 @@ void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket)
});
}
void App::stop()
{
void App::stop() {
strand_.dispatch([this, self = this->shared_from_this()]() {
isStopped_ = true;
try {
@ -122,8 +103,7 @@ void App::stop()
OPENAUTO_LOG(error) << "[App] stop: exception caused by usbHub_->cancel();";
}
if(androidAutoEntity_ != nullptr)
{
if (androidAutoEntity_ != nullptr) {
try {
androidAutoEntity_->stop();
} catch (...) {
@ -139,18 +119,15 @@ void App::stop()
}
void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle)
{
void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle) {
OPENAUTO_LOG(info) << "[App] Device connected.";
if(androidAutoEntity_ != nullptr)
{
if (androidAutoEntity_ != nullptr) {
OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
return;
}
try
{
try {
// ignore autostart if exit to csng was used
if (!disableAutostartEntity) {
OPENAUTO_LOG(info) << "[App] Start Android Auto allowed - let's go.";
@ -163,8 +140,7 @@ void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle)
OPENAUTO_LOG(info) << "[App] Start Android Auto not allowed - skip.";
}
}
catch(const aasdk::error::Error& error)
{
catch (const aasdk::error::Error &error) {
OPENAUTO_LOG(error) << "[App] USB AndroidAutoEntity create error: " << error.what();
androidAutoEntity_.reset();
@ -172,8 +148,7 @@ void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle)
}
}
void App::enumerateDevices()
{
void App::enumerateDevices() {
auto promise = aasdk::usb::IConnectedAccessoriesEnumerator::Promise::defer(strand_);
promise->then([this, self = this->shared_from_this()](auto result) {
OPENAUTO_LOG(info) << "[App] Devices enumeration result: " << result;
@ -185,8 +160,7 @@ void App::enumerateDevices()
connectedAccessoriesEnumerator_->enumerate(std::move(promise));
}
void App::waitForDevice()
{
void App::waitForDevice() {
OPENAUTO_LOG(info) << "[App] Waiting for device...";
auto promise = aasdk::usb::IUSBHub::Promise::defer(strand_);
@ -207,26 +181,24 @@ void App::startServerSocket() {
});
}
void App::handleNewClient(std::shared_ptr<boost::asio::ip::tcp::socket> socket, const boost::system::error_code &err) {
void
App::handleNewClient(std::shared_ptr<boost::asio::ip::tcp::socket> socket, const boost::system::error_code &err) {
OPENAUTO_LOG(info) << "handleNewClient() - Handle WIFI Client Connection";
if (!err) {
start(std::move(socket));
}
}
void App::pause()
{
void App::pause() {
strand_.dispatch([this, self = this->shared_from_this()]() {
OPENAUTO_LOG(info) << "[App] pause...";
androidAutoEntity_->pause();
});
}
void App::resume()
{
void App::resume() {
strand_.dispatch([this, self = this->shared_from_this()]() {
if(androidAutoEntity_ != nullptr)
{
if (androidAutoEntity_ != nullptr) {
OPENAUTO_LOG(info) << "[App] resume...";
androidAutoEntity_->resume();
} else {
@ -235,8 +207,7 @@ void App::resume()
});
}
void App::onAndroidAutoQuit()
{
void App::onAndroidAutoQuit() {
strand_.dispatch([this, self = this->shared_from_this()]() {
OPENAUTO_LOG(info) << "[App] onAndroidAutoQuit()";
@ -255,8 +226,7 @@ void App::onAndroidAutoQuit()
}
}
if(!isStopped_)
{
if (!isStopped_) {
try {
this->waitForDevice();
} catch (...) {
@ -266,8 +236,7 @@ void App::onAndroidAutoQuit()
});
}
void App::onUSBHubError(const aasdk::error::Error& error)
{
void App::onUSBHubError(const aasdk::error::Error &error) {
OPENAUTO_LOG(error) << "[App] onUSBHubError(): " << error.what();
// if(error != aasdk::error::ErrorCode::OPERATION_ABORTED &&
@ -282,5 +251,5 @@ void App::onUSBHubError(const aasdk::error::Error& error)
}
}
}
}

View File

@ -20,13 +20,10 @@
#include <f1x/openauto/Common/Log.hpp>
#include <QTouchDevice>
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace configuration
namespace f1x::openauto::autoapp::configuration
{
const std::string Configuration::cConfigFileName = "openauto.ini";
@ -766,6 +763,6 @@ void Configuration::writeButtonCodes(boost::property_tree::ptree& iniConfig)
}
}
}
}
}

View File

@ -18,13 +18,10 @@
#include <f1x/openauto/autoapp/Projection/DummyBluetoothDevice.hpp>
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
namespace f1x::openauto::autoapp::projection
{
void DummyBluetoothDevice::stop()
@ -53,6 +50,6 @@ bool DummyBluetoothDevice::isAvailable() const
}
}
}
}
}

View File

@ -22,14 +22,7 @@
#include <QBluetoothUuid>
#include <QtBluetooth>
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
namespace f1x::openauto::autoapp::projection {
LocalBluetoothDevice::LocalBluetoothDevice()
{
@ -183,7 +176,3 @@ void LocalBluetoothDevice::onHostModeStateChanged(QBluetoothLocalDevice::HostMod
}
}
}
}
}
}

View File

@ -19,11 +19,7 @@
#include <f1x/openauto/Common/Log.hpp>
#include <f1x/openauto/autoapp/Service/Bluetooth/BluetoothService.hpp>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace bluetooth {
namespace f1x::openauto::autoapp::service::bluetooth {
BluetoothService::BluetoothService(boost::asio::io_service &ioService,
aasdk::messenger::IMessenger::Pointer messenger,
@ -82,9 +78,11 @@ namespace f1x {
}
}
void BluetoothService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
void
BluetoothService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
OPENAUTO_LOG(info) << "[BluetoothService] onChannelOpenRequest()";
OPENAUTO_LOG(debug) << "[BluetoothService] Channel Id: " << request.service_id() << ", Priority: " << request.priority();
OPENAUTO_LOG(debug) << "[BluetoothService] Channel Id: " << request.service_id() << ", Priority: "
<< request.priority();
aap_protobuf::service::control::message::ChannelOpenResponse response;
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
@ -94,7 +92,6 @@ namespace f1x {
promise->then([]() {}, std::bind(&BluetoothService::onChannelError, this->shared_from_this(),
std::placeholders::_1));
channel_->sendChannelOpenResponse(response, std::move(promise));
channel_->receive(this->shared_from_this());
}
@ -122,14 +119,18 @@ namespace f1x {
response.set_already_paired(isPaired);
auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then(std::bind(&BluetoothService::sendBluetoothAuthenticationData, this->shared_from_this()), std::bind(&BluetoothService::onChannelError, this->shared_from_this(),
promise->then(std::bind(&BluetoothService::sendBluetoothAuthenticationData, this->shared_from_this()),
std::bind(&BluetoothService::onChannelError, this->shared_from_this(),
std::placeholders::_1));
channel_->sendBluetoothPairingResponse(response, std::move(promise));
channel_->receive(this->shared_from_this());
}
void BluetoothService::sendBluetoothAuthenticationData() {
OPENAUTO_LOG(info) << "[BluetoothService] sendBluetoothAuthenticationData()";
aap_protobuf::service::bluetooth::message::BluetoothAuthenticationData data;
// TODO: Bluetooth Authentication Data
data.set_auth_data("123456");
data.set_pairing_method(aap_protobuf::service::bluetooth::message::BluetoothPairingMethod::BLUETOOTH_PAIRING_PIN);
auto promise = aasdk::channel::SendPromise::defer(strand_);
@ -139,7 +140,8 @@ namespace f1x {
channel_->receive(this->shared_from_this());
}
void BluetoothService::onBluetoothAuthenticationResult(const aap_protobuf::service::bluetooth::message::BluetoothAuthenticationResult &request) {
void BluetoothService::onBluetoothAuthenticationResult(
const aap_protobuf::service::bluetooth::message::BluetoothAuthenticationResult &request) {
OPENAUTO_LOG(info) << "[BluetoothService] onBluetoothAuthenticationResult()";
OPENAUTO_LOG(info) << "[BluetoothService] AuthData " << request.status();
aap_protobuf::service::bluetooth::message::BluetoothPairingResponse response;
@ -151,7 +153,6 @@ namespace f1x {
OPENAUTO_LOG(error) << "[BluetoothService] onChannelError(): " << e.what();
}
}
}
}
}
}

View File

@ -21,17 +21,14 @@
#include <fstream>
#include <QString>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace genericnotification {
namespace f1x::openauto::autoapp::service::genericnotification {
GenericNotificationService::GenericNotificationService(boost::asio::io_service &ioService,
aasdk::messenger::IMessenger::Pointer messenger)
: strand_(ioService),
timer_(ioService),
channel_(std::make_shared<aasdk::channel::genericnotification::GenericNotificationService>(strand_, std::move(messenger))) {
channel_(std::make_shared<aasdk::channel::genericnotification::GenericNotificationService>(strand_, std::move(
messenger))) {
}
@ -69,9 +66,11 @@ namespace f1x {
auto *genericNotification = service->mutable_wifi_projection_service();
}
void GenericNotificationService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
void GenericNotificationService::onChannelOpenRequest(
const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
OPENAUTO_LOG(info) << "[GenericNotificationService] onChannelOpenRequest()";
OPENAUTO_LOG(debug) << "[GenericNotificationService] Channel Id: " << request.service_id() << ", Priority: " << request.priority();
OPENAUTO_LOG(debug) << "[GenericNotificationService] Channel Id: " << request.service_id() << ", Priority: "
<< request.priority();
aap_protobuf::service::control::message::ChannelOpenResponse response;
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
@ -89,7 +88,6 @@ namespace f1x {
OPENAUTO_LOG(error) << "[GenericNotificationService] onChannelError(): " << e.what();
}
}
}
}
}
}

View File

@ -18,11 +18,8 @@
#include <f1x/openauto/autoapp/Service/MediaSink/GuidanceAudioService.hpp>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace mediasink {
namespace f1x::openauto::autoapp::service::mediasink {
using f1x::openauto::autoapp::service::mediasink::GuidanceAudioService;
using f1x::openauto::autoapp::service::mediasink::AudioMediaSinkService;
using aasdk::channel::mediasink::audio::channel::GuidanceAudioChannel;
@ -37,7 +34,6 @@ namespace f1x {
}
}
}
}
}
}

View File

@ -19,12 +19,7 @@
#include <f1x/openauto/autoapp/Service/MediaSink/MediaAudioService.hpp>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace mediasink {
namespace f1x::openauto::autoapp::service::mediasink {
MediaAudioService::MediaAudioService(boost::asio::io_service &ioService,
aasdk::messenger::IMessenger::Pointer messenger,
projection::IAudioOutput::Pointer audioOutput)
@ -36,7 +31,6 @@ namespace f1x {
}
}
}
}
}
}

View File

@ -19,23 +19,20 @@
#include <aasdk/Channel/MediaSink/Audio/Channel/SystemAudioChannel.hpp>
#include <f1x/openauto/autoapp/Service/MediaSink/SystemAudioService.hpp>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace mediasink {
namespace f1x::openauto::autoapp::service::mediasink {
SystemAudioService::SystemAudioService(boost::asio::io_service &ioService,
aasdk::messenger::IMessenger::Pointer messenger,
projection::IAudioOutput::Pointer audioOutput)
: AudioMediaSinkService(ioService,
std::make_shared<aasdk::channel::mediasink::audio::channel::SystemAudioChannel>(strand_,
std::move(messenger)),
std::move(
messenger)),
std::move(audioOutput)) {
}
}
}
}
}
}

View File

@ -16,15 +16,11 @@
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
*/
#include <time.h>
#include <f1x/openauto/Common/Log.hpp>
#include <f1x/openauto/autoapp/Service/MediaSource/MediaSourceService.hpp>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace mediasource {
namespace f1x::openauto::autoapp::service::mediasource {
MediaSourceService::MediaSourceService(boost::asio::io_service &ioService,
aasdk::channel::mediasource::IMediaSourceService::Pointer channel,
@ -92,15 +88,18 @@ namespace f1x {
* Open Service Channel Request
* @param request
*/
void MediaSourceService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
void
MediaSourceService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
OPENAUTO_LOG(info) << "[MediaSourceService] onChannelOpenRequest()";
OPENAUTO_LOG(info) << "[MediaSourceService] Channel Id: " << request.service_id() << ", Priority: " << request.priority();
OPENAUTO_LOG(info) << "[MediaSourceService] Channel Id: " << request.service_id() << ", Priority: "
<< request.priority();
const aap_protobuf::shared::MessageStatus status = audioInput_->open()
? aap_protobuf::shared::MessageStatus::STATUS_SUCCESS
: aap_protobuf::shared::MessageStatus::STATUS_INTERNAL_ERROR;
OPENAUTO_LOG(info) << "[MediaSourceService] Status determined: " << aap_protobuf::shared::MessageStatus_Name(status);
OPENAUTO_LOG(info) << "[MediaSourceService] Status determined: "
<< aap_protobuf::shared::MessageStatus_Name(status);
aap_protobuf::service::control::message::ChannelOpenResponse response;
response.set_status(status);
@ -134,7 +133,8 @@ namespace f1x {
MediaSourceService::onMediaChannelSetupRequest(const aap_protobuf::service::media::shared::message::Setup &request) {
OPENAUTO_LOG(info) << "[MediaSourceService] onMediaChannelSetupRequest()";
OPENAUTO_LOG(info) << "[MediaSourceService] Channel Id: " << aasdk::messenger::channelIdToString(channel_->getId()) << ", Codec: " << MediaCodecType_Name(request.type());
OPENAUTO_LOG(info) << "[MediaSourceService] Channel Id: " << aasdk::messenger::channelIdToString(channel_->getId())
<< ", Codec: " << MediaCodecType_Name(request.type());
aap_protobuf::service::media::shared::message::Config response;
auto status = aap_protobuf::service::media::shared::message::Config::STATUS_READY;
@ -170,7 +170,9 @@ namespace f1x {
void MediaSourceService::onMediaSourceOpenRequest(
const aap_protobuf::service::media::source::message::MicrophoneRequest &request) {
OPENAUTO_LOG(info) << "[MediaSourceService] onMediaSourceOpenRequest()";
OPENAUTO_LOG(info) << "[MediaSourceService] Request to Open?: " << request.open() << ", anc: " << request.anc_enabled() << ", ec: " << request.ec_enabled() << ", max unacked: " << request.max_unacked();
OPENAUTO_LOG(info) << "[MediaSourceService] Request to Open?: " << request.open() << ", anc: "
<< request.anc_enabled() << ", ec: " << request.ec_enabled() << ", max unacked: "
<< request.max_unacked();
if (request.open()) {
// Request for Channel Open
@ -265,7 +267,7 @@ namespace f1x {
}
}
}
}
}
}
}

View File

@ -19,22 +19,18 @@
#include <aasdk/Channel/MediaSource/Audio/MicrophoneAudioChannel.hpp>
#include <f1x/openauto/autoapp/Service/MediaSource/MicrophoneMediaSourceService.hpp>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace mediasource {
namespace f1x::openauto::autoapp::service::mediasource {
MicrophoneMediaSourceService::MicrophoneMediaSourceService(boost::asio::io_service &ioService,
aasdk::messenger::IMessenger::Pointer messenger,
projection::IAudioInput::Pointer audioOutput)
: MediaSourceService(ioService, std::make_shared<aasdk::channel::mediasource::audio::MicrophoneAudioChannel>(strand_,
: MediaSourceService(ioService,
std::make_shared<aasdk::channel::mediasource::audio::MicrophoneAudioChannel>(strand_,
std::move(
messenger)),
std::move(audioOutput)) {
}
}
}
}
}
}

View File

@ -21,17 +21,14 @@
#include <fstream>
#include <QString>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace navigationstatus {
namespace f1x::openauto::autoapp::service::navigationstatus {
NavigationStatusService::NavigationStatusService(boost::asio::io_service &ioService,
aasdk::messenger::IMessenger::Pointer messenger)
: strand_(ioService),
timer_(ioService),
channel_(std::make_shared<aasdk::channel::navigationstatus::NavigationStatusService>(strand_, std::move(messenger))) {
channel_(std::make_shared<aasdk::channel::navigationstatus::NavigationStatusService>(strand_,
std::move(messenger))) {
}
@ -69,9 +66,11 @@ namespace f1x {
auto *navigationStatus = service->mutable_navigation_status_service();
}
void NavigationStatusService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
void NavigationStatusService::onChannelOpenRequest(
const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
OPENAUTO_LOG(info) << "[NavigationStatusService] onChannelOpenRequest()";
OPENAUTO_LOG(info) << "[NavigationStatusService] Channel Id: " << request.service_id() << ", Priority: " << request.priority();
OPENAUTO_LOG(info) << "[NavigationStatusService] Channel Id: " << request.service_id() << ", Priority: "
<< request.priority();
aap_protobuf::service::control::message::ChannelOpenResponse response;
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
@ -85,16 +84,19 @@ namespace f1x {
channel_->receive(this->shared_from_this());
}
void NavigationStatusService::onStatusUpdate(const aap_protobuf::service::navigationstatus::message::NavigationStatus &navStatus) {
void NavigationStatusService::onStatusUpdate(
const aap_protobuf::service::navigationstatus::message::NavigationStatus &navStatus) {
channel_->receive(this->shared_from_this());
}
void NavigationStatusService::onTurnEvent(const aap_protobuf::service::navigationstatus::message::NavigationNextTurnEvent &turnEvent) {
void NavigationStatusService::onTurnEvent(
const aap_protobuf::service::navigationstatus::message::NavigationNextTurnEvent &turnEvent) {
channel_->receive(this->shared_from_this());
}
void NavigationStatusService::onDistanceEvent(const aap_protobuf::service::navigationstatus::message::NavigationNextTurnDistanceEvent &distanceEvent) {
void NavigationStatusService::onDistanceEvent(
const aap_protobuf::service::navigationstatus::message::NavigationNextTurnDistanceEvent &distanceEvent) {
channel_->receive(this->shared_from_this());
}
@ -103,7 +105,6 @@ namespace f1x {
OPENAUTO_LOG(error) << "[NavigationStatusService] onChannelError(): " << e.what();
}
}
}
}
}
}

View File

@ -19,79 +19,53 @@
#include <f1x/openauto/autoapp/Service/Pinger.hpp>
#include <f1x/openauto/Common/Log.hpp>
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
namespace f1x::openauto::autoapp::service {
Pinger::Pinger(boost::asio::io_service &ioService, time_t duration)
: strand_(ioService)
, timer_(ioService)
, duration_(duration)
, cancelled_(false)
, pingsCount_(0)
, pongsCount_(0)
{
: strand_(ioService), timer_(ioService), duration_(duration), cancelled_(false), pingsCount_(0), pongsCount_(0) {
}
void Pinger::ping(Promise::Pointer promise)
{
void Pinger::ping(Promise::Pointer promise) {
strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable {
cancelled_ = false;
if(promise_ != nullptr)
{
if (promise_ != nullptr) {
promise_->reject(aasdk::error::Error(aasdk::error::ErrorCode::OPERATION_IN_PROGRESS));
}
else
{
} else {
++pingsCount_;
OPENAUTO_LOG(debug) << "[Pinger] Ping counter: " << pingsCount_;
promise_ = std::move(promise);
timer_.expires_from_now(boost::posix_time::milliseconds(duration_));
timer_.async_wait(strand_.wrap(std::bind(&Pinger::onTimerExceeded, this->shared_from_this(), std::placeholders::_1)));
timer_.async_wait(
strand_.wrap(std::bind(&Pinger::onTimerExceeded, this->shared_from_this(), std::placeholders::_1)));
}
});
}
void Pinger::pong()
{
void Pinger::pong() {
strand_.dispatch([this, self = this->shared_from_this()]() {
++pongsCount_;
OPENAUTO_LOG(debug) << "[Pinger] Pong counter: " << pongsCount_;
});
}
void Pinger::onTimerExceeded(const boost::system::error_code& error)
{
if(promise_ == nullptr)
{
void Pinger::onTimerExceeded(const boost::system::error_code &error) {
if (promise_ == nullptr) {
return;
}
else if(error == boost::asio::error::operation_aborted || cancelled_)
{
} else if (error == boost::asio::error::operation_aborted || cancelled_) {
promise_->reject(aasdk::error::Error(aasdk::error::ErrorCode::OPERATION_ABORTED));
}
else if(pingsCount_ - pongsCount_ > 4)
{
} else if (pingsCount_ - pongsCount_ > 4) {
promise_->reject(aasdk::error::Error());
}
else
{
} else {
promise_->resolve();
}
promise_.reset();
}
void Pinger::cancel()
{
void Pinger::cancel() {
strand_.dispatch([this, self = this->shared_from_this()]() {
cancelled_ = true;
timer_.cancel();
@ -99,6 +73,6 @@ void Pinger::cancel()
}
}
}
}
}

View File

@ -21,11 +21,7 @@
#include <fstream>
#include <QString>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace radio {
namespace f1x::openauto::autoapp::service::radio {
RadioService::RadioService(boost::asio::io_service &ioService,
aasdk::messenger::IMessenger::Pointer messenger)
@ -71,7 +67,8 @@ namespace f1x {
void RadioService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
OPENAUTO_LOG(info) << "[RadioService] onChannelOpenRequest()";
OPENAUTO_LOG(debug) << "[RadioService] Channel Id: " << request.service_id() << ", Priority: " << request.priority();
OPENAUTO_LOG(debug) << "[RadioService] Channel Id: " << request.service_id() << ", Priority: "
<< request.priority();
aap_protobuf::service::control::message::ChannelOpenResponse response;
@ -92,7 +89,6 @@ namespace f1x {
}
}
}
}
}

View File

@ -23,11 +23,7 @@
#include <cmath>
#include <gps.h>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace sensor {
namespace f1x::openauto::autoapp::service::sensor {
SensorService::SensorService(boost::asio::io_service &ioService,
aasdk::messenger::IMessenger::Pointer messenger)
: strand_(ioService),
@ -91,14 +87,18 @@ namespace f1x {
service->set_id(static_cast<uint32_t>(channel_->getId()));
auto *sensorChannel = service->mutable_sensor_source_service();
sensorChannel->add_sensors()->set_sensor_type(aap_protobuf::service::sensorsource::message::SensorType::SENSOR_DRIVING_STATUS_DATA);
sensorChannel->add_sensors()->set_sensor_type(aap_protobuf::service::sensorsource::message::SensorType::SENSOR_LOCATION);
sensorChannel->add_sensors()->set_sensor_type(aap_protobuf::service::sensorsource::message::SensorType::SENSOR_NIGHT_MODE);
sensorChannel->add_sensors()->set_sensor_type(
aap_protobuf::service::sensorsource::message::SensorType::SENSOR_DRIVING_STATUS_DATA);
sensorChannel->add_sensors()->set_sensor_type(
aap_protobuf::service::sensorsource::message::SensorType::SENSOR_LOCATION);
sensorChannel->add_sensors()->set_sensor_type(
aap_protobuf::service::sensorsource::message::SensorType::SENSOR_NIGHT_MODE);
}
void SensorService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
OPENAUTO_LOG(info) << "[SensorService] onChannelOpenRequest()";
OPENAUTO_LOG(debug) << "[SensorService] Channel Id: " << request.service_id() << ", Priority: " << request.priority();
OPENAUTO_LOG(debug) << "[SensorService] Channel Id: " << request.service_id() << ", Priority: "
<< request.priority();
aap_protobuf::service::control::message::ChannelOpenResponse response;
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
@ -122,18 +122,13 @@ namespace f1x {
auto promise = aasdk::channel::SendPromise::defer(strand_);
if (request.type() == aap_protobuf::service::sensorsource::message::SENSOR_DRIVING_STATUS_DATA)
{
if (request.type() == aap_protobuf::service::sensorsource::message::SENSOR_DRIVING_STATUS_DATA) {
promise->then(std::bind(&SensorService::sendDrivingStatusUnrestricted, this->shared_from_this()),
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
}
else if (request.type() == aap_protobuf::service::sensorsource::message::SensorType::SENSOR_NIGHT_MODE)
{
} else if (request.type() == aap_protobuf::service::sensorsource::message::SensorType::SENSOR_NIGHT_MODE) {
promise->then(std::bind(&SensorService::sendNightData, this->shared_from_this()),
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
}
else
{
} else {
promise->then([]() {},
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
}
@ -145,7 +140,8 @@ namespace f1x {
void SensorService::sendDrivingStatusUnrestricted() {
OPENAUTO_LOG(info) << "[SensorService] sendDrivingStatusUnrestricted()";
aap_protobuf::service::sensorsource::message::SensorBatch indication;
indication.add_driving_status_data()->set_status(aap_protobuf::service::sensorsource::message::DrivingStatus::DRIVE_STATUS_UNRESTRICTED);
indication.add_driving_status_data()->set_status(
aap_protobuf::service::sensorsource::message::DrivingStatus::DRIVE_STATUS_UNRESTRICTED);
auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {},
@ -225,8 +221,7 @@ namespace f1x {
(this->gpsData_.status != STATUS_NO_FIX) &&
(this->gpsData_.fix.mode == MODE_2D || this->gpsData_.fix.mode == MODE_3D) &&
(this->gpsData_.set & TIME_SET) &&
(this->gpsData_.set & LATLON_SET))
{
(this->gpsData_.set & LATLON_SET)) {
this->sendGPSLocationData();
}
@ -246,7 +241,6 @@ namespace f1x {
OPENAUTO_LOG(error) << "[SensorService] onChannelError(): " << e.what();
}
}
}
}
}
}

View File

@ -49,10 +49,7 @@
#include <f1x/openauto/autoapp/Projection/RemoteBluetoothDevice.hpp>
#include <f1x/openauto/autoapp/Projection/DummyBluetoothDevice.hpp>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace f1x::openauto::autoapp::service {
ServiceFactory::ServiceFactory(boost::asio::io_service &ioService,
configuration::IConfiguration::Pointer configuration)
@ -69,6 +66,7 @@ namespace f1x {
serviceList.emplace_back(this->createSensorService(messenger));
serviceList.emplace_back(this->createBluetoothService(messenger));
serviceList.emplace_back(this->createInputService(messenger));
// TODO: What is WiFi Projection Service?
//serviceList.emplace_back(this->createWifiProjectionService(messenger));
return serviceList;
@ -214,6 +212,6 @@ namespace f1x {
}
}
}
}
}

View File

@ -21,17 +21,14 @@
#include <fstream>
#include <QString>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace vendorextension {
namespace f1x::openauto::autoapp::service::vendorextension {
VendorExtensionService::VendorExtensionService(boost::asio::io_service &ioService,
aasdk::messenger::IMessenger::Pointer messenger)
: strand_(ioService),
timer_(ioService),
channel_(std::make_shared<aasdk::channel::vendorextension::VendorExtensionService>(strand_, std::move(messenger))) {
channel_(
std::make_shared<aasdk::channel::vendorextension::VendorExtensionService>(strand_, std::move(messenger))) {
}
@ -73,9 +70,11 @@ namespace f1x {
OPENAUTO_LOG(error) << "[VendorExtensionService] onChannelError(): " << e.what();
}
void VendorExtensionService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
void VendorExtensionService::onChannelOpenRequest(
const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
OPENAUTO_LOG(info) << "[VendorExtensionService] onChannelOpenRequest()";
OPENAUTO_LOG(info) << "[VendorExtensionService] Channel Id: " << request.service_id() << ", Priority: " << request.priority();
OPENAUTO_LOG(info) << "[VendorExtensionService] Channel Id: " << request.service_id() << ", Priority: "
<< request.priority();
aap_protobuf::service::control::message::ChannelOpenResponse response;
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
@ -88,7 +87,6 @@ namespace f1x {
channel_->receive(this->shared_from_this());
}
}
}
}
}
}

View File

@ -22,16 +22,14 @@
#include <QString>
#include <QNetworkInterface>
namespace f1x {
namespace openauto {
namespace autoapp {
namespace service {
namespace wifiprojection {
namespace f1x::openauto::autoapp::service::wifiprojection {
WifiProjectionService::WifiProjectionService(boost::asio::io_service &ioService,
aasdk::messenger::IMessenger::Pointer messenger)
: strand_(ioService),
timer_(ioService),
channel_(std::make_shared<aasdk::channel::wifiprojection::WifiProjectionService>(strand_, std::move(messenger))) {
channel_(
std::make_shared<aasdk::channel::wifiprojection::WifiProjectionService>(strand_, std::move(messenger))) {
}
@ -80,7 +78,8 @@ namespace f1x {
response.set_access_point_type(aap_protobuf::service::wifiprojection::message::AccessPointType::STATIC);
response.set_car_wifi_ssid("CRANKSHAFT-NG");
response.set_car_wifi_password("1234567890");
response.set_car_wifi_security_mode(aap_protobuf::service::wifiprojection::message::WifiSecurityMode::WPA2_PERSONAL);
response.set_car_wifi_security_mode(
aap_protobuf::service::wifiprojection::message::WifiSecurityMode::WPA2_PERSONAL);
auto promise = aasdk::channel::SendPromise::defer(strand_);
promise->then([]() {}, std::bind(&WifiProjectionService::onChannelError, this->shared_from_this(),
@ -90,9 +89,11 @@ namespace f1x {
}
void WifiProjectionService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
void WifiProjectionService::onChannelOpenRequest(
const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
OPENAUTO_LOG(info) << "[WifiProjectionService] onChannelOpenRequest()";
OPENAUTO_LOG(debug) << "[WifiProjectionService] Channel Id: " << request.service_id() << ", Priority: " << request.priority();
OPENAUTO_LOG(debug) << "[WifiProjectionService] Channel Id: " << request.service_id() << ", Priority: "
<< request.priority();
aap_protobuf::service::control::message::ChannelOpenResponse response;
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
@ -112,7 +113,6 @@ namespace f1x {
}
}
}
}
}

View File

@ -15,34 +15,39 @@
* You should have received a copy of the GNU General Public License
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QMessageBox>
#include <fstream>
#include <string>
#include <f1x/openauto/autoapp/UI/SettingsWindow.hpp>
#include "ui_settingswindow.h" // AutoGenerated at Compile Time
#include <QBluetoothLocalDevice>
#include <QBluetoothHostInfo>
#include <QComboBox>
#include <QCoreApplication>
#include <QDateTime>
#include <QDBusInterface>
#include <QDBusReply>
#include <QFile>
#include <QFileInfo>
#include <QTextStream>
#include <string>
#include <QTimer>
#include <QDateTime>
#include <QMessageBox>
#include <QNetworkInterface>
#include <fstream>
#include <QStorageInfo>
#include <QProcess>
#include <QStorageInfo>
#include <QTextStream>
#include <QTimer>
#include "ui_settingswindow.h" // AutoGenerated at Compile Time
#ifdef MAC_OS
#include <mach/mach_host.h>
#include <mach/mach_init.h>
#include <mach/mach_port.h>
#include <mach/vm_map.h>
#include <mach/vm_statistics.h>
#include <mach/mach_types.h>
#endif
namespace f1x {
namespace openauto {
namespace autoapp {
namespace ui {
namespace f1x::openauto::autoapp::ui {
SettingsWindow::SettingsWindow(configuration::IConfiguration::Pointer configuration, QWidget *parent)
: QWidget(parent), ui_(new Ui::SettingsWindow), configuration_(std::move(configuration)) {
@ -250,23 +255,24 @@ namespace f1x {
configuration_->playerButtonControl(ui_->checkBoxPlayerControl->isChecked());
if (ui_->radioButtonDisableBluetooth->isChecked()) {
configuration_->setBluetoothAdapterType(configuration::BluetoothAdapterType::NONE);
} else if (ui_->radioButtonUseLocalBluetoothAdapter->isChecked()) {
configuration_->setBluetoothAdapterType(configuration::BluetoothAdapterType::LOCAL);
} else if (ui_->radioButtonUseExternalBluetoothAdapter->isChecked()) {
configuration_->setBluetoothAdapterType(configuration::BluetoothAdapterType::REMOTE);
if (ui_->comboBoxBluetooth->currentText() == "none") {
configuration_->setBluetoothAdapterAddress(""); // or any string that indicates no adapter
} else {
configuration_->setBluetoothAdapterAddress(
ui_->comboBoxBluetooth->currentData().toString().toStdString());
}
configuration_->setBluetoothRemoteAdapterAddress(
ui_->lineEditExternalBluetoothAdapterAddress->text().toStdString());
configuration_->setMusicAudioChannelEnabled(ui_->checkBoxMusicAudioChannel->isChecked());
configuration_->setGuidanceAudioChannelEnabled(ui_->checkBoxSpeechAudioChannel->isChecked());
configuration_->setTelephonyAudioChannelEnabled(ui_->checkBoxVoiceAudioChannel->isChecked());
configuration_->setAudioOutputBackendType(
ui_->radioButtonRtAudio->isChecked() ? configuration::AudioOutputBackendType::RTAUDIO
: configuration::AudioOutputBackendType::QT);
configuration_->setMusicAudioChannelEnabled(ui_->checkBoxMusicAudioChannel->isChecked());
configuration_->setGuidanceAudioChannelEnabled(ui_->checkBoxSpeechAudioChannel->isChecked());
configuration_->setAudioOutputBackendType(
ui_->radioButtonRtAudio->isChecked() ? configuration::AudioOutputBackendType::RTAUDIO
: configuration::AudioOutputBackendType::QT);
configuration_->save();
@ -880,6 +886,8 @@ namespace f1x {
ui_->radioButtonScreenRotated->setChecked(true);
}
populateBluetoothComboBox(ui_->comboBoxBluetooth);
if (std::ifstream("/tmp/get_inputs")) {
QFile inputsFile(QString("/tmp/get_inputs"));
inputsFile.open(QIODevice::ReadOnly);
@ -1117,6 +1125,8 @@ namespace f1x {
ui_->comboBoxBluetooth->setCurrentText("none");
}
// set lightsensor
if (std::ifstream("/etc/cs_lightsensor")) {
ui_->comboBoxLS->setCurrentIndex(1);
@ -1187,6 +1197,7 @@ namespace f1x {
}
#ifdef MAC_OS
void SettingsWindow::getMacMemoryInfo(QString &freeMemory) {
mach_port_t host_port;
vm_size_t page_size;
@ -1204,6 +1215,7 @@ namespace f1x {
uint64_t free_memory = (uint64_t) free_count * (uint64_t) page_size;
freeMemory = QString::number(free_memory / (1024 * 1024)) + " MB";
}
#endif
void SettingsWindow::updateSystemInfo() {
@ -1372,9 +1384,7 @@ namespace f1x {
}
}
}
}
}
void f1x::openauto::autoapp::ui::SettingsWindow::on_pushButtonAudioTest_clicked() {
ui_->labelTestInProgress->show();