diff --git a/.gitignore b/.gitignore index 4e46436..b8bef0b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,20 @@ lib/ bin/ +.idea/ + CMakeLists.txt.user cmake-build-*/ -.idea/ +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps +*_autogen/ +*.pb.cc +*.pb.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9da8a3d..c115505 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,6 @@ add_subdirectory(btservice_proto) set(BTSERVICE_PROTO_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}) include_directories(${BTSERVICE_PROTO_INCLUDE_DIRS}) - add_subdirectory(openauto) add_subdirectory(autoapp) add_dependencies(autoapp btservice_proto) diff --git a/btservice/AndroidBluetoothServer.cpp b/btservice/AndroidBluetoothServer.cpp index 79eda7c..63647fe 100644 --- a/btservice/AndroidBluetoothServer.cpp +++ b/btservice/AndroidBluetoothServer.cpp @@ -1,74 +1,71 @@ -#include "OpenautoLog.hpp" -#include "btservice/AndroidBluetoothServer.hpp" #include #include +#include "OpenautoLog.hpp" +#include "btservice/AndroidBluetoothServer.hpp" namespace openauto { namespace btservice { -AndroidBluetoothServer::AndroidBluetoothServer(openauto::configuration::IConfiguration::Pointer config_) +AndroidBluetoothServer::AndroidBluetoothServer(openauto::configuration::IConfiguration::Pointer config) : rfcommServer_(std::make_unique(QBluetoothServiceInfo::RfcommProtocol, this)) - , config(std::move(config_)) + , socket_(nullptr) + , config_(std::move(config)) + , handshakeState_(ConnectionStatus::IDLE) { - handshakeState = IDLE; connect(rfcommServer_.get(), &QBluetoothServer::newConnection, this, &AndroidBluetoothServer::onClientConnected); - QThread *thread = QThread::create([&]{ this->stateMachine(); }); + + auto* thread = QThread::create([&]{ this->eventLoop(); }); thread->start(); } -void AndroidBluetoothServer::stateMachine() +void AndroidBluetoothServer::eventLoop() { - while(true){ - switch(handshakeState){ - case IDLE: - break; - - case DEVICE_CONNECTED: - handshakeState = SENDING_SOCKETINFO_MESSAGE; - break; + while(true) + { + switch(handshakeState_) + { + case ConnectionStatus::IDLE: + case ConnectionStatus::SENT_SOCKETINFO_MESSAGE: + case ConnectionStatus::SENT_NETWORKINFO_MESSAGE: + case ConnectionStatus::PHONE_RESP_NETWORKINFO: + case ConnectionStatus::ERROR: + break; - case SENDING_SOCKETINFO_MESSAGE: - writeSocketInfoMessage(); - break; + case ConnectionStatus::DEVICE_CONNECTED: + handshakeState_ = ConnectionStatus::SENDING_SOCKETINFO_MESSAGE; + break; - case SENT_SOCKETINFO_MESSAGE: - break; + case ConnectionStatus::SENDING_SOCKETINFO_MESSAGE: + this->writeSocketInfoMessage(); + break; - case PHONE_RESP_SOCKETINFO: - handshakeState = SENDING_NETWORKINFO_MESSAGE; - break; - - case SENDING_NETWORKINFO_MESSAGE: - writeNetworkInfoMessage(); - break; - - case SENT_NETWORKINFO_MESSAGE: - break; + case ConnectionStatus::PHONE_RESP_SOCKETINFO: + handshakeState_ = ConnectionStatus::SENDING_NETWORKINFO_MESSAGE; + break; - case PHONE_RESP_NETWORKINFO: - break; - + case ConnectionStatus::SENDING_NETWORKINFO_MESSAGE: + this->writeNetworkInfoMessage(); + break; } } } bool AndroidBluetoothServer::start(const QBluetoothAddress& address, uint16_t portNumber) { - OPENAUTO_LOG(info)<<"listening"; + OPENAUTO_LOG(info) << "[AndroidBluetoothServer] listening."; return rfcommServer_->listen(address, portNumber); } void AndroidBluetoothServer::onClientConnected() { - socket = rfcommServer_->nextPendingConnection(); - - if(socket != nullptr) + socket_ = rfcommServer_->nextPendingConnection(); + if(socket_ != nullptr) { - OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Device Connected: " << socket->peerName().toStdString(); - connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket())); - handshakeState = DEVICE_CONNECTED; + OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Device Connected: " << socket_->peerName().toStdString(); + connect(socket_, SIGNAL(readyRead()), this, SLOT(readSocket())); + handshakeState_ = ConnectionStatus::DEVICE_CONNECTED; } else { @@ -76,139 +73,147 @@ void AndroidBluetoothServer::onClientConnected() } } -bool AndroidBluetoothServer::writeProtoMessage(uint16_t messageType, google::protobuf::Message &message){ +bool AndroidBluetoothServer::writeProtoMessage(uint16_t messageType, google::protobuf::Message& message) +{ QByteArray byteArray(message.SerializeAsString().c_str(), message.ByteSize()); - uint16_t message_length = message.ByteSize(); - char byte1 = messageType & 0x000000ff; - char byte2 = (messageType & 0x0000ff00) >> 8; - byteArray.prepend(byte1); - byteArray.prepend(byte2); - byte1 = message_length & 0x000000ff; - byte2 = (message_length & 0x0000ff00) >> 8; - byteArray.prepend(byte1); - byteArray.prepend(byte2); - int sentBytes = socket->write(byteArray); - if(sentBytes != byteArray.length()) return false; + uint16_t messageLength = message.ByteSize(); + byteArray.prepend(messageType & 0x000000ff); + byteArray.prepend((messageType & 0x0000ff00) >> 8); + byteArray.prepend(messageLength & 0x000000ff); + byteArray.prepend((messageLength & 0x0000ff00) >> 8); + + if(socket_->write(byteArray) != byteArray.length()) + { + return false; + } + return true; } -void AndroidBluetoothServer::writeSocketInfoMessage(){ - OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Sending Socket Info"; +void AndroidBluetoothServer::writeSocketInfoMessage() +{ + OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Sending socket info."; - btservice::proto::SocketInfo socketInfo; - - QString ipAddr; - QList list = QNetworkInterface::allAddresses(); - - for(int nIter=0; nIterwriteProtoMessage(7, socketInfo)) + { + OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Sent socket info."; + handshakeState_ = ConnectionStatus::SENT_SOCKETINFO_MESSAGE; + } + else + { + OPENAUTO_LOG(error) << "[AndroidBluetoothServer] Error sending socket Info."; + handshakeState_ = ConnectionStatus::ERROR; + } } -void AndroidBluetoothServer::writeNetworkInfoMessage(){ - OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Sending Network Packet"; +void AndroidBluetoothServer::writeNetworkInfoMessage() +{ + OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Sending network packet."; btservice::proto::NetworkInfo networkMessage; - networkMessage.set_ssid(config->getWifiSSID()); - networkMessage.set_psk(config->getWifiPassword()); - + networkMessage.set_ssid(config_->getWifiSSID()); + networkMessage.set_psk(config_->getWifiPassword()); foreach(QNetworkInterface netInterface, QNetworkInterface::allInterfaces()) { // Return only the first non-loopback MAC Address if (!(netInterface.flags() & QNetworkInterface::IsLoopBack)) + { networkMessage.set_mac_addr(netInterface.hardwareAddress().toStdString()); + } } networkMessage.set_security_mode(8); networkMessage.set_unknown_2(0); - - if(writeProtoMessage(3, networkMessage)){ - OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Sent Network Packet"; - handshakeState = SENT_NETWORKINFO_MESSAGE; + if(this->writeProtoMessage(3, networkMessage)) + { + OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Sent network packet."; + handshakeState_ = ConnectionStatus::SENT_NETWORKINFO_MESSAGE; } - else{ - OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Error sending Network Packet"; - handshakeState = ERROR; + else + { + OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Error sending network packet."; + handshakeState_ = ConnectionStatus::ERROR; } } -void AndroidBluetoothServer::readSocket(){ +void AndroidBluetoothServer::readSocket() +{ OPENAUTO_LOG(info) << "[AndroidBluetoothServer] DATA: "; - if (!socket) - return; - QByteArray data = socket->read(1024); - if(data.length()==0) return; - uint16_t messageType = data[2]<<8 | data[3]; + if(!socket_) + { + return; + } + + auto data = socket_->read(1024); + if(data.length() == 0) + { + return; + } + + uint16_t messageType = (data[2] << 8) | data[3]; btservice::proto::PhoneResponse resp; - switch(messageType){ - case 2: - break; - case 6: - resp.ParseFromString(data.toStdString().c_str()); - break; - - + switch(messageType) + { + case 2: + break; + case 6: + resp.ParseFromString(data.toStdString().c_str()); + break; } - switch(handshakeState){ - case IDLE: - break; - - case DEVICE_CONNECTED: - break; - case SENDING_SOCKETINFO_MESSAGE: - break; + switch(handshakeState_) + { + case ConnectionStatus::IDLE: + case ConnectionStatus::DEVICE_CONNECTED: + case ConnectionStatus::SENDING_SOCKETINFO_MESSAGE: + case ConnectionStatus::PHONE_RESP_SOCKETINFO: + case ConnectionStatus::SENDING_NETWORKINFO_MESSAGE: + case ConnectionStatus::PHONE_RESP_NETWORKINFO: + case ConnectionStatus::ERROR: + break; - case SENT_SOCKETINFO_MESSAGE: - if(messageType == 2){ - OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Phone acknowledged Socket Info"; - handshakeState = PHONE_RESP_SOCKETINFO; - }else{ - OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Got unexpected message"; - handshakeState = ERROR; - } - break; + case ConnectionStatus::SENT_SOCKETINFO_MESSAGE: + if(messageType == 2) + { + OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Phone acknowledged socket info."; + handshakeState_ = ConnectionStatus::PHONE_RESP_SOCKETINFO; + } + else + { + OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Got unexpected message."; + handshakeState_ = ConnectionStatus::ERROR; + } + break; - case PHONE_RESP_SOCKETINFO: - break; - - case SENDING_NETWORKINFO_MESSAGE: - break; - - case SENT_NETWORKINFO_MESSAGE: - - if(messageType == 6){ - OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Phone acknowledged Network Info with status code: "< 0) - address =adapters.at(0).address(); - else{ - OPENAUTO_LOG(error) << "[btservice] No adapter found"; + if(adapters.size() > 0) + { + address = adapters.at(0).address(); + } + else + { + OPENAUTO_LOG(error) << "[btservice] No adapter found."; } - - - if(!androidBluetoothServer.start(address, servicePortNumber)) + if(!androidBluetoothServer_.start(address, cServicePortNumber)) { OPENAUTO_LOG(error) << "[btservice] Server start failed."; return; } OPENAUTO_LOG(info) << "[btservice] Listening for connections, address: " << address.toString().toStdString() - << ", port: " << servicePortNumber; + << ", port: " << cServicePortNumber; - - if(!androidBluetoothService.registerService(address)) + if(!androidBluetoothService_.registerService(address)) { OPENAUTO_LOG(error) << "[btservice] Service registration failed."; } else { - OPENAUTO_LOG(info) << "[btservice] Service registered, port: " << servicePortNumber; + OPENAUTO_LOG(info) << "[btservice] Service registered, port: " << cServicePortNumber; } } } -} \ No newline at end of file +} diff --git a/btservice_proto/CMakeLists.txt b/btservice_proto/CMakeLists.txt index f71a339..8657643 100644 --- a/btservice_proto/CMakeLists.txt +++ b/btservice_proto/CMakeLists.txt @@ -9,5 +9,5 @@ target_link_libraries(btservice_proto ${PROTOBUF_LIBRARIES}) install(TARGETS btservice_proto DESTINATION lib) install(DIRECTORY . DESTINATION include/btservice_proto - FILES_MATCHING PATTERN *.h - PATTERN CMakeFiles EXCLUDE ) + FILES_MATCHING PATTERN *.h + PATTERN CMakeFiles EXCLUDE) diff --git a/btservice_proto/NetworkInfo.proto b/btservice_proto/NetworkInfo.proto index 7152d09..5fe1416 100644 --- a/btservice_proto/NetworkInfo.proto +++ b/btservice_proto/NetworkInfo.proto @@ -1,11 +1,12 @@ syntax = "proto2"; + package openauto.btservice.proto; - -message NetworkInfo{ +message NetworkInfo +{ required string ssid = 1; required string psk = 2; required string mac_addr = 3; required int32 security_mode = 4; required int32 unknown_2 = 5; -} \ No newline at end of file +} diff --git a/btservice_proto/PhoneResponse.proto b/btservice_proto/PhoneResponse.proto index cb21d33..25fdbd7 100644 --- a/btservice_proto/PhoneResponse.proto +++ b/btservice_proto/PhoneResponse.proto @@ -1,7 +1,8 @@ syntax = "proto3"; + package openauto.btservice.proto; - -message PhoneResponse{ +message PhoneResponse +{ int32 status_code = 1; -} \ No newline at end of file +} diff --git a/btservice_proto/SocketInfo.proto b/btservice_proto/SocketInfo.proto index 7cd7af2..fe940fc 100644 --- a/btservice_proto/SocketInfo.proto +++ b/btservice_proto/SocketInfo.proto @@ -1,9 +1,10 @@ syntax = "proto2"; + package openauto.btservice.proto; - -message SocketInfo{ +message SocketInfo +{ required string address = 1; required int32 port = 2; required int32 unknown_1 = 3; -} \ No newline at end of file +} diff --git a/include/btservice/AndroidBluetoothServer.hpp b/include/btservice/AndroidBluetoothServer.hpp index aa10b1b..07a2eca 100644 --- a/include/btservice/AndroidBluetoothServer.hpp +++ b/include/btservice/AndroidBluetoothServer.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -17,13 +18,25 @@ namespace openauto namespace btservice { +enum class ConnectionStatus +{ + IDLE, + DEVICE_CONNECTED, + SENDING_SOCKETINFO_MESSAGE, + SENT_SOCKETINFO_MESSAGE, + PHONE_RESP_SOCKETINFO, + SENDING_NETWORKINFO_MESSAGE, + SENT_NETWORKINFO_MESSAGE, + PHONE_RESP_NETWORKINFO, + ERROR +}; + class AndroidBluetoothServer: public QObject, public IAndroidBluetoothServer { Q_OBJECT public: - AndroidBluetoothServer(openauto::configuration::IConfiguration::Pointer config_); - + AndroidBluetoothServer(openauto::configuration::IConfiguration::Pointer config); bool start(const QBluetoothAddress& address, uint16_t portNumber) override; private slots: @@ -32,28 +45,15 @@ private slots: private: std::unique_ptr rfcommServer_; - QBluetoothSocket* socket; + QBluetoothSocket* socket_; + openauto::configuration::IConfiguration::Pointer config_; + std::atomic handshakeState_; void writeSocketInfoMessage(); void writeNetworkInfoMessage(); - void stateMachine(); - bool writeProtoMessage(uint16_t messageType, google::protobuf::Message &message); + void eventLoop(); + bool writeProtoMessage(uint16_t messageType, google::protobuf::Message& message); - enum CONNECTION_STATUS { - IDLE, - DEVICE_CONNECTED, - SENDING_SOCKETINFO_MESSAGE, - SENT_SOCKETINFO_MESSAGE, - PHONE_RESP_SOCKETINFO, - SENDING_NETWORKINFO_MESSAGE, - SENT_NETWORKINFO_MESSAGE, - PHONE_RESP_NETWORKINFO, - ERROR - }; - - CONNECTION_STATUS handshakeState = IDLE; -protected: - openauto::configuration::IConfiguration::Pointer config; }; } diff --git a/include/btservice/btservice.hpp b/include/btservice/btservice.hpp index 09f4c87..7bc86e8 100644 --- a/include/btservice/btservice.hpp +++ b/include/btservice/btservice.hpp @@ -5,19 +5,23 @@ #include "btservice/AndroidBluetoothService.hpp" #include "btservice/AndroidBluetoothServer.hpp" #include "openauto/Configuration/Configuration.hpp" -namespace openauto{ -namespace btservice{ +namespace openauto +{ +namespace btservice +{ -class btservice{ - public: - btservice(openauto::configuration::IConfiguration::Pointer config); - private: - const uint16_t servicePortNumber = 22; - openauto::btservice::AndroidBluetoothServer androidBluetoothServer; - openauto::btservice::AndroidBluetoothService androidBluetoothService; +class btservice +{ +public: + btservice(openauto::configuration::IConfiguration::Pointer config); +private: + const uint16_t cServicePortNumber = 22; + + openauto::btservice::AndroidBluetoothService androidBluetoothService_; + openauto::btservice::AndroidBluetoothServer androidBluetoothServer_; }; } -} \ No newline at end of file +} diff --git a/include/openauto/Configuration/Configuration.hpp b/include/openauto/Configuration/Configuration.hpp index 63c70d3..1bd4190 100644 --- a/include/openauto/Configuration/Configuration.hpp +++ b/include/openauto/Configuration/Configuration.hpp @@ -69,8 +69,9 @@ public: void setAudioOutputBackendType(AudioOutputBackendType value) override; std::string getWifiSSID() override; + void setWifiSSID(std::string value) override; std::string getWifiPassword() override; - + void setWifiPassword(std::string value) override; private: void readButtonCodes(boost::property_tree::ptree& iniConfig); @@ -91,8 +92,8 @@ private: bool musicAudioChannelEnabled_; bool speechAudiochannelEnabled_; AudioOutputBackendType audioOutputBackendType_; - std::string ssid; - std::string pskey; + std::string wifiSSID_; + std::string wifiPassword_; static const std::string cConfigFileName; diff --git a/include/openauto/Configuration/IConfiguration.hpp b/include/openauto/Configuration/IConfiguration.hpp index b479146..a4a20ec 100644 --- a/include/openauto/Configuration/IConfiguration.hpp +++ b/include/openauto/Configuration/IConfiguration.hpp @@ -44,9 +44,6 @@ public: virtual void reset() = 0; virtual void save() = 0; - virtual std::string getWifiSSID() = 0; - virtual std::string getWifiPassword() = 0; - virtual void setHandednessOfTrafficType(HandednessOfTrafficType value) = 0; virtual HandednessOfTrafficType getHandednessOfTrafficType() const = 0; virtual void showClock(bool value) = 0; @@ -79,6 +76,11 @@ public: virtual void setSpeechAudioChannelEnabled(bool value) = 0; virtual AudioOutputBackendType getAudioOutputBackendType() const = 0; virtual void setAudioOutputBackendType(AudioOutputBackendType value) = 0; + + virtual std::string getWifiSSID() = 0; + virtual void setWifiSSID(std::string value) = 0; + virtual std::string getWifiPassword() = 0; + virtual void setWifiPassword(std::string value) = 0; }; } diff --git a/include/openauto/Service/AndroidAutoEntity.hpp b/include/openauto/Service/AndroidAutoEntity.hpp index 8882c0b..2d0ee3a 100644 --- a/include/openauto/Service/AndroidAutoEntity.hpp +++ b/include/openauto/Service/AndroidAutoEntity.hpp @@ -54,10 +54,10 @@ public: void onShutdownRequest(const aasdk::proto::messages::ShutdownRequest& request) override; void onShutdownResponse(const aasdk::proto::messages::ShutdownResponse& response) override; void onNavigationFocusRequest(const aasdk::proto::messages::NavigationFocusRequest& request) override; - // void onPingRequest(const aasdk::proto::messages::PingRequest& request) override; // TODO handling ping and voice session + void onPingRequest(const aasdk::proto::messages::PingRequest& request) override; void onPingResponse(const aasdk::proto::messages::PingResponse& response) override; void onChannelError(const aasdk::error::Error& e) override; - // void onVoiceSessionRequest(const aasdk::proto::messages::VoiceSessionRequest& request) override; // TODO handling ping and voice session + void onVoiceSessionRequest(const aasdk::proto::messages::VoiceSessionRequest& request) override; private: using std::enable_shared_from_this::shared_from_this; diff --git a/openauto/CMakeLists.txt b/openauto/CMakeLists.txt index 9a18d06..f648044 100644 --- a/openauto/CMakeLists.txt +++ b/openauto/CMakeLists.txt @@ -1,12 +1,5 @@ add_library(openauto SHARED App.cpp - ../btservice/AndroidBluetoothServer.cpp - ../btservice/AndroidBluetoothService.cpp - ../btservice/btservice.cpp - ${CMAKE_SOURCE_DIR}/include/btservice/AndroidBluetoothServer.hpp - ${CMAKE_SOURCE_DIR}/include/btservice/AndroidBluetoothService.hpp - ${CMAKE_SOURCE_DIR}/include/btservice/IAndroidBluetoothServer.hpp - ${CMAKE_SOURCE_DIR}/include/btservice/IAndroidBluetoothService.hpp Service/BluetoothService.cpp Service/InputService.cpp Service/MediaAudioService.cpp @@ -30,10 +23,17 @@ add_library(openauto SHARED Projection/SequentialBuffer.cpp Projection/DummyBluetoothDevice.cpp Projection/QtVideoOutput.cpp - Projection/GSTVideoOutput.cpp - Projection/QtAudioInput.cpp + Projection/GSTVideoOutput.cpp + Projection/QtAudioInput.cpp Projection/RtAudioOutput.cpp Projection/QtAudioOutput.cpp + ${CMAKE_SOURCE_DIR}/btservice/AndroidBluetoothServer.cpp + ${CMAKE_SOURCE_DIR}/btservice/AndroidBluetoothService.cpp + ${CMAKE_SOURCE_DIR}/btservice/btservice.cpp + ${CMAKE_SOURCE_DIR}/include/btservice/AndroidBluetoothServer.hpp + ${CMAKE_SOURCE_DIR}/include/btservice/AndroidBluetoothService.hpp + ${CMAKE_SOURCE_DIR}/include/btservice/IAndroidBluetoothServer.hpp + ${CMAKE_SOURCE_DIR}/include/btservice/IAndroidBluetoothService.hpp ${CMAKE_SOURCE_DIR}/include/openauto/App.hpp ${CMAKE_SOURCE_DIR}/include/openauto/Configuration/Configuration.hpp ${CMAKE_SOURCE_DIR}/include/openauto/Configuration/RecentAddressesList.hpp @@ -61,7 +61,7 @@ add_library(openauto SHARED ${CMAKE_SOURCE_DIR}/include/openauto/Service/IService.hpp ${CMAKE_SOURCE_DIR}/include/openauto/Service/Pinger.hpp ${CMAKE_SOURCE_DIR}/include/openauto/Service/InputService.hpp - ${CMAKE_SOURCE_DIR}/include/openauto/Projection/IInputDeviceEventHandler.hpp + ${CMAKE_SOURCE_DIR}/include/openauto/Projection/IInputDeviceEventHandler.hpp ${CMAKE_SOURCE_DIR}/include/openauto/Projection/IVideoOutput.hpp ${CMAKE_SOURCE_DIR}/include/openauto/Projection/RtAudioOutput.hpp ${CMAKE_SOURCE_DIR}/include/openauto/Projection/LocalBluetoothDevice.hpp @@ -84,19 +84,19 @@ add_library(openauto SHARED if(GST_BUILD) target_sources(openauto PRIVATE ${CMAKE_SOURCE_DIR}/include/openauto/Projection/GSTVideoOutput.hpp - ) + ) target_include_directories(openauto SYSTEM PUBLIC - ${QTGSTREAMER_INCLUDE_DIR} - ${GST_INCLUDE_DIRS} - ) + ${QTGSTREAMER_INCLUDE_DIR} + ${GST_INCLUDE_DIRS} + ) target_link_libraries(openauto PRIVATE - ${QTGSTREAMER_LIBRARY} - ${GST_LIBRARIES} - ${Qt5QuickWidgets_LIBRARIES} - ${QTGSTREAMER_QUICK_LIBRARY} - ) + ${QTGSTREAMER_LIBRARY} + ${GST_LIBRARIES} + ${Qt5QuickWidgets_LIBRARIES} + ${QTGSTREAMER_QUICK_LIBRARY} + ) endif() target_include_directories(openauto PRIVATE diff --git a/openauto/Configuration/Configuration.cpp b/openauto/Configuration/Configuration.cpp index 7c21c5c..472870c 100644 --- a/openauto/Configuration/Configuration.cpp +++ b/openauto/Configuration/Configuration.cpp @@ -102,8 +102,9 @@ void Configuration::load() musicAudioChannelEnabled_ = iniConfig.get(cAudioMusicAudioChannelEnabled, true); speechAudiochannelEnabled_ = iniConfig.get(cAudioSpeechAudioChannelEnabled, true); audioOutputBackendType_ = static_cast(iniConfig.get(cAudioOutputBackendType, static_cast(AudioOutputBackendType::RTAUDIO))); - ssid = iniConfig.get(cWifiSSID, ""); - pskey = iniConfig.get(cWifiPskey, ""); + + wifiSSID_ = iniConfig.get(cWifiSSID, ""); + wifiPassword_ = iniConfig.get(cWifiPskey, ""); } catch(const boost::property_tree::ini_parser_error& e) { @@ -154,10 +155,10 @@ void Configuration::save() iniConfig.put(cAudioMusicAudioChannelEnabled, musicAudioChannelEnabled_); iniConfig.put(cAudioSpeechAudioChannelEnabled, speechAudiochannelEnabled_); iniConfig.put(cAudioOutputBackendType, static_cast(audioOutputBackendType_)); - iniConfig.put(cWifiSSID, ssid); - iniConfig.put(cWifiPskey, pskey); - boost::property_tree::ini_parser::write_ini(cConfigFileName, iniConfig); + iniConfig.put(cWifiSSID, wifiSSID_); + iniConfig.put(cWifiPskey, wifiPassword_); + boost::property_tree::ini_parser::write_ini(cConfigFileName, iniConfig); } void Configuration::setHandednessOfTrafficType(HandednessOfTrafficType value) @@ -302,14 +303,23 @@ void Configuration::setAudioOutputBackendType(AudioOutputBackendType value) std::string Configuration::getWifiSSID() { - return ssid; + return wifiSSID_; +} + +void Configuration::setWifiSSID(std::string value) +{ + wifiSSID_ = value; } std::string Configuration::getWifiPassword() { - return pskey; + return wifiPassword_; } +void Configuration::setWifiPassword(std::string value) +{ + wifiPassword_ = value; +} void Configuration::readButtonCodes(boost::property_tree::ptree& iniConfig) { diff --git a/openauto/Service/AndroidAutoEntity.cpp b/openauto/Service/AndroidAutoEntity.cpp index 08ddf99..9c6e88d 100644 --- a/openauto/Service/AndroidAutoEntity.cpp +++ b/openauto/Service/AndroidAutoEntity.cpp @@ -223,11 +223,9 @@ void AndroidAutoEntity::onNavigationFocusRequest(const aasdk::proto::messages::N controlServiceChannel_->receive(this->shared_from_this()); } -/* void AndroidAutoEntity::onVoiceSessionRequest(const aasdk::proto::messages::VoiceSessionRequest& request) +void AndroidAutoEntity::onVoiceSessionRequest(const aasdk::proto::messages::VoiceSessionRequest& request) { - - OPENAUTO_LOG(info) << "[AndroidAutoEntity] Voice session request, type: " << (request.type()==1)?("START"):((request.type()==2)?("STOP"):("UNKNOWN")); - + OPENAUTO_LOG(info) << "[AndroidAutoEntity] Voice session request, type: " << ((request.type() == 1) ? "START" : ((request.type() == 2) ? "STOP" : "UNKNOWN")); auto promise = aasdk::channel::SendPromise::defer(strand_); promise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1)); @@ -237,13 +235,14 @@ void AndroidAutoEntity::onNavigationFocusRequest(const aasdk::proto::messages::N void AndroidAutoEntity::onPingRequest(const aasdk::proto::messages::PingRequest& request) { OPENAUTO_LOG(info) << "[AndroidAutoEntity] Ping Request"; + aasdk::proto::messages::PingResponse response; response.set_timestamp(request.timestamp()); auto promise = aasdk::channel::SendPromise::defer(strand_); promise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1)); controlServiceChannel_->sendPingResponse(response, std::move(promise)); controlServiceChannel_->receive(this->shared_from_this()); -} */ // TODO handling ping and voice session +} void AndroidAutoEntity::onPingResponse(const aasdk::proto::messages::PingResponse&) {