cleanup wireless device connection (#14)

* initial cleanup passthrough

* bad copypaste

* add back ! and more style fixes

* handling ping and voice session
This commit is contained in:
Robert Stanley Judka 2020-08-28 17:36:43 -05:00 committed by GitHub
parent ae66394b6b
commit 23c38158ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 281 additions and 237 deletions

16
.gitignore vendored
View File

@ -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

View File

@ -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)

View File

@ -1,74 +1,71 @@
#include "OpenautoLog.hpp"
#include "btservice/AndroidBluetoothServer.hpp"
#include <QNetworkInterface>
#include <QThread>
#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<QBluetoothServer>(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<QHostAddress> list = QNetworkInterface::allAddresses();
for(int nIter=0; nIter<list.count(); nIter++)
QString ipAddr;
foreach(QHostAddress addr, QNetworkInterface::allAddresses())
{
if(!addr.isLoopback() && (addr.protocol() == QAbstractSocket::IPv4Protocol))
{
if(!list[nIter].isLoopback())
if (list[nIter].protocol() == QAbstractSocket::IPv4Protocol )
ipAddr = list[nIter].toString();
ipAddr = addr.toString();
}
socketInfo.set_address(ipAddr.toStdString());
socketInfo.set_port(5000);
socketInfo.set_unknown_1(0);
}
if(writeProtoMessage(7, socketInfo)){
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Sent Socket Info";
handshakeState = SENT_SOCKETINFO_MESSAGE;
}
else{
OPENAUTO_LOG(error) << "[AndroidBluetoothServer] Error Sending Socket Info";
handshakeState = ERROR;
}
btservice::proto::SocketInfo socketInfo;
socketInfo.set_address(ipAddr.toStdString());
socketInfo.set_port(5000);
socketInfo.set_unknown_1(0);
if(this->writeProtoMessage(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: "<<resp.status_code();
handshakeState = PHONE_RESP_NETWORKINFO;
}else{
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Got unexpected message";
handshakeState = ERROR;
}
break;
case PHONE_RESP_NETWORKINFO:
break;
case ConnectionStatus::SENT_NETWORKINFO_MESSAGE:
if(messageType == 6)
{
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Phone acknowledged network info with status code: " << resp.status_code();
handshakeState_ = ConnectionStatus::PHONE_RESP_NETWORKINFO;
}
else
{
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Got unexpected message";
handshakeState_ = ConnectionStatus::ERROR;
}
break;
}
}
}
}
}

View File

@ -1,36 +1,43 @@
#include "btservice/btservice.hpp"
namespace openauto{
namespace btservice{
btservice::btservice(openauto::configuration::IConfiguration::Pointer config) : androidBluetoothService(servicePortNumber), androidBluetoothServer(config){
namespace openauto
{
namespace btservice
{
btservice::btservice(openauto::configuration::IConfiguration::Pointer config)
: androidBluetoothService_(cServicePortNumber)
, androidBluetoothServer_(config)
{
QBluetoothAddress address;
auto adapters = QBluetoothLocalDevice::allDevices();
if (adapters.size() > 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;
}
}
}
}
}

View File

@ -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)

View File

@ -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;
}
}

View File

@ -1,7 +1,8 @@
syntax = "proto3";
package openauto.btservice.proto;
message PhoneResponse{
message PhoneResponse
{
int32 status_code = 1;
}
}

View File

@ -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;
}
}

View File

@ -1,6 +1,7 @@
#pragma once
#include <stdint.h>
#include <atomic>
#include <memory>
#include <sstream>
#include <QBluetoothServer>
@ -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<QBluetoothServer> rfcommServer_;
QBluetoothSocket* socket;
QBluetoothSocket* socket_;
openauto::configuration::IConfiguration::Pointer config_;
std::atomic<ConnectionStatus> 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;
};
}

View File

@ -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_;
};
}
}
}

View File

@ -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;

View File

@ -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;
};
}

View File

@ -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<AndroidAutoEntity>::shared_from_this;

View File

@ -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

View File

@ -102,8 +102,9 @@ void Configuration::load()
musicAudioChannelEnabled_ = iniConfig.get<bool>(cAudioMusicAudioChannelEnabled, true);
speechAudiochannelEnabled_ = iniConfig.get<bool>(cAudioSpeechAudioChannelEnabled, true);
audioOutputBackendType_ = static_cast<AudioOutputBackendType>(iniConfig.get<uint32_t>(cAudioOutputBackendType, static_cast<uint32_t>(AudioOutputBackendType::RTAUDIO)));
ssid = iniConfig.get<std::string>(cWifiSSID, "");
pskey = iniConfig.get<std::string>(cWifiPskey, "");
wifiSSID_ = iniConfig.get<std::string>(cWifiSSID, "");
wifiPassword_ = iniConfig.get<std::string>(cWifiPskey, "");
}
catch(const boost::property_tree::ini_parser_error& e)
{
@ -154,10 +155,10 @@ void Configuration::save()
iniConfig.put<bool>(cAudioMusicAudioChannelEnabled, musicAudioChannelEnabled_);
iniConfig.put<bool>(cAudioSpeechAudioChannelEnabled, speechAudiochannelEnabled_);
iniConfig.put<uint32_t>(cAudioOutputBackendType, static_cast<uint32_t>(audioOutputBackendType_));
iniConfig.put<std::string>(cWifiSSID, ssid);
iniConfig.put<std::string>(cWifiPskey, pskey);
boost::property_tree::ini_parser::write_ini(cConfigFileName, iniConfig);
iniConfig.put<std::string>(cWifiSSID, wifiSSID_);
iniConfig.put<std::string>(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)
{

View File

@ -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&)
{