From c701e0bd67ae2e8ea592682da947718561b7b1cd Mon Sep 17 00:00:00 2001 From: "Simon.Dean" Date: Fri, 11 Feb 2022 10:19:12 +0000 Subject: [PATCH 1/7] Swap getSize() to getFrameSize() and add totalSize() for completeness. --- include/aasdk/Messenger/FrameSize.hpp | 3 ++- src/Messenger/FrameSize.cpp | 9 ++++++++- src/Messenger/MessageInStream.cpp | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/aasdk/Messenger/FrameSize.hpp b/include/aasdk/Messenger/FrameSize.hpp index d7798195..d9b06378 100644 --- a/include/aasdk/Messenger/FrameSize.hpp +++ b/include/aasdk/Messenger/FrameSize.hpp @@ -35,7 +35,8 @@ class FrameSize FrameSize(const common::DataConstBuffer& buffer); common::Data getData() const; - size_t getSize() const; + size_t getFrameSize() const; + size_t getTotalSize() const; static size_t getSizeOf(FrameSizeType type); diff --git a/src/Messenger/FrameSize.cpp b/src/Messenger/FrameSize.cpp index 6f987c3c..e92f35a3 100644 --- a/src/Messenger/FrameSize.cpp +++ b/src/Messenger/FrameSize.cpp @@ -47,6 +47,7 @@ FrameSize::FrameSize(const common::DataConstBuffer& buffer) { frameSizeType_ = FrameSizeType::SHORT; frameSize_ = boost::endian::big_to_native(reinterpret_cast(buffer.cdata[0])); + totalSize_ = frameSize_; } if(buffer.size >= 6) @@ -74,11 +75,17 @@ common::Data FrameSize::getData() const return data; } -size_t FrameSize::getSize() const +size_t FrameSize::getFrameSize() const { return frameSize_; } +size_t FrameSize::getTotalSize() const +{ + return totalSize_; +} + + size_t FrameSize::getSizeOf(FrameSizeType type) { return type == FrameSizeType::EXTENDED ? 6 : 2; diff --git a/src/Messenger/MessageInStream.cpp b/src/Messenger/MessageInStream.cpp index cd0b5250..9c638014 100644 --- a/src/Messenger/MessageInStream.cpp +++ b/src/Messenger/MessageInStream.cpp @@ -119,7 +119,8 @@ void MessageInStream::receiveFrameSizeHandler(const common::DataConstBuffer& buf }); FrameSize frameSize(buffer); - transport_->receive(frameSize.getSize(), std::move(transportPromise)); + frameSize_ = (int) frameSize.getFrameSize(); + transport_->receive(frameSize.getFrameSize(), std::move(transportPromise)); } void MessageInStream::receiveFramePayloadHandler(const common::DataConstBuffer& buffer) From 4f2f812e67691a67124cbdcbd4290448f2b340e1 Mon Sep 17 00:00:00 2001 From: "Simon.Dean" Date: Fri, 11 Feb 2022 10:19:33 +0000 Subject: [PATCH 2/7] Add SSL Error Logging --- src/Transport/SSLWrapper.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Transport/SSLWrapper.cpp b/src/Transport/SSLWrapper.cpp index 6aca9b44..f07f9837 100644 --- a/src/Transport/SSLWrapper.cpp +++ b/src/Transport/SSLWrapper.cpp @@ -22,7 +22,7 @@ #include #include #include - +#include namespace aasdk { @@ -48,6 +48,8 @@ SSLWrapper::~SSLWrapper() ERR_remove_state(0); #endif ERR_free_strings(); + ERR_load_crypto_strings(); + ERR_load_ERR_strings(); } X509* SSLWrapper::readCertificate(const std::string& certificate) @@ -187,6 +189,9 @@ int SSLWrapper::sslWrite(SSL *ssl, const void *buf, int num) int SSLWrapper::getError(SSL* ssl, int returnCode) { + while (auto err = ERR_get_error()) { + AASDK_LOG(error) << "[SSLWrapper] SSL Error " << ERR_error_string(err, NULL); + } return SSL_get_error(ssl, returnCode); } From fbaffbc466a3f8bf720228600334166baefb7187 Mon Sep 17 00:00:00 2001 From: "Simon.Dean" Date: Fri, 11 Feb 2022 10:29:02 +0000 Subject: [PATCH 3/7] Switch decrypt() to read the number of bytes from the frame size. --- include/aasdk/Messenger/Cryptor.hpp | 2 +- include/aasdk/Messenger/ICryptor.hpp | 2 +- src/Messenger/Cryptor.cpp | 20 +++++++++++++------- src/Messenger/MessageInStream.cpp | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/include/aasdk/Messenger/Cryptor.hpp b/include/aasdk/Messenger/Cryptor.hpp index c74a135f..d8b178a0 100644 --- a/include/aasdk/Messenger/Cryptor.hpp +++ b/include/aasdk/Messenger/Cryptor.hpp @@ -37,7 +37,7 @@ class Cryptor: public ICryptor void deinit() override; bool doHandshake() override; size_t encrypt(common::Data& output, const common::DataConstBuffer& buffer) override; - size_t decrypt(common::Data& output, const common::DataConstBuffer& buffer) override; + size_t decrypt(common::Data& output, const common::DataConstBuffer& buffer, int length) override; common::Data readHandshakeBuffer() override; void writeHandshakeBuffer(const common::DataConstBuffer& buffer) override; diff --git a/include/aasdk/Messenger/ICryptor.hpp b/include/aasdk/Messenger/ICryptor.hpp index eb52f79d..bc2ba1f6 100644 --- a/include/aasdk/Messenger/ICryptor.hpp +++ b/include/aasdk/Messenger/ICryptor.hpp @@ -39,7 +39,7 @@ class ICryptor virtual void deinit() = 0; virtual bool doHandshake() = 0; virtual size_t encrypt(common::Data& output, const common::DataConstBuffer& buffer) = 0; - virtual size_t decrypt(common::Data& output, const common::DataConstBuffer& buffer) = 0; + virtual size_t decrypt(common::Data& output, const common::DataConstBuffer& buffer, int length) = 0; virtual common::Data readHandshakeBuffer() = 0; virtual void writeHandshakeBuffer(const common::DataConstBuffer& buffer) = 0; virtual bool isActive() const = 0; diff --git a/src/Messenger/Cryptor.cpp b/src/Messenger/Cryptor.cpp index 154e37c6..fca0a25f 100644 --- a/src/Messenger/Cryptor.cpp +++ b/src/Messenger/Cryptor.cpp @@ -20,7 +20,7 @@ #include #include #include - +#include namespace aasdk { @@ -178,18 +178,23 @@ size_t Cryptor::encrypt(common::Data& output, const common::DataConstBuffer& buf return this->read(output); } -size_t Cryptor::decrypt(common::Data& output, const common::DataConstBuffer& buffer) +size_t Cryptor::decrypt(common::Data& output, const common::DataConstBuffer& buffer, int frameLength) { + int overhead = 29; + int length = frameLength - overhead; std::lock_guard lock(mutex_); this->write(buffer); const size_t beginOffset = output.size(); - output.resize(beginOffset + 1); - size_t availableBytes = 1; - size_t totalReadSize = 0; + size_t totalReadSize = 0; // Initialise + size_t availableBytes = length; + size_t readBytes = (length - totalReadSize) > 2048 ? 2048 : length - totalReadSize; // Calculate How many Bytes to Read + output.resize(output.size() + readBytes); // Resize Output to match the bytes we want to read + + // We try to be a bit more explicit here, using the frame length from the frame itself rather than just blindly reading from the SSL buffer. - while(availableBytes > 0) + while(readBytes > 0) { const auto& currentBuffer = common::DataBuffer(output, totalReadSize + beginOffset); auto readSize = sslWrapper_->sslRead(ssl_, currentBuffer.data, currentBuffer.size); @@ -201,7 +206,8 @@ size_t Cryptor::decrypt(common::Data& output, const common::DataConstBuffer& buf totalReadSize += readSize; availableBytes = sslWrapper_->getAvailableBytes(ssl_); - output.resize(output.size() + availableBytes); + readBytes = (length - totalReadSize) > 2048 ? 2048 : length - totalReadSize; + output.resize(output.size() + readBytes); } return totalReadSize; diff --git a/src/Messenger/MessageInStream.cpp b/src/Messenger/MessageInStream.cpp index 9c638014..c39e0a6a 100644 --- a/src/Messenger/MessageInStream.cpp +++ b/src/Messenger/MessageInStream.cpp @@ -129,7 +129,7 @@ void MessageInStream::receiveFramePayloadHandler(const common::DataConstBuffer& { try { - cryptor_->decrypt(message_->getPayload(), buffer); + cryptor_->decrypt(message_->getPayload(), buffer, frameSize_); } catch(const error::Error& e) { From 069b88acc401ebe3ddb1eac9797bfe24859b1c16 Mon Sep 17 00:00:00 2001 From: "Simon.Dean" Date: Fri, 11 Feb 2022 10:33:36 +0000 Subject: [PATCH 4/7] Support FrameType descriptor --- include/aasdk/Messenger/FrameType.hpp | 3 ++ src/Messenger/FrameType.cpp | 44 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/Messenger/FrameType.cpp diff --git a/include/aasdk/Messenger/FrameType.hpp b/include/aasdk/Messenger/FrameType.hpp index 06e2d017..08252948 100644 --- a/include/aasdk/Messenger/FrameType.hpp +++ b/include/aasdk/Messenger/FrameType.hpp @@ -19,6 +19,7 @@ #pragma once #include +#include namespace aasdk @@ -34,5 +35,7 @@ enum class FrameType BULK = FIRST | LAST }; +std::string frameTypeToString(FrameType frameType); + } } diff --git a/src/Messenger/FrameType.cpp b/src/Messenger/FrameType.cpp new file mode 100644 index 00000000..b4b80a90 --- /dev/null +++ b/src/Messenger/FrameType.cpp @@ -0,0 +1,44 @@ +/* +* This file is part of aasdk library project. +* Copyright (C) 2018 f1x.studio (Michal Szwaj) +* +* 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 . +*/ + +#include + +namespace aasdk +{ + namespace messenger + { + + std::string frameTypeToString(FrameType frameType) + { + switch(frameType) + { + case FrameType::MIDDLE: + return "MIDDLE"; + case FrameType::FIRST: + return "FIRST"; + case FrameType::LAST: + return "LAST"; + case FrameType::BULK: + return "BULK"; + default: + return "(null)"; + } + } + + } +} From 69a162666d8dde04bb75bdacb8e0dc35d0b58c9e Mon Sep 17 00:00:00 2001 From: "Simon.Dean" Date: Fri, 11 Feb 2022 12:35:07 +0000 Subject: [PATCH 5/7] Rework Message Handling. Slight tweaks - Add isInterleaved boolean - If message is NULL and Frame Type is MIDDLE or LAST, then look for an existing message in buffer (if the message_ is null, then we need a FIRST or BULK frame) - If message is still NULL, then we will create a new message, but recognise it as a valid frame ONLY if this is a FIRST or BULK frame because we cannot start on a MIDDLE or LAST. - Rename recentFrameType to thisFrameType for more accuracy - Only Resolve the Frame if the frame is BULK or LAST and the frame is valid. - If the frame is interleaved, then we will use our interleavedPromise handler. Only resolve the main promise if the frame is not interleaved. - Also reset message once resolved. - Carry on reading if the original promise is not resolved (ie FIRST, MIDDLE, or Interleaved frame) - Add some counters for debugging purposes. --- include/aasdk/Messenger/IMessageInStream.hpp | 3 +- include/aasdk/Messenger/MessageInStream.hpp | 13 +- include/aasdk/Messenger/Messenger.hpp | 5 + src/Messenger/MessageInStream.cpp | 126 ++++++++++++------- src/Messenger/Messenger.cpp | 56 ++++++++- 5 files changed, 151 insertions(+), 52 deletions(-) diff --git a/include/aasdk/Messenger/IMessageInStream.hpp b/include/aasdk/Messenger/IMessageInStream.hpp index 0d9e7981..b64e4b09 100644 --- a/include/aasdk/Messenger/IMessageInStream.hpp +++ b/include/aasdk/Messenger/IMessageInStream.hpp @@ -35,7 +35,8 @@ class IMessageInStream IMessageInStream() = default; virtual ~IMessageInStream() = default; - virtual void startReceive(ReceivePromise::Pointer promise) = 0; + virtual void startReceive(ReceivePromise::Pointer promise, ChannelId channelId, int promiseIndex, int messageIndex) = 0; + virtual void setInterleavedHandler(ReceivePromise::Pointer promise) = 0; }; } diff --git a/include/aasdk/Messenger/MessageInStream.hpp b/include/aasdk/Messenger/MessageInStream.hpp index 29e9c440..ad44a158 100644 --- a/include/aasdk/Messenger/MessageInStream.hpp +++ b/include/aasdk/Messenger/MessageInStream.hpp @@ -37,7 +37,8 @@ class MessageInStream: public IMessageInStream, public std::enable_shared_from_t public: MessageInStream(boost::asio::io_service& ioService, transport::ITransport::Pointer transport, ICryptor::Pointer cryptor); - void startReceive(ReceivePromise::Pointer promise) override; + void startReceive(ReceivePromise::Pointer promise, ChannelId channelId, int promiseIndex, int messageIndex) override; + void setInterleavedHandler(ReceivePromise::Pointer promise) override; private: using std::enable_shared_from_this::shared_from_this; @@ -49,10 +50,18 @@ class MessageInStream: public IMessageInStream, public std::enable_shared_from_t boost::asio::io_service::strand strand_; transport::ITransport::Pointer transport_; ICryptor::Pointer cryptor_; - FrameType recentFrameType_; + + FrameType thisFrameType_; ReceivePromise::Pointer promise_; + ReceivePromise::Pointer interleavedPromise_; Message::Pointer message_; + std::map messageBuffer_; + + int frameSize_; + bool isInterleaved_; + bool isValidFrame_; + int currentMessageIndex_; }; } diff --git a/include/aasdk/Messenger/Messenger.hpp b/include/aasdk/Messenger/Messenger.hpp index 6956320d..c1f4c3c0 100644 --- a/include/aasdk/Messenger/Messenger.hpp +++ b/include/aasdk/Messenger/Messenger.hpp @@ -47,7 +47,9 @@ class Messenger: public IMessenger, public std::enable_shared_from_this #include - +#include +#include namespace aasdk { @@ -30,65 +31,87 @@ MessageInStream::MessageInStream(boost::asio::io_service& ioService, transport:: , transport_(std::move(transport)) , cryptor_(std::move(cryptor)) { - + currentMessageIndex_ = 0; } -void MessageInStream::startReceive(ReceivePromise::Pointer promise) +void MessageInStream::startReceive(ReceivePromise::Pointer promise, ChannelId channelId, int promiseIndex, int messageIndex) { + AASDK_LOG(debug) << "[MessageInStream] 1. Start Receive called with channel " << channelIdToString(channelId) << " PI " << std::to_string(promiseIndex) << " MI " << std::to_string(messageIndex); + strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable { - if(promise_ == nullptr) - { + if (promise_ == nullptr) { promise_ = std::move(promise); - auto transportPromise = transport::ITransport::ReceivePromise::defer(strand_); transportPromise->then( - [this, self = this->shared_from_this()](common::Data data) mutable { - this->receiveFrameHeaderHandler(common::DataConstBuffer(data)); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - promise_->reject(e); - promise_.reset(); - }); + [this, self = this->shared_from_this()](common::Data data) mutable { + this->receiveFrameHeaderHandler(common::DataConstBuffer(data)); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + AASDK_LOG(debug) << "[MessageInStream] 2. Error Here?"; + promise_->reject(e); + promise_.reset(); + }); transport_->receive(FrameHeader::getSizeOf(), std::move(transportPromise)); - } - else - { + } else { + AASDK_LOG(debug) << "[MessageInStream] 3. Operation in Progress."; promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); } }); } +void MessageInStream::setInterleavedHandler(ReceivePromise::Pointer promise) +{ + interleavedPromise_ = std::move(promise); +} + void MessageInStream::receiveFrameHeaderHandler(const common::DataConstBuffer& buffer) { FrameHeader frameHeader(buffer); - if(message_ != nullptr && message_->getChannelId() != frameHeader.getChannelId()) - { + AASDK_LOG(debug) << "[MessageInStream] 5. Processing Frame Header: Ch " << channelIdToString(frameHeader.getChannelId()) << " Fr " << frameTypeToString(frameHeader.getType()); + + isValidFrame_ = true; + isInterleaved_ = false; + + // New Promise or Interleaved + if(message_ != nullptr && message_->getChannelId() != frameHeader.getChannelId()) { + // We have an existing message but the channels don't match... + AASDK_LOG(debug) << "[MessageInStream] 6. Interleaved ChannelId MisMatch - F: " << channelIdToString(frameHeader.getChannelId()) << " M: " << channelIdToString(message_->getChannelId()); + + isInterleaved_ = true; + + // Store message in buffer; messageBuffer_[message_->getChannelId()] = message_; - message_ = nullptr; + message_.reset(); } - auto bufferedMessage = messageBuffer_.find(frameHeader.getChannelId()); + // Look for Buffered Message + if ((message_ == nullptr) && (frameHeader.getType() == FrameType::MIDDLE || frameHeader.getType() == FrameType::LAST)) { + AASDK_LOG(debug) << "[MessageInStream] 7. Null Message but Middle or Last Frame."; + auto bufferedMessage = messageBuffer_.find(frameHeader.getChannelId()); + if (bufferedMessage != messageBuffer_.end()) { + AASDK_LOG(debug) << "[MessageInStream] 8. Found Existing Message on Channel."; - if(bufferedMessage != messageBuffer_.end()) - { - if(frameHeader.getType() != FrameType::FIRST) - { message_ = bufferedMessage->second; + messageBuffer_.erase(bufferedMessage); + + isInterleaved_ = false; } - else - { - message_ = std::make_shared(frameHeader.getChannelId(), frameHeader.getEncryptionType(), frameHeader.getMessageType()); - } - messageBuffer_.erase(bufferedMessage); } - else if(message_ == nullptr) - { + + if (message_ == nullptr) { + if (frameHeader.getType() == FrameType::FIRST || frameHeader.getType() == FrameType::BULK) { + AASDK_LOG(debug) << "[MessageInStream] 11. New message created with Index " << std::to_string(currentMessageIndex_); + currentMessageIndex_++; + } else { + // This will be an invalid message, but we still need to read from the buffer. + isValidFrame_ = false; + } message_ = std::make_shared(frameHeader.getChannelId(), frameHeader.getEncryptionType(), frameHeader.getMessageType()); } - recentFrameType_ = frameHeader.getType(); + thisFrameType_ = frameHeader.getType(); const size_t frameSize = FrameSize::getSizeOf(frameHeader.getType() == FrameType::FIRST ? FrameSizeType::EXTENDED : FrameSizeType::SHORT); auto transportPromise = transport::ITransport::ReceivePromise::defer(strand_); @@ -144,23 +167,36 @@ void MessageInStream::receiveFramePayloadHandler(const common::DataConstBuffer& message_->insertPayload(buffer); } - if(recentFrameType_ == FrameType::BULK || recentFrameType_ == FrameType::LAST) + bool isResolved = false; + + // If this is the LAST frame or a BULK frame... + if((thisFrameType_ == FrameType::BULK || thisFrameType_ == FrameType::LAST) && isValidFrame_) { - promise_->resolve(std::move(message_)); - promise_.reset(); + if (!isInterleaved_) { + AASDK_LOG(debug) << "[MessageInStream] 12. Resolving Normal message. " << std::to_string(currentMessageIndex_); + promise_->resolve(std::move(message_)); + promise_.reset(); + isResolved = true; + } else { + AASDK_LOG(debug) << "[MessageInStream] 13. Resolving Interleaved Message. " << std::to_string(currentMessageIndex_); + interleavedPromise_->resolve(std::move(message_)); + } + currentMessageIndex_--; + message_.reset(); } - else - { + + // If the main promise isn't resolved, then carry on retrieving frame headers. + if (!isResolved) { auto transportPromise = transport::ITransport::ReceivePromise::defer(strand_); transportPromise->then( - [this, self = this->shared_from_this()](common::Data data) mutable { - this->receiveFrameHeaderHandler(common::DataConstBuffer(data)); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - message_.reset(); - promise_->reject(e); - promise_.reset(); - }); + [this, self = this->shared_from_this()](common::Data data) mutable { + this->receiveFrameHeaderHandler(common::DataConstBuffer(data)); + }, + [this, self = this->shared_from_this()](const error::Error& e) mutable { + message_.reset(); + promise_->reject(e); + promise_.reset(); + }); transport_->receive(FrameHeader::getSizeOf(), std::move(transportPromise)); } diff --git a/src/Messenger/Messenger.cpp b/src/Messenger/Messenger.cpp index 0c8d7cb2..2dfd5151 100644 --- a/src/Messenger/Messenger.cpp +++ b/src/Messenger/Messenger.cpp @@ -19,7 +19,7 @@ #include #include #include - +#include namespace aasdk { @@ -32,26 +32,43 @@ Messenger::Messenger(boost::asio::io_service& ioService, IMessageInStream::Point , messageInStream_(std::move(messageInStream)) , messageOutStream_(std::move(messageOutStream)) { - + currentPromiseIndex_ = 0; + currentMessageIndex_ = 0; } void Messenger::enqueueReceive(ChannelId channelId, ReceivePromise::Pointer promise) { + // enqueueReceive is called from the service channel. + AASDK_LOG(debug) << "[Messenger] 1. enqueueReceived called on Channel " << channelIdToString(channelId); + receiveStrand_.dispatch([this, self = this->shared_from_this(), channelId, promise = std::move(promise)]() mutable { + auto interleavedPromise = ReceivePromise::defer(receiveStrand_); + interleavedPromise->then(std::bind(&Messenger::interleavedMessageHandler, this->shared_from_this(), std::placeholders::_1), + std::bind(&Messenger::rejectInterleavedMessageHandler, this->shared_from_this(), std::placeholders::_1)); + messageInStream_->setInterleavedHandler(std::move(interleavedPromise)); + + //If there's any messages on the channel, resolve. The channel will call enqueueReceive again. if(!channelReceiveMessageQueue_.empty(channelId)) { promise->resolve(std::move(channelReceiveMessageQueue_.pop(channelId))); + AASDK_LOG(debug) << "[Messenger] 2. Message Queue not Empty. Resolving promise with Existing Message."; } else { + currentPromiseIndex_++; + AASDK_LOG(debug) << "[Messenger] 3. Message Queue is Empty. Pushing Promise on Index " << std::to_string(currentPromiseIndex_); channelReceivePromiseQueue_.push(channelId, std::move(promise)); if(channelReceivePromiseQueue_.size() == 1) { + currentMessageIndex_++; + + AASDK_LOG(debug) << "[Messenger] 4. Calling startReceive on MessageIndex " << std::to_string(currentMessageIndex_); + auto inStreamPromise = ReceivePromise::defer(receiveStrand_); inStreamPromise->then(std::bind(&Messenger::inStreamMessageHandler, this->shared_from_this(), std::placeholders::_1), std::bind(&Messenger::rejectReceivePromiseQueue, this->shared_from_this(), std::placeholders::_1)); - messageInStream_->startReceive(std::move(inStreamPromise)); + messageInStream_->startReceive(std::move(inStreamPromise), channelId, currentPromiseIndex_, currentMessageIndex_); } } }); @@ -72,22 +89,32 @@ void Messenger::enqueueSend(Message::Pointer message, SendPromise::Pointer promi void Messenger::inStreamMessageHandler(Message::Pointer message) { auto channelId = message->getChannelId(); + AASDK_LOG(debug) << "[Messenger] 5. inStreamMessageHandler from Channel " << channelIdToString(channelId); + + currentMessageIndex_--; + // If there's a promise on the queue, we resolve the promise with this message.... if(channelReceivePromiseQueue_.isPending(channelId)) { channelReceivePromiseQueue_.pop(channelId)->resolve(std::move(message)); + currentPromiseIndex_--; } else { + // Or we push the message to the Message Queue for when we do get a promise + AASDK_LOG(debug) << "[Messenger] 7. Pushing Message to Queue as we have no Pending Promises." << std::to_string(currentPromiseIndex_); channelReceiveMessageQueue_.push(std::move(message)); } if(!channelReceivePromiseQueue_.empty()) { + currentMessageIndex_++; + AASDK_LOG(debug) << "[Messenger] 8. Calling startReceive on PromiseIndex " << std::to_string(currentPromiseIndex_) << " and MessageIndex " << std::to_string(currentMessageIndex_); + auto inStreamPromise = ReceivePromise::defer(receiveStrand_); inStreamPromise->then(std::bind(&Messenger::inStreamMessageHandler, this->shared_from_this(), std::placeholders::_1), std::bind(&Messenger::rejectReceivePromiseQueue, this->shared_from_this(), std::placeholders::_1)); - messageInStream_->startReceive(std::move(inStreamPromise)); + messageInStream_->startReceive(std::move(inStreamPromise), channelId, currentPromiseIndex_,currentMessageIndex_); } } @@ -101,6 +128,20 @@ void Messenger::doSend() messageOutStream_->stream(std::move(queueElementIter->first), std::move(outStreamPromise)); } +void Messenger::interleavedMessageHandler(Message::Pointer message) +{ + auto channelId = message->getChannelId(); + + AASDK_LOG(debug) << "[Messenger] 9. interleavedMessageHandler from Channel " << channelIdToString(channelId); + + channelReceiveMessageQueue_.push(std::move(message)); + + auto interleavedPromise = ReceivePromise::defer(receiveStrand_); + interleavedPromise->then(std::bind(&Messenger::interleavedMessageHandler, this->shared_from_this(), std::placeholders::_1), + std::bind(&Messenger::rejectInterleavedMessageHandler, this->shared_from_this(), std::placeholders::_1)); + messageInStream_->setInterleavedHandler(std::move(interleavedPromise)); +} + void Messenger::outStreamMessageHandler(ChannelSendQueue::iterator queueElement) { queueElement->second->resolve(); @@ -117,9 +158,15 @@ void Messenger::rejectReceivePromiseQueue(const error::Error& e) while(!channelReceivePromiseQueue_.empty()) { channelReceivePromiseQueue_.pop()->reject(e); + currentPromiseIndex_--; } } +void Messenger::rejectInterleavedMessageHandler(const error::Error& e) +{ + // Dummy +} + void Messenger::rejectSendPromiseQueue(const error::Error& e) { while(!channelSendPromiseQueue_.empty()) @@ -132,6 +179,7 @@ void Messenger::rejectSendPromiseQueue(const error::Error& e) void Messenger::stop() { + currentPromiseIndex_ = 0; receiveStrand_.dispatch([this, self = this->shared_from_this()]() { channelReceiveMessageQueue_.clear(); }); From 8064fe8ef1b6e6cbb6e39c36db2d3ab1ae86fd54 Mon Sep 17 00:00:00 2001 From: "Simon.Dean" Date: Sun, 13 Feb 2022 21:06:07 +0000 Subject: [PATCH 6/7] Reworked Message Handling - Have adjusted the buffer mechanism so instead of using the buffer to store a message in the event of an interleaved frame, we basically perform all work on the buffer (albeit we take the existing message for the channel id from the buffer for the frame we're working on and write the message to the buffer if the message isn't resolved). - Moved writing to buffer to receiveFramePayloadHandler() function if the message is BULK or LAST and therefore not resolved. - Simplified receiveFrameHeaderHandler() so that we automatically try to find a message from the buffer and then createa message as necessary depending on the frame type. - Excellent stability with no noticeable artefacts in audio after 1 hour. - Removed majority of debugging after achieving stability. --- include/aasdk/Messenger/IMessageInStream.hpp | 3 +- include/aasdk/Messenger/MessageInStream.hpp | 5 +- include/aasdk/Messenger/Messenger.hpp | 4 - src/Messenger/MessageInStream.cpp | 81 +++++++------------- src/Messenger/Messenger.cpp | 50 +----------- 5 files changed, 33 insertions(+), 110 deletions(-) diff --git a/include/aasdk/Messenger/IMessageInStream.hpp b/include/aasdk/Messenger/IMessageInStream.hpp index b64e4b09..0d9e7981 100644 --- a/include/aasdk/Messenger/IMessageInStream.hpp +++ b/include/aasdk/Messenger/IMessageInStream.hpp @@ -35,8 +35,7 @@ class IMessageInStream IMessageInStream() = default; virtual ~IMessageInStream() = default; - virtual void startReceive(ReceivePromise::Pointer promise, ChannelId channelId, int promiseIndex, int messageIndex) = 0; - virtual void setInterleavedHandler(ReceivePromise::Pointer promise) = 0; + virtual void startReceive(ReceivePromise::Pointer promise) = 0; }; } diff --git a/include/aasdk/Messenger/MessageInStream.hpp b/include/aasdk/Messenger/MessageInStream.hpp index ad44a158..489c5d71 100644 --- a/include/aasdk/Messenger/MessageInStream.hpp +++ b/include/aasdk/Messenger/MessageInStream.hpp @@ -37,8 +37,7 @@ class MessageInStream: public IMessageInStream, public std::enable_shared_from_t public: MessageInStream(boost::asio::io_service& ioService, transport::ITransport::Pointer transport, ICryptor::Pointer cryptor); - void startReceive(ReceivePromise::Pointer promise, ChannelId channelId, int promiseIndex, int messageIndex) override; - void setInterleavedHandler(ReceivePromise::Pointer promise) override; + void startReceive(ReceivePromise::Pointer promise) override; private: using std::enable_shared_from_this::shared_from_this; @@ -59,9 +58,7 @@ class MessageInStream: public IMessageInStream, public std::enable_shared_from_t std::map messageBuffer_; int frameSize_; - bool isInterleaved_; bool isValidFrame_; - int currentMessageIndex_; }; } diff --git a/include/aasdk/Messenger/Messenger.hpp b/include/aasdk/Messenger/Messenger.hpp index c1f4c3c0..b5996cfe 100644 --- a/include/aasdk/Messenger/Messenger.hpp +++ b/include/aasdk/Messenger/Messenger.hpp @@ -47,9 +47,7 @@ class Messenger: public IMessenger, public std::enable_shared_from_thisshared_from_this(), promise = std::move(promise)]() mutable { if (promise_ == nullptr) { promise_ = std::move(promise); @@ -47,68 +45,47 @@ void MessageInStream::startReceive(ReceivePromise::Pointer promise, ChannelId ch this->receiveFrameHeaderHandler(common::DataConstBuffer(data)); }, [this, self = this->shared_from_this()](const error::Error &e) mutable { - AASDK_LOG(debug) << "[MessageInStream] 2. Error Here?"; promise_->reject(e); promise_.reset(); }); transport_->receive(FrameHeader::getSizeOf(), std::move(transportPromise)); } else { - AASDK_LOG(debug) << "[MessageInStream] 3. Operation in Progress."; promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); } }); } -void MessageInStream::setInterleavedHandler(ReceivePromise::Pointer promise) -{ - interleavedPromise_ = std::move(promise); -} - void MessageInStream::receiveFrameHeaderHandler(const common::DataConstBuffer& buffer) { FrameHeader frameHeader(buffer); - AASDK_LOG(debug) << "[MessageInStream] 5. Processing Frame Header: Ch " << channelIdToString(frameHeader.getChannelId()) << " Fr " << frameTypeToString(frameHeader.getType()); + AASDK_LOG(debug) << "[MessageInStream] Processing Frame Header: Ch " << channelIdToString(frameHeader.getChannelId()) << " Fr " << frameTypeToString(frameHeader.getType()); isValidFrame_ = true; - isInterleaved_ = false; - - // New Promise or Interleaved - if(message_ != nullptr && message_->getChannelId() != frameHeader.getChannelId()) { - // We have an existing message but the channels don't match... - AASDK_LOG(debug) << "[MessageInStream] 6. Interleaved ChannelId MisMatch - F: " << channelIdToString(frameHeader.getChannelId()) << " M: " << channelIdToString(message_->getChannelId()); - - isInterleaved_ = true; - - // Store message in buffer; - messageBuffer_[message_->getChannelId()] = message_; - message_.reset(); - } - - // Look for Buffered Message - if ((message_ == nullptr) && (frameHeader.getType() == FrameType::MIDDLE || frameHeader.getType() == FrameType::LAST)) { - AASDK_LOG(debug) << "[MessageInStream] 7. Null Message but Middle or Last Frame."; - auto bufferedMessage = messageBuffer_.find(frameHeader.getChannelId()); - if (bufferedMessage != messageBuffer_.end()) { - AASDK_LOG(debug) << "[MessageInStream] 8. Found Existing Message on Channel."; - message_ = bufferedMessage->second; - messageBuffer_.erase(bufferedMessage); + auto bufferedMessage = messageBuffer_.find(frameHeader.getChannelId()); + if (bufferedMessage != messageBuffer_.end()) { + // We have found a message... + message_ = std::move(bufferedMessage->second); + messageBuffer_.erase(bufferedMessage); - isInterleaved_ = false; - } - } + AASDK_LOG(debug) << "[MessageInStream] Found existing message."; - if (message_ == nullptr) { if (frameHeader.getType() == FrameType::FIRST || frameHeader.getType() == FrameType::BULK) { - AASDK_LOG(debug) << "[MessageInStream] 11. New message created with Index " << std::to_string(currentMessageIndex_); - currentMessageIndex_++; - } else { - // This will be an invalid message, but we still need to read from the buffer. - isValidFrame_ = false; + // If it's first or bulk, we need to override the message anyhow, so we will start again. + // Need to start a new message anyhow + message_ = std::make_shared(frameHeader.getChannelId(), frameHeader.getEncryptionType(), frameHeader.getMessageType()); } + } else { + AASDK_LOG(debug) << "[MessageInStream] Could not find existing message."; + // No Message Found in Buffers and this is a middle or last frame, this an error. + // Still need to process the frame, but we will not resolve at the end. message_ = std::make_shared(frameHeader.getChannelId(), frameHeader.getEncryptionType(), frameHeader.getMessageType()); + if (frameHeader.getType() == FrameType::MIDDLE || frameHeader.getType() == FrameType::LAST) { + // This is an error + isValidFrame_ = false; + } } thisFrameType_ = frameHeader.getType(); @@ -172,17 +149,15 @@ void MessageInStream::receiveFramePayloadHandler(const common::DataConstBuffer& // If this is the LAST frame or a BULK frame... if((thisFrameType_ == FrameType::BULK || thisFrameType_ == FrameType::LAST) && isValidFrame_) { - if (!isInterleaved_) { - AASDK_LOG(debug) << "[MessageInStream] 12. Resolving Normal message. " << std::to_string(currentMessageIndex_); - promise_->resolve(std::move(message_)); - promise_.reset(); - isResolved = true; - } else { - AASDK_LOG(debug) << "[MessageInStream] 13. Resolving Interleaved Message. " << std::to_string(currentMessageIndex_); - interleavedPromise_->resolve(std::move(message_)); - } + AASDK_LOG(debug) << "[MessageInStream] Resolving message."; + promise_->resolve(std::move(message_)); + promise_.reset(); + isResolved = true; + currentMessageIndex_--; - message_.reset(); + } else { + // First or Middle message, we'll store in our buffer... + messageBuffer_[message_->getChannelId()] = std::move(message_); } // If the main promise isn't resolved, then carry on retrieving frame headers. diff --git a/src/Messenger/Messenger.cpp b/src/Messenger/Messenger.cpp index 2dfd5151..367923fb 100644 --- a/src/Messenger/Messenger.cpp +++ b/src/Messenger/Messenger.cpp @@ -32,43 +32,28 @@ Messenger::Messenger(boost::asio::io_service& ioService, IMessageInStream::Point , messageInStream_(std::move(messageInStream)) , messageOutStream_(std::move(messageOutStream)) { - currentPromiseIndex_ = 0; - currentMessageIndex_ = 0; + } void Messenger::enqueueReceive(ChannelId channelId, ReceivePromise::Pointer promise) { // enqueueReceive is called from the service channel. - AASDK_LOG(debug) << "[Messenger] 1. enqueueReceived called on Channel " << channelIdToString(channelId); - receiveStrand_.dispatch([this, self = this->shared_from_this(), channelId, promise = std::move(promise)]() mutable { - auto interleavedPromise = ReceivePromise::defer(receiveStrand_); - interleavedPromise->then(std::bind(&Messenger::interleavedMessageHandler, this->shared_from_this(), std::placeholders::_1), - std::bind(&Messenger::rejectInterleavedMessageHandler, this->shared_from_this(), std::placeholders::_1)); - messageInStream_->setInterleavedHandler(std::move(interleavedPromise)); - //If there's any messages on the channel, resolve. The channel will call enqueueReceive again. if(!channelReceiveMessageQueue_.empty(channelId)) { promise->resolve(std::move(channelReceiveMessageQueue_.pop(channelId))); - AASDK_LOG(debug) << "[Messenger] 2. Message Queue not Empty. Resolving promise with Existing Message."; } else { - currentPromiseIndex_++; - AASDK_LOG(debug) << "[Messenger] 3. Message Queue is Empty. Pushing Promise on Index " << std::to_string(currentPromiseIndex_); channelReceivePromiseQueue_.push(channelId, std::move(promise)); if(channelReceivePromiseQueue_.size() == 1) { - currentMessageIndex_++; - - AASDK_LOG(debug) << "[Messenger] 4. Calling startReceive on MessageIndex " << std::to_string(currentMessageIndex_); - auto inStreamPromise = ReceivePromise::defer(receiveStrand_); inStreamPromise->then(std::bind(&Messenger::inStreamMessageHandler, this->shared_from_this(), std::placeholders::_1), std::bind(&Messenger::rejectReceivePromiseQueue, this->shared_from_this(), std::placeholders::_1)); - messageInStream_->startReceive(std::move(inStreamPromise), channelId, currentPromiseIndex_, currentMessageIndex_); + messageInStream_->startReceive(std::move(inStreamPromise)); } } }); @@ -89,32 +74,24 @@ void Messenger::enqueueSend(Message::Pointer message, SendPromise::Pointer promi void Messenger::inStreamMessageHandler(Message::Pointer message) { auto channelId = message->getChannelId(); - AASDK_LOG(debug) << "[Messenger] 5. inStreamMessageHandler from Channel " << channelIdToString(channelId); - - currentMessageIndex_--; // If there's a promise on the queue, we resolve the promise with this message.... if(channelReceivePromiseQueue_.isPending(channelId)) { channelReceivePromiseQueue_.pop(channelId)->resolve(std::move(message)); - currentPromiseIndex_--; } else { // Or we push the message to the Message Queue for when we do get a promise - AASDK_LOG(debug) << "[Messenger] 7. Pushing Message to Queue as we have no Pending Promises." << std::to_string(currentPromiseIndex_); channelReceiveMessageQueue_.push(std::move(message)); } if(!channelReceivePromiseQueue_.empty()) { - currentMessageIndex_++; - AASDK_LOG(debug) << "[Messenger] 8. Calling startReceive on PromiseIndex " << std::to_string(currentPromiseIndex_) << " and MessageIndex " << std::to_string(currentMessageIndex_); - auto inStreamPromise = ReceivePromise::defer(receiveStrand_); inStreamPromise->then(std::bind(&Messenger::inStreamMessageHandler, this->shared_from_this(), std::placeholders::_1), std::bind(&Messenger::rejectReceivePromiseQueue, this->shared_from_this(), std::placeholders::_1)); - messageInStream_->startReceive(std::move(inStreamPromise), channelId, currentPromiseIndex_,currentMessageIndex_); + messageInStream_->startReceive(std::move(inStreamPromise)); } } @@ -128,20 +105,6 @@ void Messenger::doSend() messageOutStream_->stream(std::move(queueElementIter->first), std::move(outStreamPromise)); } -void Messenger::interleavedMessageHandler(Message::Pointer message) -{ - auto channelId = message->getChannelId(); - - AASDK_LOG(debug) << "[Messenger] 9. interleavedMessageHandler from Channel " << channelIdToString(channelId); - - channelReceiveMessageQueue_.push(std::move(message)); - - auto interleavedPromise = ReceivePromise::defer(receiveStrand_); - interleavedPromise->then(std::bind(&Messenger::interleavedMessageHandler, this->shared_from_this(), std::placeholders::_1), - std::bind(&Messenger::rejectInterleavedMessageHandler, this->shared_from_this(), std::placeholders::_1)); - messageInStream_->setInterleavedHandler(std::move(interleavedPromise)); -} - void Messenger::outStreamMessageHandler(ChannelSendQueue::iterator queueElement) { queueElement->second->resolve(); @@ -158,15 +121,9 @@ void Messenger::rejectReceivePromiseQueue(const error::Error& e) while(!channelReceivePromiseQueue_.empty()) { channelReceivePromiseQueue_.pop()->reject(e); - currentPromiseIndex_--; } } -void Messenger::rejectInterleavedMessageHandler(const error::Error& e) -{ - // Dummy -} - void Messenger::rejectSendPromiseQueue(const error::Error& e) { while(!channelSendPromiseQueue_.empty()) @@ -179,7 +136,6 @@ void Messenger::rejectSendPromiseQueue(const error::Error& e) void Messenger::stop() { - currentPromiseIndex_ = 0; receiveStrand_.dispatch([this, self = this->shared_from_this()]() { channelReceiveMessageQueue_.clear(); }); From e8236a671e82fbf2b639a8a5c256ff3d24257aea Mon Sep 17 00:00:00 2001 From: sjdean Date: Thu, 21 Nov 2024 12:46:49 +0000 Subject: [PATCH 7/7] AAP-Proto 1.6 Support and Tidy Ups * Restructure AASDK Proto Protobuf files for Android Auto 1.6 Support based on information from https://milek7.pl/.stuff/galdocs/readme.md This fleshes out enums and other methods with their full naming conventions for better readability and understanding. * Restructure AASDK source/header with additional renames to clarify differences between AudioService, VideoService and AVInput. Updated to MediaSinkService which is extended by AudioMediaSinkService and VideoMediaSinkService which themselves are extended by the individual service channels. * Added initial GenericNotification, MediaBrowser, MediaPlaybackStatus, PhoneStatus, Radio, VendorExtension and WifiProjection services. * Update AASDK_LOG entries for extra consistency * Simplify CMAKE to build and install keeping parameters to a minimum. Default to Release mode and Raspberry PI build unless otherwise specified. --- .gitignore | 844 ++++++- CMakeLists.txt | 218 +- Config.cmake.in | 3 + RELEASE.txt | 10 + aasdk_proto/AVChannelData.proto | 35 - aasdk_proto/AVChannelMessageIdsEnum.proto | 39 - .../AVChannelSetupRequestMessage.proto | 26 - .../AVChannelSetupResponseMessage.proto | 30 - aasdk_proto/AVChannelSetupStatusEnum.proto | 31 - .../AVChannelStartIndicationMessage.proto | 27 - .../AVChannelStopIndicationMessage.proto | 25 - aasdk_proto/AVInputChannelData.proto | 31 - aasdk_proto/AVInputOpenRequestMessage.proto | 29 - aasdk_proto/AVInputOpenResponseMessage.proto | 27 - aasdk_proto/AVMediaAckIndicationMessage.proto | 27 - aasdk_proto/AVStreamTypeEnum.proto | 31 - aasdk_proto/AbsoluteInputEventData.proto | 27 - aasdk_proto/AbsoluteInputEventsData.proto | 28 - aasdk_proto/AccelData.proto | 28 - aasdk_proto/AudioConfigData.proto | 28 - aasdk_proto/AudioFocusRequestMessage.proto | 28 - aasdk_proto/AudioFocusResponseMessage.proto | 28 - aasdk_proto/AudioFocusStateEnum.proto | 36 - aasdk_proto/AudioFocusTypeEnum.proto | 33 - aasdk_proto/AudioTypeEnum.proto | 33 - .../AuthCompleteIndicationMessage.proto | 28 - aasdk_proto/BindingRequestMessage.proto | 26 - aasdk_proto/BindingResponseMessage.proto | 28 - aasdk_proto/BluetoothChannelData.proto | 29 - .../BluetoothChannelMessageIdsEnum.proto | 33 - aasdk_proto/BluetoothPairingMethodEnum.proto | 33 - .../BluetoothPairingRequestMessage.proto | 29 - .../BluetoothPairingResponseMessage.proto | 29 - aasdk_proto/BluetoothPairingStatusEnum.proto | 31 - aasdk_proto/ButtonCodeEnum.proto | 55 - aasdk_proto/ButtonEventData.proto | 29 - aasdk_proto/ButtonEventsData.proto | 28 - aasdk_proto/CMakeLists.txt | 17 - aasdk_proto/ChannelDescriptorData.proto | 47 - aasdk_proto/ChannelOpenRequestMessage.proto | 27 - aasdk_proto/ChannelOpenResponseMessage.proto | 28 - aasdk_proto/CompassData.proto | 28 - aasdk_proto/ControlMessageIdsEnum.proto | 46 - aasdk_proto/DiagnosticsData.proto | 26 - aasdk_proto/DistanceUnitEnum.proto | 36 - aasdk_proto/DoorData.proto | 28 - aasdk_proto/DrivingStatusData.proto | 26 - aasdk_proto/DrivingStatusEnum.proto | 35 - aasdk_proto/EnvironmentData.proto | 28 - aasdk_proto/FuelLevelData.proto | 28 - aasdk_proto/GPSLocationData.proto | 32 - aasdk_proto/GearData.proto | 28 - aasdk_proto/GearEnum.proto | 42 - aasdk_proto/GyroData.proto | 28 - aasdk_proto/HVACData.proto | 27 - aasdk_proto/HeadlightStatusEnum.proto | 32 - aasdk_proto/IndicatorStatusEnum.proto | 32 - aasdk_proto/InputChannelData.proto | 30 - aasdk_proto/InputChannelMessageIdsEnum.proto | 32 - aasdk_proto/InputEventIndicationMessage.proto | 36 - aasdk_proto/LightData.proto | 31 - aasdk_proto/ManeuverDirectionEnum.proto | 32 - aasdk_proto/ManeuverTypeEnum.proto | 46 - aasdk_proto/MediaInfoChannelData.proto | 26 - .../MediaInfoChannelMessageIdsEnum.proto | 31 - .../MediaInfoChannelMetadataData.proto | 31 - .../MediaInfoChannelPlaybackData.proto | 39 - aasdk_proto/NavigationChannelData.proto | 31 - .../NavigationChannelMessageIdsEnum.proto | 32 - .../NavigationDistanceEventMessage.proto | 32 - .../NavigationFocusRequestMessage.proto | 26 - .../NavigationFocusResponseMessage.proto | 26 - aasdk_proto/NavigationImageOptionsData.proto | 29 - aasdk_proto/NavigationStatusMessage.proto | 33 - aasdk_proto/NavigationTurnEventMessage.proto | 34 - aasdk_proto/NavigationTurnTypeEnum.proto | 31 - aasdk_proto/NightModeData.proto | 26 - aasdk_proto/OdometerData.proto | 27 - aasdk_proto/ParkingBrakeData.proto | 26 - aasdk_proto/PassengerData.proto | 26 - aasdk_proto/PingRequestMessage.proto | 26 - aasdk_proto/PingResponseMessage.proto | 26 - aasdk_proto/RPMData.proto | 26 - aasdk_proto/RelativeInputEventData.proto | 27 - aasdk_proto/RelativeInputEventsData.proto | 28 - aasdk_proto/SensorChannelData.proto | 28 - aasdk_proto/SensorChannelMessageIdsEnum.proto | 32 - aasdk_proto/SensorData.proto | 28 - .../SensorEventIndicationMessage.proto | 64 - aasdk_proto/SensorStartRequestMessage.proto | 29 - aasdk_proto/SensorStartResponseMessage.proto | 28 - aasdk_proto/SensorTypeEnum.proto | 50 - .../ServiceDiscoveryRequestMessage.proto | 27 - .../ServiceDiscoveryResponseMessage.proto | 39 - aasdk_proto/ShutdownReasonEnum.proto | 30 - aasdk_proto/ShutdownRequestMessage.proto | 28 - aasdk_proto/ShutdownResponseMessage.proto | 25 - aasdk_proto/SpeedData.proto | 28 - aasdk_proto/StatusEnum.proto | 31 - aasdk_proto/SteeringWheelData.proto | 27 - aasdk_proto/TouchActionEnum.proto | 33 - aasdk_proto/TouchConfigData.proto | 27 - aasdk_proto/TouchEventData.proto | 31 - aasdk_proto/TouchLocationData.proto | 28 - aasdk_proto/VendorExtensionChannelData.proto | 28 - aasdk_proto/VersionResponseStatusEnum.proto | 30 - aasdk_proto/VideoConfigData.proto | 34 - aasdk_proto/VideoFPSEnum.proto | 31 - aasdk_proto/VideoFocusIndicationMessage.proto | 29 - aasdk_proto/VideoFocusModeEnum.proto | 31 - aasdk_proto/VideoFocusReasonEnum.proto | 31 - aasdk_proto/VideoFocusRequestMessage.proto | 31 - aasdk_proto/VideoResolutionEnum.proto | 36 - aasdk_proto/VoiceSessionRequestMessage.proto | 8 - aasdk_proto/WifiChannelData.proto | 30 - cmake_modules/Findaap_protobuf.cmake | 55 + docs/common.proto | 22 + docs/protos.proto | 2104 +++++++++++++++++ .../Channel/AV/AVInputServiceChannel.hpp | 57 - .../aasdk/Channel/AV/AudioServiceChannel.hpp | 56 - .../Channel/AV/IAVInputServiceChannel.hpp | 56 - .../AV/IAVInputServiceChannelEventHandler.hpp | 52 - .../aasdk/Channel/AV/IAudioServiceChannel.hpp | 54 - .../AV/IAudioServiceChannelEventHandler.hpp | 57 - .../Channel/AV/IMediaStatusServiceChannel.hpp | 50 - ...IMediaStatusServiceChannelEventHandler.hpp | 50 - .../aasdk/Channel/AV/IVideoServiceChannel.hpp | 56 - .../AV/IVideoServiceChannelEventHandler.hpp | 58 - .../Channel/AV/MediaAudioServiceChannel.hpp | 39 - .../Channel/AV/MediaStatusServiceChannel.hpp | 52 - .../Channel/AV/SpeechAudioServiceChannel.hpp | 39 - .../Channel/AV/SystemAudioServiceChannel.hpp | 39 - .../aasdk/Channel/AV/VideoServiceChannel.hpp | 57 - .../Channel/Bluetooth/BluetoothService.hpp | 65 + .../Bluetooth/BluetoothServiceChannel.hpp | 51 - .../Channel/Bluetooth/IBluetoothService.hpp | 56 + .../Bluetooth/IBluetoothServiceChannel.hpp | 52 - .../IBluetoothServiceChannelEventHandler.hpp | 48 - .../IBluetoothServiceEventHandler.hpp | 49 + include/aasdk/Channel/Channel.hpp | 47 + .../Channel/Control/ControlServiceChannel.hpp | 150 +- .../Control/IControlServiceChannel.hpp | 120 +- .../IControlServiceChannelEventHandler.hpp | 117 +- .../GenericNotificationService.hpp | 56 + .../IGenericNotificationService.hpp | 45 + ...GenericNotificationServiceEventHandler.hpp | 40 + include/aasdk/Channel/IChannel.hpp | 37 + .../Channel/Input/IInputServiceChannel.hpp | 55 - .../IInputServiceChannelEventHandler.hpp | 48 - .../Channel/Input/InputServiceChannel.hpp | 52 - .../InputSource/IInputSourceService.hpp | 55 + .../IInputSourceServiceEventHandler.hpp | 43 + .../InputSource/InputSourceService.hpp | 60 + .../MediaBrowser/IMediaBrowserService.hpp | 44 + .../IMediaBrowserServiceEventHandler.hpp | 40 + .../MediaBrowser/MediaBrowserService.hpp | 53 + .../IMediaPlaybackStatusService.hpp | 45 + ...MediaPlaybackStatusServiceEventHandler.hpp | 49 + .../MediaPlaybackStatusService.hpp | 62 + .../MediaSink/Audio/AudioMediaSinkService.hpp | 82 + .../Audio/Channel/GuidanceAudioChannel.hpp | 30 + .../Audio/Channel/MediaAudioChannel.hpp | 30 + .../Audio/Channel/SystemAudioChannel.hpp | 30 + .../Audio/Channel/TelephonyAudioChannel.hpp | 35 + .../Audio/IAudioMediaSinkService.hpp | 62 + .../IAudioMediaSinkServiceEventHandler.hpp | 60 + .../MediaSink/Video/Channel/VideoChannel.hpp | 30 + .../Video/IVideoMediaSinkService.hpp | 69 + .../IVideoMediaSinkServiceEventHandler.hpp | 62 + .../MediaSink/Video/VideoMediaSinkService.hpp | 92 + .../Audio/MicrophoneAudioChannel.hpp | 33 + .../MediaSource/IMediaSourceService.hpp | 62 + .../IMediaSourceServiceEventHandler.hpp | 56 + .../MediaSource/MediaSourceService.hpp | 74 + .../INavigationStatusServiceChannel.hpp | 50 - ...gationStatusServiceChannelEventHandler.hpp | 52 - .../NavigationStatusServiceChannel.hpp | 52 - .../INavigationStatusService.hpp | 45 + .../INavigationStatusServiceEventHandler.hpp | 50 + .../NavigationStatusService.hpp | 60 + .../PhoneStatus/IPhoneStatusService.hpp | 45 + .../IPhoneStatusServiceEventHandler.hpp | 40 + .../PhoneStatus/PhoneStatusService.hpp | 53 + include/aasdk/Channel/Promise.hpp | 43 +- include/aasdk/Channel/Radio/IRadioService.hpp | 44 + .../Radio/IRadioServiceEventHandler.hpp | 39 + include/aasdk/Channel/Radio/RadioService.hpp | 50 + .../Channel/Sensor/ISensorServiceChannel.hpp | 54 - .../ISensorServiceChannelEventHandler.hpp | 48 - .../Channel/Sensor/SensorServiceChannel.hpp | 52 - .../SensorSource/ISensorSourceService.hpp | 55 + .../ISensorSourceServiceEventHandler.hpp | 43 + .../SensorSource/SensorSourceService.hpp | 57 + include/aasdk/Channel/ServiceChannel.hpp | 47 - .../IVendorExtensionService.hpp | 45 + .../IVendorExtensionServiceEventHandler.hpp | 40 + .../VendorExtensionService.hpp | 53 + .../WifiProjection/IWifiProjectionService.hpp | 49 + .../IWifiProjectionServiceEventHandler.hpp | 43 + .../WifiProjection/WifiProjectionService.hpp | 59 + include/aasdk/Common/Data.hpp | 147 +- include/aasdk/Common/Log.hpp | 35 +- include/aasdk/Error/Error.hpp | 80 +- include/aasdk/Error/ErrorCode.hpp | 114 +- include/aasdk/IO/IOContextWrapper.hpp | 103 +- include/aasdk/IO/Promise.hpp | 413 ++-- include/aasdk/IO/PromiseLink.hpp | 165 +- include/aasdk/Messenger/ChannelId.hpp | 80 +- .../Messenger/ChannelReceiveMessageQueue.hpp | 64 +- .../Messenger/ChannelReceivePromiseQueue.hpp | 72 +- include/aasdk/Messenger/Cryptor.hpp | 113 +- include/aasdk/Messenger/EncryptionType.hpp | 50 +- include/aasdk/Messenger/FrameHeader.hpp | 79 +- include/aasdk/Messenger/FrameSize.hpp | 74 +- include/aasdk/Messenger/FrameSizeType.hpp | 50 +- include/aasdk/Messenger/FrameType.hpp | 56 +- include/aasdk/Messenger/ICryptor.hpp | 62 +- include/aasdk/Messenger/IMessageInStream.hpp | 57 +- include/aasdk/Messenger/IMessageOutStream.hpp | 57 +- include/aasdk/Messenger/IMessenger.hpp | 63 +- include/aasdk/Messenger/Message.hpp | 75 +- include/aasdk/Messenger/MessageId.hpp | 84 +- include/aasdk/Messenger/MessageInStream.hpp | 86 +- include/aasdk/Messenger/MessageOutStream.hpp | 91 +- include/aasdk/Messenger/MessageType.hpp | 52 +- include/aasdk/Messenger/Messenger.hpp | 95 +- include/aasdk/Messenger/Promise.hpp | 45 +- include/aasdk/Messenger/ServiceId.hpp | 44 + include/aasdk/Messenger/Timestamp.hpp | 64 +- include/aasdk/TCP/ITCPEndpoint.hpp | 64 +- include/aasdk/TCP/ITCPWrapper.hpp | 71 +- include/aasdk/TCP/TCPEndpoint.hpp | 69 +- include/aasdk/TCP/TCPWrapper.hpp | 64 +- include/aasdk/Transport/DataSink.hpp | 65 +- include/aasdk/Transport/ISSLWrapper.hpp | 136 +- include/aasdk/Transport/ITransport.hpp | 67 +- include/aasdk/Transport/SSLWrapper.hpp | 130 +- include/aasdk/Transport/TCPTransport.hpp | 64 +- include/aasdk/Transport/Transport.hpp | 87 +- include/aasdk/Transport/USBTransport.hpp | 71 +- include/aasdk/USB/AOAPDevice.hpp | 88 +- .../USB/AccessoryModeProtocolVersionQuery.hpp | 66 +- include/aasdk/USB/AccessoryModeQuery.hpp | 67 +- include/aasdk/USB/AccessoryModeQueryChain.hpp | 120 +- .../USB/AccessoryModeQueryChainFactory.hpp | 65 +- .../aasdk/USB/AccessoryModeQueryFactory.hpp | 60 +- include/aasdk/USB/AccessoryModeQueryType.hpp | 62 +- .../USB/AccessoryModeSendStringQuery.hpp | 65 +- .../aasdk/USB/AccessoryModeSendStringType.hpp | 58 +- include/aasdk/USB/AccessoryModeStartQuery.hpp | 61 +- .../USB/ConnectedAccessoriesEnumerator.hpp | 84 +- include/aasdk/USB/IAOAPDevice.hpp | 60 +- include/aasdk/USB/IAccessoryModeQuery.hpp | 62 +- .../aasdk/USB/IAccessoryModeQueryChain.hpp | 63 +- .../USB/IAccessoryModeQueryChainFactory.hpp | 52 +- .../aasdk/USB/IAccessoryModeQueryFactory.hpp | 56 +- .../USB/IConnectedAccessoriesEnumerator.hpp | 60 +- include/aasdk/USB/IUSBEndpoint.hpp | 74 +- include/aasdk/USB/IUSBHub.hpp | 62 +- include/aasdk/USB/IUSBWrapper.hpp | 151 +- include/aasdk/USB/USBEndpoint.hpp | 106 +- include/aasdk/USB/USBHub.hpp | 106 +- include/aasdk/USB/USBWrapper.hpp | 145 +- include/aasdk/Version.hpp | 35 +- protobuf/CMakeLists.txt | 116 + protobuf/Config.cmake.in | 3 + protobuf/README.md | 9 + protobuf/aap_protobuf/aaw/MessageId.proto | 13 + protobuf/aap_protobuf/aaw/Status.proto | 19 + .../aaw/WifiConnectionStatus.proto | 10 + .../aap_protobuf/aaw/WifiInfoRequest.proto | 7 + .../aap_protobuf/aaw/WifiInfoResponse.proto | 14 + .../aap_protobuf/aaw/WifiStartRequest.proto | 8 + .../aap_protobuf/aaw/WifiStartResponse.proto | 11 + .../aap_protobuf/aaw/WifiVersionRequest.proto | 7 + .../aaw/WifiVersionResponse.proto | 10 + .../channel/control/GalConstants.proto | 9 + .../control/GalVerificationAudioFocus.proto | 11 + .../GalVerificationBugReportRequest.proto | 7 + .../GalVerificationBugReportResponse.proto | 7 + ...erificationDisplayInformationRequest.proto | 7 + ...rificationDisplayInformationResponse.proto | 8 + .../control/GalVerificationInjectInput.proto | 9 + .../GalVerificationMediaSinkStatus.proto | 10 + .../GalVerificationScreenCaptureRequest.proto | 7 + ...GalVerificationScreenCaptureResponse.proto | 7 + .../control/GalVerificationSetSensor.proto | 9 + ...VerificationVendorExtensionMessageId.proto | 17 + .../control/GalVerificationVideoFocus.proto | 11 + .../GoogleDiagnosticsBugReportRequest.proto | 7 + .../GoogleDiagnosticsBugReportResponse.proto | 13 + ...eDiagnosticsVendorExtensionMessageId.proto | 4 + .../control/InstrumentClusterInput.proto | 17 + .../control/LocationCharacterization.proto | 15 + .../control/SessionConfiguration.proto | 10 + protobuf/aap_protobuf/service/Service.proto | 37 + .../bluetooth/BluetoothMessageId.proto | 13 + .../service/bluetooth/BluetoothService.proto | 11 + .../message/BluetoothAuthenticationData.proto | 10 + .../BluetoothAuthenticationResult.proto | 9 + .../message/BluetoothPairingMethod.proto | 13 + .../message/BluetoothPairingRequest.proto | 11 + .../message/BluetoothPairingResponse.proto | 11 + .../service/control/ControlMessageType.proto | 35 + .../message/AudioFocusNotification.proto | 10 + .../control/message/AudioFocusRequest.proto | 10 + .../AudioFocusRequestNotification.proto | 11 + .../message/AudioFocusRequestType.proto | 12 + .../control/message/AudioFocusStateType.proto | 16 + .../control/message/AuthResponse.proto | 7 + .../message/BatteryStatusNotification.proto | 9 + .../control/message/ByeByeReason.proto | 12 + .../control/message/ByeByeRequest.proto | 10 + .../control/message/ByeByeResponse.proto | 8 + .../message/CallAvailabilityStatus.proto | 7 + .../control/message/CarConnectedDevices.proto | 11 + .../message/CarConnectedDevicesRequest.proto | 7 + .../message/ChannelCloseNotification.proto | 7 + .../control/message/ChannelOpenRequest.proto | 9 + .../control/message/ChannelOpenResponse.proto | 10 + .../control/message/ConnectedDevice.proto | 8 + .../message/ConnectionConfiguration.proto | 11 + .../control/message/DriverPosition.proto | 10 + .../service/control/message/FragInfo.proto | 10 + .../control/message/HeadUnitInfo.proto | 14 + .../message/NavFocusNotification.proto | 9 + .../message/NavFocusRequestNotification.proto | 9 + .../control/message/NavFocusType.proto | 8 + .../control/message/PingConfiguration.proto | 10 + .../service/control/message/PingRequest.proto | 9 + .../control/message/PingResponse.proto | 8 + .../message/ServiceDiscoveryRequest.proto | 15 + .../message/ServiceDiscoveryResponse.proto | 31 + .../message/ServiceDiscoveryUpdate.proto | 9 + .../control/message/UpdateUiConfigReply.proto | 9 + .../message/UpdateUiConfigRequest.proto | 9 + .../control/message/UserSwitchRequest.proto | 9 + .../control/message/UserSwitchResponse.proto | 11 + .../control/message/UserSwitchStatus.proto | 16 + .../message/VersionRequestOptions.proto | 7 + .../message/VersionResponseOptions.proto | 10 + .../message/VoiceSessionNotification.proto | 11 + .../control/message/VoiceSessionStatus.proto | 8 + .../message/WirelessTcpConfiguration.proto | 9 + .../GenericNotificationMessageId.proto | 12 + .../GenericNotificationService.proto | 10 + .../message/GenericNotificationAck.proto | 10 + .../message/GenericNotificationMessage.proto | 9 + .../GenericNotificationSubscribe.proto | 7 + .../GenericNotificationUnsubscribe.proto | 7 + .../service/inputsource/InputMessageId.proto | 11 + .../inputsource/InputSourceService.proto | 33 + .../inputsource/message/AbsoluteEvent.proto | 11 + .../inputsource/message/FeedbackEvent.proto | 11 + .../inputsource/message/InputFeedback.proto | 9 + .../inputsource/message/InputReport.proto | 19 + .../inputsource/message/KeyEvent.proto | 13 + .../inputsource/message/PointerAction.proto | 12 + .../inputsource/message/RelativeEvent.proto | 11 + .../inputsource/message/TouchEvent.proto | 17 + .../inputsource/message/TouchScreenType.proto | 9 + .../shared/message/AudioConfiguration.proto | 9 + .../service/media/shared/message/Config.proto | 14 + .../service/media/shared/message/Insets.proto | 10 + .../media/shared/message/MediaCodecType.proto | 14 + .../service/media/shared/message/Setup.proto | 10 + .../service/media/shared/message/Start.proto | 8 + .../service/media/shared/message/Stop.proto | 8 + .../media/shared/message/UiConfig.proto | 13 + .../media/shared/message/UiTheme.proto | 9 + .../service/media/sink/MediaMessageId.proto | 21 + .../service/media/sink/MediaSinkService.proto | 22 + .../media/sink/message/AudioStreamType.proto | 12 + .../message/AudioUnderflowNotification.proto | 7 + .../media/sink/message/DisplayType.proto | 9 + .../sink/message/KeyBindingRequest.proto | 7 + .../sink/message/KeyBindingResponse.proto | 9 + .../service/media/sink/message/KeyCode.proto | 284 +++ .../message/VideoCodecResolutionType.proto | 15 + .../sink/message/VideoConfiguration.proto | 22 + .../sink/message/VideoFrameRateType.proto | 8 + .../media/source/MediaSourceService.proto | 13 + .../service/media/source/message/Ack.proto | 9 + .../source/message/MicrophoneRequest.proto | 10 + .../source/message/MicrophoneResponse.proto | 8 + .../media/video/message/VideoFocusMode.proto | 12 + .../message/VideoFocusNotification.proto | 10 + .../video/message/VideoFocusReason.proto | 11 + .../VideoFocusRequestNotification.proto | 12 + .../mediabrowser/MediaBrowserMessageId.proto | 12 + .../mediabrowser/MediaBrowserService.proto | 10 + .../message/MediaBrowserInput.proto | 10 + .../mediabrowser/message/MediaGetNode.proto | 9 + .../mediabrowser/message/MediaList.proto | 20 + .../mediabrowser/message/MediaListNode.proto | 13 + .../mediabrowser/message/MediaRootNode.proto | 10 + .../mediabrowser/message/MediaSong.proto | 10 + .../mediabrowser/message/MediaSongNode.proto | 11 + .../mediabrowser/message/MediaSource.proto | 9 + .../message/MediaSourceNode.proto | 13 + .../MediaPlaybackStatusMessageId.proto | 10 + .../MediaPlaybackStatusService.proto | 10 + .../message/MediaPlaybackMetadata.proto | 13 + .../message/MediaPlaybackStatus.proto | 18 + .../NavigationStatusMessageId.proto | 15 + .../NavigationStatusService.proto | 20 + .../message/NavigationCue.proto | 7 + .../message/NavigationCurrentPosition.proto | 13 + .../message/NavigationDestination.proto | 7 + .../NavigationDestinationDistance.proto | 11 + .../message/NavigationDistance.proto | 20 + .../message/NavigationLane.proto | 24 + .../message/NavigationManeuver.proto | 55 + .../NavigationNextTurnDistanceEvent.proto | 22 + .../message/NavigationNextTurnEvent.proto | 41 + .../message/NavigationRoad.proto | 7 + .../message/NavigationState.proto | 11 + .../message/NavigationStatus.proto | 14 + .../message/NavigationStatusStart.proto | 7 + .../message/NavigationStatusStop.proto | 7 + .../message/NavigationStep.proto | 15 + .../message/NavigationStepDistance.proto | 10 + .../phonestatus/PhoneStatusMessageId.proto | 10 + .../phonestatus/PhoneStatusService.proto | 10 + .../phonestatus/message/PhoneStatus.proto | 27 + .../message/PhoneStatusInput.proto | 11 + .../service/radio/RadioMessageId.proto | 33 + .../service/radio/RadioService.proto | 11 + .../message/ActiveRadioNotification.proto | 14 + .../CancelRadioOperationsRequest.proto | 9 + .../CancelRadioOperationsResponse.proto | 12 + .../ConfigureChannelSpacingRequest.proto | 10 + .../ConfigureChannelSpacingResponse.proto | 13 + .../radio/message/GetProgramListRequest.proto | 10 + .../message/GetProgramListResponse.proto | 15 + .../message/GetTrafficUpdateRequest.proto | 9 + .../message/GetTrafficUpdateResponse.proto | 14 + .../radio/message/HdAcquisionState.proto | 11 + .../message/HdRadioArtistExperience.proto | 11 + .../radio/message/HdRadioComment.proto | 11 + .../radio/message/HdRadioCommercial.proto | 16 + .../radio/message/HdRadioPsdData.proto | 19 + .../radio/message/HdRadioSisData.proto | 17 + .../radio/message/HdRadioStationInfo.proto | 17 + .../service/radio/message/ItuRegion.proto | 14 + .../service/radio/message/Location.proto | 10 + .../radio/message/MuteRadioRequest.proto | 10 + .../radio/message/MuteRadioResponse.proto | 13 + .../radio/message/RadioProperties.proto | 28 + .../radio/message/RadioSourceRequest.proto | 9 + .../radio/message/RadioSourceResponse.proto | 12 + .../message/RadioStateNotification.proto | 19 + .../radio/message/RadioStationInfo.proto | 15 + .../RadioStationInfoNotification.proto | 13 + .../radio/message/RadioStationMetaData.proto | 19 + .../service/radio/message/RadioType.proto | 14 + .../service/radio/message/Range.proto | 10 + .../service/radio/message/RdsData.proto | 17 + .../service/radio/message/RdsType.proto | 11 + .../radio/message/ScanStationsRequest.proto | 12 + .../radio/message/ScanStationsResponse.proto | 13 + .../radio/message/SeekStationRequest.proto | 11 + .../radio/message/SeekStationResponse.proto | 12 + .../message/SelectActiveRadioRequest.proto | 9 + .../service/radio/message/StationPreset.proto | 13 + .../radio/message/StationPresetList.proto | 13 + .../message/StationPresetsNotification.proto | 11 + .../radio/message/StepChannelRequest.proto | 11 + .../radio/message/StepChannelResponse.proto | 12 + .../radio/message/TrafficIncident.proto | 13 + .../radio/message/TrafficServiceType.proto | 10 + .../radio/message/TuneToStationRequest.proto | 11 + .../radio/message/TuneToStationResponse.proto | 12 + .../sensorsource/SensorMessageId.proto | 12 + .../sensorsource/SensorSourceService.proto | 15 + .../message/AccelerometerData.proto | 9 + .../sensorsource/message/CompassData.proto | 9 + .../message/DeadReckoningData.proto | 8 + .../message/DiagnosticsData.proto | 7 + .../sensorsource/message/DoorData.proto | 10 + .../sensorsource/message/DrivingStatus.proto | 13 + .../message/DrivingStatusData.proto | 8 + .../message/EnvironmentData.proto | 9 + .../message/EvConnectorType.proto | 17 + .../sensorsource/message/FuelData.proto | 9 + .../sensorsource/message/FuelType.proto | 19 + .../service/sensorsource/message/Gear.proto | 22 + .../sensorsource/message/GearData.proto | 10 + .../sensorsource/message/GpsSatellite.proto | 17 + .../sensorsource/message/GyroscopeData.proto | 9 + .../sensorsource/message/HeadLightState.proto | 9 + .../sensorsource/message/HvacData.proto | 8 + .../sensorsource/message/LightData.proto | 12 + .../sensorsource/message/LocationData.proto | 13 + .../sensorsource/message/NightModeData.proto | 7 + .../sensorsource/message/OdometerData.proto | 8 + .../message/ParkingBrakeData.proto | 7 + .../sensorsource/message/PassengerData.proto | 7 + .../sensorsource/message/RpmData.proto | 8 + .../service/sensorsource/message/Sensor.proto | 9 + .../sensorsource/message/SensorBatch.proto | 52 + .../sensorsource/message/SensorError.proto | 11 + .../message/SensorErrorType.proto | 9 + .../sensorsource/message/SensorRequest.proto | 11 + .../sensorsource/message/SensorResponse.proto | 9 + .../message/SensorStartResponseMessage.proto | 10 + .../sensorsource/message/SensorType.proto | 29 + .../sensorsource/message/SpeedData.proto | 9 + .../message/TirePressureData.proto | 7 + .../sensorsource/message/TollCardData.proto | 7 + .../message/TurnIndicatorState.proto | 9 + .../VendorExtensionService.proto | 10 + .../WifiProjectionMessageId.proto | 10 + .../WifiProjectionService.proto | 7 + .../message/AccessPointType.proto | 10 + .../message/WifiCredentialsRequest.proto | 9 + .../message/WifiCredentialsResponse.proto | 17 + .../message/WifiSecurityMode.proto | 18 + .../shared/InstrumentClusterInput.proto | 17 + .../aap_protobuf/shared/MessageStatus.proto | 38 + protobuf/aap_protobuf/shared/PhoneInfo.proto | 8 + src/Channel/AV/AVInputServiceChannel.cpp | 173 -- src/Channel/AV/AudioServiceChannel.cpp | 179 -- src/Channel/AV/MediaAudioServiceChannel.cpp | 37 - src/Channel/AV/MediaStatusServiceChannel.cpp | 146 -- src/Channel/AV/SpeechAudioServiceChannel.cpp | 37 - src/Channel/AV/SystemAudioServiceChannel.cpp | 37 - src/Channel/AV/VideoServiceChannel.cpp | 205 -- src/Channel/Bluetooth/BluetoothService.cpp | 151 ++ .../Bluetooth/BluetoothServiceChannel.cpp | 132 -- src/Channel/Channel.cpp | 45 + src/Channel/Control/ControlServiceChannel.cpp | 634 ++--- .../GenericNotification.cpp | 90 + src/Channel/Input/InputServiceChannel.cpp | 129 - .../InputSource/InputSourceService.cpp | 127 + .../MediaBrowser/MediaBrowserService.cpp | 96 + .../MediaPlaybackStatusService.cpp | 132 ++ .../MediaSink/Audio/AudioMediaSinkService.cpp | 180 ++ .../Audio/Channel/GuidanceAudioChannel.cpp | 29 + .../Audio/Channel/MediaAudioChannel.cpp | 30 + .../Audio/Channel/SystemAudioChannel.cpp | 31 + .../Audio/Channel/TelephonyAudioChannel.cpp | 27 + .../MediaSink/Video/Channel/VideoChannel.cpp | 27 + .../MediaSink/Video/VideoMediaSinkService.cpp | 204 ++ .../Audio/MicrophoneAudioChannel.cpp | 27 + .../MediaSource/MediaSourceService.cpp | 173 ++ .../NavigationStatusServiceChannel.cpp | 162 -- .../NavigationStatusService.cpp | 143 ++ .../PhoneStatus/PhoneStatusService.cpp | 93 + src/Channel/Radio/RadioService.cpp | 116 + src/Channel/Sensor/SensorServiceChannel.cpp | 129 - .../SensorSource/SensorSourceService.cpp | 127 + src/Channel/ServiceChannel.cpp | 51 - .../VendorExtensionService.cpp | 90 + .../WifiProjection/WifiProjectionService.cpp | 116 + src/Common/Data.cpp | 193 +- src/Error/Error.cpp | 112 +- src/IO/IOContextWrapper.cpp | 81 +- src/Main.ut.cpp | 35 +- src/Messenger/ChannelId.cpp | 106 +- src/Messenger/ChannelReceiveMessageQueue.cpp | 74 +- src/Messenger/ChannelReceivePromiseQueue.cpp | 101 +- src/Messenger/Cryptor.cpp | 311 ++- src/Messenger/FrameHeader.cpp | 107 +- src/Messenger/FrameSize.cpp | 117 +- src/Messenger/FrameType.cpp | 71 +- src/Messenger/Message.cpp | 145 +- src/Messenger/MessageId.cpp | 100 +- src/Messenger/MessageInStream.cpp | 247 +- src/Messenger/MessageInStream.ut.cpp | 653 ++--- src/Messenger/MessageOutStream.cpp | 212 +- src/Messenger/MessageOutStream.ut.cpp | 440 ++-- src/Messenger/Messenger.cpp | 194 +- src/Messenger/Messenger.ut.cpp | 378 +-- src/Messenger/ServiceId.cpp | 60 + src/Messenger/Timestamp.cpp | 64 +- src/TCP/TCPEndpoint.cpp | 86 +- src/TCP/TCPEndpoint.ut.cpp | 196 +- src/TCP/TCPWrapper.cpp | 89 +- src/Transport/DataSink.cpp | 98 +- src/Transport/SSLWrapper.cpp | 280 +-- src/Transport/TCPTransport.cpp | 117 +- src/Transport/TCPTransport.ut.cpp | 479 ++-- src/Transport/Transport.cpp | 155 +- src/Transport/USBTransport.cpp | 126 +- src/Transport/USBTransport.ut.cpp | 553 ++--- src/USB/AOAPDevice.cpp | 170 +- src/USB/AOAPDevice.ut.cpp | 118 +- src/USB/AccessoryModeProtocolVersionQuery.cpp | 107 +- .../AccessoryModeProtocolVersionQuery.ut.cpp | 33 +- src/USB/AccessoryModeQuery.cpp | 56 +- src/USB/AccessoryModeQueryChain.cpp | 369 ++- src/USB/AccessoryModeQueryChain.ut.cpp | 982 ++++---- src/USB/AccessoryModeQueryChainFactory.cpp | 61 +- src/USB/AccessoryModeQueryFactory.cpp | 110 +- src/USB/AccessoryModeSendStringQuery.cpp | 113 +- src/USB/AccessoryModeSendStringQuery.ut.cpp | 274 ++- src/USB/AccessoryModeStartQuery.cpp | 101 +- src/USB/AccessoryModeStartQuery.ut.cpp | 234 +- src/USB/ConnectedAccessoriesEnumerator.cpp | 184 +- src/USB/ConnectedAccessoriesEnumerator.ut.cpp | 396 ++-- src/USB/USBEndpoint.cpp | 246 +- src/USB/USBEndpoint.ut.cpp | 472 ++-- src/USB/USBHub.cpp | 174 +- src/USB/USBHub.ut.cpp | 430 ++-- src/USB/USBWrapper.cpp | 260 +- unit_test/Messenger/UT/Cryptor.mock.hpp | 18 - .../Messenger/UT/MessageInStream.mock.hpp | 18 - .../Messenger/UT/MessageOutStream.mock.hpp | 18 - .../UT/ReceivePromiseHandler.mock.hpp | 18 - .../Messenger/UT/SendPromiseHandler.mock.hpp | 18 - unit_test/TCP/UT/TCPEndpoint.mock.hpp | 18 - .../TCP/UT/TCPEndpointPromiseHandler.mock.hpp | 18 - unit_test/TCP/UT/TCPWrapper.mock.hpp | 18 - unit_test/Transport/UT/Transport.mock.hpp | 18 - .../TransportReceivePromiseHandler.mock.hpp | 18 - .../UT/TransportSendPromiseHandler.mock.hpp | 18 - unit_test/USB/UT/AOAPDevice.mock.hpp | 18 - unit_test/USB/UT/AccessoryModeQuery.mock.hpp | 18 - .../USB/UT/AccessoryModeQueryChain.mock.hpp | 18 - .../AccessoryModeQueryChainFactory.mock.hpp | 18 - ...ssoryModeQueryChainPromiseHandler.mock.hpp | 18 - .../USB/UT/AccessoryModeQueryFactory.mock.hpp | 18 - .../AccessoryModeQueryPromiseHandler.mock.hpp | 18 - ...cessoriesEnumeratorPromiseHandler.mock.hpp | 18 - unit_test/USB/UT/USBEndpoint.mock.hpp | 18 - .../USB/UT/USBEndpointPromiseHandler.mock.hpp | 18 - unit_test/USB/UT/USBHub.mock.hpp | 18 - .../USB/UT/USBHubPromiseHandler.mock.hpp | 18 - unit_test/USB/UT/USBWrapper.mock.hpp | 18 - 630 files changed, 19866 insertions(+), 15427 deletions(-) create mode 100644 Config.cmake.in create mode 100644 RELEASE.txt delete mode 100644 aasdk_proto/AVChannelData.proto delete mode 100644 aasdk_proto/AVChannelMessageIdsEnum.proto delete mode 100644 aasdk_proto/AVChannelSetupRequestMessage.proto delete mode 100644 aasdk_proto/AVChannelSetupResponseMessage.proto delete mode 100644 aasdk_proto/AVChannelSetupStatusEnum.proto delete mode 100644 aasdk_proto/AVChannelStartIndicationMessage.proto delete mode 100644 aasdk_proto/AVChannelStopIndicationMessage.proto delete mode 100644 aasdk_proto/AVInputChannelData.proto delete mode 100644 aasdk_proto/AVInputOpenRequestMessage.proto delete mode 100644 aasdk_proto/AVInputOpenResponseMessage.proto delete mode 100644 aasdk_proto/AVMediaAckIndicationMessage.proto delete mode 100644 aasdk_proto/AVStreamTypeEnum.proto delete mode 100644 aasdk_proto/AbsoluteInputEventData.proto delete mode 100644 aasdk_proto/AbsoluteInputEventsData.proto delete mode 100644 aasdk_proto/AccelData.proto delete mode 100644 aasdk_proto/AudioConfigData.proto delete mode 100644 aasdk_proto/AudioFocusRequestMessage.proto delete mode 100644 aasdk_proto/AudioFocusResponseMessage.proto delete mode 100644 aasdk_proto/AudioFocusStateEnum.proto delete mode 100644 aasdk_proto/AudioFocusTypeEnum.proto delete mode 100644 aasdk_proto/AudioTypeEnum.proto delete mode 100644 aasdk_proto/AuthCompleteIndicationMessage.proto delete mode 100644 aasdk_proto/BindingRequestMessage.proto delete mode 100644 aasdk_proto/BindingResponseMessage.proto delete mode 100644 aasdk_proto/BluetoothChannelData.proto delete mode 100644 aasdk_proto/BluetoothChannelMessageIdsEnum.proto delete mode 100644 aasdk_proto/BluetoothPairingMethodEnum.proto delete mode 100644 aasdk_proto/BluetoothPairingRequestMessage.proto delete mode 100644 aasdk_proto/BluetoothPairingResponseMessage.proto delete mode 100644 aasdk_proto/BluetoothPairingStatusEnum.proto delete mode 100644 aasdk_proto/ButtonCodeEnum.proto delete mode 100644 aasdk_proto/ButtonEventData.proto delete mode 100644 aasdk_proto/ButtonEventsData.proto delete mode 100644 aasdk_proto/CMakeLists.txt delete mode 100644 aasdk_proto/ChannelDescriptorData.proto delete mode 100644 aasdk_proto/ChannelOpenRequestMessage.proto delete mode 100644 aasdk_proto/ChannelOpenResponseMessage.proto delete mode 100644 aasdk_proto/CompassData.proto delete mode 100644 aasdk_proto/ControlMessageIdsEnum.proto delete mode 100644 aasdk_proto/DiagnosticsData.proto delete mode 100644 aasdk_proto/DistanceUnitEnum.proto delete mode 100644 aasdk_proto/DoorData.proto delete mode 100644 aasdk_proto/DrivingStatusData.proto delete mode 100644 aasdk_proto/DrivingStatusEnum.proto delete mode 100644 aasdk_proto/EnvironmentData.proto delete mode 100644 aasdk_proto/FuelLevelData.proto delete mode 100644 aasdk_proto/GPSLocationData.proto delete mode 100644 aasdk_proto/GearData.proto delete mode 100644 aasdk_proto/GearEnum.proto delete mode 100644 aasdk_proto/GyroData.proto delete mode 100644 aasdk_proto/HVACData.proto delete mode 100644 aasdk_proto/HeadlightStatusEnum.proto delete mode 100644 aasdk_proto/IndicatorStatusEnum.proto delete mode 100644 aasdk_proto/InputChannelData.proto delete mode 100644 aasdk_proto/InputChannelMessageIdsEnum.proto delete mode 100644 aasdk_proto/InputEventIndicationMessage.proto delete mode 100644 aasdk_proto/LightData.proto delete mode 100644 aasdk_proto/ManeuverDirectionEnum.proto delete mode 100644 aasdk_proto/ManeuverTypeEnum.proto delete mode 100644 aasdk_proto/MediaInfoChannelData.proto delete mode 100644 aasdk_proto/MediaInfoChannelMessageIdsEnum.proto delete mode 100644 aasdk_proto/MediaInfoChannelMetadataData.proto delete mode 100644 aasdk_proto/MediaInfoChannelPlaybackData.proto delete mode 100644 aasdk_proto/NavigationChannelData.proto delete mode 100644 aasdk_proto/NavigationChannelMessageIdsEnum.proto delete mode 100644 aasdk_proto/NavigationDistanceEventMessage.proto delete mode 100644 aasdk_proto/NavigationFocusRequestMessage.proto delete mode 100644 aasdk_proto/NavigationFocusResponseMessage.proto delete mode 100644 aasdk_proto/NavigationImageOptionsData.proto delete mode 100644 aasdk_proto/NavigationStatusMessage.proto delete mode 100644 aasdk_proto/NavigationTurnEventMessage.proto delete mode 100644 aasdk_proto/NavigationTurnTypeEnum.proto delete mode 100644 aasdk_proto/NightModeData.proto delete mode 100644 aasdk_proto/OdometerData.proto delete mode 100644 aasdk_proto/ParkingBrakeData.proto delete mode 100644 aasdk_proto/PassengerData.proto delete mode 100644 aasdk_proto/PingRequestMessage.proto delete mode 100644 aasdk_proto/PingResponseMessage.proto delete mode 100644 aasdk_proto/RPMData.proto delete mode 100644 aasdk_proto/RelativeInputEventData.proto delete mode 100644 aasdk_proto/RelativeInputEventsData.proto delete mode 100644 aasdk_proto/SensorChannelData.proto delete mode 100644 aasdk_proto/SensorChannelMessageIdsEnum.proto delete mode 100644 aasdk_proto/SensorData.proto delete mode 100644 aasdk_proto/SensorEventIndicationMessage.proto delete mode 100644 aasdk_proto/SensorStartRequestMessage.proto delete mode 100644 aasdk_proto/SensorStartResponseMessage.proto delete mode 100644 aasdk_proto/SensorTypeEnum.proto delete mode 100644 aasdk_proto/ServiceDiscoveryRequestMessage.proto delete mode 100644 aasdk_proto/ServiceDiscoveryResponseMessage.proto delete mode 100644 aasdk_proto/ShutdownReasonEnum.proto delete mode 100644 aasdk_proto/ShutdownRequestMessage.proto delete mode 100644 aasdk_proto/ShutdownResponseMessage.proto delete mode 100644 aasdk_proto/SpeedData.proto delete mode 100644 aasdk_proto/StatusEnum.proto delete mode 100644 aasdk_proto/SteeringWheelData.proto delete mode 100644 aasdk_proto/TouchActionEnum.proto delete mode 100644 aasdk_proto/TouchConfigData.proto delete mode 100644 aasdk_proto/TouchEventData.proto delete mode 100644 aasdk_proto/TouchLocationData.proto delete mode 100644 aasdk_proto/VendorExtensionChannelData.proto delete mode 100644 aasdk_proto/VersionResponseStatusEnum.proto delete mode 100644 aasdk_proto/VideoConfigData.proto delete mode 100644 aasdk_proto/VideoFPSEnum.proto delete mode 100644 aasdk_proto/VideoFocusIndicationMessage.proto delete mode 100644 aasdk_proto/VideoFocusModeEnum.proto delete mode 100644 aasdk_proto/VideoFocusReasonEnum.proto delete mode 100644 aasdk_proto/VideoFocusRequestMessage.proto delete mode 100644 aasdk_proto/VideoResolutionEnum.proto delete mode 100644 aasdk_proto/VoiceSessionRequestMessage.proto delete mode 100644 aasdk_proto/WifiChannelData.proto create mode 100644 cmake_modules/Findaap_protobuf.cmake create mode 100644 docs/common.proto create mode 100644 docs/protos.proto delete mode 100644 include/aasdk/Channel/AV/AVInputServiceChannel.hpp delete mode 100644 include/aasdk/Channel/AV/AudioServiceChannel.hpp delete mode 100644 include/aasdk/Channel/AV/IAVInputServiceChannel.hpp delete mode 100644 include/aasdk/Channel/AV/IAVInputServiceChannelEventHandler.hpp delete mode 100644 include/aasdk/Channel/AV/IAudioServiceChannel.hpp delete mode 100644 include/aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp delete mode 100644 include/aasdk/Channel/AV/IMediaStatusServiceChannel.hpp delete mode 100644 include/aasdk/Channel/AV/IMediaStatusServiceChannelEventHandler.hpp delete mode 100644 include/aasdk/Channel/AV/IVideoServiceChannel.hpp delete mode 100644 include/aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp delete mode 100644 include/aasdk/Channel/AV/MediaAudioServiceChannel.hpp delete mode 100644 include/aasdk/Channel/AV/MediaStatusServiceChannel.hpp delete mode 100644 include/aasdk/Channel/AV/SpeechAudioServiceChannel.hpp delete mode 100644 include/aasdk/Channel/AV/SystemAudioServiceChannel.hpp delete mode 100644 include/aasdk/Channel/AV/VideoServiceChannel.hpp create mode 100644 include/aasdk/Channel/Bluetooth/BluetoothService.hpp delete mode 100644 include/aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp create mode 100644 include/aasdk/Channel/Bluetooth/IBluetoothService.hpp delete mode 100644 include/aasdk/Channel/Bluetooth/IBluetoothServiceChannel.hpp delete mode 100644 include/aasdk/Channel/Bluetooth/IBluetoothServiceChannelEventHandler.hpp create mode 100644 include/aasdk/Channel/Bluetooth/IBluetoothServiceEventHandler.hpp create mode 100644 include/aasdk/Channel/Channel.hpp create mode 100644 include/aasdk/Channel/GenericNotification/GenericNotificationService.hpp create mode 100644 include/aasdk/Channel/GenericNotification/IGenericNotificationService.hpp create mode 100644 include/aasdk/Channel/GenericNotification/IGenericNotificationServiceEventHandler.hpp create mode 100644 include/aasdk/Channel/IChannel.hpp delete mode 100644 include/aasdk/Channel/Input/IInputServiceChannel.hpp delete mode 100644 include/aasdk/Channel/Input/IInputServiceChannelEventHandler.hpp delete mode 100644 include/aasdk/Channel/Input/InputServiceChannel.hpp create mode 100644 include/aasdk/Channel/InputSource/IInputSourceService.hpp create mode 100644 include/aasdk/Channel/InputSource/IInputSourceServiceEventHandler.hpp create mode 100644 include/aasdk/Channel/InputSource/InputSourceService.hpp create mode 100644 include/aasdk/Channel/MediaBrowser/IMediaBrowserService.hpp create mode 100644 include/aasdk/Channel/MediaBrowser/IMediaBrowserServiceEventHandler.hpp create mode 100644 include/aasdk/Channel/MediaBrowser/MediaBrowserService.hpp create mode 100644 include/aasdk/Channel/MediaPlaybackStatus/IMediaPlaybackStatusService.hpp create mode 100644 include/aasdk/Channel/MediaPlaybackStatus/IMediaPlaybackStatusServiceEventHandler.hpp create mode 100644 include/aasdk/Channel/MediaPlaybackStatus/MediaPlaybackStatusService.hpp create mode 100644 include/aasdk/Channel/MediaSink/Audio/AudioMediaSinkService.hpp create mode 100644 include/aasdk/Channel/MediaSink/Audio/Channel/GuidanceAudioChannel.hpp create mode 100644 include/aasdk/Channel/MediaSink/Audio/Channel/MediaAudioChannel.hpp create mode 100644 include/aasdk/Channel/MediaSink/Audio/Channel/SystemAudioChannel.hpp create mode 100644 include/aasdk/Channel/MediaSink/Audio/Channel/TelephonyAudioChannel.hpp create mode 100644 include/aasdk/Channel/MediaSink/Audio/IAudioMediaSinkService.hpp create mode 100644 include/aasdk/Channel/MediaSink/Audio/IAudioMediaSinkServiceEventHandler.hpp create mode 100644 include/aasdk/Channel/MediaSink/Video/Channel/VideoChannel.hpp create mode 100644 include/aasdk/Channel/MediaSink/Video/IVideoMediaSinkService.hpp create mode 100644 include/aasdk/Channel/MediaSink/Video/IVideoMediaSinkServiceEventHandler.hpp create mode 100644 include/aasdk/Channel/MediaSink/Video/VideoMediaSinkService.hpp create mode 100644 include/aasdk/Channel/MediaSource/Audio/MicrophoneAudioChannel.hpp create mode 100644 include/aasdk/Channel/MediaSource/IMediaSourceService.hpp create mode 100644 include/aasdk/Channel/MediaSource/IMediaSourceServiceEventHandler.hpp create mode 100644 include/aasdk/Channel/MediaSource/MediaSourceService.hpp delete mode 100644 include/aasdk/Channel/Navigation/INavigationStatusServiceChannel.hpp delete mode 100644 include/aasdk/Channel/Navigation/INavigationStatusServiceChannelEventHandler.hpp delete mode 100644 include/aasdk/Channel/Navigation/NavigationStatusServiceChannel.hpp create mode 100644 include/aasdk/Channel/NavigationStatus/INavigationStatusService.hpp create mode 100644 include/aasdk/Channel/NavigationStatus/INavigationStatusServiceEventHandler.hpp create mode 100644 include/aasdk/Channel/NavigationStatus/NavigationStatusService.hpp create mode 100644 include/aasdk/Channel/PhoneStatus/IPhoneStatusService.hpp create mode 100644 include/aasdk/Channel/PhoneStatus/IPhoneStatusServiceEventHandler.hpp create mode 100644 include/aasdk/Channel/PhoneStatus/PhoneStatusService.hpp create mode 100644 include/aasdk/Channel/Radio/IRadioService.hpp create mode 100644 include/aasdk/Channel/Radio/IRadioServiceEventHandler.hpp create mode 100644 include/aasdk/Channel/Radio/RadioService.hpp delete mode 100644 include/aasdk/Channel/Sensor/ISensorServiceChannel.hpp delete mode 100644 include/aasdk/Channel/Sensor/ISensorServiceChannelEventHandler.hpp delete mode 100644 include/aasdk/Channel/Sensor/SensorServiceChannel.hpp create mode 100644 include/aasdk/Channel/SensorSource/ISensorSourceService.hpp create mode 100644 include/aasdk/Channel/SensorSource/ISensorSourceServiceEventHandler.hpp create mode 100644 include/aasdk/Channel/SensorSource/SensorSourceService.hpp delete mode 100644 include/aasdk/Channel/ServiceChannel.hpp create mode 100644 include/aasdk/Channel/VendorExtension/IVendorExtensionService.hpp create mode 100644 include/aasdk/Channel/VendorExtension/IVendorExtensionServiceEventHandler.hpp create mode 100644 include/aasdk/Channel/VendorExtension/VendorExtensionService.hpp create mode 100644 include/aasdk/Channel/WifiProjection/IWifiProjectionService.hpp create mode 100644 include/aasdk/Channel/WifiProjection/IWifiProjectionServiceEventHandler.hpp create mode 100644 include/aasdk/Channel/WifiProjection/WifiProjectionService.hpp create mode 100644 include/aasdk/Messenger/ServiceId.hpp create mode 100644 protobuf/CMakeLists.txt create mode 100644 protobuf/Config.cmake.in create mode 100644 protobuf/README.md create mode 100644 protobuf/aap_protobuf/aaw/MessageId.proto create mode 100644 protobuf/aap_protobuf/aaw/Status.proto create mode 100644 protobuf/aap_protobuf/aaw/WifiConnectionStatus.proto create mode 100644 protobuf/aap_protobuf/aaw/WifiInfoRequest.proto create mode 100644 protobuf/aap_protobuf/aaw/WifiInfoResponse.proto create mode 100644 protobuf/aap_protobuf/aaw/WifiStartRequest.proto create mode 100644 protobuf/aap_protobuf/aaw/WifiStartResponse.proto create mode 100644 protobuf/aap_protobuf/aaw/WifiVersionRequest.proto create mode 100644 protobuf/aap_protobuf/aaw/WifiVersionResponse.proto create mode 100644 protobuf/aap_protobuf/channel/control/GalConstants.proto create mode 100644 protobuf/aap_protobuf/channel/control/GalVerificationAudioFocus.proto create mode 100644 protobuf/aap_protobuf/channel/control/GalVerificationBugReportRequest.proto create mode 100644 protobuf/aap_protobuf/channel/control/GalVerificationBugReportResponse.proto create mode 100644 protobuf/aap_protobuf/channel/control/GalVerificationDisplayInformationRequest.proto create mode 100644 protobuf/aap_protobuf/channel/control/GalVerificationDisplayInformationResponse.proto create mode 100644 protobuf/aap_protobuf/channel/control/GalVerificationInjectInput.proto create mode 100644 protobuf/aap_protobuf/channel/control/GalVerificationMediaSinkStatus.proto create mode 100644 protobuf/aap_protobuf/channel/control/GalVerificationScreenCaptureRequest.proto create mode 100644 protobuf/aap_protobuf/channel/control/GalVerificationScreenCaptureResponse.proto create mode 100644 protobuf/aap_protobuf/channel/control/GalVerificationSetSensor.proto create mode 100644 protobuf/aap_protobuf/channel/control/GalVerificationVendorExtensionMessageId.proto create mode 100644 protobuf/aap_protobuf/channel/control/GalVerificationVideoFocus.proto create mode 100644 protobuf/aap_protobuf/channel/control/GoogleDiagnosticsBugReportRequest.proto create mode 100644 protobuf/aap_protobuf/channel/control/GoogleDiagnosticsBugReportResponse.proto create mode 100644 protobuf/aap_protobuf/channel/control/GoogleDiagnosticsVendorExtensionMessageId.proto create mode 100644 protobuf/aap_protobuf/channel/control/InstrumentClusterInput.proto create mode 100644 protobuf/aap_protobuf/channel/control/LocationCharacterization.proto create mode 100644 protobuf/aap_protobuf/channel/control/SessionConfiguration.proto create mode 100644 protobuf/aap_protobuf/service/Service.proto create mode 100644 protobuf/aap_protobuf/service/bluetooth/BluetoothMessageId.proto create mode 100644 protobuf/aap_protobuf/service/bluetooth/BluetoothService.proto create mode 100644 protobuf/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationData.proto create mode 100644 protobuf/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationResult.proto create mode 100644 protobuf/aap_protobuf/service/bluetooth/message/BluetoothPairingMethod.proto create mode 100644 protobuf/aap_protobuf/service/bluetooth/message/BluetoothPairingRequest.proto create mode 100644 protobuf/aap_protobuf/service/bluetooth/message/BluetoothPairingResponse.proto create mode 100644 protobuf/aap_protobuf/service/control/ControlMessageType.proto create mode 100644 protobuf/aap_protobuf/service/control/message/AudioFocusNotification.proto create mode 100644 protobuf/aap_protobuf/service/control/message/AudioFocusRequest.proto create mode 100644 protobuf/aap_protobuf/service/control/message/AudioFocusRequestNotification.proto create mode 100644 protobuf/aap_protobuf/service/control/message/AudioFocusRequestType.proto create mode 100644 protobuf/aap_protobuf/service/control/message/AudioFocusStateType.proto create mode 100644 protobuf/aap_protobuf/service/control/message/AuthResponse.proto create mode 100644 protobuf/aap_protobuf/service/control/message/BatteryStatusNotification.proto create mode 100644 protobuf/aap_protobuf/service/control/message/ByeByeReason.proto create mode 100644 protobuf/aap_protobuf/service/control/message/ByeByeRequest.proto create mode 100644 protobuf/aap_protobuf/service/control/message/ByeByeResponse.proto create mode 100644 protobuf/aap_protobuf/service/control/message/CallAvailabilityStatus.proto create mode 100644 protobuf/aap_protobuf/service/control/message/CarConnectedDevices.proto create mode 100644 protobuf/aap_protobuf/service/control/message/CarConnectedDevicesRequest.proto create mode 100644 protobuf/aap_protobuf/service/control/message/ChannelCloseNotification.proto create mode 100644 protobuf/aap_protobuf/service/control/message/ChannelOpenRequest.proto create mode 100644 protobuf/aap_protobuf/service/control/message/ChannelOpenResponse.proto create mode 100644 protobuf/aap_protobuf/service/control/message/ConnectedDevice.proto create mode 100644 protobuf/aap_protobuf/service/control/message/ConnectionConfiguration.proto create mode 100644 protobuf/aap_protobuf/service/control/message/DriverPosition.proto create mode 100644 protobuf/aap_protobuf/service/control/message/FragInfo.proto create mode 100644 protobuf/aap_protobuf/service/control/message/HeadUnitInfo.proto create mode 100644 protobuf/aap_protobuf/service/control/message/NavFocusNotification.proto create mode 100644 protobuf/aap_protobuf/service/control/message/NavFocusRequestNotification.proto create mode 100644 protobuf/aap_protobuf/service/control/message/NavFocusType.proto create mode 100644 protobuf/aap_protobuf/service/control/message/PingConfiguration.proto create mode 100644 protobuf/aap_protobuf/service/control/message/PingRequest.proto create mode 100644 protobuf/aap_protobuf/service/control/message/PingResponse.proto create mode 100644 protobuf/aap_protobuf/service/control/message/ServiceDiscoveryRequest.proto create mode 100644 protobuf/aap_protobuf/service/control/message/ServiceDiscoveryResponse.proto create mode 100644 protobuf/aap_protobuf/service/control/message/ServiceDiscoveryUpdate.proto create mode 100644 protobuf/aap_protobuf/service/control/message/UpdateUiConfigReply.proto create mode 100644 protobuf/aap_protobuf/service/control/message/UpdateUiConfigRequest.proto create mode 100644 protobuf/aap_protobuf/service/control/message/UserSwitchRequest.proto create mode 100644 protobuf/aap_protobuf/service/control/message/UserSwitchResponse.proto create mode 100644 protobuf/aap_protobuf/service/control/message/UserSwitchStatus.proto create mode 100644 protobuf/aap_protobuf/service/control/message/VersionRequestOptions.proto create mode 100644 protobuf/aap_protobuf/service/control/message/VersionResponseOptions.proto create mode 100644 protobuf/aap_protobuf/service/control/message/VoiceSessionNotification.proto create mode 100644 protobuf/aap_protobuf/service/control/message/VoiceSessionStatus.proto create mode 100644 protobuf/aap_protobuf/service/control/message/WirelessTcpConfiguration.proto create mode 100644 protobuf/aap_protobuf/service/genericnotification/GenericNotificationMessageId.proto create mode 100644 protobuf/aap_protobuf/service/genericnotification/GenericNotificationService.proto create mode 100644 protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationAck.proto create mode 100644 protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationMessage.proto create mode 100644 protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationSubscribe.proto create mode 100644 protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationUnsubscribe.proto create mode 100644 protobuf/aap_protobuf/service/inputsource/InputMessageId.proto create mode 100644 protobuf/aap_protobuf/service/inputsource/InputSourceService.proto create mode 100644 protobuf/aap_protobuf/service/inputsource/message/AbsoluteEvent.proto create mode 100644 protobuf/aap_protobuf/service/inputsource/message/FeedbackEvent.proto create mode 100644 protobuf/aap_protobuf/service/inputsource/message/InputFeedback.proto create mode 100644 protobuf/aap_protobuf/service/inputsource/message/InputReport.proto create mode 100644 protobuf/aap_protobuf/service/inputsource/message/KeyEvent.proto create mode 100644 protobuf/aap_protobuf/service/inputsource/message/PointerAction.proto create mode 100644 protobuf/aap_protobuf/service/inputsource/message/RelativeEvent.proto create mode 100644 protobuf/aap_protobuf/service/inputsource/message/TouchEvent.proto create mode 100644 protobuf/aap_protobuf/service/inputsource/message/TouchScreenType.proto create mode 100644 protobuf/aap_protobuf/service/media/shared/message/AudioConfiguration.proto create mode 100644 protobuf/aap_protobuf/service/media/shared/message/Config.proto create mode 100644 protobuf/aap_protobuf/service/media/shared/message/Insets.proto create mode 100644 protobuf/aap_protobuf/service/media/shared/message/MediaCodecType.proto create mode 100644 protobuf/aap_protobuf/service/media/shared/message/Setup.proto create mode 100644 protobuf/aap_protobuf/service/media/shared/message/Start.proto create mode 100644 protobuf/aap_protobuf/service/media/shared/message/Stop.proto create mode 100644 protobuf/aap_protobuf/service/media/shared/message/UiConfig.proto create mode 100644 protobuf/aap_protobuf/service/media/shared/message/UiTheme.proto create mode 100644 protobuf/aap_protobuf/service/media/sink/MediaMessageId.proto create mode 100644 protobuf/aap_protobuf/service/media/sink/MediaSinkService.proto create mode 100644 protobuf/aap_protobuf/service/media/sink/message/AudioStreamType.proto create mode 100644 protobuf/aap_protobuf/service/media/sink/message/AudioUnderflowNotification.proto create mode 100644 protobuf/aap_protobuf/service/media/sink/message/DisplayType.proto create mode 100644 protobuf/aap_protobuf/service/media/sink/message/KeyBindingRequest.proto create mode 100644 protobuf/aap_protobuf/service/media/sink/message/KeyBindingResponse.proto create mode 100644 protobuf/aap_protobuf/service/media/sink/message/KeyCode.proto create mode 100644 protobuf/aap_protobuf/service/media/sink/message/VideoCodecResolutionType.proto create mode 100644 protobuf/aap_protobuf/service/media/sink/message/VideoConfiguration.proto create mode 100644 protobuf/aap_protobuf/service/media/sink/message/VideoFrameRateType.proto create mode 100644 protobuf/aap_protobuf/service/media/source/MediaSourceService.proto create mode 100644 protobuf/aap_protobuf/service/media/source/message/Ack.proto create mode 100644 protobuf/aap_protobuf/service/media/source/message/MicrophoneRequest.proto create mode 100644 protobuf/aap_protobuf/service/media/source/message/MicrophoneResponse.proto create mode 100644 protobuf/aap_protobuf/service/media/video/message/VideoFocusMode.proto create mode 100644 protobuf/aap_protobuf/service/media/video/message/VideoFocusNotification.proto create mode 100644 protobuf/aap_protobuf/service/media/video/message/VideoFocusReason.proto create mode 100644 protobuf/aap_protobuf/service/media/video/message/VideoFocusRequestNotification.proto create mode 100644 protobuf/aap_protobuf/service/mediabrowser/MediaBrowserMessageId.proto create mode 100644 protobuf/aap_protobuf/service/mediabrowser/MediaBrowserService.proto create mode 100644 protobuf/aap_protobuf/service/mediabrowser/message/MediaBrowserInput.proto create mode 100644 protobuf/aap_protobuf/service/mediabrowser/message/MediaGetNode.proto create mode 100644 protobuf/aap_protobuf/service/mediabrowser/message/MediaList.proto create mode 100644 protobuf/aap_protobuf/service/mediabrowser/message/MediaListNode.proto create mode 100644 protobuf/aap_protobuf/service/mediabrowser/message/MediaRootNode.proto create mode 100644 protobuf/aap_protobuf/service/mediabrowser/message/MediaSong.proto create mode 100644 protobuf/aap_protobuf/service/mediabrowser/message/MediaSongNode.proto create mode 100644 protobuf/aap_protobuf/service/mediabrowser/message/MediaSource.proto create mode 100644 protobuf/aap_protobuf/service/mediabrowser/message/MediaSourceNode.proto create mode 100644 protobuf/aap_protobuf/service/mediaplayback/MediaPlaybackStatusMessageId.proto create mode 100644 protobuf/aap_protobuf/service/mediaplayback/MediaPlaybackStatusService.proto create mode 100644 protobuf/aap_protobuf/service/mediaplayback/message/MediaPlaybackMetadata.proto create mode 100644 protobuf/aap_protobuf/service/mediaplayback/message/MediaPlaybackStatus.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/NavigationStatusMessageId.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/NavigationStatusService.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationCue.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationCurrentPosition.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationDestination.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationDestinationDistance.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationDistance.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationLane.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationManeuver.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationNextTurnDistanceEvent.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationNextTurnEvent.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationRoad.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationState.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationStatus.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationStatusStart.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationStatusStop.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationStep.proto create mode 100644 protobuf/aap_protobuf/service/navigationstatus/message/NavigationStepDistance.proto create mode 100644 protobuf/aap_protobuf/service/phonestatus/PhoneStatusMessageId.proto create mode 100644 protobuf/aap_protobuf/service/phonestatus/PhoneStatusService.proto create mode 100644 protobuf/aap_protobuf/service/phonestatus/message/PhoneStatus.proto create mode 100644 protobuf/aap_protobuf/service/phonestatus/message/PhoneStatusInput.proto create mode 100644 protobuf/aap_protobuf/service/radio/RadioMessageId.proto create mode 100644 protobuf/aap_protobuf/service/radio/RadioService.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/ActiveRadioNotification.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/CancelRadioOperationsRequest.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/CancelRadioOperationsResponse.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/ConfigureChannelSpacingRequest.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/ConfigureChannelSpacingResponse.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/GetProgramListRequest.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/GetProgramListResponse.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/GetTrafficUpdateRequest.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/GetTrafficUpdateResponse.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/HdAcquisionState.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/HdRadioArtistExperience.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/HdRadioComment.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/HdRadioCommercial.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/HdRadioPsdData.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/HdRadioSisData.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/HdRadioStationInfo.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/ItuRegion.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/Location.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/MuteRadioRequest.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/MuteRadioResponse.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/RadioProperties.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/RadioSourceRequest.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/RadioSourceResponse.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/RadioStateNotification.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/RadioStationInfo.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/RadioStationInfoNotification.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/RadioStationMetaData.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/RadioType.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/Range.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/RdsData.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/RdsType.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/ScanStationsRequest.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/ScanStationsResponse.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/SeekStationRequest.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/SeekStationResponse.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/SelectActiveRadioRequest.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/StationPreset.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/StationPresetList.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/StationPresetsNotification.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/StepChannelRequest.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/StepChannelResponse.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/TrafficIncident.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/TrafficServiceType.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/TuneToStationRequest.proto create mode 100644 protobuf/aap_protobuf/service/radio/message/TuneToStationResponse.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/SensorMessageId.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/SensorSourceService.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/AccelerometerData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/CompassData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/DeadReckoningData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/DiagnosticsData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/DoorData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/DrivingStatus.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/DrivingStatusData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/EnvironmentData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/EvConnectorType.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/FuelData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/FuelType.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/Gear.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/GearData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/GpsSatellite.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/GyroscopeData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/HeadLightState.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/HvacData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/LightData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/LocationData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/NightModeData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/OdometerData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/ParkingBrakeData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/PassengerData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/RpmData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/Sensor.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/SensorBatch.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/SensorError.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/SensorErrorType.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/SensorRequest.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/SensorResponse.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/SensorStartResponseMessage.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/SensorType.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/SpeedData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/TirePressureData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/TollCardData.proto create mode 100644 protobuf/aap_protobuf/service/sensorsource/message/TurnIndicatorState.proto create mode 100644 protobuf/aap_protobuf/service/vendorextension/VendorExtensionService.proto create mode 100644 protobuf/aap_protobuf/service/wifiprojection/WifiProjectionMessageId.proto create mode 100644 protobuf/aap_protobuf/service/wifiprojection/WifiProjectionService.proto create mode 100644 protobuf/aap_protobuf/service/wifiprojection/message/AccessPointType.proto create mode 100644 protobuf/aap_protobuf/service/wifiprojection/message/WifiCredentialsRequest.proto create mode 100644 protobuf/aap_protobuf/service/wifiprojection/message/WifiCredentialsResponse.proto create mode 100644 protobuf/aap_protobuf/service/wifiprojection/message/WifiSecurityMode.proto create mode 100644 protobuf/aap_protobuf/shared/InstrumentClusterInput.proto create mode 100644 protobuf/aap_protobuf/shared/MessageStatus.proto create mode 100644 protobuf/aap_protobuf/shared/PhoneInfo.proto delete mode 100644 src/Channel/AV/AVInputServiceChannel.cpp delete mode 100644 src/Channel/AV/AudioServiceChannel.cpp delete mode 100644 src/Channel/AV/MediaAudioServiceChannel.cpp delete mode 100644 src/Channel/AV/MediaStatusServiceChannel.cpp delete mode 100644 src/Channel/AV/SpeechAudioServiceChannel.cpp delete mode 100644 src/Channel/AV/SystemAudioServiceChannel.cpp delete mode 100644 src/Channel/AV/VideoServiceChannel.cpp create mode 100644 src/Channel/Bluetooth/BluetoothService.cpp delete mode 100644 src/Channel/Bluetooth/BluetoothServiceChannel.cpp create mode 100644 src/Channel/Channel.cpp create mode 100644 src/Channel/GenericNotification/GenericNotification.cpp delete mode 100644 src/Channel/Input/InputServiceChannel.cpp create mode 100644 src/Channel/InputSource/InputSourceService.cpp create mode 100644 src/Channel/MediaBrowser/MediaBrowserService.cpp create mode 100644 src/Channel/MediaPlaybackStatus/MediaPlaybackStatusService.cpp create mode 100644 src/Channel/MediaSink/Audio/AudioMediaSinkService.cpp create mode 100644 src/Channel/MediaSink/Audio/Channel/GuidanceAudioChannel.cpp create mode 100644 src/Channel/MediaSink/Audio/Channel/MediaAudioChannel.cpp create mode 100644 src/Channel/MediaSink/Audio/Channel/SystemAudioChannel.cpp create mode 100644 src/Channel/MediaSink/Audio/Channel/TelephonyAudioChannel.cpp create mode 100644 src/Channel/MediaSink/Video/Channel/VideoChannel.cpp create mode 100644 src/Channel/MediaSink/Video/VideoMediaSinkService.cpp create mode 100644 src/Channel/MediaSource/Audio/MicrophoneAudioChannel.cpp create mode 100644 src/Channel/MediaSource/MediaSourceService.cpp delete mode 100644 src/Channel/Navigation/NavigationStatusServiceChannel.cpp create mode 100644 src/Channel/NavigationStatus/NavigationStatusService.cpp create mode 100644 src/Channel/PhoneStatus/PhoneStatusService.cpp create mode 100644 src/Channel/Radio/RadioService.cpp delete mode 100644 src/Channel/Sensor/SensorServiceChannel.cpp create mode 100644 src/Channel/SensorSource/SensorSourceService.cpp delete mode 100644 src/Channel/ServiceChannel.cpp create mode 100644 src/Channel/VendorExtension/VendorExtensionService.cpp create mode 100644 src/Channel/WifiProjection/WifiProjectionService.cpp create mode 100644 src/Messenger/ServiceId.cpp diff --git a/.gitignore b/.gitignore index 9e0cbbf1..6c30c8df 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,846 @@ aasdk_proto/*.pb.h Makefile cmake_install.cmake install_manifest.txt -build/** \ No newline at end of file +build/** +/protobuf/.idea/.gitignore +/protobuf/.idea/.name +/protobuf/.idea/misc.xml +/protobuf/.idea/modules.xml +/protobuf/.idea/protobuf.iml +/protobuf/.idea/vcs.xml +/protobuf/build/aap_protobuf/channel/bluetooth/event/BluetoothPairingMethod.pb.cc +/protobuf/build/aap_protobuf/channel/bluetooth/event/BluetoothPairingMethod.pb.h +/protobuf/build/aap_protobuf/channel/bluetooth/event/BluetoothPairingRequest.pb.cc +/protobuf/build/aap_protobuf/channel/bluetooth/event/BluetoothPairingRequest.pb.h +/protobuf/build/aap_protobuf/channel/control/auth/AuthResponse.pb.cc +/protobuf/build/aap_protobuf/channel/control/auth/AuthResponse.pb.h +/protobuf/build/aap_protobuf/channel/control/byebye/event/ByeByeReason.pb.cc +/protobuf/build/aap_protobuf/channel/control/byebye/event/ByeByeReason.pb.h +/protobuf/build/aap_protobuf/channel/control/byebye/event/ByeByeRequest.pb.cc +/protobuf/build/aap_protobuf/channel/control/byebye/event/ByeByeRequest.pb.h +/protobuf/build/aap_protobuf/channel/control/byebye/notification/ByeByeResponse.pb.cc +/protobuf/build/aap_protobuf/channel/control/byebye/notification/ByeByeResponse.pb.h +/protobuf/build/aap_protobuf/channel/control/focus/audio/event/AudioFocusRequest.pb.cc +/protobuf/build/aap_protobuf/channel/control/focus/audio/event/AudioFocusRequest.pb.h +/protobuf/build/aap_protobuf/channel/control/focus/audio/event/AudioFocusRequestType.pb.cc +/protobuf/build/aap_protobuf/channel/control/focus/audio/event/AudioFocusRequestType.pb.h +/protobuf/build/aap_protobuf/channel/control/focus/audio/notification/AudioFocusNotification.pb.cc +/protobuf/build/aap_protobuf/channel/control/focus/audio/notification/AudioFocusNotification.pb.h +/protobuf/build/aap_protobuf/channel/control/focus/audio/notification/AudioFocusStateType.pb.cc +/protobuf/build/aap_protobuf/channel/control/focus/audio/notification/AudioFocusStateType.pb.h +/protobuf/build/aap_protobuf/channel/control/focus/navigation/event/NavFocusRequestNotification.pb.cc +/protobuf/build/aap_protobuf/channel/control/focus/navigation/event/NavFocusRequestNotification.pb.h +/protobuf/build/aap_protobuf/channel/control/focus/navigation/notification/NavFocusNotification.pb.cc +/protobuf/build/aap_protobuf/channel/control/focus/navigation/notification/NavFocusNotification.pb.h +/protobuf/build/aap_protobuf/channel/control/focus/navigation/shared/NavFocusType.pb.cc +/protobuf/build/aap_protobuf/channel/control/focus/navigation/shared/NavFocusType.pb.h +/protobuf/build/aap_protobuf/channel/control/focus/video/event/VideoFocusReason.pb.cc +/protobuf/build/aap_protobuf/channel/control/focus/video/event/VideoFocusReason.pb.h +/protobuf/build/aap_protobuf/channel/control/focus/video/event/VideoFocusRequestNotification.pb.cc +/protobuf/build/aap_protobuf/channel/control/focus/video/event/VideoFocusRequestNotification.pb.h +/protobuf/build/aap_protobuf/channel/control/focus/video/notification/VideoFocusNotification.pb.cc +/protobuf/build/aap_protobuf/channel/control/focus/video/notification/VideoFocusNotification.pb.h +/protobuf/build/aap_protobuf/channel/control/focus/video/shared/VideoFocusMode.pb.cc +/protobuf/build/aap_protobuf/channel/control/focus/video/shared/VideoFocusMode.pb.h +/protobuf/build/aap_protobuf/channel/control/ping/PingRequest.pb.cc +/protobuf/build/aap_protobuf/channel/control/ping/PingRequest.pb.h +/protobuf/build/aap_protobuf/channel/control/ping/PingResponse.pb.cc +/protobuf/build/aap_protobuf/channel/control/ping/PingResponse.pb.h +/protobuf/build/aap_protobuf/channel/control/servicediscovery/event/ServiceDiscoveryRequest.pb.cc +/protobuf/build/aap_protobuf/channel/control/servicediscovery/event/ServiceDiscoveryRequest.pb.h +/protobuf/build/aap_protobuf/channel/control/servicediscovery/notification/DriverPosition.pb.cc +/protobuf/build/aap_protobuf/channel/control/servicediscovery/notification/DriverPosition.pb.h +/protobuf/build/aap_protobuf/channel/control/servicediscovery/notification/ServiceDiscoveryResponse.pb.cc +/protobuf/build/aap_protobuf/channel/control/servicediscovery/notification/ServiceDiscoveryResponse.pb.h +/protobuf/build/aap_protobuf/channel/control/servicediscovery/notification/ServiceDiscoveryUpdate.pb.cc +/protobuf/build/aap_protobuf/channel/control/servicediscovery/notification/ServiceDiscoveryUpdate.pb.h +/protobuf/build/aap_protobuf/channel/control/version/event/VersionResponseOptions.pb.cc +/protobuf/build/aap_protobuf/channel/control/version/event/VersionResponseOptions.pb.h +/protobuf/build/aap_protobuf/channel/control/version/VersionRequestOptions.pb.cc +/protobuf/build/aap_protobuf/channel/control/version/VersionRequestOptions.pb.h +/protobuf/build/aap_protobuf/channel/control/voice/VoiceSessionNotification.pb.cc +/protobuf/build/aap_protobuf/channel/control/voice/VoiceSessionNotification.pb.h +/protobuf/build/aap_protobuf/channel/control/ControlMessageType.pb.cc +/protobuf/build/aap_protobuf/channel/control/ControlMessageType.pb.h +/protobuf/build/aap_protobuf/channel/input/event/BindingRequest.pb.cc +/protobuf/build/aap_protobuf/channel/input/event/BindingRequest.pb.h +/protobuf/build/aap_protobuf/channel/media/event/Setup.pb.cc +/protobuf/build/aap_protobuf/channel/media/event/Setup.pb.h +/protobuf/build/aap_protobuf/channel/media/event/Start.pb.cc +/protobuf/build/aap_protobuf/channel/media/event/Start.pb.h +/protobuf/build/aap_protobuf/channel/media/event/Stop.pb.cc +/protobuf/build/aap_protobuf/channel/media/event/Stop.pb.h +/protobuf/build/aap_protobuf/channel/navigation/event/DistanceUnit.pb.cc +/protobuf/build/aap_protobuf/channel/navigation/event/DistanceUnit.pb.h +/protobuf/build/aap_protobuf/channel/navigation/event/NavigationNextTurnEvent.pb.cc +/protobuf/build/aap_protobuf/channel/navigation/event/NavigationNextTurnEvent.pb.h +/protobuf/build/aap_protobuf/channel/navigation/event/NavigationStatus.pb.cc +/protobuf/build/aap_protobuf/channel/navigation/event/NavigationStatus.pb.h +/protobuf/build/aap_protobuf/channel/navigation/event/NavigationTurnDistanceEvent.pb.cc +/protobuf/build/aap_protobuf/channel/navigation/event/NavigationTurnDistanceEvent.pb.h +/protobuf/build/aap_protobuf/channel/navigation/event/NextTurn.pb.cc +/protobuf/build/aap_protobuf/channel/navigation/event/NextTurn.pb.h +/protobuf/build/aap_protobuf/channel/navigation/event/TurnSide.pb.cc +/protobuf/build/aap_protobuf/channel/navigation/event/TurnSide.pb.h +/protobuf/build/aap_protobuf/channel/sensor/event/SensorRequest.pb.cc +/protobuf/build/aap_protobuf/channel/sensor/event/SensorRequest.pb.h +/protobuf/build/aap_protobuf/channel/ChannelCloseNotification.pb.cc +/protobuf/build/aap_protobuf/channel/ChannelCloseNotification.pb.h +/protobuf/build/aap_protobuf/channel/ChannelOpenRequest.pb.cc +/protobuf/build/aap_protobuf/channel/ChannelOpenRequest.pb.h +/protobuf/build/aap_protobuf/channel/ChannelOpenResponse.pb.cc +/protobuf/build/aap_protobuf/channel/ChannelOpenResponse.pb.h +/protobuf/build/aap_protobuf/connection/ConnectionConfiguration.pb.cc +/protobuf/build/aap_protobuf/connection/ConnectionConfiguration.pb.h +/protobuf/build/aap_protobuf/connection/PingConfiguration.pb.cc +/protobuf/build/aap_protobuf/connection/PingConfiguration.pb.h +/protobuf/build/aap_protobuf/connection/WirelessTcpConfiguration.pb.cc +/protobuf/build/aap_protobuf/connection/WirelessTcpConfiguration.pb.h +/protobuf/build/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationData.pb.cc +/protobuf/build/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationData.pb.h +/protobuf/build/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationResult.pb.cc +/protobuf/build/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationResult.pb.h +/protobuf/build/aap_protobuf/service/bluetooth/message/BluetoothMessageId.pb.cc +/protobuf/build/aap_protobuf/service/bluetooth/message/BluetoothMessageId.pb.h +/protobuf/build/aap_protobuf/service/bluetooth/message/BluetoothPairingResponse.pb.cc +/protobuf/build/aap_protobuf/service/bluetooth/message/BluetoothPairingResponse.pb.h +/protobuf/build/aap_protobuf/service/bluetooth/BluetoothService.pb.cc +/protobuf/build/aap_protobuf/service/bluetooth/BluetoothService.pb.h +/protobuf/build/aap_protobuf/service/genericnotification/GenericNotificationService.pb.cc +/protobuf/build/aap_protobuf/service/genericnotification/GenericNotificationService.pb.h +/protobuf/build/aap_protobuf/service/input/message/AbsoluteInput.pb.cc +/protobuf/build/aap_protobuf/service/input/message/AbsoluteInput.pb.h +/protobuf/build/aap_protobuf/service/input/message/AbsoluteInputEvent.pb.cc +/protobuf/build/aap_protobuf/service/input/message/AbsoluteInputEvent.pb.h +/protobuf/build/aap_protobuf/service/input/message/InputChannelMessageId.pb.cc +/protobuf/build/aap_protobuf/service/input/message/InputChannelMessageId.pb.h +/protobuf/build/aap_protobuf/service/input/message/InputEventIndication.pb.cc +/protobuf/build/aap_protobuf/service/input/message/InputEventIndication.pb.h +/protobuf/build/aap_protobuf/service/input/message/Key.pb.cc +/protobuf/build/aap_protobuf/service/input/message/Key.pb.h +/protobuf/build/aap_protobuf/service/input/message/KeyEvent.pb.cc +/protobuf/build/aap_protobuf/service/input/message/KeyEvent.pb.h +/protobuf/build/aap_protobuf/service/input/message/RelativeInput.pb.cc +/protobuf/build/aap_protobuf/service/input/message/RelativeInput.pb.h +/protobuf/build/aap_protobuf/service/input/message/RelativeInputEvent.pb.cc +/protobuf/build/aap_protobuf/service/input/message/RelativeInputEvent.pb.h +/protobuf/build/aap_protobuf/service/input/message/TouchAction.pb.cc +/protobuf/build/aap_protobuf/service/input/message/TouchAction.pb.h +/protobuf/build/aap_protobuf/service/input/message/TouchEvent.pb.cc +/protobuf/build/aap_protobuf/service/input/message/TouchEvent.pb.h +/protobuf/build/aap_protobuf/service/input/message/TouchLocation.pb.cc +/protobuf/build/aap_protobuf/service/input/message/TouchLocation.pb.h +/protobuf/build/aap_protobuf/service/input/message/TouchPadConfig.pb.cc +/protobuf/build/aap_protobuf/service/input/message/TouchPadConfig.pb.h +/protobuf/build/aap_protobuf/service/input/message/TouchScreenConfig.pb.cc +/protobuf/build/aap_protobuf/service/input/message/TouchScreenConfig.pb.h +/protobuf/build/aap_protobuf/service/input/message/TouchScreenType.pb.cc +/protobuf/build/aap_protobuf/service/input/message/TouchScreenType.pb.h +/protobuf/build/aap_protobuf/service/input/FeedbackEventType.pb.cc +/protobuf/build/aap_protobuf/service/input/FeedbackEventType.pb.h +/protobuf/build/aap_protobuf/service/input/InputService.pb.cc +/protobuf/build/aap_protobuf/service/input/InputService.pb.h +/protobuf/build/aap_protobuf/service/media/shared/message/AudioConfiguration.pb.cc +/protobuf/build/aap_protobuf/service/media/shared/message/AudioConfiguration.pb.h +/protobuf/build/aap_protobuf/service/media/shared/message/Insets.pb.cc +/protobuf/build/aap_protobuf/service/media/shared/message/Insets.pb.h +/protobuf/build/aap_protobuf/service/media/shared/message/MediaCodecType.pb.cc +/protobuf/build/aap_protobuf/service/media/shared/message/MediaCodecType.pb.h +/protobuf/build/aap_protobuf/service/media/shared/message/MediaMessageId.pb.cc +/protobuf/build/aap_protobuf/service/media/shared/message/MediaMessageId.pb.h +/protobuf/build/aap_protobuf/service/media/shared/message/UiConfig.pb.cc +/protobuf/build/aap_protobuf/service/media/shared/message/UiConfig.pb.h +/protobuf/build/aap_protobuf/service/media/shared/message/UiTheme.pb.cc +/protobuf/build/aap_protobuf/service/media/shared/message/UiTheme.pb.h +/protobuf/build/aap_protobuf/service/media/shared/message/VideoCodecResolutionType.pb.cc +/protobuf/build/aap_protobuf/service/media/shared/message/VideoCodecResolutionType.pb.h +/protobuf/build/aap_protobuf/service/media/shared/message/VideoConfiguration.pb.cc +/protobuf/build/aap_protobuf/service/media/shared/message/VideoConfiguration.pb.h +/protobuf/build/aap_protobuf/service/media/shared/message/VideoFrameRateType.pb.cc +/protobuf/build/aap_protobuf/service/media/shared/message/VideoFrameRateType.pb.h +/protobuf/build/aap_protobuf/service/media/sink/message/BindingResponse.pb.cc +/protobuf/build/aap_protobuf/service/media/sink/message/BindingResponse.pb.h +/protobuf/build/aap_protobuf/service/media/sink/message/MediaSinkChannelSetupResponse.pb.cc +/protobuf/build/aap_protobuf/service/media/sink/message/MediaSinkChannelSetupResponse.pb.h +/protobuf/build/aap_protobuf/service/media/sink/AudioStreamType.pb.cc +/protobuf/build/aap_protobuf/service/media/sink/AudioStreamType.pb.h +/protobuf/build/aap_protobuf/service/media/sink/DisplayType.pb.cc +/protobuf/build/aap_protobuf/service/media/sink/DisplayType.pb.h +/protobuf/build/aap_protobuf/service/media/sink/KeyCode.pb.cc +/protobuf/build/aap_protobuf/service/media/sink/KeyCode.pb.h +/protobuf/build/aap_protobuf/service/media/sink/MediaSinkChannelSetupStatus.pb.cc +/protobuf/build/aap_protobuf/service/media/sink/MediaSinkChannelSetupStatus.pb.h +/protobuf/build/aap_protobuf/service/media/sink/MediaSinkService.pb.cc +/protobuf/build/aap_protobuf/service/media/sink/MediaSinkService.pb.h +/protobuf/build/aap_protobuf/service/media/source/message/MediaSourceMediaAckIndication.pb.cc +/protobuf/build/aap_protobuf/service/media/source/message/MediaSourceMediaAckIndication.pb.h +/protobuf/build/aap_protobuf/service/media/source/message/MicrophoneRequest.pb.cc +/protobuf/build/aap_protobuf/service/media/source/message/MicrophoneRequest.pb.h +/protobuf/build/aap_protobuf/service/media/source/message/MicrophoneResponse.pb.cc +/protobuf/build/aap_protobuf/service/media/source/message/MicrophoneResponse.pb.h +/protobuf/build/aap_protobuf/service/media/source/MediaSourceService.pb.cc +/protobuf/build/aap_protobuf/service/media/source/MediaSourceService.pb.h +/protobuf/build/aap_protobuf/service/mediabrowser/MediaBrowserMessageId.pb.cc +/protobuf/build/aap_protobuf/service/mediabrowser/MediaBrowserMessageId.pb.h +/protobuf/build/aap_protobuf/service/mediabrowser/MediaBrowserService.pb.cc +/protobuf/build/aap_protobuf/service/mediabrowser/MediaBrowserService.pb.h +/protobuf/build/aap_protobuf/service/mediaplayback/message/MediaPlaybackMetadata.pb.cc +/protobuf/build/aap_protobuf/service/mediaplayback/message/MediaPlaybackMetadata.pb.h +/protobuf/build/aap_protobuf/service/mediaplayback/message/MediaPlaybackStatus.pb.cc +/protobuf/build/aap_protobuf/service/mediaplayback/message/MediaPlaybackStatus.pb.h +/protobuf/build/aap_protobuf/service/mediaplayback/MediaPlaybackStatusMessageId.pb.cc +/protobuf/build/aap_protobuf/service/mediaplayback/MediaPlaybackStatusMessageId.pb.h +/protobuf/build/aap_protobuf/service/mediaplayback/MediaPlaybackStatusService.pb.cc +/protobuf/build/aap_protobuf/service/mediaplayback/MediaPlaybackStatusService.pb.h +/protobuf/build/aap_protobuf/service/navigation/message/NavigationCue.pb.cc +/protobuf/build/aap_protobuf/service/navigation/message/NavigationCue.pb.h +/protobuf/build/aap_protobuf/service/navigation/message/NavigationCurrentPosition.pb.cc +/protobuf/build/aap_protobuf/service/navigation/message/NavigationCurrentPosition.pb.h +/protobuf/build/aap_protobuf/service/navigation/message/NavigationDestination.pb.cc +/protobuf/build/aap_protobuf/service/navigation/message/NavigationDestination.pb.h +/protobuf/build/aap_protobuf/service/navigation/message/NavigationDestinationDistance.pb.cc +/protobuf/build/aap_protobuf/service/navigation/message/NavigationDestinationDistance.pb.h +/protobuf/build/aap_protobuf/service/navigation/message/NavigationDistance.pb.cc +/protobuf/build/aap_protobuf/service/navigation/message/NavigationDistance.pb.h +/protobuf/build/aap_protobuf/service/navigation/message/NavigationImageOptions.pb.cc +/protobuf/build/aap_protobuf/service/navigation/message/NavigationImageOptions.pb.h +/protobuf/build/aap_protobuf/service/navigation/message/NavigationLane.pb.cc +/protobuf/build/aap_protobuf/service/navigation/message/NavigationLane.pb.h +/protobuf/build/aap_protobuf/service/navigation/message/NavigationManeuver.pb.cc +/protobuf/build/aap_protobuf/service/navigation/message/NavigationManeuver.pb.h +/protobuf/build/aap_protobuf/service/navigation/message/NavigationRoad.pb.cc +/protobuf/build/aap_protobuf/service/navigation/message/NavigationRoad.pb.h +/protobuf/build/aap_protobuf/service/navigation/message/NavigationState.pb.cc +/protobuf/build/aap_protobuf/service/navigation/message/NavigationState.pb.h +/protobuf/build/aap_protobuf/service/navigation/message/NavigationStatusStart.pb.cc +/protobuf/build/aap_protobuf/service/navigation/message/NavigationStatusStart.pb.h +/protobuf/build/aap_protobuf/service/navigation/message/NavigationStatusStop.pb.cc +/protobuf/build/aap_protobuf/service/navigation/message/NavigationStatusStop.pb.h +/protobuf/build/aap_protobuf/service/navigation/message/NavigationStep.pb.cc +/protobuf/build/aap_protobuf/service/navigation/message/NavigationStep.pb.h +/protobuf/build/aap_protobuf/service/navigation/message/NavigationStepDistance.pb.cc +/protobuf/build/aap_protobuf/service/navigation/message/NavigationStepDistance.pb.h +/protobuf/build/aap_protobuf/service/navigation/InstrumentClusterType.pb.cc +/protobuf/build/aap_protobuf/service/navigation/InstrumentClusterType.pb.h +/protobuf/build/aap_protobuf/service/navigation/NavigationChannelMessageIds.pb.cc +/protobuf/build/aap_protobuf/service/navigation/NavigationChannelMessageIds.pb.h +/protobuf/build/aap_protobuf/service/navigation/NavigationService.pb.cc +/protobuf/build/aap_protobuf/service/navigation/NavigationService.pb.h +/protobuf/build/aap_protobuf/service/phonestatus/PhoneStatusMessageId.pb.cc +/protobuf/build/aap_protobuf/service/phonestatus/PhoneStatusMessageId.pb.h +/protobuf/build/aap_protobuf/service/phonestatus/PhoneStatusService.pb.cc +/protobuf/build/aap_protobuf/service/phonestatus/PhoneStatusService.pb.h +/protobuf/build/aap_protobuf/service/radio/message/ActiveRadioNotification.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/ActiveRadioNotification.pb.h +/protobuf/build/aap_protobuf/service/radio/message/CancelRadioOperationsRequest.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/CancelRadioOperationsRequest.pb.h +/protobuf/build/aap_protobuf/service/radio/message/CancelRadioOperationsResponse.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/CancelRadioOperationsResponse.pb.h +/protobuf/build/aap_protobuf/service/radio/message/ConfigureChannelSpacingRequest.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/ConfigureChannelSpacingRequest.pb.h +/protobuf/build/aap_protobuf/service/radio/message/ConfigureChannelSpacingResponse.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/ConfigureChannelSpacingResponse.pb.h +/protobuf/build/aap_protobuf/service/radio/message/GetProgramListRequest.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/GetProgramListRequest.pb.h +/protobuf/build/aap_protobuf/service/radio/message/GetProgramListResponse.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/GetProgramListResponse.pb.h +/protobuf/build/aap_protobuf/service/radio/message/GetTrafficUpdateRequest.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/GetTrafficUpdateRequest.pb.h +/protobuf/build/aap_protobuf/service/radio/message/GetTrafficUpdateResponse.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/GetTrafficUpdateResponse.pb.h +/protobuf/build/aap_protobuf/service/radio/message/HdAcquisionState.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/HdAcquisionState.pb.h +/protobuf/build/aap_protobuf/service/radio/message/HdRadioArtistExperience.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/HdRadioArtistExperience.pb.h +/protobuf/build/aap_protobuf/service/radio/message/HdRadioComment.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/HdRadioComment.pb.h +/protobuf/build/aap_protobuf/service/radio/message/HdRadioCommercial.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/HdRadioCommercial.pb.h +/protobuf/build/aap_protobuf/service/radio/message/HdRadioPsdData.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/HdRadioPsdData.pb.h +/protobuf/build/aap_protobuf/service/radio/message/HdRadioSisData.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/HdRadioSisData.pb.h +/protobuf/build/aap_protobuf/service/radio/message/HdRadioStationInfo.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/HdRadioStationInfo.pb.h +/protobuf/build/aap_protobuf/service/radio/message/ItuRegion.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/ItuRegion.pb.h +/protobuf/build/aap_protobuf/service/radio/message/Location.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/Location.pb.h +/protobuf/build/aap_protobuf/service/radio/message/MuteRadioRequest.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/MuteRadioRequest.pb.h +/protobuf/build/aap_protobuf/service/radio/message/MuteRadioResponse.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/MuteRadioResponse.pb.h +/protobuf/build/aap_protobuf/service/radio/message/RadioProperties.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/RadioProperties.pb.h +/protobuf/build/aap_protobuf/service/radio/message/RadioSourceRequest.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/RadioSourceRequest.pb.h +/protobuf/build/aap_protobuf/service/radio/message/RadioSourceResponse.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/RadioSourceResponse.pb.h +/protobuf/build/aap_protobuf/service/radio/message/RadioStateNotification.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/RadioStateNotification.pb.h +/protobuf/build/aap_protobuf/service/radio/message/RadioStationInfo.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/RadioStationInfo.pb.h +/protobuf/build/aap_protobuf/service/radio/message/RadioStationInfoNotification.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/RadioStationInfoNotification.pb.h +/protobuf/build/aap_protobuf/service/radio/message/RadioStationMetaData.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/RadioStationMetaData.pb.h +/protobuf/build/aap_protobuf/service/radio/message/RadioType.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/RadioType.pb.h +/protobuf/build/aap_protobuf/service/radio/message/Range.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/Range.pb.h +/protobuf/build/aap_protobuf/service/radio/message/RdsData.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/RdsData.pb.h +/protobuf/build/aap_protobuf/service/radio/message/RdsType.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/RdsType.pb.h +/protobuf/build/aap_protobuf/service/radio/message/ScanStationsRequest.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/ScanStationsRequest.pb.h +/protobuf/build/aap_protobuf/service/radio/message/ScanStationsResponse.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/ScanStationsResponse.pb.h +/protobuf/build/aap_protobuf/service/radio/message/SeekStationRequest.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/SeekStationRequest.pb.h +/protobuf/build/aap_protobuf/service/radio/message/SeekStationResponse.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/SeekStationResponse.pb.h +/protobuf/build/aap_protobuf/service/radio/message/SelectActiveRadioRequest.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/SelectActiveRadioRequest.pb.h +/protobuf/build/aap_protobuf/service/radio/message/StationPreset.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/StationPreset.pb.h +/protobuf/build/aap_protobuf/service/radio/message/StationPresetList.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/StationPresetList.pb.h +/protobuf/build/aap_protobuf/service/radio/message/StationPresetsNotification.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/StationPresetsNotification.pb.h +/protobuf/build/aap_protobuf/service/radio/message/StepChannelRequest.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/StepChannelRequest.pb.h +/protobuf/build/aap_protobuf/service/radio/message/StepChannelResponse.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/StepChannelResponse.pb.h +/protobuf/build/aap_protobuf/service/radio/message/TrafficIncident.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/TrafficIncident.pb.h +/protobuf/build/aap_protobuf/service/radio/message/TrafficServiceType.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/TrafficServiceType.pb.h +/protobuf/build/aap_protobuf/service/radio/message/TuneToStationRequest.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/TuneToStationRequest.pb.h +/protobuf/build/aap_protobuf/service/radio/message/TuneToStationResponse.pb.cc +/protobuf/build/aap_protobuf/service/radio/message/TuneToStationResponse.pb.h +/protobuf/build/aap_protobuf/service/radio/RadioMessageId.pb.cc +/protobuf/build/aap_protobuf/service/radio/RadioMessageId.pb.h +/protobuf/build/aap_protobuf/service/radio/RadioService.pb.cc +/protobuf/build/aap_protobuf/service/radio/RadioService.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/AccelerometerData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/AccelerometerData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/CompassData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/CompassData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/DeadReckoningData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/DeadReckoningData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/DiagnosticsData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/DiagnosticsData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/DoorData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/DoorData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/DrivingStatus.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/DrivingStatus.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/DrivingStatusData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/DrivingStatusData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/EnvironmentData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/EnvironmentData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/EvConnectorType.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/EvConnectorType.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/FuelLevelData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/FuelLevelData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/FuelType.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/FuelType.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/Gear.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/Gear.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/GearData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/GearData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/GpsSatellite.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/GpsSatellite.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/GyroscopeData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/GyroscopeData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/HeadLightState.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/HeadLightState.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/HVACData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/HVACData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/LightData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/LightData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/LocationData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/LocationData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/NightModeData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/NightModeData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/OdometerData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/OdometerData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/ParkingBrakeData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/ParkingBrakeData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/PassengerData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/PassengerData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/RPMData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/RPMData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/Sensor.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/Sensor.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/SensorBatch.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/SensorBatch.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/SensorStartResponseMessage.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/SensorStartResponseMessage.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/SensorType.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/SensorType.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/SpeedData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/SpeedData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/TirePressureData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/TirePressureData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/TollCardData.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/TollCardData.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/message/TurnIndicatorState.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/message/TurnIndicatorState.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/SensorChannelMessageId.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/SensorChannelMessageId.pb.h +/protobuf/build/aap_protobuf/service/sensorsource/SensorService.pb.cc +/protobuf/build/aap_protobuf/service/sensorsource/SensorService.pb.h +/protobuf/build/aap_protobuf/service/vendorextension/VendorExtensionService.pb.cc +/protobuf/build/aap_protobuf/service/vendorextension/VendorExtensionService.pb.h +/protobuf/build/aap_protobuf/service/wifiprojection/message/AccessPointType.pb.cc +/protobuf/build/aap_protobuf/service/wifiprojection/message/AccessPointType.pb.h +/protobuf/build/aap_protobuf/service/wifiprojection/message/WifiCredentialsRequest.pb.cc +/protobuf/build/aap_protobuf/service/wifiprojection/message/WifiCredentialsRequest.pb.h +/protobuf/build/aap_protobuf/service/wifiprojection/message/WifiCredentialsResponse.pb.cc +/protobuf/build/aap_protobuf/service/wifiprojection/message/WifiCredentialsResponse.pb.h +/protobuf/build/aap_protobuf/service/wifiprojection/message/WifiSecurityMode.pb.cc +/protobuf/build/aap_protobuf/service/wifiprojection/message/WifiSecurityMode.pb.h +/protobuf/build/aap_protobuf/service/wifiprojection/WifiProjectionMessageId.pb.cc +/protobuf/build/aap_protobuf/service/wifiprojection/WifiProjectionMessageId.pb.h +/protobuf/build/aap_protobuf/service/wifiprojection/WifiProjectionService.pb.cc +/protobuf/build/aap_protobuf/service/wifiprojection/WifiProjectionService.pb.h +/protobuf/build/aap_protobuf/service/ServiceDescriptor.pb.cc +/protobuf/build/aap_protobuf/service/ServiceDescriptor.pb.h +/protobuf/build/aap_protobuf/shared/MessageStatus.pb.cc +/protobuf/build/aap_protobuf/shared/MessageStatus.pb.h +/protobuf/build/aap_protobuf/shared/PhoneInfo.pb.cc +/protobuf/build/aap_protobuf/shared/PhoneInfo.pb.h +/protobuf/build/aap_protobufConfig.cmake +/protobuf/build/aap_protobufConfigVersion.cmake +/protobuf/build/libaap_protobuf.a +/protobuf/cmake-build-debug/.cmake/api/v1/query/cache-v2 +/protobuf/cmake-build-debug/.cmake/api/v1/query/cmakeFiles-v1 +/protobuf/cmake-build-debug/.cmake/api/v1/query/codemodel-v2 +/protobuf/cmake-build-debug/.cmake/api/v1/query/toolchains-v1 +/protobuf/cmake-build-debug/.cmake/api/v1/reply/cache-v2-b456976728f8e5f68953.json +/protobuf/cmake-build-debug/.cmake/api/v1/reply/cmakeFiles-v1-4f1f005a996a0ea7a5c4.json +/protobuf/cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-462f1743707f337c5953.json +/protobuf/cmake-build-debug/.cmake/api/v1/reply/directory-.-Debug-1da93a99f704a4b42e88.json +/protobuf/cmake-build-debug/.cmake/api/v1/reply/index-2024-10-31T09-57-38-0894.json +/protobuf/cmake-build-debug/.cmake/api/v1/reply/target-aap_protobuf-Debug-64b3e728dfeacd2868c5.json +/protobuf/cmake-build-debug/.cmake/api/v1/reply/toolchains-v1-6b9824543f81a3a90126.json +/protobuf/cmake-build-debug/aap_protobuf/channel/bluetooth/event/BluetoothPairingMethod.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/bluetooth/event/BluetoothPairingMethod.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/bluetooth/event/BluetoothPairingRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/bluetooth/event/BluetoothPairingRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/auth/AuthResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/auth/AuthResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/byebye/event/ByeByeReason.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/byebye/event/ByeByeReason.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/byebye/event/ByeByeRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/byebye/event/ByeByeRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/byebye/notification/ByeByeResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/byebye/notification/ByeByeResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/audio/event/AudioFocusRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/audio/event/AudioFocusRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/audio/event/AudioFocusRequestType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/audio/event/AudioFocusRequestType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/audio/notification/AudioFocusNotification.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/audio/notification/AudioFocusNotification.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/audio/notification/AudioFocusStateType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/audio/notification/AudioFocusStateType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/navigation/event/NavFocusRequestNotification.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/navigation/event/NavFocusRequestNotification.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/navigation/notification/NavFocusNotification.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/navigation/notification/NavFocusNotification.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/navigation/shared/NavFocusType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/navigation/shared/NavFocusType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/video/event/VideoFocusReason.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/video/event/VideoFocusReason.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/video/event/VideoFocusRequestNotification.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/video/event/VideoFocusRequestNotification.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/video/notification/VideoFocusNotification.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/video/notification/VideoFocusNotification.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/video/shared/VideoFocusMode.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/focus/video/shared/VideoFocusMode.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/ping/PingRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/ping/PingRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/ping/PingResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/ping/PingResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/servicediscovery/event/ServiceDiscoveryRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/servicediscovery/event/ServiceDiscoveryRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/servicediscovery/notification/DriverPosition.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/servicediscovery/notification/DriverPosition.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/servicediscovery/notification/ServiceDiscoveryResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/servicediscovery/notification/ServiceDiscoveryResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/servicediscovery/notification/ServiceDiscoveryUpdate.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/servicediscovery/notification/ServiceDiscoveryUpdate.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/version/event/VersionResponseOptions.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/version/event/VersionResponseOptions.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/version/VersionRequestOptions.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/version/VersionRequestOptions.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/voice/VoiceSessionNotification.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/voice/VoiceSessionNotification.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/control/ControlMessageType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/control/ControlMessageType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/input/event/BindingRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/input/event/BindingRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/media/event/Setup.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/media/event/Setup.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/media/event/Start.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/media/event/Start.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/media/event/Stop.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/media/event/Stop.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/navigation/event/DistanceUnit.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/navigation/event/DistanceUnit.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/navigation/event/NavigationNextTurnEvent.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/navigation/event/NavigationNextTurnEvent.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/navigation/event/NavigationStatus.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/navigation/event/NavigationStatus.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/navigation/event/NavigationTurnDistanceEvent.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/navigation/event/NavigationTurnDistanceEvent.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/navigation/event/NextTurn.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/navigation/event/NextTurn.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/navigation/event/TurnSide.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/navigation/event/TurnSide.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/sensor/event/SensorRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/sensor/event/SensorRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/ChannelCloseNotification.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/ChannelCloseNotification.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/ChannelOpenRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/ChannelOpenRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/channel/ChannelOpenResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/channel/ChannelOpenResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/connection/ConnectionConfiguration.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/connection/ConnectionConfiguration.pb.h +/protobuf/cmake-build-debug/aap_protobuf/connection/PingConfiguration.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/connection/PingConfiguration.pb.h +/protobuf/cmake-build-debug/aap_protobuf/connection/WirelessTcpConfiguration.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/connection/WirelessTcpConfiguration.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationResult.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationResult.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/bluetooth/message/BluetoothMessageId.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/bluetooth/message/BluetoothMessageId.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/bluetooth/message/BluetoothPairingResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/bluetooth/message/BluetoothPairingResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/bluetooth/BluetoothService.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/bluetooth/BluetoothService.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/genericnotification/GenericNotificationService.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/genericnotification/GenericNotificationService.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/AbsoluteInput.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/AbsoluteInput.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/AbsoluteInputEvent.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/AbsoluteInputEvent.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/InputChannelMessageId.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/InputChannelMessageId.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/InputEventIndication.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/InputEventIndication.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/Key.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/Key.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/KeyEvent.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/KeyEvent.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/RelativeInput.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/RelativeInput.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/RelativeInputEvent.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/RelativeInputEvent.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/TouchAction.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/TouchAction.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/TouchEvent.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/TouchEvent.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/TouchLocation.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/TouchLocation.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/TouchPadConfig.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/TouchPadConfig.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/TouchScreenConfig.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/TouchScreenConfig.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/TouchScreenType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/message/TouchScreenType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/FeedbackEventType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/FeedbackEventType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/input/InputService.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/input/InputService.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/AudioConfiguration.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/AudioConfiguration.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/Insets.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/Insets.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/MediaCodecType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/MediaCodecType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/MediaMessageId.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/MediaMessageId.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/UiConfig.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/UiConfig.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/UiTheme.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/UiTheme.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/VideoCodecResolutionType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/VideoCodecResolutionType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/VideoConfiguration.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/VideoConfiguration.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/VideoFrameRateType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/shared/message/VideoFrameRateType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/sink/message/BindingResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/sink/message/BindingResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/sink/message/MediaSinkChannelSetupResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/sink/message/MediaSinkChannelSetupResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/sink/AudioStreamType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/sink/AudioStreamType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/sink/DisplayType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/sink/DisplayType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/sink/KeyCode.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/sink/KeyCode.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/sink/MediaSinkChannelSetupStatus.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/sink/MediaSinkChannelSetupStatus.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/sink/MediaSinkService.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/sink/MediaSinkService.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/source/message/MediaSourceMediaAckIndication.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/source/message/MediaSourceMediaAckIndication.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/source/message/MicrophoneRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/source/message/MicrophoneRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/source/message/MicrophoneResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/source/message/MicrophoneResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/media/source/MediaSourceService.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/media/source/MediaSourceService.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/mediabrowser/MediaBrowserMessageId.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/mediabrowser/MediaBrowserMessageId.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/mediabrowser/MediaBrowserService.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/mediabrowser/MediaBrowserService.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/mediaplayback/message/MediaPlaybackMetadata.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/mediaplayback/message/MediaPlaybackMetadata.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/mediaplayback/message/MediaPlaybackStatus.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/mediaplayback/message/MediaPlaybackStatus.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/mediaplayback/MediaPlaybackStatusMessageId.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/mediaplayback/MediaPlaybackStatusMessageId.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/mediaplayback/MediaPlaybackStatusService.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/mediaplayback/MediaPlaybackStatusService.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationCue.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationCue.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationCurrentPosition.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationCurrentPosition.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationDestination.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationDestination.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationDestinationDistance.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationDestinationDistance.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationDistance.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationDistance.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationImageOptions.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationImageOptions.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationLane.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationLane.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationManeuver.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationManeuver.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationRoad.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationRoad.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationState.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationState.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationStatusStart.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationStatusStart.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationStatusStop.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationStatusStop.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationStep.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationStep.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationStepDistance.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/message/NavigationStepDistance.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/InstrumentClusterType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/InstrumentClusterType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/NavigationChannelMessageIds.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/NavigationChannelMessageIds.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/NavigationService.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/navigation/NavigationService.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/phonestatus/PhoneStatusMessageId.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/phonestatus/PhoneStatusMessageId.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/phonestatus/PhoneStatusService.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/phonestatus/PhoneStatusService.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/ActiveRadioNotification.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/ActiveRadioNotification.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/CancelRadioOperationsRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/CancelRadioOperationsRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/CancelRadioOperationsResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/CancelRadioOperationsResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/ConfigureChannelSpacingRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/ConfigureChannelSpacingRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/ConfigureChannelSpacingResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/ConfigureChannelSpacingResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/GetProgramListRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/GetProgramListRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/GetProgramListResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/GetProgramListResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/GetTrafficUpdateRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/GetTrafficUpdateRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/GetTrafficUpdateResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/GetTrafficUpdateResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/HdAcquisionState.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/HdAcquisionState.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/HdRadioArtistExperience.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/HdRadioArtistExperience.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/HdRadioComment.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/HdRadioComment.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/HdRadioCommercial.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/HdRadioCommercial.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/HdRadioPsdData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/HdRadioPsdData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/HdRadioSisData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/HdRadioSisData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/HdRadioStationInfo.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/HdRadioStationInfo.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/ItuRegion.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/ItuRegion.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/Location.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/Location.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/MuteRadioRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/MuteRadioRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/MuteRadioResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/MuteRadioResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioProperties.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioProperties.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioSourceRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioSourceRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioSourceResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioSourceResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioStateNotification.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioStateNotification.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioStationInfo.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioStationInfo.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioStationInfoNotification.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioStationInfoNotification.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioStationMetaData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioStationMetaData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RadioType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/Range.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/Range.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RdsData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RdsData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RdsType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/RdsType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/ScanStationsRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/ScanStationsRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/ScanStationsResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/ScanStationsResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/SeekStationRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/SeekStationRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/SeekStationResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/SeekStationResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/SelectActiveRadioRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/SelectActiveRadioRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/StationPreset.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/StationPreset.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/StationPresetList.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/StationPresetList.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/StationPresetsNotification.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/StationPresetsNotification.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/StepChannelRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/StepChannelRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/StepChannelResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/StepChannelResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/TrafficIncident.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/TrafficIncident.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/TrafficServiceType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/TrafficServiceType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/TuneToStationRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/TuneToStationRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/TuneToStationResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/message/TuneToStationResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/RadioMessageId.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/RadioMessageId.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/radio/RadioService.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/radio/RadioService.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensorsource/message/AccelerometerData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensorsource/message/AccelerometerData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensorsource/message/CompassData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensorsource/message/CompassData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensorsource/message/DeadReckoningData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensorsource/message/DeadReckoningData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensorsource/message/DiagnosticsData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/DiagnosticsData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/DoorData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/DoorData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/DrivingStatus.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/DrivingStatus.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/DrivingStatusData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/DrivingStatusData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/EnvironmentData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/EnvironmentData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/EvConnectorType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/EvConnectorType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/FuelLevelData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/FuelLevelData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/FuelType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/FuelType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/Gear.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/Gear.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/GearData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/GearData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/GpsSatellite.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/GpsSatellite.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/GyroscopeData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/GyroscopeData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/HeadLightState.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/HeadLightState.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/HVACData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/HVACData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/LightData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/LightData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/LocationData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/LocationData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/NightModeData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/NightModeData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/OdometerData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/OdometerData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/ParkingBrakeData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/ParkingBrakeData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/PassengerData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/PassengerData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/RPMData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/RPMData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/Sensor.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/Sensor.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/SensorBatch.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/SensorBatch.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/SensorStartResponseMessage.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/SensorStartResponseMessage.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/SensorType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/SensorType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/SpeedData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/SpeedData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/TirePressureData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/TirePressureData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/TollCardData.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/TollCardData.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/TurnIndicatorState.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/message/TurnIndicatorState.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/SensorChannelMessageId.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/SensorChannelMessageId.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/SensorService.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/sensor/SensorService.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/vendorextension/VendorExtensionService.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/vendorextension/VendorExtensionService.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/wifiprojection/message/AccessPointType.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/wifiprojection/message/AccessPointType.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/wifiprojection/message/WifiCredentialsRequest.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/wifiprojection/message/WifiCredentialsRequest.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/wifiprojection/message/WifiCredentialsResponse.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/wifiprojection/message/WifiCredentialsResponse.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/wifiprojection/message/WifiSecurityMode.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/wifiprojection/message/WifiSecurityMode.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/wifiprojection/WifiProjectionMessageId.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/wifiprojection/WifiProjectionMessageId.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/wifiprojection/WifiProjectionService.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/wifiprojection/WifiProjectionService.pb.h +/protobuf/cmake-build-debug/aap_protobuf/service/ServiceDescriptor.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/service/ServiceDescriptor.pb.h +/protobuf/cmake-build-debug/aap_protobuf/shared/MessageStatus.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/shared/MessageStatus.pb.h +/protobuf/cmake-build-debug/aap_protobuf/shared/PhoneInfo.pb.cc +/protobuf/cmake-build-debug/aap_protobuf/shared/PhoneInfo.pb.h +/protobuf/cmake-build-debug/Testing/Temporary/LastTest.log +/protobuf/cmake-build-debug/.ninja_log +/protobuf/cmake-build-debug/aap_protobufConfig.cmake +/protobuf/cmake-build-debug/aap_protobufConfigVersion.cmake +/protobuf/cmake-build-debug/build.ninja +/.idea/.gitignore +/.idea/vcs.xml +/cmake-build-debug/ +/build/ +/buildenv/ +/protobuf/build/ +/protobuf/cmake-build-debug/ +/protobuf/.idea/ +/.vscode/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 86de9bf3..2235e2fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,57 +1,77 @@ cmake_minimum_required(VERSION 3.5.1) +project(aasdk) +message(STATUS "AASDK Library") +message(STATUS "Cross Compiling?") + +# Cross Compiling Architecture if( TARGET_ARCH STREQUAL "amd64" ) - message("Building for amd64") - set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") + message(STATUS "...amd64") + set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") elseif( TARGET_ARCH STREQUAL "armhf" ) - message("Building for armhf") + message(STATUS "...armhf") set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc-8) set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++-8) - set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "armhf") + set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "armhf") else() - message("Target Architecture not specified, not cross compiling") + message(STATUS "...not cross compiling") endif() -set (aasdk_VERSION_MAJOR 3) -set (aasdk_VERSION_MINOR 1) -set (aasdk_VERSION_PATCH 0) - -project(aasdk -VERSION ${aasdk_VERSION_MAJOR}.${aasdk_VERSION_MINOR}.${aasdk_VERSION_PATCH} -LANGUAGES CXX) +# Set Compile Versions +set(LIBRARY_BUILD_DATE "20241121") # Binary Release Build Date +set(LIBRARY_BUILD_MAJOR_RELEASE 4) # Binary Release Build Number (increment if released on same day) +set(LIBRARY_BUILD_MINOR_RELEASE 0) # Binary Release Build Number (increment if released on same day) +set(LIBRARY_BUILD_INCREMENTAL 0) # Binary Build Version - Increment for Each Build +# Cache find_program(CCACHE_PROGRAM ccache) if(CCACHE_PROGRAM) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") endif() -set(base_directory ${CMAKE_CURRENT_SOURCE_DIR}) -set(sources_directory ${base_directory}/src) - -set(include_directory ${base_directory}/include) -set(include_ut_directory ${base_directory}/include_ut) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${base_directory}/lib) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${base_directory}/lib) +# Configure CMAKE +message(STATUS "Configuring CMAKE") +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${base_directory}/bin) -set(EXECUTABLE_OUTPUT_PATH ${base_directory}/bin) - -SET(CMAKE_CXX_STANDARD 14) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake_modules/") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -fPIC -Wall -pedantic") set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") set(CMAKE_CXX_FLAGS_RELEASE "-g -O3") +# Default to Release mode unless overridden with -DCMAKE_BUILD_TYPE=Debug on cmake command +if(NOT CMAKE_BUILD_TYPE) + message(STATUS "Forcing Release build type") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + +# Paths +set(sources_directory ${CMAKE_CURRENT_SOURCE_DIR}/src) +set(include_directory ${CMAKE_CURRENT_SOURCE_DIR}/include) +set(include_ut_directory ${CMAKE_CURRENT_SOURCE_DIR}/include_ut) + +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin) + +set (CMAKE_PROJECT_VERSION_PATCH ${_commit_timestamp}) + +# Configure Boost set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) add_definitions(-DBOOST_ALL_DYN_LINK) -include(${base_directory}/cmake_modules/gitversion.cmake) -set (aasdk_VERSION_PATCH ${_commit_timestamp}) -set (CMAKE_PROJECT_VERSION_PATCH ${aasdk_VERSION_PATCH}) +if(CMAKE_BUILD_TYPE STREQUAL "Release") + message(STATUS "Disabling Boost DEBUG logs") + add_definitions(-DNDEBUG) +endif() if(WIN32) set(WINSOCK2_LIBRARIES "ws2_32") @@ -61,23 +81,32 @@ if(AASDK_TEST) include(ExternalGtest) endif(AASDK_TEST) -add_subdirectory(aasdk_proto) +find_package(aap_protobuf REQUIRED) + +# Building on a Mac requires Abseil +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # macOS + message(STATUS "MacOS System Detected") + find_package(protobuf REQUIRED CONFIG) + find_package(absl REQUIRED) +else () + find_package(Protobuf REQUIRED) +endif () + +include(FindProtobuf) find_package(Boost REQUIRED COMPONENTS system log OPTIONAL_COMPONENTS unit_test_framework) find_package(libusb-1.0 REQUIRED) -find_package(Protobuf REQUIRED) find_package(OpenSSL REQUIRED) -set(AASDK_PROTO_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}) - -include_directories(${AASDK_PROTO_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${PROTOBUF_INCLUDE_DIR} - ${OPENSSL_INCLUDE_DIR} - ${GTEST_INCLUDE_DIRS} - ${GMOCK_INCLUDE_DIRS} - ${include_directory} - ${include_ut_directory}) +include_directories( + ${Boost_INCLUDE_DIRS} + ${PROTOBUF_INCLUDE_DIR} + ${AAP_PROTOBUF_INCLUDE_DIR} + ${OPENSSL_INCLUDE_DIR} + ${GTEST_INCLUDE_DIRS} + ${GMOCK_INCLUDE_DIRS} + ${include_directory} + ${include_ut_directory}) file(GLOB_RECURSE source_files ${sources_directory}/*.cpp) file(GLOB_RECURSE include_files ${include_directory}/*.hpp) @@ -86,37 +115,82 @@ file(GLOB_RECURSE tests_include_files ${include_ut_directory}/*.hpp) list(REMOVE_ITEM source_files ${tests_source_files}) -add_library(aasdk SHARED - ${source_files} - ${include_files}) - -add_dependencies(aasdk aasdk_proto) -target_link_libraries(aasdk - aasdk_proto - libusb - ${Boost_LIBRARIES} - ${PROTOBUF_LIBRARIES} - ${OPENSSL_LIBRARIES} - ${WINSOCK2_LIBRARIES}) - -set(aasdk_VERSION_STRING ${aasdk_VERSION_MAJOR}.${aasdk_VERSION_MINOR}.${aasdk_VERSION_PATCH}) -message(INFO " Project Version: ${aasdk_VERSION_STRING}") -set_target_properties(aasdk PROPERTIES VERSION ${aasdk_VERSION_STRING} - SOVERSION ${aasdk_VERSION_MAJOR}) - -install(TARGETS aasdk DESTINATION lib COMPONENT libraries) -install(DIRECTORY include/aasdk DESTINATION include COMPONENT headers) +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # macOS + message(NOTICE "Configuring STATIC Library for MacOS") + add_library(aasdk STATIC + ${source_files} + ${include_files}) +else() + message(NOTICE "Configuring SHARED Library") + add_library(aasdk SHARED + ${source_files} + ${include_files}) +endif() +target_include_directories(aasdk PUBLIC ${AAP_PROTOBUF_INCLUDE_DIR}) + +target_link_libraries(aasdk PUBLIC + libusb + ${Boost_LIBRARIES} + ${PROTOBUF_LIBRARIES} + ${AAP_PROTOBUF_LIB_DIR} + ${OPENSSL_LIBRARIES} + ${WINSOCK2_LIBRARIES}) + + +set(LIBRARY_VERSION_STRING "${LIBRARY_BUILD_MAJOR_RELEASE}.${LIBRARY_BUILD_MINOR_RELEASE}.${LIBRARY_BUILD_INCREMENTAL}+${LIBRARY_BUILD_DATE}") +message(STATUS "Project Version: ${LIBRARY_VERSION_STRING}") +set_target_properties(aasdk + PROPERTIES VERSION ${LIBRARY_VERSION_STRING} SOVERSION ${LIBRARY_BUILD_INCREMENTAL}) + +# Install rules +install(TARGETS aasdk libusb + EXPORT aasdkTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) + +# Install headers explicitly +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/aasdk + DESTINATION include +) + +# Export the targets to a script +install(EXPORT aasdkTargets + FILE aasdkTargets.cmake + NAMESPACE AASDK:: + DESTINATION lib/cmake/aasdk +) + +# Create a Config file for FindPackage +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/aasdkConfigVersion.cmake" + VERSION 1.0 + COMPATIBILITY AnyNewerVersion +) + +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/aasdkConfig.cmake" + INSTALL_DESTINATION lib/cmake/aasdk +) + +# Install the config files +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/aasdkConfigVersion.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/aasdkConfig.cmake" + DESTINATION lib/cmake/aasdk) if(AASDK_TEST) add_executable(aasdk_ut - ${tests_source_files} - ${tests_include_files}) + ${tests_source_files} + ${tests_include_files}) add_dependencies(aasdk_ut aasdk) target_link_libraries(aasdk_ut - aasdk - ${GMOCK_LIBRARY_PATH} - ${GTEST_LIBRARY_PATH}) + aasdk + ${GMOCK_LIBRARY_PATH} + ${GTEST_LIBRARY_PATH}) if(AASDK_CODE_COVERAGE) include(CodeCoverage) @@ -124,27 +198,29 @@ if(AASDK_TEST) setup_target_for_coverage(NAME aasdk_coverage EXECUTABLE aasdk_ut DEPENDENCIES aasdk_ut) endif(AASDK_CODE_COVERAGE) endif(AASDK_TEST) -SET(CPACK_GENERATOR "DEB") -SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "AASDK") #required -SET(CPACK_PACKAGE_VENDOR "AASDK") -set(CPACK_PACKAGE_VERSION ${aasdk_VERSION_STRING}) + + +set(CPACK_GENERATOR "DEB") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "AASDK") #required +set(CPACK_PACKAGE_VENDOR "AASDK") +set(CPACK_PACKAGE_VERSION ${LIBRARY_VERSION_STRING}) set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) set(CPACK_DEBIAN_PACKAGE_DEPENDS "libusb-1.0-0,libboost-all-dev,libssl-dev,libprotobuf-dev") set(CPACK_COMPONENTS_ALL libraries headers Unspecified) set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers") set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION - "Static libraries used to build programs with AASDK") + "Static libraries used to build programs with AASDK") set(CPACK_COMPONENT_HEADERS_DESCRIPTION - "C/C++ header files for use with AASDK") + "C/C++ header files for use with AASDK") set(CPACK_COMPONENT_LIBRARIES_GROUP "Development") set(CPACK_COMPONENT_HEADERS_GROUP "Development") set(CPACK_COMPONENT_GROUP_DEVELOPMENT_EXPANDED ON) set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION - "All of the tools you'll ever need to develop software") + "All of the tools you'll ever need to develop software") set(CPACK_COMPONENT_HEADERS_DEPENDS libraries) set(CPACK_ALL_INSTALL_TYPES Full Developer) set(CPACK_INSTALL_TYPE_FULL_DISPLAY_NAME "Everything") set(CPACK_COMPONENT_LIBRARIES_INSTALL_TYPES Developer Full) set(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full) -INCLUDE(CPack) +include(CPack) diff --git a/Config.cmake.in b/Config.cmake.in new file mode 100644 index 00000000..2563ac96 --- /dev/null +++ b/Config.cmake.in @@ -0,0 +1,3 @@ +set(AASDK_INCLUDE_DIRS @CMAKE_INSTALL_FULL_INCLUDEDIR@) +set(AASDK_LIB_DIRS @CMAKE_INSTALL_FULL_LIBDIR@) +include("${CMAKE_CURRENT_LIST_DIR}/aasdkTargets.cmake") \ No newline at end of file diff --git a/RELEASE.txt b/RELEASE.txt new file mode 100644 index 00000000..920a25a7 --- /dev/null +++ b/RELEASE.txt @@ -0,0 +1,10 @@ +Release Notes +============= +20241120 - 2.0.1 +- Restructure AASDK Proto Protobuf files for Android Auto 1.6 Support based on information from https://milek7.pl/.stuff/galdocs/readme.md +This fleshes out enums and other methods with their full naming conventions for better readability and understanding. +- Restructure AASDK source/header with additional renames to clarify differences between AudioService, VideoService and AVInput. Updated to MediaSinkService which is extended by AudioMediaSinkService and VideoMediaSinkService which themselves are extended by the individual service channels. +- Added initial GenericNotification, MediaBrowser, MediaPlaybackStatus, PhoneStatus, Radio, VendorExtension and WifiProjection services. +- Update AASDK_LOG entries for extra consistency +- Simplify CMAKE to build and install keeping parameters to a minimum. Default to Release mode and Raspberry PI build unless otherwise specified. +- diff --git a/aasdk_proto/AVChannelData.proto b/aasdk_proto/AVChannelData.proto deleted file mode 100644 index f7be2419..00000000 --- a/aasdk_proto/AVChannelData.proto +++ /dev/null @@ -1,35 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "AVStreamTypeEnum.proto"; -import "AudioTypeEnum.proto"; -import "AudioConfigData.proto"; -import "VideoConfigData.proto"; - -package aasdk.proto.data; - -message AVChannel -{ - required enums.AVStreamType.Enum stream_type = 1; - optional enums.AudioType.Enum audio_type = 2; - repeated AudioConfig audio_configs = 3; - repeated VideoConfig video_configs = 4; - optional bool available_while_in_call = 5; -} diff --git a/aasdk_proto/AVChannelMessageIdsEnum.proto b/aasdk_proto/AVChannelMessageIdsEnum.proto deleted file mode 100644 index 54702d0b..00000000 --- a/aasdk_proto/AVChannelMessageIdsEnum.proto +++ /dev/null @@ -1,39 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.ids; - -message AVChannelMessage -{ - enum Enum - { - AV_MEDIA_WITH_TIMESTAMP_INDICATION = 0x0000; - AV_MEDIA_INDICATION = 0x0001; - SETUP_REQUEST = 0x8000; - START_INDICATION = 0x8001; - STOP_INDICATION = 0x8002; - SETUP_RESPONSE = 0x8003; - AV_MEDIA_ACK_INDICATION = 0x8004; - AV_INPUT_OPEN_REQUEST = 0x8005; - AV_INPUT_OPEN_RESPONSE = 0x8006; - VIDEO_FOCUS_REQUEST = 0x8007; - VIDEO_FOCUS_INDICATION = 0x8008; - } -} diff --git a/aasdk_proto/AVChannelSetupRequestMessage.proto b/aasdk_proto/AVChannelSetupRequestMessage.proto deleted file mode 100644 index e7741438..00000000 --- a/aasdk_proto/AVChannelSetupRequestMessage.proto +++ /dev/null @@ -1,26 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message AVChannelSetupRequest -{ - required uint32 config_index = 1; -} diff --git a/aasdk_proto/AVChannelSetupResponseMessage.proto b/aasdk_proto/AVChannelSetupResponseMessage.proto deleted file mode 100644 index 6d337821..00000000 --- a/aasdk_proto/AVChannelSetupResponseMessage.proto +++ /dev/null @@ -1,30 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "AVChannelSetupStatusEnum.proto"; - -package aasdk.proto.messages; - -message AVChannelSetupResponse -{ - required enums.AVChannelSetupStatus.Enum media_status = 1; - required uint32 max_unacked = 2; - repeated uint32 configs = 3; -} diff --git a/aasdk_proto/AVChannelSetupStatusEnum.proto b/aasdk_proto/AVChannelSetupStatusEnum.proto deleted file mode 100644 index dd3dc196..00000000 --- a/aasdk_proto/AVChannelSetupStatusEnum.proto +++ /dev/null @@ -1,31 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message AVChannelSetupStatus -{ - enum Enum - { - NONE = 0; - FAIL = 1; - OK = 2; - } -} diff --git a/aasdk_proto/AVChannelStartIndicationMessage.proto b/aasdk_proto/AVChannelStartIndicationMessage.proto deleted file mode 100644 index 3f9d39d2..00000000 --- a/aasdk_proto/AVChannelStartIndicationMessage.proto +++ /dev/null @@ -1,27 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message AVChannelStartIndication -{ - required int32 session = 1; - required uint32 config = 2; -} diff --git a/aasdk_proto/AVChannelStopIndicationMessage.proto b/aasdk_proto/AVChannelStopIndicationMessage.proto deleted file mode 100644 index 0332371f..00000000 --- a/aasdk_proto/AVChannelStopIndicationMessage.proto +++ /dev/null @@ -1,25 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message AVChannelStopIndication -{ -} diff --git a/aasdk_proto/AVInputChannelData.proto b/aasdk_proto/AVInputChannelData.proto deleted file mode 100644 index 940a5532..00000000 --- a/aasdk_proto/AVInputChannelData.proto +++ /dev/null @@ -1,31 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "AVStreamTypeEnum.proto"; -import "AudioConfigData.proto"; - -package aasdk.proto.data; - -message AVInputChannel -{ - required enums.AVStreamType.Enum stream_type = 1; - required AudioConfig audio_config = 2; - optional bool available_while_in_call = 3; -} diff --git a/aasdk_proto/AVInputOpenRequestMessage.proto b/aasdk_proto/AVInputOpenRequestMessage.proto deleted file mode 100644 index dbe44dfe..00000000 --- a/aasdk_proto/AVInputOpenRequestMessage.proto +++ /dev/null @@ -1,29 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message AVInputOpenRequest -{ - required bool open = 1; - optional bool anc = 2; - optional bool ec = 3; - optional int32 max_unacked = 4; -} diff --git a/aasdk_proto/AVInputOpenResponseMessage.proto b/aasdk_proto/AVInputOpenResponseMessage.proto deleted file mode 100644 index c4b06387..00000000 --- a/aasdk_proto/AVInputOpenResponseMessage.proto +++ /dev/null @@ -1,27 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message AVInputOpenResponse -{ - required int32 session = 1; - required uint32 value = 2; -} diff --git a/aasdk_proto/AVMediaAckIndicationMessage.proto b/aasdk_proto/AVMediaAckIndicationMessage.proto deleted file mode 100644 index 58b5de49..00000000 --- a/aasdk_proto/AVMediaAckIndicationMessage.proto +++ /dev/null @@ -1,27 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message AVMediaAckIndication -{ - required int32 session = 1; - required uint32 value = 2; -} diff --git a/aasdk_proto/AVStreamTypeEnum.proto b/aasdk_proto/AVStreamTypeEnum.proto deleted file mode 100644 index 4202c040..00000000 --- a/aasdk_proto/AVStreamTypeEnum.proto +++ /dev/null @@ -1,31 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message AVStreamType -{ - enum Enum - { - NONE = 0; - AUDIO = 1; - VIDEO = 3; - } -} diff --git a/aasdk_proto/AbsoluteInputEventData.proto b/aasdk_proto/AbsoluteInputEventData.proto deleted file mode 100644 index efc0a5b6..00000000 --- a/aasdk_proto/AbsoluteInputEventData.proto +++ /dev/null @@ -1,27 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message AbsoluteInputEvent -{ - required uint32 scan_code = 1; - required int32 value = 2; -} diff --git a/aasdk_proto/AbsoluteInputEventsData.proto b/aasdk_proto/AbsoluteInputEventsData.proto deleted file mode 100644 index d328c429..00000000 --- a/aasdk_proto/AbsoluteInputEventsData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "AbsoluteInputEventData.proto"; - -package aasdk.proto.data; - -message AbsoluteInputEvents -{ - repeated AbsoluteInputEvent absolute_input_events = 1; -} diff --git a/aasdk_proto/AccelData.proto b/aasdk_proto/AccelData.proto deleted file mode 100644 index 35a7445a..00000000 --- a/aasdk_proto/AccelData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message Accel -{ - required int32 acceleration_x = 1; - required int32 acceleration_y = 2; - required int32 acceleration_z = 3; -} diff --git a/aasdk_proto/AudioConfigData.proto b/aasdk_proto/AudioConfigData.proto deleted file mode 100644 index 7daca1c8..00000000 --- a/aasdk_proto/AudioConfigData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message AudioConfig -{ - required uint32 sample_rate = 1; - required uint32 bit_depth = 2; - required uint32 channel_count = 3; -} diff --git a/aasdk_proto/AudioFocusRequestMessage.proto b/aasdk_proto/AudioFocusRequestMessage.proto deleted file mode 100644 index 1bece29c..00000000 --- a/aasdk_proto/AudioFocusRequestMessage.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "AudioFocusTypeEnum.proto"; - -package aasdk.proto.messages; - -message AudioFocusRequest -{ - required enums.AudioFocusType.Enum audio_focus_type = 1; -} diff --git a/aasdk_proto/AudioFocusResponseMessage.proto b/aasdk_proto/AudioFocusResponseMessage.proto deleted file mode 100644 index 1b00ebe6..00000000 --- a/aasdk_proto/AudioFocusResponseMessage.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "AudioFocusStateEnum.proto"; - -package aasdk.proto.messages; - -message AudioFocusResponse -{ - required enums.AudioFocusState.Enum audio_focus_state = 1; -} diff --git a/aasdk_proto/AudioFocusStateEnum.proto b/aasdk_proto/AudioFocusStateEnum.proto deleted file mode 100644 index c79eddf8..00000000 --- a/aasdk_proto/AudioFocusStateEnum.proto +++ /dev/null @@ -1,36 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message AudioFocusState -{ - enum Enum - { - NONE = 0; - GAIN = 1; - GAIN_TRANSIENT = 2; - LOSS = 3; - LOSS_TRANSIENT_CAN_DUCK = 4; - LOSS_TRANSIENT = 5; - GAIN_MEDIA_ONLY = 6; - GAIN_TRANSIENT_GUIDANCE_ONLY = 7; - } -} diff --git a/aasdk_proto/AudioFocusTypeEnum.proto b/aasdk_proto/AudioFocusTypeEnum.proto deleted file mode 100644 index 12bc0576..00000000 --- a/aasdk_proto/AudioFocusTypeEnum.proto +++ /dev/null @@ -1,33 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message AudioFocusType -{ - enum Enum - { - NONE = 0; - GAIN = 1; - GAIN_TRANSIENT = 2; - GAIN_NAVI = 3; - RELEASE = 4; - } -} diff --git a/aasdk_proto/AudioTypeEnum.proto b/aasdk_proto/AudioTypeEnum.proto deleted file mode 100644 index c80f29fb..00000000 --- a/aasdk_proto/AudioTypeEnum.proto +++ /dev/null @@ -1,33 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message AudioType -{ - enum Enum - { - NONE = 0; - SPEECH = 1; - SYSTEM = 2; - MEDIA = 3; - ALARM = 4; - } -} diff --git a/aasdk_proto/AuthCompleteIndicationMessage.proto b/aasdk_proto/AuthCompleteIndicationMessage.proto deleted file mode 100644 index 36d3a120..00000000 --- a/aasdk_proto/AuthCompleteIndicationMessage.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "StatusEnum.proto"; - -package aasdk.proto.messages; - -message AuthCompleteIndication -{ - required enums.Status.Enum status = 1; -} diff --git a/aasdk_proto/BindingRequestMessage.proto b/aasdk_proto/BindingRequestMessage.proto deleted file mode 100644 index 9b94cee9..00000000 --- a/aasdk_proto/BindingRequestMessage.proto +++ /dev/null @@ -1,26 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message BindingRequest -{ - repeated int32 scan_codes = 1; -} diff --git a/aasdk_proto/BindingResponseMessage.proto b/aasdk_proto/BindingResponseMessage.proto deleted file mode 100644 index 8d48b25c..00000000 --- a/aasdk_proto/BindingResponseMessage.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "StatusEnum.proto"; - -package aasdk.proto.messages; - -message BindingResponse -{ - required enums.Status.Enum status = 1; -} diff --git a/aasdk_proto/BluetoothChannelData.proto b/aasdk_proto/BluetoothChannelData.proto deleted file mode 100644 index 411f796a..00000000 --- a/aasdk_proto/BluetoothChannelData.proto +++ /dev/null @@ -1,29 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "BluetoothPairingMethodEnum.proto"; - -package aasdk.proto.data; - -message BluetoothChannel -{ - required string adapter_address = 1; - repeated enums.BluetoothPairingMethod.Enum supported_pairing_methods = 2; -} diff --git a/aasdk_proto/BluetoothChannelMessageIdsEnum.proto b/aasdk_proto/BluetoothChannelMessageIdsEnum.proto deleted file mode 100644 index ff5d6405..00000000 --- a/aasdk_proto/BluetoothChannelMessageIdsEnum.proto +++ /dev/null @@ -1,33 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.ids; - -message BluetoothChannelMessage -{ - enum Enum - { - NONE = 0x0000; - PAIRING_REQUEST = 0x8001; - PAIRING_RESPONSE = 0x8002; - AUTH_DATA = 0x8003; - } -} - diff --git a/aasdk_proto/BluetoothPairingMethodEnum.proto b/aasdk_proto/BluetoothPairingMethodEnum.proto deleted file mode 100644 index 92beaa5d..00000000 --- a/aasdk_proto/BluetoothPairingMethodEnum.proto +++ /dev/null @@ -1,33 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message BluetoothPairingMethod -{ - enum Enum - { - NONE = 0; - UNK_1 = 1; - A2DP = 2; - UNK_3 = 3; - HFP = 4; - } -} diff --git a/aasdk_proto/BluetoothPairingRequestMessage.proto b/aasdk_proto/BluetoothPairingRequestMessage.proto deleted file mode 100644 index 08cb16d8..00000000 --- a/aasdk_proto/BluetoothPairingRequestMessage.proto +++ /dev/null @@ -1,29 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "BluetoothPairingMethodEnum.proto"; - -package aasdk.proto.messages; - -message BluetoothPairingRequest -{ - required string phone_address = 1; - required enums.BluetoothPairingMethod.Enum pairing_method = 2; -} diff --git a/aasdk_proto/BluetoothPairingResponseMessage.proto b/aasdk_proto/BluetoothPairingResponseMessage.proto deleted file mode 100644 index 5d57e055..00000000 --- a/aasdk_proto/BluetoothPairingResponseMessage.proto +++ /dev/null @@ -1,29 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "BluetoothPairingStatusEnum.proto"; - -package aasdk.proto.messages; - -message BluetoothPairingResponse -{ - required bool already_paired = 1; - required enums.BluetoothPairingStatus.Enum status = 2; -} diff --git a/aasdk_proto/BluetoothPairingStatusEnum.proto b/aasdk_proto/BluetoothPairingStatusEnum.proto deleted file mode 100644 index b2e7ef8c..00000000 --- a/aasdk_proto/BluetoothPairingStatusEnum.proto +++ /dev/null @@ -1,31 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message BluetoothPairingStatus -{ - enum Enum - { - NONE = 0; - OK = 1; - FAIL = 2; - } -} diff --git a/aasdk_proto/ButtonCodeEnum.proto b/aasdk_proto/ButtonCodeEnum.proto deleted file mode 100644 index 0781d596..00000000 --- a/aasdk_proto/ButtonCodeEnum.proto +++ /dev/null @@ -1,55 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message ButtonCode -{ - enum Enum - { - NONE = 0x00; - MICROPHONE_2 = 0x01; - MENU = 0x02; - HOME = 0x03; - BACK = 0x04; - PHONE = 0x05; - CALL_END = 0x06; - UP = 0x13; - DOWN = 0x14; - LEFT = 0x15; - RIGHT = 0x16; - ENTER = 0x17; - MICROPHONE_1 = 0x54; - TOGGLE_PLAY = 0x55; - NEXT = 0x57; - PREV = 0x58; - PLAY = 0x7E; - PAUSE = 0x7F; - MUSIC = 0xD1; - SCROLL_WHEEL = 0x10000; - MEDIA = 0x10001; - NAVIGATION = 0x10002; - RADIO = 0x10003; - TEL = 0x10004; - PRIMARY_BUTTON = 0x10005; - SECONDARY_BUTTON = 0x10006; - TERTIARY_BUTTON = 0x10007; - } -} diff --git a/aasdk_proto/ButtonEventData.proto b/aasdk_proto/ButtonEventData.proto deleted file mode 100644 index 8ae03678..00000000 --- a/aasdk_proto/ButtonEventData.proto +++ /dev/null @@ -1,29 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message ButtonEvent -{ - required uint32 scan_code = 1; - required bool is_pressed = 2; - optional uint32 meta = 3; - optional bool long_press = 4; -} diff --git a/aasdk_proto/ButtonEventsData.proto b/aasdk_proto/ButtonEventsData.proto deleted file mode 100644 index 52bc70f6..00000000 --- a/aasdk_proto/ButtonEventsData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "ButtonEventData.proto"; - -package aasdk.proto.data; - -message ButtonEvents -{ - repeated ButtonEvent button_events = 1; -} diff --git a/aasdk_proto/CMakeLists.txt b/aasdk_proto/CMakeLists.txt deleted file mode 100644 index 4c0d40fc..00000000 --- a/aasdk_proto/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -include(FindProtobuf) -find_package(Protobuf REQUIRED) -include_directories(${PROTOBUF_INCLUDE_DIR}) - -file(GLOB_RECURSE proto_files ${CMAKE_CURRENT_SOURCE_DIR}/*.proto) -protobuf_generate_cpp(proto_sources proto_headers ${proto_files}) -add_library(aasdk_proto SHARED ${proto_headers} ${proto_sources}) -target_link_libraries(aasdk_proto ${PROTOBUF_LIBRARIES}) - -set(aasdk_VERSION_STRING ${aasdk_VERSION_MAJOR}.${aasdk_VERSION_MINOR}.${aasdk_VERSION_PATCH}) -set_target_properties(aasdk_proto PROPERTIES VERSION ${aasdk_VERSION_STRING} - SOVERSION ${aasdk_VERSION_MAJOR}) - -install(TARGETS aasdk_proto DESTINATION lib) -install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DESTINATION include - FILES_MATCHING PATTERN *.h - PATTERN CMakeFiles EXCLUDE ) diff --git a/aasdk_proto/ChannelDescriptorData.proto b/aasdk_proto/ChannelDescriptorData.proto deleted file mode 100644 index 786f408e..00000000 --- a/aasdk_proto/ChannelDescriptorData.proto +++ /dev/null @@ -1,47 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -option optimize_for=SPEED; - -import "SensorChannelData.proto"; -import "AVChannelData.proto"; -import "InputChannelData.proto"; -import "AVInputChannelData.proto"; -import "BluetoothChannelData.proto"; -import "NavigationChannelData.proto"; -import "VendorExtensionChannelData.proto"; -import "MediaInfoChannelData.proto"; -import "WifiChannelData.proto"; - -package aasdk.proto.data; - -message ChannelDescriptor -{ - required uint32 channel_id = 1; - optional SensorChannel sensor_channel = 2; - optional AVChannel av_channel = 3; - optional InputChannel input_channel = 4; - optional AVInputChannel av_input_channel = 5; - optional BluetoothChannel bluetooth_channel = 6; - optional NavigationChannel navigation_channel = 8; - optional MediaInfoChannel media_infoChannel = 9; - optional VendorExtensionChannel vendor_extension_channel = 12; - optional WifiChannel wifi_channel=16; -} diff --git a/aasdk_proto/ChannelOpenRequestMessage.proto b/aasdk_proto/ChannelOpenRequestMessage.proto deleted file mode 100644 index ff350cb8..00000000 --- a/aasdk_proto/ChannelOpenRequestMessage.proto +++ /dev/null @@ -1,27 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message ChannelOpenRequest -{ - required int32 priority = 1; - required int32 channel_id = 2; -} diff --git a/aasdk_proto/ChannelOpenResponseMessage.proto b/aasdk_proto/ChannelOpenResponseMessage.proto deleted file mode 100644 index d4f793c4..00000000 --- a/aasdk_proto/ChannelOpenResponseMessage.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "StatusEnum.proto"; - -package aasdk.proto.messages; - -message ChannelOpenResponse -{ - required enums.Status.Enum status = 1; -} diff --git a/aasdk_proto/CompassData.proto b/aasdk_proto/CompassData.proto deleted file mode 100644 index 931b3ae9..00000000 --- a/aasdk_proto/CompassData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message Compass -{ - required int32 bearing =1; - required int32 pitch = 2; - required int32 roll = 3; -} diff --git a/aasdk_proto/ControlMessageIdsEnum.proto b/aasdk_proto/ControlMessageIdsEnum.proto deleted file mode 100644 index 258ec181..00000000 --- a/aasdk_proto/ControlMessageIdsEnum.proto +++ /dev/null @@ -1,46 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.ids; - -message ControlMessage -{ - enum Enum - { - NONE = 0x0000; - VERSION_REQUEST = 0x0001; - VERSION_RESPONSE = 0x0002; - SSL_HANDSHAKE = 0x0003; - AUTH_COMPLETE = 0x0004; - SERVICE_DISCOVERY_REQUEST = 0x0005; - SERVICE_DISCOVERY_RESPONSE = 0x0006; - CHANNEL_OPEN_REQUEST = 0x0007; - CHANNEL_OPEN_RESPONSE = 0x0008; - PING_REQUEST = 0x000b; - PING_RESPONSE = 0x000c; - NAVIGATION_FOCUS_REQUEST = 0x000d; - NAVIGATION_FOCUS_RESPONSE = 0x000e; - SHUTDOWN_REQUEST = 0x000f; - SHUTDOWN_RESPONSE = 0x0010; - VOICE_SESSION_REQUEST = 0x0011; - AUDIO_FOCUS_REQUEST = 0x0012; - AUDIO_FOCUS_RESPONSE = 0x0013; - } -} diff --git a/aasdk_proto/DiagnosticsData.proto b/aasdk_proto/DiagnosticsData.proto deleted file mode 100644 index 36a146ab..00000000 --- a/aasdk_proto/DiagnosticsData.proto +++ /dev/null @@ -1,26 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message Diagnostics -{ - required bytes diagnostics = 1; -} diff --git a/aasdk_proto/DistanceUnitEnum.proto b/aasdk_proto/DistanceUnitEnum.proto deleted file mode 100644 index acfbf840..00000000 --- a/aasdk_proto/DistanceUnitEnum.proto +++ /dev/null @@ -1,36 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message DistanceUnit -{ - enum Enum - { - UNKNOWN = 0; - METERS = 1; - KILOMETERS = 2; - KILOMETERS_PARTIAL = 3; - MILES = 4; - MILES_PARTIAL = 5; - FEET = 6; - YARDS = 7; - } -} diff --git a/aasdk_proto/DoorData.proto b/aasdk_proto/DoorData.proto deleted file mode 100644 index 75221470..00000000 --- a/aasdk_proto/DoorData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message Door -{ - required bool hood_open = 1; - required bool boot_open = 2; - repeated bool door_open = 3; -} diff --git a/aasdk_proto/DrivingStatusData.proto b/aasdk_proto/DrivingStatusData.proto deleted file mode 100644 index 417d6f58..00000000 --- a/aasdk_proto/DrivingStatusData.proto +++ /dev/null @@ -1,26 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message DrivingStatus -{ - required int32 status = 1; -} diff --git a/aasdk_proto/DrivingStatusEnum.proto b/aasdk_proto/DrivingStatusEnum.proto deleted file mode 100644 index 12e6296c..00000000 --- a/aasdk_proto/DrivingStatusEnum.proto +++ /dev/null @@ -1,35 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message DrivingStatus -{ - enum Enum - { - UNRESTRICTED = 0; - NO_VIDEO = 1; - NO_KEYBOARD_INPUT = 2; - NO_VOICE_INPUT = 4; - NO_CONFIG = 8; - LIMIT_MESSAGE_LEN = 16; - FULLY_RESTRICTED = 31; - } -} diff --git a/aasdk_proto/EnvironmentData.proto b/aasdk_proto/EnvironmentData.proto deleted file mode 100644 index 27f08b89..00000000 --- a/aasdk_proto/EnvironmentData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message Environment -{ - required int32 temperature =1; - required int32 pressure = 2; - required int32 rain = 3; -} diff --git a/aasdk_proto/FuelLevelData.proto b/aasdk_proto/FuelLevelData.proto deleted file mode 100644 index ace8c4c2..00000000 --- a/aasdk_proto/FuelLevelData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message FuelLevel -{ - required int32 fuel_level = 1; - required int32 range = 2; - required bool low_fuel = 3; -} diff --git a/aasdk_proto/GPSLocationData.proto b/aasdk_proto/GPSLocationData.proto deleted file mode 100644 index 0fb1723d..00000000 --- a/aasdk_proto/GPSLocationData.proto +++ /dev/null @@ -1,32 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message GPSLocation -{ - required uint64 timestamp = 1; - required int32 latitude = 2; - required int32 longitude = 3; - required uint32 accuracy = 4; - optional int32 altitude = 5; - optional int32 speed = 6; - optional int32 bearing = 7; -} diff --git a/aasdk_proto/GearData.proto b/aasdk_proto/GearData.proto deleted file mode 100644 index 88047248..00000000 --- a/aasdk_proto/GearData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "GearEnum.proto"; - -package aasdk.proto.data; - -message Gear -{ - required enums.Gear.Enum gear = 1; -} diff --git a/aasdk_proto/GearEnum.proto b/aasdk_proto/GearEnum.proto deleted file mode 100644 index 0c805fc7..00000000 --- a/aasdk_proto/GearEnum.proto +++ /dev/null @@ -1,42 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message Gear -{ - enum Enum - { - NEUTRAL = 0; - FIRST = 1; - SECOND = 2; - THIRD = 3; - FOURTH = 4; - FIFTH = 5; - SIXTH = 6; - SEVENTH = 7; - EIGHTH = 8; - NINTH = 9; - TENTH = 10; - DRIVE = 100; - PARK = 101; - REVERSE = 102; - } -} diff --git a/aasdk_proto/GyroData.proto b/aasdk_proto/GyroData.proto deleted file mode 100644 index 17046757..00000000 --- a/aasdk_proto/GyroData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message Gyro -{ - required int32 rotation_speed_x = 1; - required int32 rotation_speed_y = 2; - required int32 rotation_speed_z = 3; -} diff --git a/aasdk_proto/HVACData.proto b/aasdk_proto/HVACData.proto deleted file mode 100644 index e1933522..00000000 --- a/aasdk_proto/HVACData.proto +++ /dev/null @@ -1,27 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message HVAC -{ - required int32 target_temperature = 1; - required int32 current_temperature = 2; -} diff --git a/aasdk_proto/HeadlightStatusEnum.proto b/aasdk_proto/HeadlightStatusEnum.proto deleted file mode 100644 index b2879e19..00000000 --- a/aasdk_proto/HeadlightStatusEnum.proto +++ /dev/null @@ -1,32 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message HeadlightStatus -{ - enum Enum - { - STATE_0 = 0; - STATE_1 = 1; - STATE_2 = 2; - STATE_3 = 3; - } -} diff --git a/aasdk_proto/IndicatorStatusEnum.proto b/aasdk_proto/IndicatorStatusEnum.proto deleted file mode 100644 index fe0b7f18..00000000 --- a/aasdk_proto/IndicatorStatusEnum.proto +++ /dev/null @@ -1,32 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message IndicatorStatus -{ - enum Enum - { - STATE_0 = 0; - STATE_1 = 1; - STATE_2 = 2; - STATE_3 = 3; - } -} diff --git a/aasdk_proto/InputChannelData.proto b/aasdk_proto/InputChannelData.proto deleted file mode 100644 index d4cf8fdf..00000000 --- a/aasdk_proto/InputChannelData.proto +++ /dev/null @@ -1,30 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "TouchConfigData.proto"; - -package aasdk.proto.data; - -message InputChannel -{ - repeated uint32 supported_keycodes = 1; - optional TouchConfig touch_screen_config = 2; - optional TouchConfig touch_pad_config = 3; -} diff --git a/aasdk_proto/InputChannelMessageIdsEnum.proto b/aasdk_proto/InputChannelMessageIdsEnum.proto deleted file mode 100644 index bb9f82af..00000000 --- a/aasdk_proto/InputChannelMessageIdsEnum.proto +++ /dev/null @@ -1,32 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.ids; - -message InputChannelMessage -{ - enum Enum - { - NONE = 0x0000; - INPUT_EVENT_INDICATION = 0x8001; - BINDING_REQUEST = 0x8002; - BINDING_RESPONSE = 0x8003; - } -} diff --git a/aasdk_proto/InputEventIndicationMessage.proto b/aasdk_proto/InputEventIndicationMessage.proto deleted file mode 100644 index 61fc8b17..00000000 --- a/aasdk_proto/InputEventIndicationMessage.proto +++ /dev/null @@ -1,36 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "TouchEventData.proto"; -import "ButtonEventsData.proto"; -import "AbsoluteInputEventsData.proto"; -import "RelativeInputEventsData.proto"; - -package aasdk.proto.messages; - -message InputEventIndication -{ - required uint64 timestamp = 1; - optional int32 disp_channel = 2; - optional data.TouchEvent touch_event = 3; - optional data.ButtonEvents button_event = 4; - optional data.AbsoluteInputEvents absolute_input_event = 5; - optional data.RelativeInputEvents relative_input_event = 6; -} diff --git a/aasdk_proto/LightData.proto b/aasdk_proto/LightData.proto deleted file mode 100644 index 29ddf876..00000000 --- a/aasdk_proto/LightData.proto +++ /dev/null @@ -1,31 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "HeadlightStatusEnum.proto"; -import "IndicatorStatusEnum.proto"; - -package aasdk.proto.data; - -message Light -{ - required enums.HeadlightStatus.Enum headlight = 1; - required enums.IndicatorStatus.Enum indicator = 2; - required bool hazard_light_on = 3; -} diff --git a/aasdk_proto/ManeuverDirectionEnum.proto b/aasdk_proto/ManeuverDirectionEnum.proto deleted file mode 100644 index a1ee0b0c..00000000 --- a/aasdk_proto/ManeuverDirectionEnum.proto +++ /dev/null @@ -1,32 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message ManeuverDirection -{ - enum Enum - { - UNKNOWN = 0; - LEFT = 1; - RIGHT = 2; - UNSPECIFIED = 3; - } -} diff --git a/aasdk_proto/ManeuverTypeEnum.proto b/aasdk_proto/ManeuverTypeEnum.proto deleted file mode 100644 index bf37d942..00000000 --- a/aasdk_proto/ManeuverTypeEnum.proto +++ /dev/null @@ -1,46 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message ManeuverType -{ - enum Enum - { - UNKNOWN = 0; - DEPART = 1; - NAME_CHANGE = 2; - SLIGHT_TURN = 3; - TURN = 4; - SHARP_TURN = 5; - U_TURN = 6; - ON_RAMP = 7; - OFF_RAMP = 8; - FORK = 9; - MERGE = 10; - ROUNDABOUT_ENTER = 11; - ROUNDABOUT_EXIT = 12; - ROUNDABOUT_ENTER_AND_EXIT = 13; - STRAIGHT = 14; - FERRY_BOAT = 16; - FERRY_TRAIN = 17; - DESTINATION = 19; - } -} diff --git a/aasdk_proto/MediaInfoChannelData.proto b/aasdk_proto/MediaInfoChannelData.proto deleted file mode 100644 index 5680a04f..00000000 --- a/aasdk_proto/MediaInfoChannelData.proto +++ /dev/null @@ -1,26 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message MediaInfoChannel -{ - -} diff --git a/aasdk_proto/MediaInfoChannelMessageIdsEnum.proto b/aasdk_proto/MediaInfoChannelMessageIdsEnum.proto deleted file mode 100644 index 90d0bbe2..00000000 --- a/aasdk_proto/MediaInfoChannelMessageIdsEnum.proto +++ /dev/null @@ -1,31 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.ids; - -message MediaInfoChannelMessage -{ - enum Enum - { - NONE = 0x0000; - PLAYBACK = 0x8001; - METADATA = 0x8003; - } -} diff --git a/aasdk_proto/MediaInfoChannelMetadataData.proto b/aasdk_proto/MediaInfoChannelMetadataData.proto deleted file mode 100644 index b3e68dd9..00000000 --- a/aasdk_proto/MediaInfoChannelMetadataData.proto +++ /dev/null @@ -1,31 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message MediaInfoChannelMetadataData -{ - required string track_name = 1; - optional string artist_name = 2; - optional string album_name = 3; - optional bytes album_art = 4; - required int32 track_length = 6; - required int32 unknown1 = 7; -} diff --git a/aasdk_proto/MediaInfoChannelPlaybackData.proto b/aasdk_proto/MediaInfoChannelPlaybackData.proto deleted file mode 100644 index e6f2d000..00000000 --- a/aasdk_proto/MediaInfoChannelPlaybackData.proto +++ /dev/null @@ -1,39 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message MediaInfoChannelPlaybackData -{ - enum PlaybackState - { - NONE = 0x0000; - TRACK_CHANGE = 1; - PLAY = 2; - PAUSE = 3; - } - required PlaybackState playback_state = 1; - required string media_source = 2; - required int32 track_progress = 3; - required int32 unknown1 = 4; - required int32 unknown2 = 5; - required int32 unknown3 = 6; - -} diff --git a/aasdk_proto/NavigationChannelData.proto b/aasdk_proto/NavigationChannelData.proto deleted file mode 100644 index 5c18a04c..00000000 --- a/aasdk_proto/NavigationChannelData.proto +++ /dev/null @@ -1,31 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "NavigationTurnTypeEnum.proto"; -import "NavigationImageOptionsData.proto"; - -package aasdk.proto.data; - -message NavigationChannel -{ - required uint32 minimum_interval_ms = 1; - required enums.NavigationTurnType.Enum type = 2; - required NavigationImageOptions image_options = 3; -} diff --git a/aasdk_proto/NavigationChannelMessageIdsEnum.proto b/aasdk_proto/NavigationChannelMessageIdsEnum.proto deleted file mode 100644 index ba44dd67..00000000 --- a/aasdk_proto/NavigationChannelMessageIdsEnum.proto +++ /dev/null @@ -1,32 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.ids; - -message NavigationChannelMessage -{ - enum Enum - { - NONE = 0x0000; - STATUS = 0x8003; - TURN_EVENT = 0x8004; - DISTANCE_EVENT = 0x8005; - } -} diff --git a/aasdk_proto/NavigationDistanceEventMessage.proto b/aasdk_proto/NavigationDistanceEventMessage.proto deleted file mode 100644 index 74920b92..00000000 --- a/aasdk_proto/NavigationDistanceEventMessage.proto +++ /dev/null @@ -1,32 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "DistanceUnitEnum.proto"; - -package aasdk.proto.messages; - -message NavigationDistanceEvent -{ - required uint32 meters = 1; - required uint32 timeToStepSeconds = 2; - required uint32 distanceToStepMillis = 3; - required enums.DistanceUnit.Enum distanceUnit = 4; - -} diff --git a/aasdk_proto/NavigationFocusRequestMessage.proto b/aasdk_proto/NavigationFocusRequestMessage.proto deleted file mode 100644 index efa52d0f..00000000 --- a/aasdk_proto/NavigationFocusRequestMessage.proto +++ /dev/null @@ -1,26 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message NavigationFocusRequest -{ - required uint32 type = 1; -} diff --git a/aasdk_proto/NavigationFocusResponseMessage.proto b/aasdk_proto/NavigationFocusResponseMessage.proto deleted file mode 100644 index 1af85ba5..00000000 --- a/aasdk_proto/NavigationFocusResponseMessage.proto +++ /dev/null @@ -1,26 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message NavigationFocusResponse -{ - required uint32 type = 1; -} diff --git a/aasdk_proto/NavigationImageOptionsData.proto b/aasdk_proto/NavigationImageOptionsData.proto deleted file mode 100644 index bb38a2fa..00000000 --- a/aasdk_proto/NavigationImageOptionsData.proto +++ /dev/null @@ -1,29 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message NavigationImageOptions -{ - required int32 width = 1; - required int32 height = 2; - required int32 colour_depth_bits = 3; - required int32 dunno = 4; -} diff --git a/aasdk_proto/NavigationStatusMessage.proto b/aasdk_proto/NavigationStatusMessage.proto deleted file mode 100644 index a5b6a22e..00000000 --- a/aasdk_proto/NavigationStatusMessage.proto +++ /dev/null @@ -1,33 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message NavigationStatus -{ - required Enum status = 1; - enum Enum - { - UNAVAILABLE = 0; - ACTIVE = 1; - INACTIVE = 2; - REROUTING = 3; - } -} diff --git a/aasdk_proto/NavigationTurnEventMessage.proto b/aasdk_proto/NavigationTurnEventMessage.proto deleted file mode 100644 index e9fefbdb..00000000 --- a/aasdk_proto/NavigationTurnEventMessage.proto +++ /dev/null @@ -1,34 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "ManeuverTypeEnum.proto"; -import "ManeuverDirectionEnum.proto"; - -package aasdk.proto.messages; - -message NavigationTurnEvent -{ - required string street_name = 1; - required enums.ManeuverDirection.Enum maneuverDirection = 2; - required enums.ManeuverType.Enum maneuverType = 3; - required bytes turnImage = 4; - required uint32 roundaboutExitNumber = 5; - required uint32 roundaboutExitAngle = 6; -} diff --git a/aasdk_proto/NavigationTurnTypeEnum.proto b/aasdk_proto/NavigationTurnTypeEnum.proto deleted file mode 100644 index bd355023..00000000 --- a/aasdk_proto/NavigationTurnTypeEnum.proto +++ /dev/null @@ -1,31 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message NavigationTurnType -{ - enum Enum - { - UNKNOWN = 0; - IMAGE = 1; - ENUM = 2; - } -} diff --git a/aasdk_proto/NightModeData.proto b/aasdk_proto/NightModeData.proto deleted file mode 100644 index 82706307..00000000 --- a/aasdk_proto/NightModeData.proto +++ /dev/null @@ -1,26 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message NightMode -{ - required bool is_night = 1; -} diff --git a/aasdk_proto/OdometerData.proto b/aasdk_proto/OdometerData.proto deleted file mode 100644 index fb9ee015..00000000 --- a/aasdk_proto/OdometerData.proto +++ /dev/null @@ -1,27 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message Odometer -{ - required int32 total_mileage = 1; - required int32 trip_mileage = 2; -} diff --git a/aasdk_proto/ParkingBrakeData.proto b/aasdk_proto/ParkingBrakeData.proto deleted file mode 100644 index 154f64e1..00000000 --- a/aasdk_proto/ParkingBrakeData.proto +++ /dev/null @@ -1,26 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message ParkingBrake -{ - required bool parking_brake = 1; -} diff --git a/aasdk_proto/PassengerData.proto b/aasdk_proto/PassengerData.proto deleted file mode 100644 index f4395634..00000000 --- a/aasdk_proto/PassengerData.proto +++ /dev/null @@ -1,26 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message Passenger -{ - required bool passenger_present = 1; -} diff --git a/aasdk_proto/PingRequestMessage.proto b/aasdk_proto/PingRequestMessage.proto deleted file mode 100644 index ce7f0ea0..00000000 --- a/aasdk_proto/PingRequestMessage.proto +++ /dev/null @@ -1,26 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message PingRequest -{ - required int64 timestamp = 1; -} diff --git a/aasdk_proto/PingResponseMessage.proto b/aasdk_proto/PingResponseMessage.proto deleted file mode 100644 index 3871b620..00000000 --- a/aasdk_proto/PingResponseMessage.proto +++ /dev/null @@ -1,26 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message PingResponse -{ - required int64 timestamp = 1; -} diff --git a/aasdk_proto/RPMData.proto b/aasdk_proto/RPMData.proto deleted file mode 100644 index b24ffdc3..00000000 --- a/aasdk_proto/RPMData.proto +++ /dev/null @@ -1,26 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message RPM -{ - required int32 rpm = 1; -} diff --git a/aasdk_proto/RelativeInputEventData.proto b/aasdk_proto/RelativeInputEventData.proto deleted file mode 100644 index 5b4d8a7b..00000000 --- a/aasdk_proto/RelativeInputEventData.proto +++ /dev/null @@ -1,27 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message RelativeInputEvent -{ - required uint32 scan_code = 1; - required int32 delta = 2; -} diff --git a/aasdk_proto/RelativeInputEventsData.proto b/aasdk_proto/RelativeInputEventsData.proto deleted file mode 100644 index c9eddb79..00000000 --- a/aasdk_proto/RelativeInputEventsData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "RelativeInputEventData.proto"; - -package aasdk.proto.data; - -message RelativeInputEvents -{ - repeated RelativeInputEvent relative_input_events = 1; -} diff --git a/aasdk_proto/SensorChannelData.proto b/aasdk_proto/SensorChannelData.proto deleted file mode 100644 index 74916354..00000000 --- a/aasdk_proto/SensorChannelData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "SensorData.proto"; - -package aasdk.proto.data; - -message SensorChannel -{ - repeated Sensor sensors = 1; -} diff --git a/aasdk_proto/SensorChannelMessageIdsEnum.proto b/aasdk_proto/SensorChannelMessageIdsEnum.proto deleted file mode 100644 index 71cfd699..00000000 --- a/aasdk_proto/SensorChannelMessageIdsEnum.proto +++ /dev/null @@ -1,32 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.ids; - -message SensorChannelMessage -{ - enum Enum - { - NONE = 0x0000; - SENSOR_START_REQUEST = 0x8001; - SENSOR_START_RESPONSE = 0x8002; - SENSOR_EVENT_INDICATION = 0x8003; - } -} diff --git a/aasdk_proto/SensorData.proto b/aasdk_proto/SensorData.proto deleted file mode 100644 index 943676be..00000000 --- a/aasdk_proto/SensorData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "SensorTypeEnum.proto"; - -package aasdk.proto.data; - -message Sensor -{ - required enums.SensorType.Enum type = 1; -} diff --git a/aasdk_proto/SensorEventIndicationMessage.proto b/aasdk_proto/SensorEventIndicationMessage.proto deleted file mode 100644 index 7fc16bfe..00000000 --- a/aasdk_proto/SensorEventIndicationMessage.proto +++ /dev/null @@ -1,64 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "GPSLocationData.proto"; -import "CompassData.proto"; -import "SpeedData.proto"; -import "RPMData.proto"; -import "OdometerData.proto"; -import "FuelLevelData.proto"; -import "ParkingBrakeData.proto"; -import "GearData.proto"; -import "DiagnosticsData.proto"; -import "NightModeData.proto"; -import "EnvironmentData.proto"; -import "HVACData.proto"; -import "DrivingStatusData.proto"; -import "SteeringWheelData.proto"; -import "PassengerData.proto"; -import "DoorData.proto"; -import "LightData.proto"; -import "AccelData.proto"; -import "GyroData.proto"; - -package aasdk.proto.messages; - -message SensorEventIndication -{ - repeated data.GPSLocation gps_location = 1; - repeated data.Compass compass = 2; - repeated data.Speed speed = 3; - repeated data.RPM rpm = 4; - repeated data.Odometer odometer = 5; - repeated data.FuelLevel fuel_level = 6; - repeated data.ParkingBrake parking_brake = 7; - repeated data.Gear gear = 8; - repeated data.Diagnostics diagnostics = 9; - repeated data.NightMode night_mode = 10; - repeated data.Environment enviorment = 11; - repeated data.HVAC hvac = 12; - repeated data.DrivingStatus driving_status = 13; - repeated data.SteeringWheel steering_wheel = 14; - repeated data.Passenger passenger = 15; - repeated data.Door door = 16; - repeated data.Light light = 17; - repeated data.Accel accel = 19; - repeated data.Gyro gyro = 20; -} diff --git a/aasdk_proto/SensorStartRequestMessage.proto b/aasdk_proto/SensorStartRequestMessage.proto deleted file mode 100644 index d1181ff1..00000000 --- a/aasdk_proto/SensorStartRequestMessage.proto +++ /dev/null @@ -1,29 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "SensorTypeEnum.proto"; - -package aasdk.proto.messages; - -message SensorStartRequestMessage -{ - required enums.SensorType.Enum sensor_type = 1; - required int64 refresh_interval = 2; -} diff --git a/aasdk_proto/SensorStartResponseMessage.proto b/aasdk_proto/SensorStartResponseMessage.proto deleted file mode 100644 index e841892d..00000000 --- a/aasdk_proto/SensorStartResponseMessage.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "StatusEnum.proto"; - -package aasdk.proto.messages; - -message SensorStartResponseMessage -{ - required enums.Status.Enum status = 1; -} diff --git a/aasdk_proto/SensorTypeEnum.proto b/aasdk_proto/SensorTypeEnum.proto deleted file mode 100644 index 93bc27e0..00000000 --- a/aasdk_proto/SensorTypeEnum.proto +++ /dev/null @@ -1,50 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message SensorType -{ - enum Enum - { - NONE = 0; - LOCATION = 1; - COMPASS = 2; - CAR_SPEED = 3; - RPM = 4; - ODOMETER = 5; - FUEL_LEVEL = 6; - PARKING_BRAKE = 7; - GEAR = 8; - DIAGNOSTICS = 9; - NIGHT_DATA = 10; - ENVIRONMENT = 11; - HVAC = 12; - DRIVING_STATUS = 13; - DEAD_RECONING = 14; - PASSENGER = 15; - DOOR = 16; - LIGHT = 17; - TIRE = 18; - ACCEL = 19; - GYRO = 20; - GPS = 21; - } -} diff --git a/aasdk_proto/ServiceDiscoveryRequestMessage.proto b/aasdk_proto/ServiceDiscoveryRequestMessage.proto deleted file mode 100644 index 6fde863e..00000000 --- a/aasdk_proto/ServiceDiscoveryRequestMessage.proto +++ /dev/null @@ -1,27 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message ServiceDiscoveryRequest -{ - required string device_name = 4; - required string device_brand = 5; -} diff --git a/aasdk_proto/ServiceDiscoveryResponseMessage.proto b/aasdk_proto/ServiceDiscoveryResponseMessage.proto deleted file mode 100644 index a5d76895..00000000 --- a/aasdk_proto/ServiceDiscoveryResponseMessage.proto +++ /dev/null @@ -1,39 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "ChannelDescriptorData.proto"; - -package aasdk.proto.messages; - -message ServiceDiscoveryResponse -{ - repeated data.ChannelDescriptor channels = 1; - required string head_unit_name = 2; - required string car_model = 3; - required string car_year = 4; - required string car_serial = 5; - required bool left_hand_drive_vehicle = 6; - required string headunit_manufacturer = 7; - required string headunit_model = 8; - required string sw_build = 9; - required string sw_version = 10; - required bool can_play_native_media_during_vr = 11; - optional bool hide_clock = 12; -} diff --git a/aasdk_proto/ShutdownReasonEnum.proto b/aasdk_proto/ShutdownReasonEnum.proto deleted file mode 100644 index 08be4853..00000000 --- a/aasdk_proto/ShutdownReasonEnum.proto +++ /dev/null @@ -1,30 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message ShutdownReason -{ - enum Enum - { - NONE = 0; - QUIT = 1; - } -} diff --git a/aasdk_proto/ShutdownRequestMessage.proto b/aasdk_proto/ShutdownRequestMessage.proto deleted file mode 100644 index 595e3031..00000000 --- a/aasdk_proto/ShutdownRequestMessage.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "ShutdownReasonEnum.proto"; - -package aasdk.proto.messages; - -message ShutdownRequest -{ - required enums.ShutdownReason.Enum reason = 1; -} diff --git a/aasdk_proto/ShutdownResponseMessage.proto b/aasdk_proto/ShutdownResponseMessage.proto deleted file mode 100644 index 240f9807..00000000 --- a/aasdk_proto/ShutdownResponseMessage.proto +++ /dev/null @@ -1,25 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.messages; - -message ShutdownResponse -{ -} diff --git a/aasdk_proto/SpeedData.proto b/aasdk_proto/SpeedData.proto deleted file mode 100644 index 2bb4439e..00000000 --- a/aasdk_proto/SpeedData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message Speed -{ - required int32 speed = 1; - optional bool cruise_engaged = 2; - optional bool cruise_set_speed = 3; -} diff --git a/aasdk_proto/StatusEnum.proto b/aasdk_proto/StatusEnum.proto deleted file mode 100644 index 0d8f9403..00000000 --- a/aasdk_proto/StatusEnum.proto +++ /dev/null @@ -1,31 +0,0 @@ - -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message Status -{ - enum Enum - { - OK = 0; - FAIL = 1; - } -} diff --git a/aasdk_proto/SteeringWheelData.proto b/aasdk_proto/SteeringWheelData.proto deleted file mode 100644 index e94078e6..00000000 --- a/aasdk_proto/SteeringWheelData.proto +++ /dev/null @@ -1,27 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message SteeringWheel -{ - required int32 steering_angle = 1; - required int32 wheel_speed = 2; -} diff --git a/aasdk_proto/TouchActionEnum.proto b/aasdk_proto/TouchActionEnum.proto deleted file mode 100644 index ef14ccc2..00000000 --- a/aasdk_proto/TouchActionEnum.proto +++ /dev/null @@ -1,33 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message TouchAction -{ - enum Enum - { - PRESS = 0; - RELEASE = 1; - DRAG = 2; - POINTER_DOWN = 5; - POINTER_UP = 6; - } -} diff --git a/aasdk_proto/TouchConfigData.proto b/aasdk_proto/TouchConfigData.proto deleted file mode 100644 index 9944dde6..00000000 --- a/aasdk_proto/TouchConfigData.proto +++ /dev/null @@ -1,27 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message TouchConfig -{ - required uint32 width = 1; - required uint32 height = 2; -} diff --git a/aasdk_proto/TouchEventData.proto b/aasdk_proto/TouchEventData.proto deleted file mode 100644 index 78b27a0d..00000000 --- a/aasdk_proto/TouchEventData.proto +++ /dev/null @@ -1,31 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "TouchLocationData.proto"; -import "TouchActionEnum.proto"; - -package aasdk.proto.data; - -message TouchEvent -{ - repeated data.TouchLocation touch_location = 1; - optional uint32 action_index = 2; - required enums.TouchAction.Enum touch_action = 3; -} diff --git a/aasdk_proto/TouchLocationData.proto b/aasdk_proto/TouchLocationData.proto deleted file mode 100644 index 51b46113..00000000 --- a/aasdk_proto/TouchLocationData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message TouchLocation -{ - required uint32 x = 1; - required uint32 y = 2; - required uint32 pointer_id = 3; -} diff --git a/aasdk_proto/VendorExtensionChannelData.proto b/aasdk_proto/VendorExtensionChannelData.proto deleted file mode 100644 index 61c8c145..00000000 --- a/aasdk_proto/VendorExtensionChannelData.proto +++ /dev/null @@ -1,28 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.data; - -message VendorExtensionChannel -{ - required string name = 1; - repeated string package_white_list = 2; - optional bytes data = 3; -} diff --git a/aasdk_proto/VersionResponseStatusEnum.proto b/aasdk_proto/VersionResponseStatusEnum.proto deleted file mode 100644 index fb4540c2..00000000 --- a/aasdk_proto/VersionResponseStatusEnum.proto +++ /dev/null @@ -1,30 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message VersionResponseStatus -{ - enum Enum - { - MATCH = 0; - MISMATCH = 0xFFFF; - } -} diff --git a/aasdk_proto/VideoConfigData.proto b/aasdk_proto/VideoConfigData.proto deleted file mode 100644 index c951fdaa..00000000 --- a/aasdk_proto/VideoConfigData.proto +++ /dev/null @@ -1,34 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "VideoResolutionEnum.proto"; -import "VideoFPSEnum.proto"; - -package aasdk.proto.data; - -message VideoConfig -{ - required enums.VideoResolution.Enum video_resolution = 1; - required enums.VideoFPS.Enum video_fps = 2; - required uint32 margin_width = 3; - required uint32 margin_height = 4; - required uint32 dpi = 5; - optional uint32 additional_depth = 6; -} diff --git a/aasdk_proto/VideoFPSEnum.proto b/aasdk_proto/VideoFPSEnum.proto deleted file mode 100644 index 4ca91de6..00000000 --- a/aasdk_proto/VideoFPSEnum.proto +++ /dev/null @@ -1,31 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message VideoFPS -{ - enum Enum - { - NONE = 0; - _30 = 1; - _60 = 2; - } -} diff --git a/aasdk_proto/VideoFocusIndicationMessage.proto b/aasdk_proto/VideoFocusIndicationMessage.proto deleted file mode 100644 index 01314bc0..00000000 --- a/aasdk_proto/VideoFocusIndicationMessage.proto +++ /dev/null @@ -1,29 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "VideoFocusModeEnum.proto"; - -package aasdk.proto.messages; - -message VideoFocusIndication -{ - required enums.VideoFocusMode.Enum focus_mode = 1; - required bool unrequested = 2; -} diff --git a/aasdk_proto/VideoFocusModeEnum.proto b/aasdk_proto/VideoFocusModeEnum.proto deleted file mode 100644 index b72e4e71..00000000 --- a/aasdk_proto/VideoFocusModeEnum.proto +++ /dev/null @@ -1,31 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message VideoFocusMode -{ - enum Enum - { - NONE = 0; - FOCUSED = 1; - UNFOCUSED = 2; - } -} diff --git a/aasdk_proto/VideoFocusReasonEnum.proto b/aasdk_proto/VideoFocusReasonEnum.proto deleted file mode 100644 index 36d84b00..00000000 --- a/aasdk_proto/VideoFocusReasonEnum.proto +++ /dev/null @@ -1,31 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message VideoFocusReason -{ - enum Enum - { - NONE = 0; - UNK_1 = 1; - UNK_2 = 2; - } -} diff --git a/aasdk_proto/VideoFocusRequestMessage.proto b/aasdk_proto/VideoFocusRequestMessage.proto deleted file mode 100644 index a8b1bc69..00000000 --- a/aasdk_proto/VideoFocusRequestMessage.proto +++ /dev/null @@ -1,31 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -import "VideoFocusModeEnum.proto"; -import "VideoFocusReasonEnum.proto"; - -package aasdk.proto.messages; - -message VideoFocusRequest -{ - optional int32 disp_index = 1; - required enums.VideoFocusMode.Enum focus_mode = 2; - required enums.VideoFocusReason.Enum focus_reason = 3; -} diff --git a/aasdk_proto/VideoResolutionEnum.proto b/aasdk_proto/VideoResolutionEnum.proto deleted file mode 100644 index 061393b1..00000000 --- a/aasdk_proto/VideoResolutionEnum.proto +++ /dev/null @@ -1,36 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -package aasdk.proto.enums; - -message VideoResolution -{ - enum Enum - { - NONE = 0; - _480p = 1; - _720p = 2; - _1080p = 3; - _1440p = 4; - _720p_p = 5; - _1080pp = 6; - _108s0p_p = 7; - } -} diff --git a/aasdk_proto/VoiceSessionRequestMessage.proto b/aasdk_proto/VoiceSessionRequestMessage.proto deleted file mode 100644 index c358fa58..00000000 --- a/aasdk_proto/VoiceSessionRequestMessage.proto +++ /dev/null @@ -1,8 +0,0 @@ -syntax="proto3"; - -package aasdk.proto.messages; - -message VoiceSessionRequest -{ - uint32 type = 1; // 1 = start, 2 = stop -} \ No newline at end of file diff --git a/aasdk_proto/WifiChannelData.proto b/aasdk_proto/WifiChannelData.proto deleted file mode 100644 index 5036d33c..00000000 --- a/aasdk_proto/WifiChannelData.proto +++ /dev/null @@ -1,30 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -syntax="proto2"; - -option optimize_for=SPEED; - - - -package aasdk.proto.data; - -message WifiChannel -{ - required string ssid = 1; -} diff --git a/cmake_modules/Findaap_protobuf.cmake b/cmake_modules/Findaap_protobuf.cmake new file mode 100644 index 00000000..7e2eda82 --- /dev/null +++ b/cmake_modules/Findaap_protobuf.cmake @@ -0,0 +1,55 @@ +if (AAP_PROTOBUF_LIB_DIRS AND AAP_PROTOBUF_INCLUDE_DIRS) + # in cache already + message(STATUS "aap_protobuf is cached") + set(AAP_PROTOBUF_FOUND TRUE) +else (AAP_PROTOBUF_LIB_DIRS AND AAP_PROTOBUF_INCLUDE_DIRS) + find_path(AAP_PROTOBUF_INCLUDE_DIR + NAMES + channel/control/GalConstants.pb.h + PATHS + /usr/include + /usr/local/include + /opt/local/include + /sw/include + PATH_SUFFIXES + aap_protobuf + ) + + find_library(AAP_PROTOBUF_LIB_DIR + NAMES + aap_protobuf libaap_protobuf + PATHS + /usr/lib + /usr/local/lib + /opt/local/lib + /sw/lib + ) + + set(AAP_PROTOBUF_INCLUDE_DIRS + ${AAP_PROTOBUF_INCLUDE_DIR} + ) + set(AAP_PROTOBUF_LIB_DIRS + ${AAP_PROTOBUF_LIB_DIR} + ) + + if (AAP_PROTOBUF_INCLUDE_DIRS AND AAP_PROTOBUF_LIB_DIRS) + set(AAP_PROTOBUF_FOUND TRUE) + endif (AAP_PROTOBUF_INCLUDE_DIRS AND AAP_PROTOBUF_LIB_DIRS) + + if (AAP_PROTOBUF_FOUND) + message(STATUS "SUCCESS. Found: aap_protobuf:") + message(STATUS " - Includes: ${AAP_PROTOBUF_INCLUDE_DIRS}") + message(STATUS " - Libraries: ${AAP_PROTOBUF_LIB_DIRS}") + add_library(aap_protobuf INTERFACE) + target_include_directories(aap_protobuf SYSTEM INTERFACE ${AAP_PROTOBUF_INCLUDE_DIR}) + target_link_libraries(aap_protobuf INTERFACE ${AAP_PROTOBUF_LIB_DIR}) + else (AAP_PROTOBUF_FOUND) + message(STATUS " - Includes: ${AAP_PROTOBUF_INCLUDE_DIRS}") + message(STATUS " - Libraries: ${AAP_PROTOBUF_LIB_DIRS}") + message(FATAL_ERROR "Could not locate aap_protobuf") + endif (AAP_PROTOBUF_FOUND) + + # show the AAP_PROTOBUF_INCLUDE_DIRS and AAP_PROTOBUF_LIB_DIRS variables only in the advanced view + mark_as_advanced(AAP_PROTOBUF_INCLUDE_DIRS AAP_PROTOBUF_LIB_DIRS) + +endif (AAP_PROTOBUF_LIB_DIRS AND AAP_PROTOBUF_INCLUDE_DIRS) diff --git a/docs/common.proto b/docs/common.proto new file mode 100644 index 00000000..f0b446de --- /dev/null +++ b/docs/common.proto @@ -0,0 +1,22 @@ +syntax = "proto2"; + +package common; + +option java_outer_classname = "Common"; +option java_package = "com.google.android.projection.proto"; + +message PhoneInfo { + optional string instance_id = 1; + optional string connectivity_lifetime_id = 2; +} + +message HeadUnitInfo { + optional string make = 1; + optional string model = 2; + optional string year = 3; + optional string vehicle_id = 4; + optional string head_unit_make = 5; + optional string head_unit_model = 6; + optional string head_unit_software_build = 7; + optional string head_unit_software_version = 8; +} diff --git a/docs/protos.proto b/docs/protos.proto new file mode 100644 index 00000000..d1eff78a --- /dev/null +++ b/docs/protos.proto @@ -0,0 +1,2104 @@ +syntax = "proto2"; + +import "common.proto"; + +option java_outer_classname = "Protos"; +option java_package = "com.google.android.projection.proto"; + +message VersionRequestOptions { + optional int64 snapshot_version = 1; +} + +message VersionResponseOptions { + optional ConnectionConfiguration connection_configuration = 1; +} + +message AuthResponse { + required int32 status = 1; +} + +message ServiceDiscoveryRequest { + optional bytes small_icon = 1; + optional bytes medium_icon = 2; + optional bytes large_icon = 3; + optional string label_text = 4; + optional string device_name = 5; + optional common.PhoneInfo phone_info = 6; +} + +message ServiceDiscoveryResponse { + repeated Service services = 1; + optional string make = 2 [deprecated = true]; + optional string model = 3 [deprecated = true]; + optional string year = 4 [deprecated = true]; + optional string vehicle_id = 5 [deprecated = true]; + optional DriverPosition driver_position = 6; + optional string head_unit_make = 7 [deprecated = true]; + optional string head_unit_model = 8 [deprecated = true]; + optional string head_unit_software_build = 9 [deprecated = true]; + optional string head_unit_software_version = 10 [deprecated = true]; + optional bool can_play_native_media_during_vr = 11 [deprecated = true]; + optional int32 session_configuration = 13; + optional string display_name = 14; + optional bool probe_for_support = 15; + optional ConnectionConfiguration connection_configuration = 16; + optional common.HeadUnitInfo headunit_info = 17; +} + +message ServiceDiscoveryUpdate { + optional Service service = 1; +} + +message Service { + required int32 id = 1; + optional SensorSourceService sensor_source_service = 2; + optional MediaSinkService media_sink_service = 3; + optional InputSourceService input_source_service = 4; + optional MediaSourceService media_source_service = 5; + optional BluetoothService bluetooth_service = 6; + optional RadioService radio_service = 7; + optional NavigationStatusService navigation_status_service = 8; + optional MediaPlaybackStatusService media_playback_service = 9; + optional PhoneStatusService phone_status_service = 10; + optional MediaBrowserService media_browser_service = 11; + optional VendorExtensionService vendor_extension_service = 12; + optional GenericNotificationService generic_notification_service = 13; + optional WifiProjectionService wifi_projection_service = 14; +} + +message ConnectionConfiguration { + optional PingConfiguration ping_configuration = 1; + optional WirelessTcpConfiguration wireless_tcp_configuration = 2; +} + +message PingConfiguration { + optional uint32 timeout_ms = 1; + optional uint32 interval_ms = 2; + optional uint32 high_latency_threshold_ms = 3; + optional uint32 tracked_ping_count = 4; +} + +message WirelessTcpConfiguration { + optional uint32 socket_receive_buffer_size_kb = 1; + optional uint32 socket_send_buffer_size_kb = 2; + optional uint32 socket_read_timeout_ms = 3; +} + +message SensorSourceService { + repeated Sensor sensors = 1; + message Sensor { + required SensorType sensor_type = 1; + } + + optional uint32 location_characterization = 2; + repeated FuelType supported_fuel_types = 3; + repeated EvConnectorType supported_ev_connector_types = 4; +} + +message MediaSinkService { + optional MediaCodecType available_type = 1 [default = MEDIA_CODEC_AUDIO_PCM]; + optional AudioStreamType audio_type = 2; + repeated AudioConfiguration audio_configs = 3; + repeated VideoConfiguration video_configs = 4; + optional bool available_while_in_call = 5; + optional uint32 display_id = 6; + optional DisplayType display_type = 7; + optional KeyCode initial_content_keycode = 8; +} + +message VideoConfiguration { + optional VideoCodecResolutionType codec_resolution = 1; + optional VideoFrameRateType frame_rate = 2; + optional uint32 width_margin = 3; + optional uint32 height_margin = 4; + optional uint32 density = 5; + optional uint32 decoder_additional_depth = 6; + optional uint32 viewing_distance = 7; + optional uint32 pixel_aspect_ratio_e4 = 8; + optional uint32 real_density = 9; + optional MediaCodecType video_codec_type = 10; + optional UiConfig ui_config = 11; +} + +message UiConfig { + optional Insets margins = 1; + optional Insets content_insets = 2; + optional Insets stable_content_insets = 3; + optional UiTheme ui_theme = 4; +} + +message Insets { + optional uint32 top = 1; + optional uint32 bottom = 2; + optional uint32 left = 3; + optional uint32 right = 4; +} + +message MediaSourceService { + optional MediaCodecType available_type = 1 [default = MEDIA_CODEC_AUDIO_PCM]; + optional AudioConfiguration audio_config = 2; + optional bool available_while_in_call = 3; +} + +message AudioConfiguration { + required uint32 sampling_rate = 1; + required uint32 number_of_bits = 2; + required uint32 number_of_channels = 3; +} + +message InputSourceService { + repeated int32 keycodes_supported = 1 [packed = true]; + + repeated TouchScreen touchscreen = 2; + message TouchScreen { + required int32 width = 1; + required int32 height = 2; + optional TouchScreenType type = 3; + optional bool is_secondary = 4; + } + + repeated TouchPad touchpad = 3; + message TouchPad { + required int32 width = 1; + required int32 height = 2; + optional bool ui_navigation = 3; + optional int32 physical_width = 4; + optional int32 physical_height = 5; + optional bool ui_absolute = 6; + optional bool tap_as_select = 7; + optional int32 sensitivity = 8; + } + + repeated FeedbackEvent feedback_events_supported = 4; + optional uint32 display_id = 5; +} + +message BluetoothService { + required string car_address = 1; + repeated BluetoothPairingMethod supported_pairing_methods = 2 [packed = true]; +} + +message RadioService { + repeated RadioProperties radio_properties = 1; +} + +message RadioProperties { + required int32 radio_id = 1; + required RadioType type = 2; + repeated Range channel_range = 3; + repeated int32 channel_spacings = 4; + required int32 channel_spacing = 5; + optional bool background_tuner = 6; + optional ItuRegion region = 7; + optional RdsType rds = 8; + optional bool af_switch = 9; + optional bool ta = 10; + optional TrafficServiceType traffic_service = 11; + optional bool audio_loopback = 12; + optional bool mute_capability = 13; + optional int32 station_presets_access = 14; +} + +message Range { + required int32 min = 1; + required int32 max = 2; +} + +message NavigationStatusService { + required int32 minimum_interval_ms = 1; + + required InstrumentClusterType type = 2; + enum InstrumentClusterType { + IMAGE = 1; + ENUM = 2; + } + + optional ImageOptions image_options = 3; + message ImageOptions { + required int32 height = 1; + required int32 width = 2; + required int32 colour_depth_bits = 3; + } +} + +message MediaPlaybackStatusService { + +} + +message PhoneStatusService { + +} + +message MediaBrowserService { + +} + +message VendorExtensionService { + required string service_name = 1; + repeated string package_white_list = 2; + optional bytes data = 3; +} + +message GenericNotificationService { + +} + +message ChannelOpenRequest { + required sint32 priority = 1; + required int32 service_id = 2; +} + +message ChannelOpenResponse { + required MessageStatus status = 1; +} + +message ChannelCloseNotification { + +} + +message NavFocusRequestNotification { + optional NavFocusType focus_type = 1; +} + +message NavFocusNotification { + required NavFocusType focus_type = 1; +} + +message PingRequest { + required int64 timestamp = 1; + optional bool bug_report = 2; + optional bytes data = 3; +} + +message PingResponse { + required int64 timestamp = 1; + optional bytes data = 2; +} + +message ByeByeRequest { + required ByeByeReason reason = 1; +} + +message ByeByeResponse { + +} + +message VoiceSessionNotification { + optional VoiceSessionStatus status = 1; +} + +message CarConnectedDevicesRequest { + +} + +message CarConnectedDevices { + repeated ConnectedDevice connected_devices = 1; + optional bool unsolicited = 2; + optional bool final_list = 3 [default = true]; +} + +message ConnectedDevice { + optional string device_name = 1; + optional int32 device_id = 2; +} + +message UserSwitchRequest { + optional ConnectedDevice selected_device = 1; +} + +message UserSwitchResponse { + optional UserSwitchStatus status = 1; + optional ConnectedDevice selected_device = 2; +} + +message BatteryStatusNotification { + required uint32 battery_level = 1; + optional uint32 time_remaining_s = 2; + optional bool critical_battery = 3; +} + +message CallAvailabilityStatus { + optional bool call_available = 1; +} + +message SensorRequest { + required SensorType type = 1; + required int64 min_update_period = 2; +} + +message SensorResponse { + required MessageStatus status = 1; +} + +message SensorBatch { + repeated LocationData location_data = 1; + repeated CompassData compass_data = 2; + repeated SpeedData speed_data = 3; + repeated RpmData rpm_data = 4; + repeated OdometerData odometer_data = 5; + repeated FuelData fuel_data = 6; + repeated ParkingBrakeData parking_brake_data = 7; + repeated GearData gear_data = 8; + repeated DiagnosticsData diagnostics_data = 9; + repeated NightModeData night_mode_data = 10; + repeated EnvironmentData environment_data = 11; + repeated HvacData hvac_data = 12; + repeated DrivingStatusData driving_status_data = 13; + repeated DeadReckoningData dead_reckoning_data = 14; + repeated PassengerData passenger_data = 15; + repeated DoorData door_data = 16; + repeated LightData light_data = 17; + repeated TirePressureData tire_pressure_data = 18; + repeated AccelerometerData accelerometer_data = 19; + repeated GyroscopeData gyroscope_data = 20; + repeated GpsSatelliteData gps_satellite_data = 21; + repeated TollCardData toll_card_data = 22; +} + +message SensorError { + required SensorType sensor_type = 1; + required SensorErrorType sensor_error_type = 2; +} + +message LocationData { + optional uint64 timestamp = 1 [deprecated = true]; + required int32 latitude_e7 = 2; + required int32 longitude_e7 = 3; + optional uint32 accuracy_e3 = 4; + optional int32 altitude_e2 = 5; + optional int32 speed_e3 = 6; + optional int32 bearing_e6 = 7; +} + +message CompassData { + required int32 bearing_e6 = 1; + optional int32 pitch_e6 = 2; + optional int32 roll_e6 = 3; +} + +message SpeedData { + required int32 speed_e3 = 1; + optional bool cruise_engaged = 2; + optional int32 cruise_set_speed = 4; +} + +message RpmData { + required int32 rpm_e3 = 1; +} + +message OdometerData { + required int32 kms_e1 = 1; + optional int32 trip_kms_e1 = 2; +} + +message FuelData { + optional int32 fuel_level = 1; + optional int32 range = 2; + optional bool low_fuel_warning = 3; +} + +message ParkingBrakeData { + required bool parking_brake = 1; +} + +message GearData { + required Gear gear = 1; +} + +message DiagnosticsData { + optional bytes dtc = 1; +} + +message NightModeData { + optional bool night_mode = 1; +} + +message EnvironmentData { + optional int32 temperature_e3 = 1; + optional int32 pressure_e3 = 2; + optional int32 rain = 3; +} + +message HvacData { + optional int32 target_temperature_e3 = 1; + optional int32 current_temperature_e3 = 2; +} + +message DrivingStatusData { + required int32 status = 1; +} + +message DeadReckoningData { + optional int32 steering_angle_e1 = 1; + repeated int32 wheel_speed_e3 = 2; +} + +message LightData { + optional HeadLightState head_light_state = 1; + optional TurnIndicatorState turn_indicator_state = 2; + optional bool hazard_lights_on = 3; +} + +message PassengerData { + optional bool passenger_present = 1; +} + +message DoorData { + optional bool hood_open = 1; + optional bool trunk_open = 2; + repeated bool door_open = 3; +} + +message TirePressureData { + repeated int32 tire_pressures_e2 = 1; +} + +message AccelerometerData { + optional int32 acceleration_x_e3 = 1; + optional int32 acceleration_y_e3 = 2; + optional int32 acceleration_z_e3 = 3; +} + +message GyroscopeData { + optional int32 rotation_speed_x_e3 = 1; + optional int32 rotation_speed_y_e3 = 2; + optional int32 rotation_speed_z_e3 = 3; +} + +message GpsSatellite { + required int32 prn = 1; + required int32 snr_e3 = 2; + required bool used_in_fix = 3; + optional int32 azimuth_e3 = 4; + optional int32 elevation_e3 = 5; +} + +message GpsSatelliteData { + required int32 number_in_use = 1; + optional int32 number_in_view = 2; + repeated GpsSatellite satellites = 3; +} + +message TollCardData { + required bool is_card_present = 1; +} + +message Setup { + required MediaCodecType type = 1; +} + +message Start { + required int32 session_id = 1; + required uint32 configuration_index = 2; +} + +message Stop { + +} + +message Config { + required Status status = 1; + enum Status { + STATUS_WAIT = 1; + STATUS_READY = 2; + } + + optional uint32 max_unacked = 2; + repeated uint32 configuration_indices = 3; +} + +message Ack { + required int32 session_id = 1; + optional uint32 ack = 2; + repeated uint64 receive_timestamp_ns = 3; +} + +message AudioUnderflowNotification { + required int32 session_id = 1; +} + +message VideoFocusRequestNotification { + optional int32 disp_channel_id = 1 [deprecated = true]; + optional VideoFocusMode mode = 2; + optional VideoFocusReason reason = 3; +} + +message VideoFocusNotification { + optional VideoFocusMode focus = 1; + optional bool unsolicited = 2; +} + +message UpdateUiConfigRequest { + optional UiConfig ui_config = 1; +} + +message UpdateUiConfigReply { + optional UiConfig ui_config = 1; +} + +message AudioFocusRequestNotification { + required AudioFocusRequestType request = 1; +} + +message AudioFocusNotification { + required AudioFocusStateType focus_state = 1; + optional bool unsolicited = 2; +} + +message MicrophoneRequest { + required bool open = 1; + optional bool anc_enabled = 2; + optional bool ec_enabled = 3; + optional int32 max_unacked = 4; +} + +message MicrophoneResponse { + required int32 status = 1; + optional int32 session_id = 2; +} + +message KeyBindingRequest { + repeated int32 keycodes = 1 [packed = true]; +} + +message KeyBindingResponse { + required int32 status = 1; +} + +message InputReport { + required uint64 timestamp = 1; + optional int32 disp_channel_id = 2 [deprecated = true]; + optional TouchEvent touch_event = 3; + optional KeyEvent key_event = 4; + optional AbsoluteEvent absolute_event = 5; + optional RelativeEvent relative_event = 6; + optional TouchEvent touchpad_event = 7; +} + +message KeyEvent { + repeated Key keys = 1; + message Key { + required uint32 keycode = 1; + required bool down = 2; + required uint32 metastate = 3; + optional bool longpress = 4; + } +} + +message TouchEvent { + repeated Pointer pointer_data = 1; + message Pointer { + required uint32 x = 1; + required uint32 y = 2; + required uint32 pointer_id = 3; + } + + optional uint32 action_index = 2; + optional PointerAction action = 3; +} + +message AbsoluteEvent { + repeated Abs data = 1; + message Abs { + required uint32 keycode = 1; + required int32 value = 2; + } +} + +message RelativeEvent { + repeated Rel data = 1; + message Rel { + required uint32 keycode = 1; + required int32 delta = 2; + } +} + +message InputFeedback { + optional FeedbackEvent event = 1; +} + +message BluetoothPairingRequest { + required string phone_address = 1; + required BluetoothPairingMethod pairing_method = 2; +} + +message BluetoothPairingResponse { + required MessageStatus status = 1; + required bool already_paired = 2; +} + +message BluetoothAuthenticationData { + required string auth_data = 1; + optional BluetoothPairingMethod pairing_method = 2; +} + +message BluetoothAuthenticationResult { + required MessageStatus status = 1; +} + +message WifiProjectionService { + optional string car_wifi_bssid = 1; +} + +message WifiCredentialsRequest { + +} + +message WifiCredentialsResponse { + optional string car_wifi_password = 1; + optional WifiSecurityMode car_wifi_security_mode = 2; + optional string car_wifi_ssid = 3; + repeated int32 supported_wifi_channels = 4; + optional AccessPointType access_point_type = 5; +} + +message RadioStateNotification { + required bool radio_source_enabled = 1; + optional bool radio_muted = 2; + required int32 active_radio_id = 3; + required RadioStationInfo station_info = 4; + repeated RadioStationInfo program_list = 5; + repeated StationPresetList station_preset_lists = 6; +} + +message RadioSourceRequest { + +} + +message RadioSourceResponse { + optional MessageStatus status = 1; + required bool radio_source_enabled = 2; +} + +message SelectActiveRadioRequest { + required int32 radio_id = 1; +} + +message ActiveRadioNotification { + optional MessageStatus status = 1; + required int32 radio_id = 2; + optional RadioStationInfo station_info = 3; +} + +message StepChannelRequest { + required int32 radio_id = 1; + required bool up = 2; + required bool skip_sub_channel = 3; +} + +message StepChannelResponse { + optional MessageStatus status = 1; + required int32 radio_id = 2; +} + +message SeekStationRequest { + required int32 radio_id = 1; + required bool up = 2; + required bool skip_sub_channel = 3; +} + +message SeekStationResponse { + optional MessageStatus status = 1; + required int32 radio_id = 2; +} + +message ScanStationsRequest { + required int32 radio_id = 1; + required bool start = 2; + required bool up = 3; + required bool skip_sub_channel = 4; +} + +message ScanStationsResponse { + optional MessageStatus status = 1; + required int32 radio_id = 2; + optional bool started = 3; +} + +message TuneToStationRequest { + required int32 radio_id = 1; + required int32 channel = 2; + optional int32 sub_channel = 3; +} + +message TuneToStationResponse { + required MessageStatus status = 1; + required int32 radio_id = 2; +} + +message RadioStationInfoNotification { + required int32 radio_id = 1; + required RadioStationInfo station_info = 2; +} + +message RadioStationInfo { + required RadioType type = 1; + required int32 channel = 2; + optional int32 sub_channel = 3; + optional RadioStationMetaData meta_data = 4; +} + +message RadioStationMetaData { + optional int32 audio_channels = 1; + optional int32 signal_quality = 2; + optional RdsData rds = 3; + optional HdRadioStationInfo hd_station_info = 4; +} + +message RdsData { + repeated int32 alternative_frequencies = 1; + optional int32 program_id = 2; + optional int32 music_speech_switch = 3; + optional string program_service_name = 4; + optional int32 program_type = 5; + optional string program_type_name = 6; + optional string radio_text = 7; + optional bool traffic_program_flag = 8; + optional bool traffic_announcement_flag = 9; +} + +message HdRadioStationInfo { + optional HdAcquisionState acquisition_state = 1; + optional int32 digital_signal_strength = 2; + optional HdRadioPsdData psd = 3; + optional HdRadioSisData sis = 4; +} + +message HdRadioPsdData { + optional string title = 1; + optional string artist = 2; + optional string album = 3; + optional string genre = 4; + optional HdRadioComment comment = 5; + optional HdRadioCommercial commercial = 6; + optional HdRadioArtistExperience artist_experience = 7; +} + +message HdRadioComment { + optional string description = 1; + optional string text = 2; +} + +message HdRadioCommercial { + optional int32 encoding = 1; + optional string price = 2; + optional string valid = 3; + optional string url = 4; + optional int32 received = 5; + optional string seller = 6; + optional string description = 7; +} + +message HdRadioArtistExperience { + optional bytes image = 1; +} + +message HdRadioSisData { + optional int32 station_id = 1; + optional string station_name_short = 2; + optional string station_name_long = 3; + optional Location station_location = 4; + optional string station_message = 5; + optional string service_info_message = 6; + optional string universal_short_station_name_slogan = 7; +} + +message Location { + required double longitude = 1; + required double latitude = 2; +} + +message GetProgramListRequest { + required int32 radio_id = 1; +} + +message GetProgramListResponse { + required MessageStatus status = 1; + required int32 radio_id = 2; + required bool completed = 3; + repeated RadioStationInfo program_list = 4; +} + +message CancelRadioOperationsRequest { + required int32 radio_id = 1; +} + +message CancelRadioOperationsResponse { + required MessageStatus status = 1; + required int32 radio_id = 2; +} + +message ConfigureChannelSpacingRequest { + required int32 radio_id = 1; + required int32 channel_spacing = 2; +} + +message ConfigureChannelSpacingResponse { + required MessageStatus status = 1; + required int32 radio_id = 2; + required int32 channel_spacing = 3; +} + +message StationPresetsNotification { + repeated StationPresetList preset_lists = 2; +} + +message StationPresetList { + optional string name = 1; + repeated int32 restricted_station_types = 2; + repeated StationPreset presets = 3; +} + +message StationPreset { + required RadioType type = 1; + required int32 channel = 2; + optional int32 sub_channel = 3; +} + +message GetTrafficUpdateRequest { + required int32 radio_id = 1; +} + +message GetTrafficUpdateResponse { + required MessageStatus status = 1; + required int32 radio_id = 2; + repeated TrafficIncident incidents = 3; +} + +message TrafficIncident { + required int32 event_code = 1; + required Location location = 2; + required int32 expected_incident_duration = 3; +} + +message MuteRadioRequest { + optional int32 radio_id = 1; + required bool mute = 2; +} + +message MuteRadioResponse { + optional MessageStatus status = 1; + optional int32 radio_id = 2; + optional bool muted = 3; +} + +message NavigationStatusStart { + +} + +message NavigationStatusStop { + +} + +message NavigationStatus { + required NavigationStatusEnum status = 1; + enum NavigationStatusEnum { + UNAVAILABLE = 0; + ACTIVE = 1; + INACTIVE = 2; + REROUTING = 3; + } +} + +message NavigationNextTurnEvent { + option deprecated = true; + required string road = 1; + + optional TurnSide turn_side = 2; + enum TurnSide { + LEFT = 1; + RIGHT = 2; + UNSPECIFIED = 3; + } + + optional NextTurnEnum event = 3; + enum NextTurnEnum { + UNKNOWN = 0; + DEPART = 1; + NAME_CHANGE = 2; + SLIGHT_TURN = 3; + TURN = 4; + SHARP_TURN = 5; + U_TURN = 6; + ON_RAMP = 7; + OFF_RAMP = 8; + FORK = 9; + MERGE = 10; + ROUNDABOUT_ENTER = 11; + ROUNDABOUT_EXIT = 12; + ROUNDABOUT_ENTER_AND_EXIT = 13; + STRAIGHT = 14; + FERRY_BOAT = 16; + FERRY_TRAIN = 17; + DESTINATION = 19; + } + + optional bytes image = 4; + optional int32 turn_number = 5; + optional int32 turn_angle = 6; +} + +message NavigationNextTurnDistanceEvent { + option deprecated = true; + required int32 distance_meters = 1; + required int32 time_to_turn_seconds = 2; + optional int32 display_distance_e3 = 3; + + optional DistanceUnits display_distance_unit = 4; + enum DistanceUnits { + UNKNOWN_DISTANCE_UNIT = 0; + METERS = 1; + KILOMETERS = 2; + KILOMETERS_P1 = 3; + MILES = 4; + MILES_P1 = 5; + FEET = 6; + YARDS = 7; + } +} + +message NavigationState { + repeated NavigationStep steps = 1; + repeated NavigationDestination destinations = 2; +} + +message NavigationStep { + optional NavigationManeuver maneuver = 1; + optional NavigationRoad road = 2; + repeated NavigationLane lanes = 3; + optional NavigationCue cue = 4; +} + +message NavigationManeuver { + optional NavigationType type = 1; + enum NavigationType { + UNKNOWN = 0; + DEPART = 1; + NAME_CHANGE = 2; + KEEP_LEFT = 3; + KEEP_RIGHT = 4; + TURN_SLIGHT_LEFT = 5; + TURN_SLIGHT_RIGHT = 6; + TURN_NORMAL_LEFT = 7; + TURN_NORMAL_RIGHT = 8; + TURN_SHARP_LEFT = 9; + TURN_SHARP_RIGHT = 10; + U_TURN_LEFT = 11; + U_TURN_RIGHT = 12; + ON_RAMP_SLIGHT_LEFT = 13; + ON_RAMP_SLIGHT_RIGHT = 14; + ON_RAMP_NORMAL_LEFT = 15; + ON_RAMP_NORMAL_RIGHT = 16; + ON_RAMP_SHARP_LEFT = 17; + ON_RAMP_SHARP_RIGHT = 18; + ON_RAMP_U_TURN_LEFT = 19; + ON_RAMP_U_TURN_RIGHT = 20; + OFF_RAMP_SLIGHT_LEFT = 21; + OFF_RAMP_SLIGHT_RIGHT = 22; + OFF_RAMP_NORMAL_LEFT = 23; + OFF_RAMP_NORMAL_RIGHT = 24; + FORK_LEFT = 25; + FORK_RIGHT = 26; + MERGE_LEFT = 27; + MERGE_RIGHT = 28; + MERGE_SIDE_UNSPECIFIED = 29; + ROUNDABOUT_ENTER = 30; + ROUNDABOUT_EXIT = 31; + ROUNDABOUT_ENTER_AND_EXIT_CW = 32; + ROUNDABOUT_ENTER_AND_EXIT_CW_WITH_ANGLE = 33; + ROUNDABOUT_ENTER_AND_EXIT_CCW = 34; + ROUNDABOUT_ENTER_AND_EXIT_CCW_WITH_ANGLE = 35; + STRAIGHT = 36; + FERRY_BOAT = 37; + FERRY_TRAIN = 38; + DESTINATION = 39; + DESTINATION_STRAIGHT = 40; + DESTINATION_LEFT = 41; + DESTINATION_RIGHT = 42; + } + + optional int32 roundabout_exit_number = 2; + optional int32 roundabout_exit_angle = 3; +} + +message NavigationCue { + repeated string alternate_text = 1; +} + +message NavigationLane { + repeated LaneDirection lane_directions = 1; + message LaneDirection { + optional Shape shape = 1; + enum Shape { + UNKNOWN = 0; + STRAIGHT = 1; + SLIGHT_LEFT = 2; + SLIGHT_RIGHT = 3; + NORMAL_LEFT = 4; + NORMAL_RIGHT = 5; + SHARP_LEFT = 6; + SHARP_RIGHT = 7; + U_TURN_LEFT = 8; + U_TURN_RIGHT = 9; + } + + optional bool is_highlighted = 2; + } +} + +message NavigationDestination { + optional string address = 1; +} + +message NavigationCurrentPosition { + optional NavigationStepDistance step_distance = 1; + repeated NavigationDestinationDistance destination_distances = 2; + optional NavigationRoad current_road = 3; +} + +message NavigationStepDistance { + optional NavigationDistance distance = 1; + optional int64 time_to_step_seconds = 2; +} + +message NavigationDestinationDistance { + optional NavigationDistance distance = 1; + optional string estimated_time_at_arrival = 2; + optional int64 time_to_arrival_seconds = 3; +} + +message NavigationRoad { + optional string name = 1; +} + +message NavigationDistance { + optional int32 meters = 1; + optional string display_value = 2; + + optional DistanceUnits display_units = 3; + enum DistanceUnits { + UNKNOWN_DISTANCE_UNIT = 0; + METERS = 1; + KILOMETERS = 2; + KILOMETERS_P1 = 3; + MILES = 4; + MILES_P1 = 5; + FEET = 6; + YARDS = 7; + } +} + +message InstrumentClusterInput { + required InstrumentClusterAction action = 1; + enum InstrumentClusterAction { + UNKNOWN = 0; + UP = 1; + DOWN = 2; + LEFT = 3; + RIGHT = 4; + ENTER = 5; + BACK = 6; + CALL = 7; + } +} + +message MediaPlaybackStatus { + optional State state = 1; + enum State { + STOPPED = 1; + PLAYING = 2; + PAUSED = 3; + } + + optional string media_source = 2; + optional uint32 playback_seconds = 3; + optional bool shuffle = 4; + optional bool repeat = 5; + optional bool repeat_one = 6; +} + +message MediaPlaybackMetadata { + optional string song = 1; + optional string artist = 2; + optional string album = 3; + optional bytes album_art = 4; + optional string playlist = 5; + optional uint32 duration_seconds = 6; + optional int32 rating = 7; +} + +message PhoneStatus { + repeated Call calls = 1; + message Call { + required State phone_state = 1; + required uint32 call_duration_seconds = 2; + optional string caller_number = 3; + optional string caller_id = 4; + optional string caller_number_type = 5; + optional bytes caller_thumbnail = 6; + } + + optional uint32 signal_strength = 2; + + enum State { + UNKNOWN = 0; + IN_CALL = 1; + ON_HOLD = 2; + INACTIVE = 3; + INCOMING = 4; + CONFERENCED = 5; + MUTED = 6; + } +} + +message PhoneStatusInput { + required InstrumentClusterInput input = 1; + optional string caller_number = 2; + optional string caller_id = 3; +} + +message MediaRootNode { + required string path = 1; + repeated MediaSource media_sources = 2; +} + +message MediaSource { + required string path = 1; + required string name = 2; + optional bytes album_art = 3; +} + +message MediaSourceNode { + required MediaSource source = 1; + optional int32 start = 2; + optional int32 total = 3; + repeated MediaList lists = 4; +} + +message MediaList { + required string path = 1; + + required Type type = 2; + enum Type { + UNKNOWN = 0; + PLAYLIST = 1; + ALBUM = 2; + ARTIST = 3; + STATION = 4; + GENRE = 5; + } + + optional string name = 3; + optional bytes album_art = 4; +} + +message MediaListNode { + required MediaList list = 1; + optional int32 start = 2; + optional int32 total = 3; + repeated MediaSong songs = 4; +} + +message MediaSong { + required string path = 1; + required string name = 2; + optional string artist = 3; + optional string album = 4; +} + +message MediaSongNode { + required MediaSong song = 1; + optional bytes album_art = 2; + optional uint32 duration_seconds = 3; +} + +message MediaGetNode { + required string path = 1; + optional int32 start = 2; + optional bool get_album_art = 3 [default = true]; +} + +message MediaBrowserInput { + required InstrumentClusterInput input = 1; + required string path = 2; +} + +message GalVerificationSetSensor { + optional SensorBatch sensors = 1; +} + +message GalVerificationMediaSinkStatus { + required int32 channel = 1; + required Config.Status status = 2; +} + +message GalVerificationVideoFocus { + required VideoFocusMode video_focus_mode = 1; + optional bool deny = 2; + optional bool unsolicited = 3; +} + +message GalVerificationAudioFocus { + required AudioFocusStateType audio_focus_state = 1; + required int32 channel = 2; + optional bool unsolicited = 3; +} + +message GalVerificationInjectInput { + required InputReport input = 1; +} + +message GalVerificationBugReportRequest { + +} + +message GalVerificationBugReportResponse { + required string bug_report = 1; +} + +message GalVerificationScreenCaptureRequest { + +} + +message GalVerificationScreenCaptureResponse { + required bytes screen_capture = 1; +} + +message GalVerificationDisplayInformationRequest { + +} + +message GalVerificationDisplayInformationResponse { + required int32 native_width = 1; + required int32 native_height = 2; +} + +message GenericNotificationSubscribe { + +} + +message GenericNotificationUnsubscribe { + +} + +message GenericNotificationMessage { + optional string id = 1; + optional string text = 2; + optional bytes icon = 3; +} + +message GenericNotificationAck { + optional string id = 1; + optional bool handled = 2; +} + +message GoogleDiagnosticsBugReportRequest { + required int32 token = 1; +} + +message GoogleDiagnosticsBugReportResponse { + optional string bug_report = 1; + repeated int32 tokens = 2; +} + +enum ControlMessageType { + MESSAGE_VERSION_REQUEST = 1; + MESSAGE_VERSION_RESPONSE = 2; + MESSAGE_ENCAPSULATED_SSL = 3; + MESSAGE_AUTH_COMPLETE = 4; + MESSAGE_SERVICE_DISCOVERY_REQUEST = 5; + MESSAGE_SERVICE_DISCOVERY_RESPONSE = 6; + MESSAGE_CHANNEL_OPEN_REQUEST = 7; + MESSAGE_CHANNEL_OPEN_RESPONSE = 8; + MESSAGE_CHANNEL_CLOSE_NOTIFICATION = 9; + MESSAGE_PING_REQUEST = 11; + MESSAGE_PING_RESPONSE = 12; + MESSAGE_NAV_FOCUS_REQUEST = 13; + MESSAGE_NAV_FOCUS_NOTIFICATION = 14; + MESSAGE_BYEBYE_REQUEST = 15; + MESSAGE_BYEBYE_RESPONSE = 16; + MESSAGE_VOICE_SESSION_NOTIFICATION = 17; + MESSAGE_AUDIO_FOCUS_REQUEST = 18; + MESSAGE_AUDIO_FOCUS_NOTIFICATION = 19; + MESSAGE_CAR_CONNECTED_DEVICES_REQUEST = 20; + MESSAGE_CAR_CONNECTED_DEVICES_RESPONSE = 21; + MESSAGE_USER_SWITCH_REQUEST = 22; + MESSAGE_BATTERY_STATUS_NOTIFICATION = 23; + MESSAGE_CALL_AVAILABILITY_STATUS = 24; + MESSAGE_USER_SWITCH_RESPONSE = 25; + MESSAGE_SERVICE_DISCOVERY_UPDATE = 26; + MESSAGE_UNEXPECTED_MESSAGE = 255; + MESSAGE_FRAMING_ERROR = 65535; +} + +enum FragInfo { + FRAG_CONTINUATION = 0; + FRAG_FIRST = 1; + FRAG_LAST = 2; + FRAG_UNFRAGMENTED = 3; +} + +enum DriverPosition { + DRIVER_POSITION_LEFT = 0; + DRIVER_POSITION_RIGHT = 1; + DRIVER_POSITION_CENTER = 2; + DRIVER_POSITION_UNKNOWN = 3; +} + +enum SessionConfiguration { + UI_CONFIG_HIDE_CLOCK = 1; + UI_CONFIG_HIDE_PHONE_SIGNAL = 2; + UI_CONFIG_HIDE_BATTERY_LEVEL = 4; + CAN_PLAY_NATIVE_MEDIA_DURING_VR = 8; +} + +enum LocationCharacterization { + PRIOR_LOCATIONS = 1; + GYROSCOPE_FUSION = 2; + ACCELEROMETER_FUSION = 4; + COMPASS_FUSION = 8; + WHEEL_SPEED_FUSION = 16; + STEERING_ANGLE_FUSION = 32; + CAR_SPEED_FUSION = 64; + DEAD_RECKONED = 128; + RAW_GPS_ONLY = 256; +} + +enum SensorType { + SENSOR_LOCATION = 1; + SENSOR_COMPASS = 2; + SENSOR_SPEED = 3; + SENSOR_RPM = 4; + SENSOR_ODOMETER = 5; + SENSOR_FUEL = 6; + SENSOR_PARKING_BRAKE = 7; + SENSOR_GEAR = 8; + SENSOR_OBDII_DIAGNOSTIC_CODE = 9; + SENSOR_NIGHT_MODE = 10; + SENSOR_ENVIRONMENT_DATA = 11; + SENSOR_HVAC_DATA = 12; + SENSOR_DRIVING_STATUS_DATA = 13; + SENSOR_DEAD_RECKONING_DATA = 14; + SENSOR_PASSENGER_DATA = 15; + SENSOR_DOOR_DATA = 16; + SENSOR_LIGHT_DATA = 17; + SENSOR_TIRE_PRESSURE_DATA = 18; + SENSOR_ACCELEROMETER_DATA = 19; + SENSOR_GYROSCOPE_DATA = 20; + SENSOR_GPS_SATELLITE_DATA = 21; + SENSOR_TOLL_CARD = 22; +} + +enum FuelType { + FUEL_TYPE_UNKNOWN = 0; + FUEL_TYPE_UNLEADED = 1; + FUEL_TYPE_LEADED = 2; + FUEL_TYPE_DIESEL_1 = 3; + FUEL_TYPE_DIESEL_2 = 4; + FUEL_TYPE_BIODIESEL = 5; + FUEL_TYPE_E85 = 6; + FUEL_TYPE_LPG = 7; + FUEL_TYPE_CNG = 8; + FUEL_TYPE_LNG = 9; + FUEL_TYPE_ELECTRIC = 10; + FUEL_TYPE_HYDROGEN = 11; + FUEL_TYPE_OTHER = 12; +} + +enum EvConnectorType { + EV_CONNECTOR_TYPE_UNKNOWN = 0; + EV_CONNECTOR_TYPE_J1772 = 1; + EV_CONNECTOR_TYPE_MENNEKES = 2; + EV_CONNECTOR_TYPE_CHADEMO = 3; + EV_CONNECTOR_TYPE_COMBO_1 = 4; + EV_CONNECTOR_TYPE_COMBO_2 = 5; + EV_CONNECTOR_TYPE_TESLA_ROADSTER = 6 [deprecated = true]; + EV_CONNECTOR_TYPE_TESLA_HPWC = 7 [deprecated = true]; + EV_CONNECTOR_TYPE_TESLA_SUPERCHARGER = 8; + EV_CONNECTOR_TYPE_GBT = 9; + EV_CONNECTOR_TYPE_OTHER = 101; +} + +enum VideoCodecResolutionType { + VIDEO_800x480 = 1; + VIDEO_1280x720 = 2; + VIDEO_1920x1080 = 3; + VIDEO_2560x1440 = 4; + VIDEO_3840x2160 = 5; + VIDEO_720x1280 = 6; + VIDEO_1080x1920 = 7; + VIDEO_1440x2560 = 8; + VIDEO_2160x3840 = 9; +} + +enum VideoFrameRateType { + VIDEO_FPS_60 = 1; + VIDEO_FPS_30 = 2; +} + +enum MediaCodecType { + MEDIA_CODEC_AUDIO_PCM = 1; + MEDIA_CODEC_AUDIO_AAC_LC = 2; + MEDIA_CODEC_VIDEO_H264_BP = 3; + MEDIA_CODEC_AUDIO_AAC_LC_ADTS = 4; + MEDIA_CODEC_VIDEO_VP9 = 5; + MEDIA_CODEC_VIDEO_AV1 = 6; + MEDIA_CODEC_VIDEO_H265 = 7; +} + +enum AudioStreamType { + AUDIO_STREAM_GUIDANCE = 1; + AUDIO_STREAM_SYSTEM_AUDIO = 2; + AUDIO_STREAM_MEDIA = 3; + AUDIO_STREAM_TELEPHONY = 4; +} + +enum DisplayType { + DISPLAY_TYPE_MAIN = 0; + DISPLAY_TYPE_CLUSTER = 1; + DISPLAY_TYPE_AUXILIARY = 2; +} + +enum UiTheme { + UI_THEME_AUTOMATIC = 0; + UI_THEME_LIGHT = 1; + UI_THEME_DARK = 2; +} + +enum TouchScreenType { + CAPACITIVE = 1; + RESISTIVE = 2; + INFRARED = 3; +} + +enum BluetoothPairingMethod { + BLUETOOTH_PAIRING_UNAVAILABLE = -1; + BLUETOOTH_PAIRING_OOB = 1; + BLUETOOTH_PAIRING_NUMERIC_COMPARISON = 2; + BLUETOOTH_PAIRING_PASSKEY_ENTRY = 3; + BLUETOOTH_PAIRING_PIN = 4; +} + +enum TrafficServiceType { + NO_TRAFFIC_SERVICE = 0; + TMC_TRAFFIC_SERVICE = 1; +} + +enum RdsType { + NO_RDS = 0; + RDS = 1; + RBDS = 2; +} + +enum RadioType { + AM_RADIO = 0; + FM_RADIO = 1; + AM_HD_RADIO = 2; + FM_HD_RADIO = 3; + DAB_RADIO = 4; + XM_RADIO = 5; +} + +enum ItuRegion { + RADIO_REGION_NONE = 0; + RADIO_REGION_ITU_1 = 1; + RADIO_REGION_ITU_2 = 2; + RADIO_REGION_OIRT = 3; + RADIO_REGION_JAPAN = 4; + RADIO_REGION_KOREA = 5; +} + +enum NavFocusType { + NAV_FOCUS_NATIVE = 1; + NAV_FOCUS_PROJECTED = 2; +} + +enum ByeByeReason { + USER_SELECTION = 1; + DEVICE_SWITCH = 2; + NOT_SUPPORTED = 3; + NOT_CURRENTLY_SUPPORTED = 4; + PROBE_SUPPORTED = 5; +} + +enum VoiceSessionStatus { + VOICE_SESSION_START = 1; + VOICE_SESSION_END = 2; +} + +enum UserSwitchStatus { + STATUS_OK = 0; + ERROR_NO_RFCOMM_CONNECTION = -1; + ERROR_BT_CLOSED_BEFORE_START = -2; + ERROR_BT_CLOSED_AFTER_START = -3; + ERROR_INCOMPATIBLE_PHONE_PROTOCOL_VERSION = -4; + ERROR_PHONE_UNABLE_TO_CONNECT_WIFI = -5; + ERROR_MULTIPLE_USER_SWITCH_REQUEST = -6; + ERROR_HU_INTERNAL = -7; + ERROR_INVALID_REQUEST = -8; + ERROR_REQUEST_TIMEOUT = -9; +} + +enum SensorErrorType { + SENSOR_OK = 1; + SENSOR_ERROR_TRANSIENT = 2; + SENSOR_ERROR_PERMANENT = 3; +} + +enum Gear { + GEAR_NEUTRAL = 0; + GEAR_1 = 1; + GEAR_2 = 2; + GEAR_3 = 3; + GEAR_4 = 4; + GEAR_5 = 5; + GEAR_6 = 6; + GEAR_7 = 7; + GEAR_8 = 8; + GEAR_9 = 9; + GEAR_10 = 10; + GEAR_DRIVE = 100; + GEAR_PARK = 101; + GEAR_REVERSE = 102; +} + +enum DrivingStatus { + DRIVE_STATUS_UNRESTRICTED = 0; + DRIVE_STATUS_NO_VIDEO = 1; + DRIVE_STATUS_NO_KEYBOARD_INPUT = 2; + DRIVE_STATUS_NO_VOICE_INPUT = 4; + DRIVE_STATUS_NO_CONFIG = 8; + DRIVE_STATUS_LIMIT_MESSAGE_LEN = 16; +} + +enum HeadLightState { + HEAD_LIGHT_STATE_OFF = 1; + HEAD_LIGHT_STATE_ON = 2; + HEAD_LIGHT_STATE_HIGH = 3; +} + +enum TurnIndicatorState { + TURN_INDICATOR_NONE = 1; + TURN_INDICATOR_LEFT = 2; + TURN_INDICATOR_RIGHT = 3; +} + +enum SensorMessageId { + SENSOR_MESSAGE_REQUEST = 32769; + SENSOR_MESSAGE_RESPONSE = 32770; + SENSOR_MESSAGE_BATCH = 32771; + SENSOR_MESSAGE_ERROR = 32772; +} + +enum VideoFocusReason { + UNKNOWN = 0; + PHONE_SCREEN_OFF = 1; + LAUNCH_NATIVE = 2; +} + +enum VideoFocusMode { + VIDEO_FOCUS_PROJECTED = 1; + VIDEO_FOCUS_NATIVE = 2; + VIDEO_FOCUS_NATIVE_TRANSIENT = 3; + VIDEO_FOCUS_PROJECTED_NO_INPUT_FOCUS = 4; +} + +enum AudioFocusRequestType { + AUDIO_FOCUS_GAIN = 1; + AUDIO_FOCUS_GAIN_TRANSIENT = 2; + AUDIO_FOCUS_GAIN_TRANSIENT_MAY_DUCK = 3; + AUDIO_FOCUS_RELEASE = 4; +} + +enum AudioFocusStateType { + AUDIO_FOCUS_STATE_INVALID = 0; + AUDIO_FOCUS_STATE_GAIN = 1; + AUDIO_FOCUS_STATE_GAIN_TRANSIENT = 2; + AUDIO_FOCUS_STATE_LOSS = 3; + AUDIO_FOCUS_STATE_LOSS_TRANSIENT_CAN_DUCK = 4; + AUDIO_FOCUS_STATE_LOSS_TRANSIENT = 5; + AUDIO_FOCUS_STATE_GAIN_MEDIA_ONLY = 6; + AUDIO_FOCUS_STATE_GAIN_TRANSIENT_GUIDANCE_ONLY = 7; +} + +enum MediaMessageId { + MEDIA_MESSAGE_DATA = 0; + MEDIA_MESSAGE_CODEC_CONFIG = 1; + MEDIA_MESSAGE_SETUP = 32768; + MEDIA_MESSAGE_START = 32769; + MEDIA_MESSAGE_STOP = 32770; + MEDIA_MESSAGE_CONFIG = 32771; + MEDIA_MESSAGE_ACK = 32772; + MEDIA_MESSAGE_MICROPHONE_REQUEST = 32773; + MEDIA_MESSAGE_MICROPHONE_RESPONSE = 32774; + MEDIA_MESSAGE_VIDEO_FOCUS_REQUEST = 32775; + MEDIA_MESSAGE_VIDEO_FOCUS_NOTIFICATION = 32776; + MEDIA_MESSAGE_UPDATE_UI_CONFIG_REQUEST = 32777; + MEDIA_MESSAGE_UPDATE_UI_CONFIG_REPLY = 32778; + MEDIA_MESSAGE_AUDIO_UNDERFLOW_NOTIFICATION = 32779; +} + +enum PointerAction { + ACTION_DOWN = 0; + ACTION_UP = 1; + ACTION_MOVED = 2; + ACTION_POINTER_DOWN = 5; + ACTION_POINTER_UP = 6; +} + +enum FeedbackEvent { + FEEDBACK_SELECT = 1; + FEEDBACK_FOCUS_CHANGE = 2; + FEEDBACK_DRAG_SELECT = 3; + FEEDBACK_DRAG_START = 4; + FEEDBACK_DRAG_END = 5; +} + +enum InputMessageId { + INPUT_MESSAGE_INPUT_REPORT = 32769; + INPUT_MESSAGE_KEY_BINDING_REQUEST = 32770; + INPUT_MESSAGE_KEY_BINDING_RESPONSE = 32771; + INPUT_MESSAGE_INPUT_FEEDBACK = 32772; +} + +enum BluetoothMessageId { + BLUETOOTH_MESSAGE_PAIRING_REQUEST = 32769; + BLUETOOTH_MESSAGE_PAIRING_RESPONSE = 32770; + BLUETOOTH_MESSAGE_AUTHENTICATION_DATA = 32771; + BLUETOOTH_MESSAGE_AUTHENTICATION_RESULT = 32772; +} + +enum WifiSecurityMode { + UNKNOWN_SECURITY_MODE = 0; + OPEN = 1; + WEP_64 = 2; + WEP_128 = 3; + WPA_PERSONAL = 4; + WPA2_PERSONAL = 5; + WPA_WPA2_PERSONAL = 6; + WPA_ENTERPRISE = 7; + WPA2_ENTERPRISE = 8; + WPA_WPA2_ENTERPRISE = 9; +} + +enum AccessPointType { + STATIC = 0; + DYNAMIC = 1; +} + +enum WifiProjectionMessageId { + WIFI_MESSAGE_CREDENTIALS_REQUEST = 32769; + WIFI_MESSAGE_CREDENTIALS_RESPONSE = 32770; +} + +enum RadioMessageId { + RADIO_MESSAGE_ACTIVE_RADIO_NOTIFICATION = 32769; + RADIO_MESSAGE_SELECT_ACTIVE_RADIO_REQUEST = 32770; + RADIO_MESSAGE_STEP_CHANNEL_REQUEST = 32771; + RADIO_MESSAGE_STEP_CHANNEL_RESPONSE = 32772; + RADIO_MESSAGE_SEEK_STATION_REQUEST = 32773; + RADIO_MESSAGE_SEEK_STATION_RESPONSE = 32774; + RADIO_MESSAGE_SCAN_STATIONS_REQUEST = 32775; + RADIO_MESSAGE_SCAN_STATIONS_RESPONSE = 32776; + RADIO_MESSAGE_TUNE_TO_STATION_REQUEST = 32777; + RADIO_MESSAGE_TUNE_TO_STATION_RESPONSE = 32778; + RADIO_MESSAGE_GET_PROGRAM_LIST_REQUEST = 32779; + RADIO_MESSAGE_GET_PROGRAM_LIST_RESPONSE = 32780; + RADIO_MESSAGE_STATION_PRESETS_NOTIFICATION = 32781; + RADIO_MESSAGE_CANCEL_OPERATIONS_REQUEST = 32782; + RADIO_MESSAGE_CANCEL_OPERATIONS_RESPONSE = 32783; + RADIO_MESSAGE_CONFIGURE_CHANNEL_SPACING_REQUEST = 32784; + RADIO_MESSAGE_CONFIGURE_CHANNEL_SPACING_RESPONSE = 32785; + RADIO_MESSAGE_RADIO_STATION_INFO_NOTIFICATION = 32786; + RADIO_MESSAGE_MUTE_RADIO_REQUEST = 32787; + RADIO_MESSAGE_MUTE_RADIO_RESPONSE = 32788; + RADIO_MESSAGE_GET_TRAFFIC_UPDATE_REQUEST = 32789; + RADIO_MESSAGE_GET_TRAFFIC_UPDATE_RESPONSE = 32790; + RADIO_MESSAGE_RADIO_SOURCE_REQUEST = 32791; + RADIO_MESSAGE_RADIO_SOURCE_RESPONSE = 32792; + RADIO_MESSAGE_STATE_NOTIFICATION = 32793; +} + +enum HdAcquisionState { + ANALOG = 0; + ACQUIRING_HD = 1; + ACQUIRED_HD = 2; +} + +enum NavigationStatusMessageId { + INSTRUMENT_CLUSTER_START = 32769; + INSTRUMENT_CLUSTER_STOP = 32770; + INSTRUMENT_CLUSTER_NAVIGATION_STATUS = 32771; + INSTRUMENT_CLUSTER_NAVIGATION_TURN_EVENT = 32772 [deprecated = true]; + INSTRUMENT_CLUSTER_NAVIGATION_DISTANCE_EVENT = 32773 [deprecated = true]; + INSTRUMENT_CLUSTER_NAVIGATION_STATE = 32774; + INSTRUMENT_CLUSTER_NAVIGATION_CURRENT_POSITION = 32775; +} + +enum MediaPlaybackStatusMessageId { + MEDIA_PLAYBACK_STATUS = 32769; + MEDIA_PLAYBACK_INPUT = 32770; + MEDIA_PLAYBACK_METADATA = 32771; +} + +enum PhoneStatusMessageId { + PHONE_STATUS = 32769; + PHONE_STATUS_INPUT = 32770; +} + +enum MediaBrowserMessageId { + MEDIA_ROOT_NODE = 32769; + MEDIA_SOURCE_NODE = 32770; + MEDIA_LIST_NODE = 32771; + MEDIA_SONG_NODE = 32772; + MEDIA_GET_NODE = 32773; + MEDIA_BROWSE_INPUT = 32774; +} + +enum GalVerificationVendorExtensionMessageId { + GAL_VERIFICATION_SET_SENSOR = 32769; + GAL_VERIFICATION_MEDIA_SINK_STATUS = 32770; + GAL_VERIFICATION_VIDEO_FOCUS = 32771; + GAL_VERIFICATION_AUDIO_FOCUS = 32772; + GAL_VERIFICATION_INJECT_INPUT = 32773; + GAL_VERIFICATION_BUG_REPORT_REQUEST = 32774; + GAL_VERIFICATION_BUG_REPORT_RESPONSE = 32775; + GAL_VERIFICATION_SCREEN_CAPTURE_REQUEST = 32776; + GAL_VERIFICATION_SCREEN_CAPTURE_RESPONSE = 32777; + GAL_VERIFICATION_DISPLAY_INFORMATION_REQUEST = 32778; + GAL_VERIFICATION_DISPLAY_INFORMATION_RESPONSE = 32779; +} + +enum GenericNotificationMessageId { + GENERIC_NOTIFICATION_SUBSCRIBE = 32769; + GENERIC_NOTIFICATION_UNSUBSCRIBE = 32770; + GENERIC_NOTIFICATION_MESSAGE = 32771; + GENERIC_NOTIFICATION_ACK = 32772; +} + +enum GoogleDiagnosticsVendorExtensionMessageId { + DIAGNOSTICS_BUG_REPORT_REQUEST = 1; + DIAGNOSTICS_BUG_REPORT_RESPONSE = 2; +} + +enum MessageStatus { + STATUS_UNSOLICITED_MESSAGE = 1; + STATUS_SUCCESS = 0; + STATUS_NO_COMPATIBLE_VERSION = -1; + STATUS_CERTIFICATE_ERROR = -2; + STATUS_AUTHENTICATION_FAILURE = -3; + STATUS_INVALID_SERVICE = -4; + STATUS_INVALID_CHANNEL = -5; + STATUS_INVALID_PRIORITY = -6; + STATUS_INTERNAL_ERROR = -7; + STATUS_MEDIA_CONFIG_MISMATCH = -8; + STATUS_INVALID_SENSOR = -9; + STATUS_BLUETOOTH_PAIRING_DELAYED = -10; + STATUS_BLUETOOTH_UNAVAILABLE = -11; + STATUS_BLUETOOTH_INVALID_ADDRESS = -12; + STATUS_BLUETOOTH_INVALID_PAIRING_METHOD = -13; + STATUS_BLUETOOTH_INVALID_AUTH_DATA = -14; + STATUS_BLUETOOTH_AUTH_DATA_MISMATCH = -15; + STATUS_BLUETOOTH_HFP_ANOTHER_CONNECTION = -16; + STATUS_BLUETOOTH_HFP_CONNECTION_FAILURE = -17; + STATUS_KEYCODE_NOT_BOUND = -18; + STATUS_RADIO_INVALID_STATION = -19; + STATUS_INVALID_INPUT = -20; + STATUS_RADIO_STATION_PRESETS_NOT_SUPPORTED = -21; + STATUS_RADIO_COMM_ERROR = -22; + STATUS_AUTHENTICATION_FAILURE_CERT_NOT_YET_VALID = -23; + STATUS_AUTHENTICATION_FAILURE_CERT_EXPIRED = -24; + STATUS_PING_TIMEOUT = -25; + STATUS_COMMAND_NOT_SUPPORTED = -250; + STATUS_FRAMING_ERROR = -251; + STATUS_UNEXPECTED_MESSAGE = -253; + STATUS_BUSY = -254; + STATUS_OUT_OF_MEMORY = -255; +} + +enum KeyCode { + KEYCODE_UNKNOWN = 0; + KEYCODE_SOFT_LEFT = 1; + KEYCODE_SOFT_RIGHT = 2; + KEYCODE_HOME = 3; + KEYCODE_BACK = 4; + KEYCODE_CALL = 5; + KEYCODE_ENDCALL = 6; + KEYCODE_0 = 7; + KEYCODE_1 = 8; + KEYCODE_2 = 9; + KEYCODE_3 = 10; + KEYCODE_4 = 11; + KEYCODE_5 = 12; + KEYCODE_6 = 13; + KEYCODE_7 = 14; + KEYCODE_8 = 15; + KEYCODE_9 = 16; + KEYCODE_STAR = 17; + KEYCODE_POUND = 18; + KEYCODE_DPAD_UP = 19; + KEYCODE_DPAD_DOWN = 20; + KEYCODE_DPAD_LEFT = 21; + KEYCODE_DPAD_RIGHT = 22; + KEYCODE_DPAD_CENTER = 23; + KEYCODE_VOLUME_UP = 24; + KEYCODE_VOLUME_DOWN = 25; + KEYCODE_POWER = 26; + KEYCODE_CAMERA = 27; + KEYCODE_CLEAR = 28; + KEYCODE_A = 29; + KEYCODE_B = 30; + KEYCODE_C = 31; + KEYCODE_D = 32; + KEYCODE_E = 33; + KEYCODE_F = 34; + KEYCODE_G = 35; + KEYCODE_H = 36; + KEYCODE_I = 37; + KEYCODE_J = 38; + KEYCODE_K = 39; + KEYCODE_L = 40; + KEYCODE_M = 41; + KEYCODE_N = 42; + KEYCODE_O = 43; + KEYCODE_P = 44; + KEYCODE_Q = 45; + KEYCODE_R = 46; + KEYCODE_S = 47; + KEYCODE_T = 48; + KEYCODE_U = 49; + KEYCODE_V = 50; + KEYCODE_W = 51; + KEYCODE_X = 52; + KEYCODE_Y = 53; + KEYCODE_Z = 54; + KEYCODE_COMMA = 55; + KEYCODE_PERIOD = 56; + KEYCODE_ALT_LEFT = 57; + KEYCODE_ALT_RIGHT = 58; + KEYCODE_SHIFT_LEFT = 59; + KEYCODE_SHIFT_RIGHT = 60; + KEYCODE_TAB = 61; + KEYCODE_SPACE = 62; + KEYCODE_SYM = 63; + KEYCODE_EXPLORER = 64; + KEYCODE_ENVELOPE = 65; + KEYCODE_ENTER = 66; + KEYCODE_DEL = 67; + KEYCODE_GRAVE = 68; + KEYCODE_MINUS = 69; + KEYCODE_EQUALS = 70; + KEYCODE_LEFT_BRACKET = 71; + KEYCODE_RIGHT_BRACKET = 72; + KEYCODE_BACKSLASH = 73; + KEYCODE_SEMICOLON = 74; + KEYCODE_APOSTROPHE = 75; + KEYCODE_SLASH = 76; + KEYCODE_AT = 77; + KEYCODE_NUM = 78; + KEYCODE_HEADSETHOOK = 79; + KEYCODE_FOCUS = 80; + KEYCODE_PLUS = 81; + KEYCODE_MENU = 82; + KEYCODE_NOTIFICATION = 83; + KEYCODE_SEARCH = 84; + KEYCODE_MEDIA_PLAY_PAUSE = 85; + KEYCODE_MEDIA_STOP = 86; + KEYCODE_MEDIA_NEXT = 87; + KEYCODE_MEDIA_PREVIOUS = 88; + KEYCODE_MEDIA_REWIND = 89; + KEYCODE_MEDIA_FAST_FORWARD = 90; + KEYCODE_MUTE = 91; + KEYCODE_PAGE_UP = 92; + KEYCODE_PAGE_DOWN = 93; + KEYCODE_PICTSYMBOLS = 94; + KEYCODE_SWITCH_CHARSET = 95; + KEYCODE_BUTTON_A = 96; + KEYCODE_BUTTON_B = 97; + KEYCODE_BUTTON_C = 98; + KEYCODE_BUTTON_X = 99; + KEYCODE_BUTTON_Y = 100; + KEYCODE_BUTTON_Z = 101; + KEYCODE_BUTTON_L1 = 102; + KEYCODE_BUTTON_R1 = 103; + KEYCODE_BUTTON_L2 = 104; + KEYCODE_BUTTON_R2 = 105; + KEYCODE_BUTTON_THUMBL = 106; + KEYCODE_BUTTON_THUMBR = 107; + KEYCODE_BUTTON_START = 108; + KEYCODE_BUTTON_SELECT = 109; + KEYCODE_BUTTON_MODE = 110; + KEYCODE_ESCAPE = 111; + KEYCODE_FORWARD_DEL = 112; + KEYCODE_CTRL_LEFT = 113; + KEYCODE_CTRL_RIGHT = 114; + KEYCODE_CAPS_LOCK = 115; + KEYCODE_SCROLL_LOCK = 116; + KEYCODE_META_LEFT = 117; + KEYCODE_META_RIGHT = 118; + KEYCODE_FUNCTION = 119; + KEYCODE_SYSRQ = 120; + KEYCODE_BREAK = 121; + KEYCODE_MOVE_HOME = 122; + KEYCODE_MOVE_END = 123; + KEYCODE_INSERT = 124; + KEYCODE_FORWARD = 125; + KEYCODE_MEDIA_PLAY = 126; + KEYCODE_MEDIA_PAUSE = 127; + KEYCODE_MEDIA_CLOSE = 128; + KEYCODE_MEDIA_EJECT = 129; + KEYCODE_MEDIA_RECORD = 130; + KEYCODE_F1 = 131; + KEYCODE_F2 = 132; + KEYCODE_F3 = 133; + KEYCODE_F4 = 134; + KEYCODE_F5 = 135; + KEYCODE_F6 = 136; + KEYCODE_F7 = 137; + KEYCODE_F8 = 138; + KEYCODE_F9 = 139; + KEYCODE_F10 = 140; + KEYCODE_F11 = 141; + KEYCODE_F12 = 142; + KEYCODE_NUM_LOCK = 143; + KEYCODE_NUMPAD_0 = 144; + KEYCODE_NUMPAD_1 = 145; + KEYCODE_NUMPAD_2 = 146; + KEYCODE_NUMPAD_3 = 147; + KEYCODE_NUMPAD_4 = 148; + KEYCODE_NUMPAD_5 = 149; + KEYCODE_NUMPAD_6 = 150; + KEYCODE_NUMPAD_7 = 151; + KEYCODE_NUMPAD_8 = 152; + KEYCODE_NUMPAD_9 = 153; + KEYCODE_NUMPAD_DIVIDE = 154; + KEYCODE_NUMPAD_MULTIPLY = 155; + KEYCODE_NUMPAD_SUBTRACT = 156; + KEYCODE_NUMPAD_ADD = 157; + KEYCODE_NUMPAD_DOT = 158; + KEYCODE_NUMPAD_COMMA = 159; + KEYCODE_NUMPAD_ENTER = 160; + KEYCODE_NUMPAD_EQUALS = 161; + KEYCODE_NUMPAD_LEFT_PAREN = 162; + KEYCODE_NUMPAD_RIGHT_PAREN = 163; + KEYCODE_VOLUME_MUTE = 164; + KEYCODE_INFO = 165; + KEYCODE_CHANNEL_UP = 166; + KEYCODE_CHANNEL_DOWN = 167; + KEYCODE_ZOOM_IN = 168; + KEYCODE_ZOOM_OUT = 169; + KEYCODE_TV = 170; + KEYCODE_WINDOW = 171; + KEYCODE_GUIDE = 172; + KEYCODE_DVR = 173; + KEYCODE_BOOKMARK = 174; + KEYCODE_CAPTIONS = 175; + KEYCODE_SETTINGS = 176; + KEYCODE_TV_POWER = 177; + KEYCODE_TV_INPUT = 178; + KEYCODE_STB_POWER = 179; + KEYCODE_STB_INPUT = 180; + KEYCODE_AVR_POWER = 181; + KEYCODE_AVR_INPUT = 182; + KEYCODE_PROG_RED = 183; + KEYCODE_PROG_GREEN = 184; + KEYCODE_PROG_YELLOW = 185; + KEYCODE_PROG_BLUE = 186; + KEYCODE_APP_SWITCH = 187; + KEYCODE_BUTTON_1 = 188; + KEYCODE_BUTTON_2 = 189; + KEYCODE_BUTTON_3 = 190; + KEYCODE_BUTTON_4 = 191; + KEYCODE_BUTTON_5 = 192; + KEYCODE_BUTTON_6 = 193; + KEYCODE_BUTTON_7 = 194; + KEYCODE_BUTTON_8 = 195; + KEYCODE_BUTTON_9 = 196; + KEYCODE_BUTTON_10 = 197; + KEYCODE_BUTTON_11 = 198; + KEYCODE_BUTTON_12 = 199; + KEYCODE_BUTTON_13 = 200; + KEYCODE_BUTTON_14 = 201; + KEYCODE_BUTTON_15 = 202; + KEYCODE_BUTTON_16 = 203; + KEYCODE_LANGUAGE_SWITCH = 204; + KEYCODE_MANNER_MODE = 205; + KEYCODE_3D_MODE = 206; + KEYCODE_CONTACTS = 207; + KEYCODE_CALENDAR = 208; + KEYCODE_MUSIC = 209; + KEYCODE_CALCULATOR = 210; + KEYCODE_ZENKAKU_HANKAKU = 211; + KEYCODE_EISU = 212; + KEYCODE_MUHENKAN = 213; + KEYCODE_HENKAN = 214; + KEYCODE_KATAKANA_HIRAGANA = 215; + KEYCODE_YEN = 216; + KEYCODE_RO = 217; + KEYCODE_KANA = 218; + KEYCODE_ASSIST = 219; + KEYCODE_BRIGHTNESS_DOWN = 220; + KEYCODE_BRIGHTNESS_UP = 221; + KEYCODE_MEDIA_AUDIO_TRACK = 222; + KEYCODE_SLEEP = 223; + KEYCODE_WAKEUP = 224; + KEYCODE_PAIRING = 225; + KEYCODE_MEDIA_TOP_MENU = 226; + KEYCODE_11 = 227; + KEYCODE_12 = 228; + KEYCODE_LAST_CHANNEL = 229; + KEYCODE_TV_DATA_SERVICE = 230; + KEYCODE_VOICE_ASSIST = 231; + KEYCODE_TV_RADIO_SERVICE = 232; + KEYCODE_TV_TELETEXT = 233; + KEYCODE_TV_NUMBER_ENTRY = 234; + KEYCODE_TV_TERRESTRIAL_ANALOG = 235; + KEYCODE_TV_TERRESTRIAL_DIGITAL = 236; + KEYCODE_TV_SATELLITE = 237; + KEYCODE_TV_SATELLITE_BS = 238; + KEYCODE_TV_SATELLITE_CS = 239; + KEYCODE_TV_SATELLITE_SERVICE = 240; + KEYCODE_TV_NETWORK = 241; + KEYCODE_TV_ANTENNA_CABLE = 242; + KEYCODE_TV_INPUT_HDMI_1 = 243; + KEYCODE_TV_INPUT_HDMI_2 = 244; + KEYCODE_TV_INPUT_HDMI_3 = 245; + KEYCODE_TV_INPUT_HDMI_4 = 246; + KEYCODE_TV_INPUT_COMPOSITE_1 = 247; + KEYCODE_TV_INPUT_COMPOSITE_2 = 248; + KEYCODE_TV_INPUT_COMPONENT_1 = 249; + KEYCODE_TV_INPUT_COMPONENT_2 = 250; + KEYCODE_TV_INPUT_VGA_1 = 251; + KEYCODE_TV_AUDIO_DESCRIPTION = 252; + KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP = 253; + KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN = 254; + KEYCODE_TV_ZOOM_MODE = 255; + KEYCODE_TV_CONTENTS_MENU = 256; + KEYCODE_TV_MEDIA_CONTEXT_MENU = 257; + KEYCODE_TV_TIMER_PROGRAMMING = 258; + KEYCODE_HELP = 259; + KEYCODE_NAVIGATE_PREVIOUS = 260; + KEYCODE_NAVIGATE_NEXT = 261; + KEYCODE_NAVIGATE_IN = 262; + KEYCODE_NAVIGATE_OUT = 263; + KEYCODE_DPAD_UP_LEFT = 268; + KEYCODE_DPAD_DOWN_LEFT = 269; + KEYCODE_DPAD_UP_RIGHT = 270; + KEYCODE_DPAD_DOWN_RIGHT = 271; + KEYCODE_SENTINEL = 65535; + KEYCODE_ROTARY_CONTROLLER = 65536; + KEYCODE_MEDIA = 65537; + KEYCODE_NAVIGATION = 65538; + KEYCODE_RADIO = 65539; + KEYCODE_TEL = 65540; + KEYCODE_PRIMARY_BUTTON = 65541; + KEYCODE_SECONDARY_BUTTON = 65542; + KEYCODE_TERTIARY_BUTTON = 65543; + KEYCODE_TURN_CARD = 65544; +} + +enum GalConstants { + WIFI_PORT = 30515; + PROTOCOL_MAJOR_VERSION = 1; + PROTOCOL_MINOR_VERSION = 6; +} diff --git a/include/aasdk/Channel/AV/AVInputServiceChannel.hpp b/include/aasdk/Channel/AV/AVInputServiceChannel.hpp deleted file mode 100644 index d4ddb404..00000000 --- a/include/aasdk/Channel/AV/AVInputServiceChannel.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class AVInputServiceChannel: public IAVInputServiceChannel, public ServiceChannel, public std::enable_shared_from_this -{ -public: - AVInputServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger); - - void receive(IAVInputServiceChannelEventHandler::Pointer eventHandler) override; - void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) override; - void sendAVChannelSetupResponse(const proto::messages::AVChannelSetupResponse& response, SendPromise::Pointer promise) override; - void sendAVInputOpenResponse(const proto::messages::AVInputOpenResponse& response, SendPromise::Pointer promise) override; - void sendAVMediaWithTimestampIndication(messenger::Timestamp::ValueType, const common::Data& data, SendPromise::Pointer promise) override; - messenger::ChannelId getId() const override; - -private: - using std::enable_shared_from_this::shared_from_this; - void messageHandler(messenger::Message::Pointer message, IAVInputServiceChannelEventHandler::Pointer eventHandler); - void handleAVChannelSetupRequest(const common::DataConstBuffer& payload, IAVInputServiceChannelEventHandler::Pointer eventHandler); - void handleAVInputOpenRequest(const common::DataConstBuffer& payload, IAVInputServiceChannelEventHandler::Pointer eventHandler); - void handleAVMediaAckIndication(const common::DataConstBuffer& payload, IAVInputServiceChannelEventHandler::Pointer eventHandler); - void handleChannelOpenRequest(const common::DataConstBuffer& payload, IAVInputServiceChannelEventHandler::Pointer eventHandler); -}; - -} -} -} diff --git a/include/aasdk/Channel/AV/AudioServiceChannel.hpp b/include/aasdk/Channel/AV/AudioServiceChannel.hpp deleted file mode 100644 index d460a0b7..00000000 --- a/include/aasdk/Channel/AV/AudioServiceChannel.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class AudioServiceChannel: public IAudioServiceChannel, public ServiceChannel, public std::enable_shared_from_this -{ -public: - AudioServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger, messenger::ChannelId channelId); - - void receive(IAudioServiceChannelEventHandler::Pointer eventHandler) override; - void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) override; - void sendAVChannelSetupResponse(const proto::messages::AVChannelSetupResponse& response, SendPromise::Pointer promise) override; - void sendAVMediaAckIndication(const proto::messages::AVMediaAckIndication& indication, SendPromise::Pointer promise) override; - messenger::ChannelId getId() const override; - -private: - using std::enable_shared_from_this::shared_from_this; - void messageHandler(messenger::Message::Pointer message, IAudioServiceChannelEventHandler::Pointer eventHandler); - void handleAVChannelSetupRequest(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler); - void handleStartIndication(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler); - void handleStopIndication(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler); - void handleChannelOpenRequest(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler); - void handleAVMediaWithTimestampIndication(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler); -}; - -} -} -} diff --git a/include/aasdk/Channel/AV/IAVInputServiceChannel.hpp b/include/aasdk/Channel/AV/IAVInputServiceChannel.hpp deleted file mode 100644 index 189eebb6..00000000 --- a/include/aasdk/Channel/AV/IAVInputServiceChannel.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class IAVInputServiceChannel -{ -public: - typedef std::shared_ptr Pointer; - - IAVInputServiceChannel() = default; - virtual ~IAVInputServiceChannel() = default; - - virtual void receive(IAVInputServiceChannelEventHandler::Pointer eventHandler) = 0; - virtual void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) = 0; - virtual void sendAVChannelSetupResponse(const proto::messages::AVChannelSetupResponse& response, SendPromise::Pointer promise) = 0; - virtual void sendAVMediaWithTimestampIndication(messenger::Timestamp::ValueType, const common::Data& data, SendPromise::Pointer promise) = 0; - virtual void sendAVInputOpenResponse(const proto::messages::AVInputOpenResponse& response, SendPromise::Pointer promise) = 0; - virtual messenger::ChannelId getId() const = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/AV/IAVInputServiceChannelEventHandler.hpp b/include/aasdk/Channel/AV/IAVInputServiceChannelEventHandler.hpp deleted file mode 100644 index 7f47de0f..00000000 --- a/include/aasdk/Channel/AV/IAVInputServiceChannelEventHandler.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class IAVInputServiceChannelEventHandler -{ -public: - typedef std::shared_ptr Pointer; - - IAVInputServiceChannelEventHandler() = default; - virtual ~IAVInputServiceChannelEventHandler() = default; - - virtual void onChannelOpenRequest(const proto::messages::ChannelOpenRequest& request) = 0; - virtual void onAVChannelSetupRequest(const proto::messages::AVChannelSetupRequest& request) = 0; - virtual void onAVInputOpenRequest(const proto::messages::AVInputOpenRequest& request) = 0; - virtual void onAVMediaAckIndication(const proto::messages::AVMediaAckIndication& indication) = 0; - virtual void onChannelError(const error::Error& e) = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/AV/IAudioServiceChannel.hpp b/include/aasdk/Channel/AV/IAudioServiceChannel.hpp deleted file mode 100644 index 7e42a32a..00000000 --- a/include/aasdk/Channel/AV/IAudioServiceChannel.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class IAudioServiceChannel -{ -public: - typedef std::shared_ptr Pointer; - - IAudioServiceChannel() = default; - virtual ~IAudioServiceChannel() = default; - - virtual void receive(IAudioServiceChannelEventHandler::Pointer eventHandler) = 0; - virtual void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) = 0; - virtual void sendAVChannelSetupResponse(const proto::messages::AVChannelSetupResponse& response, SendPromise::Pointer promise) = 0; - virtual void sendAVMediaAckIndication(const proto::messages::AVMediaAckIndication& indication, SendPromise::Pointer promise) = 0; - virtual messenger::ChannelId getId() const = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp b/include/aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp deleted file mode 100644 index c633ff8f..00000000 --- a/include/aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class IAudioServiceChannelEventHandler -{ -public: - typedef std::shared_ptr Pointer; - - IAudioServiceChannelEventHandler() = default; - virtual ~IAudioServiceChannelEventHandler() = default; - - virtual void onChannelOpenRequest(const proto::messages::ChannelOpenRequest& request) = 0; - virtual void onAVChannelSetupRequest(const proto::messages::AVChannelSetupRequest& request) = 0; - virtual void onAVChannelStartIndication(const proto::messages::AVChannelStartIndication& indication) = 0; - virtual void onAVChannelStopIndication(const proto::messages::AVChannelStopIndication& indication) = 0; - virtual void onAVMediaWithTimestampIndication(messenger::Timestamp::ValueType, const common::DataConstBuffer& buffer) = 0; - virtual void onAVMediaIndication(const common::DataConstBuffer& buffer) = 0; - virtual void onChannelError(const error::Error& e) = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/AV/IMediaStatusServiceChannel.hpp b/include/aasdk/Channel/AV/IMediaStatusServiceChannel.hpp deleted file mode 100644 index e388f607..00000000 --- a/include/aasdk/Channel/AV/IMediaStatusServiceChannel.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class IMediaStatusServiceChannel -{ -public: - typedef std::shared_ptr Pointer; - - IMediaStatusServiceChannel() = default; - virtual ~IMediaStatusServiceChannel() = default; - - virtual void receive(IMediaStatusServiceChannelEventHandler::Pointer eventHandler) = 0; - virtual void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) = 0; - virtual messenger::ChannelId getId() const = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/AV/IMediaStatusServiceChannelEventHandler.hpp b/include/aasdk/Channel/AV/IMediaStatusServiceChannelEventHandler.hpp deleted file mode 100644 index 56e068d2..00000000 --- a/include/aasdk/Channel/AV/IMediaStatusServiceChannelEventHandler.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class IMediaStatusServiceChannelEventHandler -{ -public: - typedef std::shared_ptr Pointer; - - IMediaStatusServiceChannelEventHandler() = default; - virtual ~IMediaStatusServiceChannelEventHandler() = default; - - virtual void onChannelOpenRequest(const proto::messages::ChannelOpenRequest& request) = 0; - virtual void onChannelError(const error::Error& e) = 0; - virtual void onMetadataUpdate(const proto::messages::MediaInfoChannelMetadataData& metadata) = 0; - virtual void onPlaybackUpdate(const proto::messages::MediaInfoChannelPlaybackData& playback) = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/AV/IVideoServiceChannel.hpp b/include/aasdk/Channel/AV/IVideoServiceChannel.hpp deleted file mode 100644 index c0d6d68b..00000000 --- a/include/aasdk/Channel/AV/IVideoServiceChannel.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class IVideoServiceChannel -{ -public: - typedef std::shared_ptr Pointer; - - IVideoServiceChannel() = default; - virtual ~IVideoServiceChannel() = default; - - virtual void receive(IVideoServiceChannelEventHandler::Pointer eventHandler) = 0; - virtual void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) = 0; - virtual void sendAVChannelSetupResponse(const proto::messages::AVChannelSetupResponse& response, SendPromise::Pointer promise) = 0; - virtual void sendVideoFocusIndication(const proto::messages::VideoFocusIndication& indication, SendPromise::Pointer promise) = 0; - virtual void sendAVMediaAckIndication(const proto::messages::AVMediaAckIndication& indication, SendPromise::Pointer promise) = 0; - virtual messenger::ChannelId getId() const = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp b/include/aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp deleted file mode 100644 index 0ff91eb1..00000000 --- a/include/aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class IVideoServiceChannelEventHandler -{ -public: - typedef std::shared_ptr Pointer; - - IVideoServiceChannelEventHandler() = default; - virtual ~IVideoServiceChannelEventHandler() = default; - - virtual void onChannelOpenRequest(const proto::messages::ChannelOpenRequest& request) = 0; - virtual void onAVChannelSetupRequest(const proto::messages::AVChannelSetupRequest& request) = 0; - virtual void onAVChannelStartIndication(const proto::messages::AVChannelStartIndication& indication) = 0; - virtual void onAVChannelStopIndication(const proto::messages::AVChannelStopIndication& indication) = 0; - virtual void onAVMediaWithTimestampIndication(messenger::Timestamp::ValueType, const common::DataConstBuffer& buffer) = 0; - virtual void onAVMediaIndication(const common::DataConstBuffer& buffer) = 0; - virtual void onVideoFocusRequest(const proto::messages::VideoFocusRequest& request) = 0; - virtual void onChannelError(const error::Error& e) = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/AV/MediaAudioServiceChannel.hpp b/include/aasdk/Channel/AV/MediaAudioServiceChannel.hpp deleted file mode 100644 index 3dd1af40..00000000 --- a/include/aasdk/Channel/AV/MediaAudioServiceChannel.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class MediaAudioServiceChannel: public AudioServiceChannel -{ -public: - MediaAudioServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger); -}; - -} -} -} diff --git a/include/aasdk/Channel/AV/MediaStatusServiceChannel.hpp b/include/aasdk/Channel/AV/MediaStatusServiceChannel.hpp deleted file mode 100644 index 0b02992f..00000000 --- a/include/aasdk/Channel/AV/MediaStatusServiceChannel.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class MediaStatusServiceChannel: public IMediaStatusServiceChannel, public ServiceChannel, public std::enable_shared_from_this -{ -public: - MediaStatusServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger); - - void receive(IMediaStatusServiceChannelEventHandler::Pointer eventHandler) override; - messenger::ChannelId getId() const override; - void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) override; - -private: - using std::enable_shared_from_this::shared_from_this; - void messageHandler(messenger::Message::Pointer message, IMediaStatusServiceChannelEventHandler::Pointer eventHandler); - void handleChannelOpenRequest(const common::DataConstBuffer& payload, IMediaStatusServiceChannelEventHandler::Pointer eventHandler); - void handleMetadataUpdate(const common::DataConstBuffer& payload, IMediaStatusServiceChannelEventHandler::Pointer eventHandler); - void handlePlaybackUpdate(const common::DataConstBuffer& payload, IMediaStatusServiceChannelEventHandler::Pointer eventHandler); - -}; - -} -} -} diff --git a/include/aasdk/Channel/AV/SpeechAudioServiceChannel.hpp b/include/aasdk/Channel/AV/SpeechAudioServiceChannel.hpp deleted file mode 100644 index 70b88bad..00000000 --- a/include/aasdk/Channel/AV/SpeechAudioServiceChannel.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class SpeechAudioServiceChannel: public AudioServiceChannel -{ -public: - SpeechAudioServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger); -}; - -} -} -} diff --git a/include/aasdk/Channel/AV/SystemAudioServiceChannel.hpp b/include/aasdk/Channel/AV/SystemAudioServiceChannel.hpp deleted file mode 100644 index f7b98fe5..00000000 --- a/include/aasdk/Channel/AV/SystemAudioServiceChannel.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class SystemAudioServiceChannel: public AudioServiceChannel -{ -public: - SystemAudioServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger); -}; - -} -} -} diff --git a/include/aasdk/Channel/AV/VideoServiceChannel.hpp b/include/aasdk/Channel/AV/VideoServiceChannel.hpp deleted file mode 100644 index 42557058..00000000 --- a/include/aasdk/Channel/AV/VideoServiceChannel.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -class VideoServiceChannel: public IVideoServiceChannel, public ServiceChannel, public std::enable_shared_from_this -{ -public: - VideoServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger); - - void receive(IVideoServiceChannelEventHandler::Pointer eventHandler) override; - void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) override; - void sendAVChannelSetupResponse(const proto::messages::AVChannelSetupResponse& response, SendPromise::Pointer promise) override; - void sendVideoFocusIndication(const proto::messages::VideoFocusIndication& indication, SendPromise::Pointer promise) override; - void sendAVMediaAckIndication(const proto::messages::AVMediaAckIndication& indication, SendPromise::Pointer promise) override; - messenger::ChannelId getId() const override; - -private: - using std::enable_shared_from_this::shared_from_this; - void messageHandler(messenger::Message::Pointer message, IVideoServiceChannelEventHandler::Pointer eventHandler); - void handleAVChannelSetupRequest(const common::DataConstBuffer& payload, IVideoServiceChannelEventHandler::Pointer eventHandler); - void handleStartIndication(const common::DataConstBuffer& payload, IVideoServiceChannelEventHandler::Pointer eventHandler); - void handleStopIndication(const common::DataConstBuffer& payload, IVideoServiceChannelEventHandler::Pointer eventHandler); - void handleChannelOpenRequest(const common::DataConstBuffer& payload, IVideoServiceChannelEventHandler::Pointer eventHandler); - void handleVideoFocusRequest(const common::DataConstBuffer& payload, IVideoServiceChannelEventHandler::Pointer eventHandler); - void handleAVMediaWithTimestampIndication(const common::DataConstBuffer& payload, IVideoServiceChannelEventHandler::Pointer eventHandler); -}; - -} -} -} diff --git a/include/aasdk/Channel/Bluetooth/BluetoothService.hpp b/include/aasdk/Channel/Bluetooth/BluetoothService.hpp new file mode 100644 index 00000000..eb689251 --- /dev/null +++ b/include/aasdk/Channel/Bluetooth/BluetoothService.hpp @@ -0,0 +1,65 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/Channel.hpp" +#include "IBluetoothService.hpp" + +namespace aasdk::channel::bluetooth { + + class BluetoothService + : public IBluetoothService, public Channel, public std::enable_shared_from_this { + public: + BluetoothService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + + // Senders and Receivers + + void receive(IBluetoothServiceEventHandler::Pointer eventHandler) override; + + void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) override; + + void + sendBluetoothPairingResponse(const aap_protobuf::service::bluetooth::message::BluetoothPairingResponse &response, + SendPromise::Pointer promise) override; + + void sendBluetoothAuthenticationData( + const aap_protobuf::service::bluetooth::message::BluetoothAuthenticationData &response, + SendPromise::Pointer promise) override; + + private: + using std::enable_shared_from_this::shared_from_this; + + // Internal Message Handlers + + void messageHandler(messenger::Message::Pointer message, IBluetoothServiceEventHandler::Pointer eventHandler); + + void handleChannelOpenRequest(const common::DataConstBuffer &payload, + IBluetoothServiceEventHandler::Pointer eventHandler); + + void handleBluetoothPairingRequest(const common::DataConstBuffer &payload, + IBluetoothServiceEventHandler::Pointer eventHandler); + + void handleBluetoothAuthenticationResult(const common::DataConstBuffer &payload, + IBluetoothServiceEventHandler::Pointer eventHandler); + }; + +} + + diff --git a/include/aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp b/include/aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp deleted file mode 100644 index 3f2eb241..00000000 --- a/include/aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace bluetooth -{ - -class BluetoothServiceChannel: public IBluetoothServiceChannel, public ServiceChannel, public std::enable_shared_from_this -{ -public: - BluetoothServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger); - - void receive(IBluetoothServiceChannelEventHandler::Pointer eventHandler) override; - messenger::ChannelId getId() const override; - void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) override; - void sendBluetoothPairingResponse(const proto::messages::BluetoothPairingResponse& response, SendPromise::Pointer promise) override; - -private: - using std::enable_shared_from_this::shared_from_this; - void messageHandler(messenger::Message::Pointer message, IBluetoothServiceChannelEventHandler::Pointer eventHandler); - void handleChannelOpenRequest(const common::DataConstBuffer& payload, IBluetoothServiceChannelEventHandler::Pointer eventHandler); - void handleBluetoothPairingRequest(const common::DataConstBuffer& payload, IBluetoothServiceChannelEventHandler::Pointer eventHandler); -}; - -} -} -} diff --git a/include/aasdk/Channel/Bluetooth/IBluetoothService.hpp b/include/aasdk/Channel/Bluetooth/IBluetoothService.hpp new file mode 100644 index 00000000..a2008175 --- /dev/null +++ b/include/aasdk/Channel/Bluetooth/IBluetoothService.hpp @@ -0,0 +1,56 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include +#include +#include "IBluetoothServiceEventHandler.hpp" + +namespace aasdk::channel::bluetooth { + + class IBluetoothService : public virtual IChannel { + public: + typedef std::shared_ptr Pointer; + + IBluetoothService() = default; + + virtual ~IBluetoothService() = default; + + virtual void receive(IBluetoothServiceEventHandler::Pointer eventHandler) = 0; + + virtual void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) = 0; + + virtual void sendBluetoothAuthenticationData( + const aap_protobuf::service::bluetooth::message::BluetoothAuthenticationData &response, + SendPromise::Pointer promise) = 0; + + virtual void + sendBluetoothPairingResponse(const aap_protobuf::service::bluetooth::message::BluetoothPairingResponse &response, + SendPromise::Pointer promise) = 0; + }; + +} + + diff --git a/include/aasdk/Channel/Bluetooth/IBluetoothServiceChannel.hpp b/include/aasdk/Channel/Bluetooth/IBluetoothServiceChannel.hpp deleted file mode 100644 index 6e21fffe..00000000 --- a/include/aasdk/Channel/Bluetooth/IBluetoothServiceChannel.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace bluetooth -{ - -class IBluetoothServiceChannel -{ -public: - typedef std::shared_ptr Pointer; - - IBluetoothServiceChannel() = default; - virtual ~IBluetoothServiceChannel() = default; - - virtual void receive(IBluetoothServiceChannelEventHandler::Pointer eventHandler) = 0; - virtual void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) = 0; - virtual void sendBluetoothPairingResponse(const proto::messages::BluetoothPairingResponse& response, SendPromise::Pointer promise) = 0; - virtual messenger::ChannelId getId() const = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/Bluetooth/IBluetoothServiceChannelEventHandler.hpp b/include/aasdk/Channel/Bluetooth/IBluetoothServiceChannelEventHandler.hpp deleted file mode 100644 index 956e66de..00000000 --- a/include/aasdk/Channel/Bluetooth/IBluetoothServiceChannelEventHandler.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace bluetooth -{ - -class IBluetoothServiceChannelEventHandler -{ -public: - typedef std::shared_ptr Pointer; - - IBluetoothServiceChannelEventHandler() = default; - virtual ~IBluetoothServiceChannelEventHandler() = default; - - virtual void onChannelOpenRequest(const proto::messages::ChannelOpenRequest& request) = 0; - virtual void onBluetoothPairingRequest(const proto::messages::BluetoothPairingRequest& request) = 0; - virtual void onChannelError(const error::Error& e) = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/Bluetooth/IBluetoothServiceEventHandler.hpp b/include/aasdk/Channel/Bluetooth/IBluetoothServiceEventHandler.hpp new file mode 100644 index 00000000..4c11ff5d --- /dev/null +++ b/include/aasdk/Channel/Bluetooth/IBluetoothServiceEventHandler.hpp @@ -0,0 +1,49 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include +#include +#include +#include "aasdk/Error/Error.hpp" + +namespace aasdk::channel::bluetooth { + + class IBluetoothServiceEventHandler { + public: + typedef std::shared_ptr Pointer; + + IBluetoothServiceEventHandler() = default; + + virtual ~IBluetoothServiceEventHandler() = default; + + virtual void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) = 0; + + virtual void + onBluetoothPairingRequest(const aap_protobuf::service::bluetooth::message::BluetoothPairingRequest &request) = 0; + + virtual void + onBluetoothAuthenticationResult(const aap_protobuf::service::bluetooth::message::BluetoothAuthenticationResult &request) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + }; + +} + + diff --git a/include/aasdk/Channel/Channel.hpp b/include/aasdk/Channel/Channel.hpp new file mode 100644 index 00000000..838936c8 --- /dev/null +++ b/include/aasdk/Channel/Channel.hpp @@ -0,0 +1,47 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Messenger/IMessenger.hpp" +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include + +namespace aasdk { + namespace channel { + class Channel : public virtual IChannel { + public: + Channel(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger, + messenger::ChannelId channelId); + + virtual ~Channel() = default; + + messenger::ChannelId getId() const override; + + void send(messenger::Message::Pointer message, SendPromise::Pointer promise) override; + + protected: + boost::asio::io_service::strand &strand_; + messenger::IMessenger::Pointer messenger_; + messenger::ChannelId channelId_; + }; + + } +} diff --git a/include/aasdk/Channel/Control/ControlServiceChannel.hpp b/include/aasdk/Channel/Control/ControlServiceChannel.hpp index e8062cee..e15ea2a9 100644 --- a/include/aasdk/Channel/Control/ControlServiceChannel.hpp +++ b/include/aasdk/Channel/Control/ControlServiceChannel.hpp @@ -1,69 +1,115 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include #include -#include +#include "aasdk/Channel/Channel.hpp" #include -namespace aasdk -{ -namespace channel -{ -namespace control -{ +namespace aasdk::channel::control { -class ControlServiceChannel: public IControlServiceChannel, public ServiceChannel, public std::enable_shared_from_this -{ -public: - ControlServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger); + class ControlServiceChannel + : public IControlServiceChannel, public Channel, public std::enable_shared_from_this { + public: + ControlServiceChannel(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + + // Senders and Receivers void receive(IControlServiceChannelEventHandler::Pointer eventHandler) override; void sendVersionRequest(SendPromise::Pointer promise) override; + void sendHandshake(common::Data handshakeBuffer, SendPromise::Pointer promise) override; - void sendAuthComplete(const proto::messages::AuthCompleteIndication& response, SendPromise::Pointer promise) override; - void sendServiceDiscoveryResponse(const proto::messages::ServiceDiscoveryResponse& response, SendPromise::Pointer promise) override; - void sendAudioFocusResponse(const proto::messages::AudioFocusResponse& response, SendPromise::Pointer promise) override; - void sendShutdownRequest(const proto::messages::ShutdownRequest& request, SendPromise::Pointer promise) override; - void sendShutdownResponse(const proto::messages::ShutdownResponse& response, SendPromise::Pointer promise) override; - void sendNavigationFocusResponse(const proto::messages::NavigationFocusResponse& respons, SendPromise::Pointer promisee) override; - void sendPingRequest(const proto::messages::PingRequest& request, SendPromise::Pointer promise) override; - void sendPingResponse(const proto::messages::PingResponse& response, SendPromise::Pointer promise) override; - -private: + + void sendAuthComplete(const aap_protobuf::service::control::message::AuthResponse &response, + SendPromise::Pointer promise) override; + + void sendServiceDiscoveryResponse( + const aap_protobuf::service::control::message::ServiceDiscoveryResponse &response, + SendPromise::Pointer promise) override; + + void + sendAudioFocusResponse( + const aap_protobuf::service::control::message::AudioFocusNotification &response, + SendPromise::Pointer promise) override; + + void sendShutdownRequest(const aap_protobuf::service::control::message::ByeByeRequest &request, + SendPromise::Pointer promise) override; + + void sendShutdownResponse(const aap_protobuf::service::control::message::ByeByeResponse &response, + SendPromise::Pointer promise) override; + + void sendVoiceSessionFocusResponse(const aap_protobuf::service::control::message::VoiceSessionNotification &response, + SendPromise::Pointer promise) override; + + void sendNavigationFocusResponse( + const aap_protobuf::service::control::message::NavFocusNotification &response, + SendPromise::Pointer promise) override; + + void + sendPingRequest(const aap_protobuf::service::control::message::PingRequest &request, + SendPromise::Pointer promise) override; + + void + sendPingResponse(const aap_protobuf::service::control::message::PingResponse &response, + SendPromise::Pointer promise) override; + + private: using std::enable_shared_from_this::shared_from_this; - void messageHandler(messenger::Message::Pointer message, IControlServiceChannelEventHandler::Pointer eventHandler); - - void handleVersionResponse(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler); - void handleServiceDiscoveryRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler); - void handleAudioFocusRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler); - void handleShutdownRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler); - void handleShutdownResponse(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler); - void handleNavigationFocusRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler); - void handlePingRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler); - void handlePingResponse(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler); - void handleVoiceSessionRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler); -}; + + // Internal Message Handlers + + void + messageHandler(messenger::Message::Pointer message, IControlServiceChannelEventHandler::Pointer eventHandler); + + void handleVersionResponse(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler); + + void handleServiceDiscoveryRequest(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler); + + void handleAudioFocusRequest(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler); + + void handleShutdownRequest(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler); + + void handleShutdownResponse(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler); + + void handleNavigationFocusRequest(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler); + + void handlePingRequest(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler); + + void handlePingResponse(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler); + + void handleVoiceSessionRequest(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler); + + void handleBatteryStatusNotification(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler); + }; } -} -} + + diff --git a/include/aasdk/Channel/Control/IControlServiceChannel.hpp b/include/aasdk/Channel/Control/IControlServiceChannel.hpp index e1cbe26f..d2a208c5 100644 --- a/include/aasdk/Channel/Control/IControlServiceChannel.hpp +++ b/include/aasdk/Channel/Control/IControlServiceChannel.hpp @@ -1,66 +1,92 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include #include -namespace aasdk -{ -namespace channel -{ -namespace control -{ +namespace aasdk::channel::control { -class IControlServiceChannel -{ -public: + class IControlServiceChannel : public virtual IChannel { + public: typedef std::shared_ptr Pointer; IControlServiceChannel() = default; + virtual ~IControlServiceChannel() = default; virtual void receive(IControlServiceChannelEventHandler::Pointer eventHandler) = 0; virtual void sendVersionRequest(SendPromise::Pointer promise) = 0; + virtual void sendHandshake(common::Data handshakeBuffer, SendPromise::Pointer promise) = 0; - virtual void sendAuthComplete(const proto::messages::AuthCompleteIndication& response, SendPromise::Pointer promise) = 0; - virtual void sendServiceDiscoveryResponse(const proto::messages::ServiceDiscoveryResponse& response, SendPromise::Pointer promise) = 0; - virtual void sendAudioFocusResponse(const proto::messages::AudioFocusResponse& response, SendPromise::Pointer promise) = 0; - virtual void sendShutdownRequest(const proto::messages::ShutdownRequest& request, SendPromise::Pointer promise) = 0; - virtual void sendShutdownResponse(const proto::messages::ShutdownResponse& response, SendPromise::Pointer promise) = 0; - virtual void sendNavigationFocusResponse(const proto::messages::NavigationFocusResponse& response, SendPromise::Pointer promise) = 0; - virtual void sendPingRequest(const proto::messages::PingRequest& request, SendPromise::Pointer promise) = 0; - virtual void sendPingResponse(const proto::messages::PingResponse& response, SendPromise::Pointer promise) = 0; -}; + virtual void sendAuthComplete(const aap_protobuf::service::control::message::AuthResponse &response, + SendPromise::Pointer promise) = 0; + + virtual void sendServiceDiscoveryResponse( + const aap_protobuf::service::control::message::ServiceDiscoveryResponse &response, + SendPromise::Pointer promise) = 0; + + virtual void + sendAudioFocusResponse( + const aap_protobuf::service::control::message::AudioFocusNotification &response, + SendPromise::Pointer promise) = 0; + + virtual void + sendShutdownRequest(const aap_protobuf::service::control::message::ByeByeRequest &request, + SendPromise::Pointer promise) = 0; + + virtual void + sendShutdownResponse(const aap_protobuf::service::control::message::ByeByeResponse &response, + SendPromise::Pointer promise) = 0; + + virtual void + sendNavigationFocusResponse( + const aap_protobuf::service::control::message::NavFocusNotification &response, + SendPromise::Pointer promise) = 0; + + virtual void + sendVoiceSessionFocusResponse(const aap_protobuf::service::control::message::VoiceSessionNotification &response, + SendPromise::Pointer promise) = 0; + + virtual void + sendPingRequest(const aap_protobuf::service::control::message::PingRequest &request, SendPromise::Pointer promise) = 0; + + virtual void + sendPingResponse(const aap_protobuf::service::control::message::PingResponse &response, + SendPromise::Pointer promise) = 0; + }; } -} -} + + diff --git a/include/aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp b/include/aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp index d0bf0b8e..99032d73 100644 --- a/include/aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp +++ b/include/aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp @@ -1,65 +1,76 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -namespace aasdk -{ -namespace channel -{ -namespace control -{ - -class IControlServiceChannelEventHandler -{ -public: +#include +#include +#include +#include +#include +#include +#include +#include + +namespace aasdk::channel::control { + + class IControlServiceChannelEventHandler { + public: typedef std::shared_ptr Pointer; IControlServiceChannelEventHandler() = default; + virtual ~IControlServiceChannelEventHandler() = default; - virtual void onVersionResponse(uint16_t majorCode, uint16_t minorCode, proto::enums::VersionResponseStatus::Enum status) = 0; - virtual void onHandshake(const common::DataConstBuffer& payload) = 0; - virtual void onServiceDiscoveryRequest(const proto::messages::ServiceDiscoveryRequest& request) = 0; - virtual void onAudioFocusRequest(const proto::messages::AudioFocusRequest& request) = 0; - virtual void onShutdownRequest(const proto::messages::ShutdownRequest& request) = 0; - virtual void onShutdownResponse(const proto::messages::ShutdownResponse& response) = 0; - virtual void onNavigationFocusRequest(const proto::messages::NavigationFocusRequest& request) = 0; - virtual void onPingRequest(const proto::messages::PingRequest& request) = 0; - virtual void onPingResponse(const proto::messages::PingResponse& response) = 0; - virtual void onChannelError(const error::Error& e) = 0; - virtual void onVoiceSessionRequest(const proto::messages::VoiceSessionRequest& request) = 0; -}; + virtual void onVersionResponse(uint16_t majorCode, uint16_t minorCode, + aap_protobuf::shared::MessageStatus status) = 0; + virtual void onHandshake(const common::DataConstBuffer &payload) = 0; + + virtual void onServiceDiscoveryRequest( + const aap_protobuf::service::control::message::ServiceDiscoveryRequest &request) = 0; + + virtual void + onAudioFocusRequest(const aap_protobuf::service::control::message::AudioFocusRequest &request) = 0; + + virtual void onByeByeRequest(const aap_protobuf::service::control::message::ByeByeRequest &request) = 0; + + virtual void + onByeByeResponse(const aap_protobuf::service::control::message::ByeByeResponse &response) = 0; + + virtual void onBatteryStatusNotification(const aap_protobuf::service::control::message::BatteryStatusNotification ¬ification) = 0; + + virtual void + onNavigationFocusRequest( + const aap_protobuf::service::control::message::NavFocusRequestNotification &request) = 0; + + virtual void + onVoiceSessionRequest(const aap_protobuf::service::control::message::VoiceSessionNotification &request) = 0; + + virtual void onPingRequest(const aap_protobuf::service::control::message::PingRequest &request) = 0; + + virtual void onPingResponse(const aap_protobuf::service::control::message::PingResponse &response) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + + + }; } -} -} + + diff --git a/include/aasdk/Channel/GenericNotification/GenericNotificationService.hpp b/include/aasdk/Channel/GenericNotification/GenericNotificationService.hpp new file mode 100644 index 00000000..d0fc49e1 --- /dev/null +++ b/include/aasdk/Channel/GenericNotification/GenericNotificationService.hpp @@ -0,0 +1,56 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/Channel.hpp" +#include "IGenericNotificationService.hpp" + + +namespace aasdk::channel::genericnotification { + + + class GenericNotificationService + : public IGenericNotificationService, + public Channel, + public std::enable_shared_from_this { + public: + GenericNotificationService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + + // Senders and Receivers + + void receive(IGenericNotificationServiceEventHandler::Pointer eventHandler) override; + + void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) override; + + + private: + using std::enable_shared_from_this::shared_from_this; + + // Internal Message Handlers + + void + messageHandler(messenger::Message::Pointer message, IGenericNotificationServiceEventHandler::Pointer eventHandler); + + void handleChannelOpenRequest(const common::DataConstBuffer &payload, + IGenericNotificationServiceEventHandler::Pointer eventHandler); + + }; + +} diff --git a/include/aasdk/Channel/GenericNotification/IGenericNotificationService.hpp b/include/aasdk/Channel/GenericNotification/IGenericNotificationService.hpp new file mode 100644 index 00000000..b5510786 --- /dev/null +++ b/include/aasdk/Channel/GenericNotification/IGenericNotificationService.hpp @@ -0,0 +1,45 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include +#include "IGenericNotificationServiceEventHandler.hpp" + +namespace aasdk::channel::genericnotification { + + class IGenericNotificationService : public virtual IChannel { + public: + typedef std::shared_ptr Pointer; + + IGenericNotificationService() = default; + + virtual ~IGenericNotificationService() = default; + + virtual void receive(IGenericNotificationServiceEventHandler::Pointer eventHandler) = 0; + + virtual void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) = 0; + + }; +} diff --git a/include/aasdk/Channel/GenericNotification/IGenericNotificationServiceEventHandler.hpp b/include/aasdk/Channel/GenericNotification/IGenericNotificationServiceEventHandler.hpp new file mode 100644 index 00000000..2e0b4651 --- /dev/null +++ b/include/aasdk/Channel/GenericNotification/IGenericNotificationServiceEventHandler.hpp @@ -0,0 +1,40 @@ +// 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) +// +// 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 . + +#pragma once + + +#include +#include "aasdk/Error/Error.hpp" + +namespace aasdk::channel::genericnotification { + + + class IGenericNotificationServiceEventHandler { + public: + typedef std::shared_ptr Pointer; + + IGenericNotificationServiceEventHandler() = default; + + virtual ~IGenericNotificationServiceEventHandler() = default; + + virtual void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + }; + +} diff --git a/include/aasdk/Channel/IChannel.hpp b/include/aasdk/Channel/IChannel.hpp new file mode 100644 index 00000000..8cca9591 --- /dev/null +++ b/include/aasdk/Channel/IChannel.hpp @@ -0,0 +1,37 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Messenger/ChannelId.hpp" +#include "aasdk/Channel/Promise.hpp" + +namespace aasdk::channel { + + class IChannel { + public: + IChannel() = default; + + virtual ~IChannel() = default; + + virtual messenger::ChannelId getId() const = 0; + + virtual void send(messenger::Message::Pointer message, SendPromise::Pointer promise) = 0; + + }; +} diff --git a/include/aasdk/Channel/Input/IInputServiceChannel.hpp b/include/aasdk/Channel/Input/IInputServiceChannel.hpp deleted file mode 100644 index d626a884..00000000 --- a/include/aasdk/Channel/Input/IInputServiceChannel.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace input -{ - -class IInputServiceChannel -{ -public: - typedef std::shared_ptr Pointer; - - IInputServiceChannel() = default; - virtual ~IInputServiceChannel() = default; - - virtual void receive(IInputServiceChannelEventHandler::Pointer eventHandler) = 0; - virtual void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) = 0; - virtual void sendInputEventIndication(const proto::messages::InputEventIndication& indication, SendPromise::Pointer promise) = 0; - virtual void sendBindingResponse(const proto::messages::BindingResponse& response, SendPromise::Pointer promise) = 0; - virtual messenger::ChannelId getId() const = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/Input/IInputServiceChannelEventHandler.hpp b/include/aasdk/Channel/Input/IInputServiceChannelEventHandler.hpp deleted file mode 100644 index 5a0ae7b8..00000000 --- a/include/aasdk/Channel/Input/IInputServiceChannelEventHandler.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace input -{ - -class IInputServiceChannelEventHandler -{ -public: - typedef std::shared_ptr Pointer; - - IInputServiceChannelEventHandler() = default; - virtual ~IInputServiceChannelEventHandler() = default; - - virtual void onChannelOpenRequest(const proto::messages::ChannelOpenRequest& request) = 0; - virtual void onBindingRequest(const proto::messages::BindingRequest& request) = 0; - virtual void onChannelError(const error::Error& e) = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/Input/InputServiceChannel.hpp b/include/aasdk/Channel/Input/InputServiceChannel.hpp deleted file mode 100644 index 75706fc5..00000000 --- a/include/aasdk/Channel/Input/InputServiceChannel.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace input -{ - -class InputServiceChannel: public IInputServiceChannel, public ServiceChannel, public std::enable_shared_from_this -{ - public: - InputServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger); - - void receive(IInputServiceChannelEventHandler::Pointer eventHandler) override; - void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) override; - void sendInputEventIndication(const proto::messages::InputEventIndication& indication, SendPromise::Pointer promise) override; - void sendBindingResponse(const proto::messages::BindingResponse& response, SendPromise::Pointer promise) override; - messenger::ChannelId getId() const override; - -private: - using std::enable_shared_from_this::shared_from_this; - void messageHandler(messenger::Message::Pointer message, IInputServiceChannelEventHandler::Pointer eventHandler); - void handleBindingRequest(const common::DataConstBuffer& payload, IInputServiceChannelEventHandler::Pointer eventHandler); - void handleChannelOpenRequest(const common::DataConstBuffer& payload, IInputServiceChannelEventHandler::Pointer eventHandler); -}; - -} -} -} diff --git a/include/aasdk/Channel/InputSource/IInputSourceService.hpp b/include/aasdk/Channel/InputSource/IInputSourceService.hpp new file mode 100644 index 00000000..2acbb2ed --- /dev/null +++ b/include/aasdk/Channel/InputSource/IInputSourceService.hpp @@ -0,0 +1,55 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include +#include +#include +#include "IInputSourceServiceEventHandler.hpp" + + +namespace aasdk::channel::inputsource { + class IInputSourceService : public virtual IChannel { + public: + typedef std::shared_ptr Pointer; + + IInputSourceService() = default; + + virtual ~IInputSourceService() = default; + + virtual void receive(IInputSourceServiceEventHandler::Pointer eventHandler) = 0; + + virtual void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) = 0; + + virtual void sendInputReport(const aap_protobuf::service::inputsource::message::InputReport &indication, + SendPromise::Pointer promise) = 0; + + virtual void sendKeyBindingResponse(const aap_protobuf::service::media::sink::message::KeyBindingResponse &response, + SendPromise::Pointer promise) = 0; + }; + +} + + diff --git a/include/aasdk/Channel/InputSource/IInputSourceServiceEventHandler.hpp b/include/aasdk/Channel/InputSource/IInputSourceServiceEventHandler.hpp new file mode 100644 index 00000000..392d4797 --- /dev/null +++ b/include/aasdk/Channel/InputSource/IInputSourceServiceEventHandler.hpp @@ -0,0 +1,43 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include +#include + +namespace aasdk::channel::inputsource { + + class IInputSourceServiceEventHandler { + public: + typedef std::shared_ptr Pointer; + + IInputSourceServiceEventHandler() = default; + + virtual ~IInputSourceServiceEventHandler() = default; + + virtual void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) = 0; + + virtual void onKeyBindingRequest(const aap_protobuf::service::media::sink::message::KeyBindingRequest &request) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + }; + +} + + diff --git a/include/aasdk/Channel/InputSource/InputSourceService.hpp b/include/aasdk/Channel/InputSource/InputSourceService.hpp new file mode 100644 index 00000000..c4cb0456 --- /dev/null +++ b/include/aasdk/Channel/InputSource/InputSourceService.hpp @@ -0,0 +1,60 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/Channel.hpp" +#include "IInputSourceService.hpp" + +namespace aasdk::channel::inputsource { + + class InputSourceService + : public IInputSourceService, public Channel, public std::enable_shared_from_this { + public: + InputSourceService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + + // Senders and Receivers + + void receive(IInputSourceServiceEventHandler::Pointer eventHandler) override; + + void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) override; + + void sendInputReport(const aap_protobuf::service::inputsource::message::InputReport &indication, + SendPromise::Pointer promise) override; + + void sendKeyBindingResponse(const aap_protobuf::service::media::sink::message::KeyBindingResponse &response, + SendPromise::Pointer promise) override; + + private: + using std::enable_shared_from_this::shared_from_this; + + // Internal Message Handlers + + void messageHandler(messenger::Message::Pointer message, IInputSourceServiceEventHandler::Pointer eventHandler); + + void + handleKeyBindingRequest(const common::DataConstBuffer &payload, IInputSourceServiceEventHandler::Pointer eventHandler); + + void handleChannelOpenRequest(const common::DataConstBuffer &payload, + IInputSourceServiceEventHandler::Pointer eventHandler); + }; + +} + + diff --git a/include/aasdk/Channel/MediaBrowser/IMediaBrowserService.hpp b/include/aasdk/Channel/MediaBrowser/IMediaBrowserService.hpp new file mode 100644 index 00000000..d3fad433 --- /dev/null +++ b/include/aasdk/Channel/MediaBrowser/IMediaBrowserService.hpp @@ -0,0 +1,44 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include "IMediaBrowserServiceEventHandler.hpp" + +namespace aasdk::channel::mediabrowser { + + class IMediaBrowserService : public virtual IChannel { + public: + typedef std::shared_ptr Pointer; + + IMediaBrowserService() = default; + + virtual ~IMediaBrowserService() = default; + + virtual void receive(IMediaBrowserServiceEventHandler::Pointer eventHandler) = 0; + + virtual void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) = 0; + + }; +} diff --git a/include/aasdk/Channel/MediaBrowser/IMediaBrowserServiceEventHandler.hpp b/include/aasdk/Channel/MediaBrowser/IMediaBrowserServiceEventHandler.hpp new file mode 100644 index 00000000..d1a9f2ba --- /dev/null +++ b/include/aasdk/Channel/MediaBrowser/IMediaBrowserServiceEventHandler.hpp @@ -0,0 +1,40 @@ +// 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) +// +// 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 . + +#pragma once + + +#include +#include "aasdk/Error/Error.hpp" + +namespace aasdk::channel::mediabrowser { + + + class IMediaBrowserServiceEventHandler { + public: + typedef std::shared_ptr Pointer; + + IMediaBrowserServiceEventHandler() = default; + + virtual ~IMediaBrowserServiceEventHandler() = default; + + virtual void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + }; + +} diff --git a/include/aasdk/Channel/MediaBrowser/MediaBrowserService.hpp b/include/aasdk/Channel/MediaBrowser/MediaBrowserService.hpp new file mode 100644 index 00000000..86cde368 --- /dev/null +++ b/include/aasdk/Channel/MediaBrowser/MediaBrowserService.hpp @@ -0,0 +1,53 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/Channel.hpp" +#include "IMediaBrowserService.hpp" + + +namespace aasdk::channel::mediabrowser { + + + class MediaBrowserService + : public IMediaBrowserService, public Channel, public std::enable_shared_from_this { + public: + MediaBrowserService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + + // Senders and Receivers + + void receive(IMediaBrowserServiceEventHandler::Pointer eventHandler) override; + + void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) override; + + + private: + using std::enable_shared_from_this::shared_from_this; + + // Internal Message Handlers + + void messageHandler(messenger::Message::Pointer message, IMediaBrowserServiceEventHandler::Pointer eventHandler); + + void handleChannelOpenRequest(const common::DataConstBuffer &payload, + IMediaBrowserServiceEventHandler::Pointer eventHandler); + + }; + +} diff --git a/include/aasdk/Channel/MediaPlaybackStatus/IMediaPlaybackStatusService.hpp b/include/aasdk/Channel/MediaPlaybackStatus/IMediaPlaybackStatusService.hpp new file mode 100644 index 00000000..a16f79d2 --- /dev/null +++ b/include/aasdk/Channel/MediaPlaybackStatus/IMediaPlaybackStatusService.hpp @@ -0,0 +1,45 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include "IMediaPlaybackStatusServiceEventHandler.hpp" + + +namespace aasdk::channel::mediaplaybackstatus { + + class IMediaPlaybackStatusService : public virtual IChannel { + public: + typedef std::shared_ptr Pointer; + + IMediaPlaybackStatusService() = default; + + virtual ~IMediaPlaybackStatusService() = default; + + virtual void receive(IMediaPlaybackStatusServiceEventHandler::Pointer eventHandler) = 0; + + virtual void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) = 0; + }; + +} diff --git a/include/aasdk/Channel/MediaPlaybackStatus/IMediaPlaybackStatusServiceEventHandler.hpp b/include/aasdk/Channel/MediaPlaybackStatus/IMediaPlaybackStatusServiceEventHandler.hpp new file mode 100644 index 00000000..14083443 --- /dev/null +++ b/include/aasdk/Channel/MediaPlaybackStatus/IMediaPlaybackStatusServiceEventHandler.hpp @@ -0,0 +1,49 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include +#include +#include "aasdk/Error/Error.hpp" + + +namespace aasdk::channel::mediaplaybackstatus { + + class IMediaPlaybackStatusServiceEventHandler { + public: + typedef std::shared_ptr Pointer; + + IMediaPlaybackStatusServiceEventHandler() = default; + + virtual ~IMediaPlaybackStatusServiceEventHandler() = default; + + virtual void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + + virtual void + onMetadataUpdate(const aap_protobuf::service::mediaplayback::message::MediaPlaybackMetadata &metadata) = 0; + + virtual void + onPlaybackUpdate(const aap_protobuf::service::mediaplayback::message::MediaPlaybackStatus &playback) = 0; + }; + +} + + diff --git a/include/aasdk/Channel/MediaPlaybackStatus/MediaPlaybackStatusService.hpp b/include/aasdk/Channel/MediaPlaybackStatus/MediaPlaybackStatusService.hpp new file mode 100644 index 00000000..75085594 --- /dev/null +++ b/include/aasdk/Channel/MediaPlaybackStatus/MediaPlaybackStatusService.hpp @@ -0,0 +1,62 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/Channel.hpp" +#include "IMediaPlaybackStatusService.hpp" + + +namespace aasdk::channel::mediaplaybackstatus { + + + class MediaPlaybackStatusService + : public IMediaPlaybackStatusService, + public Channel, + public std::enable_shared_from_this { + public: + MediaPlaybackStatusService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + + // Senders and Receivers + + void receive(IMediaPlaybackStatusServiceEventHandler::Pointer eventHandler) override; + + void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) override; + + private: + using std::enable_shared_from_this::shared_from_this; + + // Internal Message Handlers + + void + messageHandler(messenger::Message::Pointer message, IMediaPlaybackStatusServiceEventHandler::Pointer eventHandler); + + void handleChannelOpenRequest(const common::DataConstBuffer &payload, + IMediaPlaybackStatusServiceEventHandler::Pointer eventHandler); + + void handleMetadataUpdate(const common::DataConstBuffer &payload, + IMediaPlaybackStatusServiceEventHandler::Pointer eventHandler); + + void handlePlaybackUpdate(const common::DataConstBuffer &payload, + IMediaPlaybackStatusServiceEventHandler::Pointer eventHandler); + + }; + +} + diff --git a/include/aasdk/Channel/MediaSink/Audio/AudioMediaSinkService.hpp b/include/aasdk/Channel/MediaSink/Audio/AudioMediaSinkService.hpp new file mode 100644 index 00000000..30a3d4d8 --- /dev/null +++ b/include/aasdk/Channel/MediaSink/Audio/AudioMediaSinkService.hpp @@ -0,0 +1,82 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Messenger/MessageId.hpp" +#include "aasdk/Channel/Channel.hpp" +#include "IAudioMediaSinkService.hpp" + +namespace aasdk::channel::mediasink::audio { + + class AudioMediaSinkService + : public IAudioMediaSinkService, public Channel, public std::enable_shared_from_this { + public: + AudioMediaSinkService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger, + messenger::ChannelId channelId); + + // Senders and Receivers + + void receive(IAudioMediaSinkServiceEventHandler::Pointer eventHandler) override; + + void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) override; + + void + sendChannelSetupResponse(const aap_protobuf::service::media::shared::message::Config &response, + SendPromise::Pointer promise) override; + + void + sendMediaAckIndication( + const aap_protobuf::service::media::source::message::Ack &indication, + SendPromise::Pointer promise) override; + + + protected: + void registerMessageHandler(int messageId, + std::function handler); + + private: + using std::enable_shared_from_this::shared_from_this; + + // Internal Message Handlers + std::unordered_map> messageHandlers_; + + void messageHandler(messenger::Message::Pointer message, IAudioMediaSinkServiceEventHandler::Pointer eventHandler); + + void handleChannelSetupRequest(const common::DataConstBuffer &payload, + IAudioMediaSinkServiceEventHandler::Pointer eventHandler); + + void + handleStartIndication(const common::DataConstBuffer &payload, + IAudioMediaSinkServiceEventHandler::Pointer eventHandler); + + void + handleStopIndication(const common::DataConstBuffer &payload, + IAudioMediaSinkServiceEventHandler::Pointer eventHandler); + + void handleChannelOpenRequest(const common::DataConstBuffer &payload, + IAudioMediaSinkServiceEventHandler::Pointer eventHandler); + + void handleMediaWithTimestampIndication(const common::DataConstBuffer &payload, + IAudioMediaSinkServiceEventHandler::Pointer eventHandler); + + }; +} \ No newline at end of file diff --git a/include/aasdk/Channel/MediaSink/Audio/Channel/GuidanceAudioChannel.hpp b/include/aasdk/Channel/MediaSink/Audio/Channel/GuidanceAudioChannel.hpp new file mode 100644 index 00000000..8b7f339f --- /dev/null +++ b/include/aasdk/Channel/MediaSink/Audio/Channel/GuidanceAudioChannel.hpp @@ -0,0 +1,30 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/MediaSink/Audio/AudioMediaSinkService.hpp" + +namespace aasdk::channel::mediasink::audio::channel { + using aasdk::channel::mediasink::audio::AudioMediaSinkService; + + + class GuidanceAudioChannel : public AudioMediaSinkService { + public: + GuidanceAudioChannel(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + }; +} diff --git a/include/aasdk/Channel/MediaSink/Audio/Channel/MediaAudioChannel.hpp b/include/aasdk/Channel/MediaSink/Audio/Channel/MediaAudioChannel.hpp new file mode 100644 index 00000000..09f7add9 --- /dev/null +++ b/include/aasdk/Channel/MediaSink/Audio/Channel/MediaAudioChannel.hpp @@ -0,0 +1,30 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/MediaSink/Audio/AudioMediaSinkService.hpp" + +namespace aasdk::channel::mediasink::audio::channel { + using aasdk::channel::mediasink::audio::AudioMediaSinkService; + + + class MediaAudioChannel : public AudioMediaSinkService { + public: + MediaAudioChannel(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + }; +} diff --git a/include/aasdk/Channel/MediaSink/Audio/Channel/SystemAudioChannel.hpp b/include/aasdk/Channel/MediaSink/Audio/Channel/SystemAudioChannel.hpp new file mode 100644 index 00000000..38fe1bc7 --- /dev/null +++ b/include/aasdk/Channel/MediaSink/Audio/Channel/SystemAudioChannel.hpp @@ -0,0 +1,30 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/MediaSink/Audio/AudioMediaSinkService.hpp" + +namespace aasdk::channel::mediasink::audio::channel { + using aasdk::channel::mediasink::audio::AudioMediaSinkService; + + + class SystemAudioChannel : public AudioMediaSinkService { + public: + SystemAudioChannel(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + }; +} diff --git a/include/aasdk/Channel/MediaSink/Audio/Channel/TelephonyAudioChannel.hpp b/include/aasdk/Channel/MediaSink/Audio/Channel/TelephonyAudioChannel.hpp new file mode 100644 index 00000000..93505796 --- /dev/null +++ b/include/aasdk/Channel/MediaSink/Audio/Channel/TelephonyAudioChannel.hpp @@ -0,0 +1,35 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/MediaSink/Audio/AudioMediaSinkService.hpp" + +namespace aasdk::channel::mediasink::audio::channel { + using aasdk::channel::mediasink::audio::AudioMediaSinkService; + + + class TelephonyAudioChannel : public AudioMediaSinkService { + public: + TelephonyAudioChannel(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + }; +} + + + + + diff --git a/include/aasdk/Channel/MediaSink/Audio/IAudioMediaSinkService.hpp b/include/aasdk/Channel/MediaSink/Audio/IAudioMediaSinkService.hpp new file mode 100644 index 00000000..f11d77f2 --- /dev/null +++ b/include/aasdk/Channel/MediaSink/Audio/IAudioMediaSinkService.hpp @@ -0,0 +1,62 @@ + +// 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) +// +// 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 . + +#pragma once + +#include +#include "IAudioMediaSinkServiceEventHandler.hpp" +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include +#include +#include +#include +#include + +namespace aasdk::channel::mediasink::audio { + + class IAudioMediaSinkService : public virtual IChannel { + public: + typedef std::shared_ptr Pointer; + + IAudioMediaSinkService() = default; + + virtual ~IAudioMediaSinkService() = default; + + virtual void receive(IAudioMediaSinkServiceEventHandler::Pointer eventHandler) = 0; + + virtual void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) = 0; + + virtual void + sendChannelSetupResponse(const aap_protobuf::service::media::shared::message::Config &response, + SendPromise::Pointer promise) = 0; + + virtual void + sendMediaAckIndication( + const aap_protobuf::service::media::source::message::Ack &indication, + SendPromise::Pointer promise) = 0; + + }; + +} + + diff --git a/include/aasdk/Channel/MediaSink/Audio/IAudioMediaSinkServiceEventHandler.hpp b/include/aasdk/Channel/MediaSink/Audio/IAudioMediaSinkServiceEventHandler.hpp new file mode 100644 index 00000000..d40e9a1c --- /dev/null +++ b/include/aasdk/Channel/MediaSink/Audio/IAudioMediaSinkServiceEventHandler.hpp @@ -0,0 +1,60 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include +#include +#include +#include +#include +#include "aasdk/Messenger/Timestamp.hpp" +#include "aasdk/Common/Data.hpp" +#include "aasdk/Error/Error.hpp" +#include + +namespace aasdk::channel::mediasink::audio { + + class IAudioMediaSinkServiceEventHandler { + public: + typedef std::shared_ptr Pointer; + + IAudioMediaSinkServiceEventHandler() = default; + + virtual ~IAudioMediaSinkServiceEventHandler() = default; + + virtual void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) = 0; + + virtual void onMediaChannelSetupRequest(const aap_protobuf::service::media::shared::message::Setup &request) = 0; + + virtual void onMediaChannelStartIndication(const aap_protobuf::service::media::shared::message::Start &indication) = 0; + + virtual void onMediaChannelStopIndication(const aap_protobuf::service::media::shared::message::Stop &indication) = 0; + + virtual void + onMediaWithTimestampIndication(messenger::Timestamp::ValueType, const common::DataConstBuffer &buffer) = 0; + + virtual void onMediaIndication(const common::DataConstBuffer &buffer) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + + }; + +} + + diff --git a/include/aasdk/Channel/MediaSink/Video/Channel/VideoChannel.hpp b/include/aasdk/Channel/MediaSink/Video/Channel/VideoChannel.hpp new file mode 100644 index 00000000..c4e13982 --- /dev/null +++ b/include/aasdk/Channel/MediaSink/Video/Channel/VideoChannel.hpp @@ -0,0 +1,30 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/MediaSink/Video/VideoMediaSinkService.hpp" + +namespace aasdk::channel::mediasink::video::channel { + using aasdk::channel::mediasink::video::VideoMediaSinkService; + + + class VideoChannel : public VideoMediaSinkService { + public: + VideoChannel(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + }; +} diff --git a/include/aasdk/Channel/MediaSink/Video/IVideoMediaSinkService.hpp b/include/aasdk/Channel/MediaSink/Video/IVideoMediaSinkService.hpp new file mode 100644 index 00000000..1118ce82 --- /dev/null +++ b/include/aasdk/Channel/MediaSink/Video/IVideoMediaSinkService.hpp @@ -0,0 +1,69 @@ + +// 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) +// +// 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 . + +#pragma once + +#include +#include "IVideoMediaSinkServiceEventHandler.hpp" +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include +#include +#include +#include +#include + +namespace aasdk::channel::mediasink::video { + + class IVideoMediaSinkService : public virtual IChannel { + public: + typedef std::shared_ptr Pointer; + + IVideoMediaSinkService() = default; + + virtual ~IVideoMediaSinkService() = default; + + virtual void receive(IVideoMediaSinkServiceEventHandler::Pointer eventHandler) = 0; + + virtual void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) = 0; + + virtual void + sendChannelSetupResponse(const aap_protobuf::service::media::shared::message::Config &response, + SendPromise::Pointer promise) = 0; + + virtual void + sendMediaAckIndication( + const aap_protobuf::service::media::source::message::Ack &indication, + SendPromise::Pointer promise) = 0; + + virtual void + sendVideoFocusIndication( + const aap_protobuf::service::media::video::message::VideoFocusNotification &indication, + SendPromise::Pointer promise) = 0; + + }; + +} + + + + diff --git a/include/aasdk/Channel/MediaSink/Video/IVideoMediaSinkServiceEventHandler.hpp b/include/aasdk/Channel/MediaSink/Video/IVideoMediaSinkServiceEventHandler.hpp new file mode 100644 index 00000000..09d498b4 --- /dev/null +++ b/include/aasdk/Channel/MediaSink/Video/IVideoMediaSinkServiceEventHandler.hpp @@ -0,0 +1,62 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include +#include +#include +#include +#include +#include "aasdk/Messenger/Timestamp.hpp" +#include "aasdk/Common/Data.hpp" +#include "aasdk/Error/Error.hpp" +#include + +namespace aasdk::channel::mediasink::video { + + class IVideoMediaSinkServiceEventHandler { + public: + typedef std::shared_ptr Pointer; + + IVideoMediaSinkServiceEventHandler() = default; + + virtual ~IVideoMediaSinkServiceEventHandler() = default; + + virtual void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) = 0; + + virtual void onMediaChannelSetupRequest(const aap_protobuf::service::media::shared::message::Setup &request) = 0; + + virtual void onMediaChannelStartIndication(const aap_protobuf::service::media::shared::message::Start &indication) = 0; + + virtual void onMediaChannelStopIndication(const aap_protobuf::service::media::shared::message::Stop &indication) = 0; + + virtual void + onMediaWithTimestampIndication(messenger::Timestamp::ValueType, const common::DataConstBuffer &buffer) = 0; + + virtual void onMediaIndication(const common::DataConstBuffer &buffer) = 0; + + virtual void onVideoFocusRequest( + const aap_protobuf::service::media::video::message::VideoFocusRequestNotification &request) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + }; + +} + + diff --git a/include/aasdk/Channel/MediaSink/Video/VideoMediaSinkService.hpp b/include/aasdk/Channel/MediaSink/Video/VideoMediaSinkService.hpp new file mode 100644 index 00000000..fdfd8bb0 --- /dev/null +++ b/include/aasdk/Channel/MediaSink/Video/VideoMediaSinkService.hpp @@ -0,0 +1,92 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Messenger/MessageId.hpp" +#include "aasdk/Channel/Channel.hpp" +#include "IVideoMediaSinkService.hpp" +#include + +namespace aasdk::channel::mediasink::video { + + class VideoMediaSinkService + : public IVideoMediaSinkService, public Channel, public std::enable_shared_from_this { + public: + VideoMediaSinkService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger, + messenger::ChannelId channelId); + + // Senders and Receivers + + void receive(IVideoMediaSinkServiceEventHandler::Pointer eventHandler) override; + + void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) override; + + void + sendChannelSetupResponse(const aap_protobuf::service::media::shared::message::Config &response, + SendPromise::Pointer promise) override; + + void + sendMediaAckIndication( + const aap_protobuf::service::media::source::message::Ack &indication, + SendPromise::Pointer promise) override; + + void sendVideoFocusIndication( + const aap_protobuf::service::media::video::message::VideoFocusNotification &indication, + SendPromise::Pointer promise) override; + + protected: + void registerMessageHandler(int messageId, + std::function handler); + + private: + using std::enable_shared_from_this::shared_from_this; + + // Internal Message Handlers + std::unordered_map> messageHandlers_; + + void messageHandler(messenger::Message::Pointer message, IVideoMediaSinkServiceEventHandler::Pointer eventHandler); + + void handleChannelSetupRequest(const common::DataConstBuffer &payload, + IVideoMediaSinkServiceEventHandler::Pointer eventHandler); + + void + handleStartIndication(const common::DataConstBuffer &payload, + IVideoMediaSinkServiceEventHandler::Pointer eventHandler); + + void + handleStopIndication(const common::DataConstBuffer &payload, + IVideoMediaSinkServiceEventHandler::Pointer eventHandler); + + void handleChannelOpenRequest(const common::DataConstBuffer &payload, + IVideoMediaSinkServiceEventHandler::Pointer eventHandler); + + void handleMediaWithTimestampIndication(const common::DataConstBuffer &payload, + IVideoMediaSinkServiceEventHandler::Pointer eventHandler); + + void handleVideoFocusRequest(const common::DataConstBuffer &payload, + IVideoMediaSinkServiceEventHandler::Pointer eventHandler); + + }; + +} + + diff --git a/include/aasdk/Channel/MediaSource/Audio/MicrophoneAudioChannel.hpp b/include/aasdk/Channel/MediaSource/Audio/MicrophoneAudioChannel.hpp new file mode 100644 index 00000000..ab13545a --- /dev/null +++ b/include/aasdk/Channel/MediaSource/Audio/MicrophoneAudioChannel.hpp @@ -0,0 +1,33 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/MediaSource/MediaSourceService.hpp" + +namespace aasdk::channel::mediasource::audio { + + class MicrophoneAudioChannel : public MediaSourceService { + public: + MicrophoneAudioChannel(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + }; +} + + + + + diff --git a/include/aasdk/Channel/MediaSource/IMediaSourceService.hpp b/include/aasdk/Channel/MediaSource/IMediaSourceService.hpp new file mode 100644 index 00000000..dcd47b7b --- /dev/null +++ b/include/aasdk/Channel/MediaSource/IMediaSourceService.hpp @@ -0,0 +1,62 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include +#include +#include +#include +#include +#include "aasdk/Messenger/Timestamp.hpp" +#include "IMediaSourceServiceEventHandler.hpp" + + +namespace aasdk::channel::mediasource { + + class IMediaSourceService : public virtual IChannel { + public: + typedef std::shared_ptr Pointer; + + IMediaSourceService() = default; + + virtual ~IMediaSourceService() = default; + + virtual void receive(IMediaSourceServiceEventHandler::Pointer eventHandler) = 0; + + virtual void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) = 0; + + virtual void + sendChannelSetupResponse(const aap_protobuf::service::media::shared::message::Config &response, + SendPromise::Pointer promise) = 0; + + virtual void sendMediaSourceWithTimestampIndication(messenger::Timestamp::ValueType, const common::Data &data, + SendPromise::Pointer promise) = 0; + + virtual void + sendMicrophoneOpenResponse(const aap_protobuf::service::media::source::message::MicrophoneResponse &response, + SendPromise::Pointer promise) = 0; + }; + +} diff --git a/include/aasdk/Channel/MediaSource/IMediaSourceServiceEventHandler.hpp b/include/aasdk/Channel/MediaSource/IMediaSourceServiceEventHandler.hpp new file mode 100644 index 00000000..00e861b7 --- /dev/null +++ b/include/aasdk/Channel/MediaSource/IMediaSourceServiceEventHandler.hpp @@ -0,0 +1,56 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include "aasdk/Error/Error.hpp" + + +namespace aasdk::channel::mediasource { + + class IMediaSourceServiceEventHandler { + public: + typedef std::shared_ptr Pointer; + + IMediaSourceServiceEventHandler() = default; + + virtual ~IMediaSourceServiceEventHandler() = default; + + virtual void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) = 0; + + virtual void onMediaChannelSetupRequest(const aap_protobuf::service::media::shared::message::Setup &request) = 0; + + virtual void + onMediaSourceOpenRequest(const aap_protobuf::service::media::source::message::MicrophoneRequest &request) = 0; + + virtual void + onMediaChannelAckIndication( + const aap_protobuf::service::media::source::message::Ack &indication) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + }; + +} + + diff --git a/include/aasdk/Channel/MediaSource/MediaSourceService.hpp b/include/aasdk/Channel/MediaSource/MediaSourceService.hpp new file mode 100644 index 00000000..7aea9785 --- /dev/null +++ b/include/aasdk/Channel/MediaSource/MediaSourceService.hpp @@ -0,0 +1,74 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Messenger/MessageId.hpp" +#include "aasdk/Messenger/Timestamp.hpp" +#include "aasdk/Channel/Channel.hpp" +#include "IMediaSourceService.hpp" + + +namespace aasdk::channel::mediasource { + + class MediaSourceService + : public IMediaSourceService, public Channel, public std::enable_shared_from_this { + public: + MediaSourceService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger, + messenger::ChannelId channelId); + + // Senders and Receivers + + void receive(IMediaSourceServiceEventHandler::Pointer eventHandler) override; + + void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) override; + + void + sendChannelSetupResponse(const aap_protobuf::service::media::shared::message::Config &response, + SendPromise::Pointer promise) override; + + void sendMicrophoneOpenResponse(const aap_protobuf::service::media::source::message::MicrophoneResponse &response, + SendPromise::Pointer promise) override; + + void sendMediaSourceWithTimestampIndication(messenger::Timestamp::ValueType, const common::Data &data, + SendPromise::Pointer promise) override; + + private: + using std::enable_shared_from_this::shared_from_this; + + // Internal Message Handlers + + void messageHandler(messenger::Message::Pointer message, IMediaSourceServiceEventHandler::Pointer eventHandler); + + void handleAVChannelSetupRequest(const common::DataConstBuffer &payload, + IMediaSourceServiceEventHandler::Pointer eventHandler); + + void handleAVInputOpenRequest(const common::DataConstBuffer &payload, + IMediaSourceServiceEventHandler::Pointer eventHandler); + + void handleAVMediaAckIndication(const common::DataConstBuffer &payload, + IMediaSourceServiceEventHandler::Pointer eventHandler); + + void handleChannelOpenRequest(const common::DataConstBuffer &payload, + IMediaSourceServiceEventHandler::Pointer eventHandler); + }; + +} + + diff --git a/include/aasdk/Channel/Navigation/INavigationStatusServiceChannel.hpp b/include/aasdk/Channel/Navigation/INavigationStatusServiceChannel.hpp deleted file mode 100644 index 87c49104..00000000 --- a/include/aasdk/Channel/Navigation/INavigationStatusServiceChannel.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace navigation -{ - -class INavigationStatusServiceChannel -{ -public: - typedef std::shared_ptr Pointer; - - INavigationStatusServiceChannel() = default; - virtual ~INavigationStatusServiceChannel() = default; - - virtual void receive(INavigationStatusServiceChannelEventHandler::Pointer eventHandler) = 0; - virtual void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) = 0; - virtual messenger::ChannelId getId() const = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/Navigation/INavigationStatusServiceChannelEventHandler.hpp b/include/aasdk/Channel/Navigation/INavigationStatusServiceChannelEventHandler.hpp deleted file mode 100644 index 8c9a1a53..00000000 --- a/include/aasdk/Channel/Navigation/INavigationStatusServiceChannelEventHandler.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace navigation -{ - -class INavigationStatusServiceChannelEventHandler -{ -public: - typedef std::shared_ptr Pointer; - - INavigationStatusServiceChannelEventHandler() = default; - virtual ~INavigationStatusServiceChannelEventHandler() = default; - - virtual void onChannelOpenRequest(const proto::messages::ChannelOpenRequest& request) = 0; - virtual void onChannelError(const error::Error& e) = 0; - virtual void onStatusUpdate(const proto::messages::NavigationStatus& navStatus) = 0; - virtual void onTurnEvent(const proto::messages::NavigationTurnEvent& turnEvent) = 0; - virtual void onDistanceEvent(const proto::messages::NavigationDistanceEvent& distanceEvent) = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/Navigation/NavigationStatusServiceChannel.hpp b/include/aasdk/Channel/Navigation/NavigationStatusServiceChannel.hpp deleted file mode 100644 index b74b9747..00000000 --- a/include/aasdk/Channel/Navigation/NavigationStatusServiceChannel.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace navigation -{ - -class NavigationStatusServiceChannel: public INavigationStatusServiceChannel, public ServiceChannel, public std::enable_shared_from_this -{ -public: - NavigationStatusServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger); - - void receive(INavigationStatusServiceChannelEventHandler::Pointer eventHandler) override; - messenger::ChannelId getId() const override; - void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) override; - -private: - using std::enable_shared_from_this::shared_from_this; - void messageHandler(messenger::Message::Pointer message, INavigationStatusServiceChannelEventHandler::Pointer eventHandler); - void handleChannelOpenRequest(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler); - void handleStatusUpdate(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler); - void handleTurnEvent(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler); - void handleDistanceEvent(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler); -}; - -} -} -} diff --git a/include/aasdk/Channel/NavigationStatus/INavigationStatusService.hpp b/include/aasdk/Channel/NavigationStatus/INavigationStatusService.hpp new file mode 100644 index 00000000..6ee32e53 --- /dev/null +++ b/include/aasdk/Channel/NavigationStatus/INavigationStatusService.hpp @@ -0,0 +1,45 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include "INavigationStatusServiceEventHandler.hpp" + + +namespace aasdk::channel::navigationstatus { + + class INavigationStatusService : public virtual IChannel { + public: + typedef std::shared_ptr Pointer; + + INavigationStatusService() = default; + + virtual ~INavigationStatusService() = default; + + virtual void receive(INavigationStatusServiceEventHandler::Pointer eventHandler) = 0; + + virtual void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) = 0; + }; + +} diff --git a/include/aasdk/Channel/NavigationStatus/INavigationStatusServiceEventHandler.hpp b/include/aasdk/Channel/NavigationStatus/INavigationStatusServiceEventHandler.hpp new file mode 100644 index 00000000..2d03f8b0 --- /dev/null +++ b/include/aasdk/Channel/NavigationStatus/INavigationStatusServiceEventHandler.hpp @@ -0,0 +1,50 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include +#include +#include +#include "aasdk/Error/Error.hpp" + +namespace aasdk::channel::navigationstatus { + + class INavigationStatusServiceEventHandler { + public: + typedef std::shared_ptr Pointer; + + INavigationStatusServiceEventHandler() = default; + + virtual ~INavigationStatusServiceEventHandler() = default; + + virtual void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + + virtual void onStatusUpdate(const aap_protobuf::service::navigationstatus::message::NavigationStatus &navStatus) = 0; + + virtual void onTurnEvent(const aap_protobuf::service::navigationstatus::message::NavigationNextTurnEvent &turnEvent) = 0; + + virtual void + onDistanceEvent(const aap_protobuf::service::navigationstatus::message::NavigationNextTurnDistanceEvent &distanceEvent) = 0; + }; + +} + + diff --git a/include/aasdk/Channel/NavigationStatus/NavigationStatusService.hpp b/include/aasdk/Channel/NavigationStatus/NavigationStatusService.hpp new file mode 100644 index 00000000..bab1da1f --- /dev/null +++ b/include/aasdk/Channel/NavigationStatus/NavigationStatusService.hpp @@ -0,0 +1,60 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/Channel.hpp" +#include "INavigationStatusService.hpp" + + +namespace aasdk::channel::navigationstatus { + + + class NavigationStatusService + : public INavigationStatusService, public Channel, public std::enable_shared_from_this { + public: + NavigationStatusService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + + // Senders and Receivers + + void receive(INavigationStatusServiceEventHandler::Pointer eventHandler) override; + + void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) override; + + private: + using std::enable_shared_from_this::shared_from_this; + + void + messageHandler(messenger::Message::Pointer message, INavigationStatusServiceEventHandler::Pointer eventHandler); + + void handleChannelOpenRequest(const common::DataConstBuffer &payload, + INavigationStatusServiceEventHandler::Pointer eventHandler); + + void handleStatusUpdate(const common::DataConstBuffer &payload, + INavigationStatusServiceEventHandler::Pointer eventHandler); + + void + handleTurnEvent(const common::DataConstBuffer &payload, INavigationStatusServiceEventHandler::Pointer eventHandler); + + void handleDistanceEvent(const common::DataConstBuffer &payload, + INavigationStatusServiceEventHandler::Pointer eventHandler); + }; + +} + diff --git a/include/aasdk/Channel/PhoneStatus/IPhoneStatusService.hpp b/include/aasdk/Channel/PhoneStatus/IPhoneStatusService.hpp new file mode 100644 index 00000000..ba86d475 --- /dev/null +++ b/include/aasdk/Channel/PhoneStatus/IPhoneStatusService.hpp @@ -0,0 +1,45 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include +#include "IPhoneStatusServiceEventHandler.hpp" + +namespace aasdk::channel::phonestatus { + + class IPhoneStatusService : public virtual IChannel { + public: + typedef std::shared_ptr Pointer; + + IPhoneStatusService() = default; + + virtual ~IPhoneStatusService() = default; + + virtual void receive(IPhoneStatusServiceEventHandler::Pointer eventHandler) = 0; + + virtual void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) = 0; + + }; +} diff --git a/include/aasdk/Channel/PhoneStatus/IPhoneStatusServiceEventHandler.hpp b/include/aasdk/Channel/PhoneStatus/IPhoneStatusServiceEventHandler.hpp new file mode 100644 index 00000000..ee412c66 --- /dev/null +++ b/include/aasdk/Channel/PhoneStatus/IPhoneStatusServiceEventHandler.hpp @@ -0,0 +1,40 @@ +// 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) +// +// 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 . + +#pragma once + + +#include +#include "aasdk/Error/Error.hpp" + +namespace aasdk::channel::phonestatus { + + + class IPhoneStatusServiceEventHandler { + public: + typedef std::shared_ptr Pointer; + + IPhoneStatusServiceEventHandler() = default; + + virtual ~IPhoneStatusServiceEventHandler() = default; + + virtual void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + }; + +} diff --git a/include/aasdk/Channel/PhoneStatus/PhoneStatusService.hpp b/include/aasdk/Channel/PhoneStatus/PhoneStatusService.hpp new file mode 100644 index 00000000..732805c2 --- /dev/null +++ b/include/aasdk/Channel/PhoneStatus/PhoneStatusService.hpp @@ -0,0 +1,53 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/Channel.hpp" +#include "IPhoneStatusService.hpp" + + +namespace aasdk::channel::phonestatus { + + + class PhoneStatusService + : public IPhoneStatusService, public Channel, public std::enable_shared_from_this { + public: + PhoneStatusService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + + // Senders and Receivers + + void receive(IPhoneStatusServiceEventHandler::Pointer eventHandler) override; + + void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) override; + + + private: + using std::enable_shared_from_this::shared_from_this; + + // Internal Message Handlers + + void messageHandler(messenger::Message::Pointer message, IPhoneStatusServiceEventHandler::Pointer eventHandler); + + void handleChannelOpenRequest(const common::DataConstBuffer &payload, + IPhoneStatusServiceEventHandler::Pointer eventHandler); + + }; + +} diff --git a/include/aasdk/Channel/Promise.hpp b/include/aasdk/Channel/Promise.hpp index dab17d45..7d2d1196 100644 --- a/include/aasdk/Channel/Promise.hpp +++ b/include/aasdk/Channel/Promise.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -22,12 +21,10 @@ #include -namespace aasdk -{ -namespace channel -{ +namespace aasdk { + namespace channel { -typedef io::Promise SendPromise; + typedef io::Promise SendPromise; -} + } } diff --git a/include/aasdk/Channel/Radio/IRadioService.hpp b/include/aasdk/Channel/Radio/IRadioService.hpp new file mode 100644 index 00000000..6790b439 --- /dev/null +++ b/include/aasdk/Channel/Radio/IRadioService.hpp @@ -0,0 +1,44 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include "IRadioServiceEventHandler.hpp" + +namespace aasdk::channel::radio { + + class IRadioService : public virtual IChannel { + public: + typedef std::shared_ptr Pointer; + + IRadioService() = default; + + virtual ~IRadioService() = default; + + virtual void receive(IRadioServiceEventHandler::Pointer eventHandler) = 0; + + virtual void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) = 0; + + }; +} diff --git a/include/aasdk/Channel/Radio/IRadioServiceEventHandler.hpp b/include/aasdk/Channel/Radio/IRadioServiceEventHandler.hpp new file mode 100644 index 00000000..8ca9143f --- /dev/null +++ b/include/aasdk/Channel/Radio/IRadioServiceEventHandler.hpp @@ -0,0 +1,39 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Error/Error.hpp" + +namespace aasdk::channel::radio { + + + class IRadioServiceEventHandler { + public: + typedef std::shared_ptr Pointer; + + IRadioServiceEventHandler() = default; + + virtual ~IRadioServiceEventHandler() = default; + + virtual void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + }; + +} diff --git a/include/aasdk/Channel/Radio/RadioService.hpp b/include/aasdk/Channel/Radio/RadioService.hpp new file mode 100644 index 00000000..6ace1801 --- /dev/null +++ b/include/aasdk/Channel/Radio/RadioService.hpp @@ -0,0 +1,50 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/Channel.hpp" +#include "IRadioService.hpp" + +namespace aasdk::channel::radio { + + + class RadioService + : public IRadioService, public Channel, public std::enable_shared_from_this { + public: + RadioService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + + // Senders and Receivers + + void receive(IRadioServiceEventHandler::Pointer eventHandler) override; + + void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) override; + + + private: + using std::enable_shared_from_this::shared_from_this; + + void messageHandler(messenger::Message::Pointer message, IRadioServiceEventHandler::Pointer eventHandler); + + void handleChannelOpenRequest(const common::DataConstBuffer &payload, + IRadioServiceEventHandler::Pointer eventHandler); + + }; + +} diff --git a/include/aasdk/Channel/Sensor/ISensorServiceChannel.hpp b/include/aasdk/Channel/Sensor/ISensorServiceChannel.hpp deleted file mode 100644 index b2a403c7..00000000 --- a/include/aasdk/Channel/Sensor/ISensorServiceChannel.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace sensor -{ - -class ISensorServiceChannel -{ -public: - typedef std::shared_ptr Pointer; - - ISensorServiceChannel() = default; - virtual ~ISensorServiceChannel() = default; - - virtual void receive(ISensorServiceChannelEventHandler::Pointer eventHandler) = 0; - virtual messenger::ChannelId getId() const = 0; - virtual void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) = 0; - virtual void sendSensorEventIndication(const proto::messages::SensorEventIndication& indication, SendPromise::Pointer promise) = 0; - virtual void sendSensorStartResponse(const proto::messages::SensorStartResponseMessage& response, SendPromise::Pointer promise) = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/Sensor/ISensorServiceChannelEventHandler.hpp b/include/aasdk/Channel/Sensor/ISensorServiceChannelEventHandler.hpp deleted file mode 100644 index 407a1e22..00000000 --- a/include/aasdk/Channel/Sensor/ISensorServiceChannelEventHandler.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace sensor -{ - -class ISensorServiceChannelEventHandler -{ -public: - typedef std::shared_ptr Pointer; - - ISensorServiceChannelEventHandler() = default; - virtual ~ISensorServiceChannelEventHandler() = default; - - virtual void onChannelOpenRequest(const proto::messages::ChannelOpenRequest& request) = 0; - virtual void onSensorStartRequest(const proto::messages::SensorStartRequestMessage& request) = 0; - virtual void onChannelError(const error::Error& e) = 0; -}; - -} -} -} diff --git a/include/aasdk/Channel/Sensor/SensorServiceChannel.hpp b/include/aasdk/Channel/Sensor/SensorServiceChannel.hpp deleted file mode 100644 index c7154b38..00000000 --- a/include/aasdk/Channel/Sensor/SensorServiceChannel.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace sensor -{ - -class SensorServiceChannel: public ISensorServiceChannel, public ServiceChannel, public std::enable_shared_from_this -{ -public: - SensorServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger); - - void receive(ISensorServiceChannelEventHandler::Pointer eventHandler) override; - messenger::ChannelId getId() const override; - void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) override; - void sendSensorEventIndication(const proto::messages::SensorEventIndication& indication, SendPromise::Pointer promise) override; - void sendSensorStartResponse(const proto::messages::SensorStartResponseMessage& response, SendPromise::Pointer promise) override; - -private: - using std::enable_shared_from_this::shared_from_this; - void messageHandler(messenger::Message::Pointer message, ISensorServiceChannelEventHandler::Pointer eventHandler); - void handleSensorStartRequest(const common::DataConstBuffer& payload, ISensorServiceChannelEventHandler::Pointer eventHandler); - void handleChannelOpenRequest(const common::DataConstBuffer& payload, ISensorServiceChannelEventHandler::Pointer eventHandler); -}; - -} -} -} diff --git a/include/aasdk/Channel/SensorSource/ISensorSourceService.hpp b/include/aasdk/Channel/SensorSource/ISensorSourceService.hpp new file mode 100644 index 00000000..f1776573 --- /dev/null +++ b/include/aasdk/Channel/SensorSource/ISensorSourceService.hpp @@ -0,0 +1,55 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include +#include +#include "ISensorSourceServiceEventHandler.hpp" + +namespace aasdk::channel::sensorsource { + + class ISensorSourceService : public virtual IChannel { + public: + typedef std::shared_ptr Pointer; + + ISensorSourceService() = default; + + virtual ~ISensorSourceService() = default; + + virtual void receive(ISensorSourceServiceEventHandler::Pointer eventHandler) = 0; + + virtual void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) = 0; + + virtual void sendSensorEventIndication(const aap_protobuf::service::sensorsource::message::SensorBatch &indication, + SendPromise::Pointer promise) = 0; + + virtual void + sendSensorStartResponse(const aap_protobuf::service::sensorsource::message::SensorStartResponseMessage &response, + SendPromise::Pointer promise) = 0; + }; + +} + + diff --git a/include/aasdk/Channel/SensorSource/ISensorSourceServiceEventHandler.hpp b/include/aasdk/Channel/SensorSource/ISensorSourceServiceEventHandler.hpp new file mode 100644 index 00000000..8262e18a --- /dev/null +++ b/include/aasdk/Channel/SensorSource/ISensorSourceServiceEventHandler.hpp @@ -0,0 +1,43 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include +#include "aasdk/Error/Error.hpp" + +namespace aasdk::channel::sensorsource { + + class ISensorSourceServiceEventHandler { + public: + typedef std::shared_ptr Pointer; + + ISensorSourceServiceEventHandler() = default; + + virtual ~ISensorSourceServiceEventHandler() = default; + + virtual void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) = 0; + + virtual void onSensorStartRequest(const aap_protobuf::service::sensorsource::message::SensorRequest &request) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + }; + +} + + diff --git a/include/aasdk/Channel/SensorSource/SensorSourceService.hpp b/include/aasdk/Channel/SensorSource/SensorSourceService.hpp new file mode 100644 index 00000000..6bbd6192 --- /dev/null +++ b/include/aasdk/Channel/SensorSource/SensorSourceService.hpp @@ -0,0 +1,57 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/Channel.hpp" +#include "ISensorSourceService.hpp" + +namespace aasdk::channel::sensorsource { + + class SensorSourceService : public ISensorSourceService, public Channel, public std::enable_shared_from_this { + public: + SensorSourceService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + + // Senders and Receivers + + void receive(ISensorSourceServiceEventHandler::Pointer eventHandler) override; + + void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) override; + + void sendSensorEventIndication(const aap_protobuf::service::sensorsource::message::SensorBatch &indication, + SendPromise::Pointer promise) override; + + void sendSensorStartResponse(const aap_protobuf::service::sensorsource::message::SensorStartResponseMessage &response, + SendPromise::Pointer promise) override; + + private: + using std::enable_shared_from_this::shared_from_this; + + // Internal Message Handlers + + void messageHandler(messenger::Message::Pointer message, ISensorSourceServiceEventHandler::Pointer eventHandler); + + void + handleSensorStartRequest(const common::DataConstBuffer &payload, ISensorSourceServiceEventHandler::Pointer eventHandler); + + void + handleChannelOpenRequest(const common::DataConstBuffer &payload, ISensorSourceServiceEventHandler::Pointer eventHandler); + }; + +} diff --git a/include/aasdk/Channel/ServiceChannel.hpp b/include/aasdk/Channel/ServiceChannel.hpp deleted file mode 100644 index b24fd438..00000000 --- a/include/aasdk/Channel/ServiceChannel.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once - -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ - -class ServiceChannel -{ -protected: - ServiceChannel(boost::asio::io_service::strand& strand, - messenger::IMessenger::Pointer messenger, - messenger::ChannelId channelId); - - virtual ~ServiceChannel() = default; - void send(messenger::Message::Pointer message, SendPromise::Pointer promise); - - boost::asio::io_service::strand& strand_; - messenger::IMessenger::Pointer messenger_; - messenger::ChannelId channelId_; -}; - -} -} diff --git a/include/aasdk/Channel/VendorExtension/IVendorExtensionService.hpp b/include/aasdk/Channel/VendorExtension/IVendorExtensionService.hpp new file mode 100644 index 00000000..5ae2680d --- /dev/null +++ b/include/aasdk/Channel/VendorExtension/IVendorExtensionService.hpp @@ -0,0 +1,45 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include +#include "IVendorExtensionServiceEventHandler.hpp" + +namespace aasdk::channel::vendorextension { + + class IVendorExtensionService : public virtual IChannel { + public: + typedef std::shared_ptr Pointer; + + IVendorExtensionService() = default; + + virtual ~IVendorExtensionService() = default; + + virtual void receive(IVendorExtensionServiceEventHandler::Pointer eventHandler) = 0; + + virtual void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) = 0; + + }; +} diff --git a/include/aasdk/Channel/VendorExtension/IVendorExtensionServiceEventHandler.hpp b/include/aasdk/Channel/VendorExtension/IVendorExtensionServiceEventHandler.hpp new file mode 100644 index 00000000..2db6c6bb --- /dev/null +++ b/include/aasdk/Channel/VendorExtension/IVendorExtensionServiceEventHandler.hpp @@ -0,0 +1,40 @@ + +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Error/Error.hpp" + +namespace aasdk::channel::vendorextension { + + + class IVendorExtensionServiceEventHandler { + public: + typedef std::shared_ptr Pointer; + + IVendorExtensionServiceEventHandler() = default; + + virtual ~IVendorExtensionServiceEventHandler() = default; + + virtual void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + }; + +} diff --git a/include/aasdk/Channel/VendorExtension/VendorExtensionService.hpp b/include/aasdk/Channel/VendorExtension/VendorExtensionService.hpp new file mode 100644 index 00000000..8c127b1d --- /dev/null +++ b/include/aasdk/Channel/VendorExtension/VendorExtensionService.hpp @@ -0,0 +1,53 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/Channel.hpp" +#include "IVendorExtensionService.hpp" + + +namespace aasdk::channel::vendorextension { + + + class VendorExtensionService + : public IVendorExtensionService, public Channel, public std::enable_shared_from_this { + public: + VendorExtensionService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + + // Senders and Receivers + + void receive(IVendorExtensionServiceEventHandler::Pointer eventHandler) override; + + void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) override; + + + private: + using std::enable_shared_from_this::shared_from_this; + + // Internal Message Handlers + + void messageHandler(messenger::Message::Pointer message, IVendorExtensionServiceEventHandler::Pointer eventHandler); + + void handleChannelOpenRequest(const common::DataConstBuffer &payload, + IVendorExtensionServiceEventHandler::Pointer eventHandler); + + }; + +} diff --git a/include/aasdk/Channel/WifiProjection/IWifiProjectionService.hpp b/include/aasdk/Channel/WifiProjection/IWifiProjectionService.hpp new file mode 100644 index 00000000..42479f58 --- /dev/null +++ b/include/aasdk/Channel/WifiProjection/IWifiProjectionService.hpp @@ -0,0 +1,49 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include "aasdk/Channel/Promise.hpp" +#include "aasdk/Channel/IChannel.hpp" +#include "aasdk/Messenger/ChannelId.hpp" +#include +#include +#include "IWifiProjectionServiceEventHandler.hpp" + +namespace aasdk::channel::wifiprojection { + + class IWifiProjectionService : public virtual IChannel { + public: + typedef std::shared_ptr Pointer; + + IWifiProjectionService() = default; + + virtual ~IWifiProjectionService() = default; + + virtual void receive(IWifiProjectionServiceEventHandler::Pointer eventHandler) = 0; + + virtual void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) = 0; + + virtual void + sendWifiCredentialsResponse(const aap_protobuf::service::wifiprojection::message::WifiCredentialsResponse &response, + SendPromise::Pointer promise) = 0; + + }; +} diff --git a/include/aasdk/Channel/WifiProjection/IWifiProjectionServiceEventHandler.hpp b/include/aasdk/Channel/WifiProjection/IWifiProjectionServiceEventHandler.hpp new file mode 100644 index 00000000..8caf2621 --- /dev/null +++ b/include/aasdk/Channel/WifiProjection/IWifiProjectionServiceEventHandler.hpp @@ -0,0 +1,43 @@ +// 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) +// +// 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 . + +#pragma once + +#include +#include +#include "aasdk/Error/Error.hpp" + +namespace aasdk::channel::wifiprojection { + + + class IWifiProjectionServiceEventHandler { + public: + typedef std::shared_ptr Pointer; + + IWifiProjectionServiceEventHandler() = default; + + virtual ~IWifiProjectionServiceEventHandler() = default; + + virtual void + onWifiCredentialsRequest(const aap_protobuf::service::wifiprojection::message::WifiCredentialsRequest &request) = 0; + + virtual void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) = 0; + + virtual void onChannelError(const error::Error &e) = 0; + }; + +} diff --git a/include/aasdk/Channel/WifiProjection/WifiProjectionService.hpp b/include/aasdk/Channel/WifiProjection/WifiProjectionService.hpp new file mode 100644 index 00000000..c6f903a8 --- /dev/null +++ b/include/aasdk/Channel/WifiProjection/WifiProjectionService.hpp @@ -0,0 +1,59 @@ +// 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) +// +// 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 . + +#pragma once + +#include "aasdk/Channel/Channel.hpp" +#include "IWifiProjectionService.hpp" + + +namespace aasdk::channel::wifiprojection { + + + class WifiProjectionService + : public IWifiProjectionService, public Channel, public std::enable_shared_from_this { + public: + WifiProjectionService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger); + + // Senders and Receivers + + void receive(IWifiProjectionServiceEventHandler::Pointer eventHandler) override; + + void + sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) override; + + void + sendWifiCredentialsResponse(const aap_protobuf::service::wifiprojection::message::WifiCredentialsResponse &response, + SendPromise::Pointer promise) override; + + private: + using std::enable_shared_from_this::shared_from_this; + + // Internal Message Handlers + + void messageHandler(messenger::Message::Pointer message, IWifiProjectionServiceEventHandler::Pointer eventHandler); + + void handleWifiCredentialsRequest(const common::DataConstBuffer &payload, + IWifiProjectionServiceEventHandler::Pointer eventHandler); + + void handleChannelOpenRequest(const common::DataConstBuffer &payload, + IWifiProjectionServiceEventHandler::Pointer eventHandler); + + }; + +} diff --git a/include/aasdk/Common/Data.hpp b/include/aasdk/Common/Data.hpp index 507633ac..a2484e2d 100644 --- a/include/aasdk/Common/Data.hpp +++ b/include/aasdk/Common/Data.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -24,62 +23,68 @@ #include -namespace aasdk -{ -namespace common -{ - -typedef std::vector Data; - -static constexpr size_t cStaticDataSize = 30 * 1024 * 1024; - -struct DataBuffer -{ - DataBuffer(); - DataBuffer(Data::value_type* _data, Data::size_type _size, Data::size_type offset = 0); - DataBuffer(void* _data, Data::size_type _size, Data::size_type offset = 0); - explicit DataBuffer(Data& _data, Data::size_type offset = 0); - bool operator==(const std::nullptr_t&) const; - bool operator==(const DataBuffer& buffer) const; - - Data::value_type* data; - Data::size_type size; -}; - -struct DataConstBuffer -{ - DataConstBuffer(); - explicit DataConstBuffer(const DataBuffer& other); - DataConstBuffer(const Data::value_type* _data, Data::size_type _size, Data::size_type offset = 0); - DataConstBuffer(const void* _data, Data::size_type _size, Data::size_type offset = 0); - explicit DataConstBuffer(const Data& _data, Data::size_type offset = 0); - bool operator==(const std::nullptr_t&) const; - bool operator==(const DataConstBuffer& buffer) const; - - const Data::value_type* cdata; - Data::size_type size; -}; - -template -void copy(DataType& data, const DataBuffer& buffer) -{ - size_t offset = data.size(); - data.resize(data.size() + buffer.size); - memcpy(&data[offset], buffer.data, buffer.size); -} +namespace aasdk { + namespace common { -template -void copy(DataType& data, const DataConstBuffer& buffer) -{ - size_t offset = data.size(); - data.resize(data.size() + buffer.size); - memcpy(&data[offset], buffer.cdata, buffer.size); -} + typedef std::vector Data; -common::Data createData(const DataConstBuffer& buffer); + static constexpr size_t cStaticDataSize = 30 * 1024 * 1024; -std::string dump(const Data& data); -std::string dump(const DataConstBuffer& buffer); + struct DataBuffer { + DataBuffer(); -} + DataBuffer(Data::value_type *_data, Data::size_type _size, Data::size_type offset = 0); + + DataBuffer(void *_data, Data::size_type _size, Data::size_type offset = 0); + + explicit DataBuffer(Data &_data, Data::size_type offset = 0); + + bool operator==(const std::nullptr_t &) const; + + bool operator==(const DataBuffer &buffer) const; + + Data::value_type *data; + Data::size_type size; + }; + + struct DataConstBuffer { + DataConstBuffer(); + + explicit DataConstBuffer(const DataBuffer &other); + + DataConstBuffer(const Data::value_type *_data, Data::size_type _size, Data::size_type offset = 0); + + DataConstBuffer(const void *_data, Data::size_type _size, Data::size_type offset = 0); + + explicit DataConstBuffer(const Data &_data, Data::size_type offset = 0); + + bool operator==(const std::nullptr_t &) const; + + bool operator==(const DataConstBuffer &buffer) const; + + const Data::value_type *cdata; + Data::size_type size; + }; + + template + void copy(DataType &data, const DataBuffer &buffer) { + size_t offset = data.size(); + data.resize(data.size() + buffer.size); + memcpy(&data[offset], buffer.data, buffer.size); + } + + template + void copy(DataType &data, const DataConstBuffer &buffer) { + size_t offset = data.size(); + data.resize(data.size() + buffer.size); + memcpy(&data[offset], buffer.cdata, buffer.size); + } + + common::Data createData(const DataConstBuffer &buffer); + + std::string dump(const Data &data); + + std::string dump(const DataConstBuffer &buffer); + + } } diff --git a/include/aasdk/Common/Log.hpp b/include/aasdk/Common/Log.hpp index 6a7197f6..e31dc432 100644 --- a/include/aasdk/Common/Log.hpp +++ b/include/aasdk/Common/Log.hpp @@ -1,23 +1,22 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include -#define AASDK_LOG(severity) BOOST_LOG_TRIVIAL(severity) << "[AaSdk] " +#define AASDK_LOG(severity) BOOST_LOG_TRIVIAL(severity) << "[AASDK] " diff --git a/include/aasdk/Error/Error.hpp b/include/aasdk/Error/Error.hpp index 3ba441a4..ae811dca 100644 --- a/include/aasdk/Error/Error.hpp +++ b/include/aasdk/Error/Error.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -23,31 +22,34 @@ #include -namespace aasdk -{ -namespace error -{ +namespace aasdk { + namespace error { -class Error: public std::exception -{ -public: - Error(); - Error(ErrorCode code, uint32_t nativeCode = 0); + class Error : public std::exception { + public: + Error(); - ErrorCode getCode() const; - uint32_t getNativeCode() const; - const char* what() const noexcept override; + Error(ErrorCode code, uint32_t nativeCode = 0, std::string information = ""); - bool operator!() const; - bool operator==(const Error& other) const; - bool operator==(const ErrorCode& code) const; - bool operator!=(const ErrorCode& code) const; + ErrorCode getCode() const; -private: - ErrorCode code_; - uint32_t nativeCode_; - std::string message_; -}; + uint32_t getNativeCode() const; -} + const char *what() const noexcept override; + + bool operator!() const; + + bool operator==(const Error &other) const; + + bool operator==(const ErrorCode &code) const; + + bool operator!=(const ErrorCode &code) const; + + private: + ErrorCode code_; + uint32_t nativeCode_; + std::string message_; + std::string information_; + }; + } } diff --git a/include/aasdk/Error/ErrorCode.hpp b/include/aasdk/Error/ErrorCode.hpp index 67c5fd3f..160650ab 100644 --- a/include/aasdk/Error/ErrorCode.hpp +++ b/include/aasdk/Error/ErrorCode.hpp @@ -1,68 +1,64 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include -namespace aasdk -{ -namespace error -{ +namespace aasdk { + namespace error { -enum class ErrorCode -{ - NONE = 0, - USB_CLAIM_INTERFACE = 1, - USB_INVALID_CONFIG_DESCRIPTOR = 2, - USB_OBTAIN_INTERFACE_DESCRIPTOR = 3, - USB_EMPTY_INTERFACES = 4, - USB_INVALID_DEVICE_ENDPOINTS = 5, - USB_INVALID_TRANSFER_METHOD = 6, - USB_TRANSFER_ALLOCATION = 7, - USB_LIST_DEVICES = 8, - USB_OBTAIN_CONFIG_DESCRIPTOR = 9, - USB_TRANSFER = 10, - DATA_SINK_COMMIT_OVERFLOW = 11, - DATA_SINK_CONSUME_UNDERFLOW = 12, - USB_AOAP_PROTOCOL_VERSION = 13, - USB_AOAP_DEVICE_NOT_FOUND = 14, - SSL_READ_CERTIFICATE = 15, - SSL_READ_PRIVATE_KEY = 16, - SSL_METHOD = 17, - SSL_CONTEXT_CREATION = 18, - SSL_USE_CERTIFICATE = 19, - SSL_USE_PRIVATE_KEY = 20, - SSL_HANDLER_CREATION = 21, - SSL_READ_BIO_CREATION = 22, - SSL_WRITE_BIO_CREATION = 23, - SSL_HANDSHAKE = 24, - SSL_WRITE = 25, - SSL_READ = 26, - SSL_BIO_READ = 27, - SSL_BIO_WRITE = 28, - MESSENGER_INTERTWINED_CHANNELS = 29, - OPERATION_ABORTED = 30, - OPERATION_IN_PROGRESS = 31, - PARSE_PAYLOAD = 32, - TCP_TRANSFER = 33 -}; + enum class ErrorCode { + NONE = 0, + USB_CLAIM_INTERFACE = 1, + USB_INVALID_CONFIG_DESCRIPTOR = 2, + USB_OBTAIN_INTERFACE_DESCRIPTOR = 3, + USB_EMPTY_INTERFACES = 4, + USB_INVALID_DEVICE_ENDPOINTS = 5, + USB_INVALID_TRANSFER_METHOD = 6, + USB_TRANSFER_ALLOCATION = 7, + USB_LIST_DEVICES = 8, + USB_OBTAIN_CONFIG_DESCRIPTOR = 9, + USB_TRANSFER = 10, + DATA_SINK_COMMIT_OVERFLOW = 11, + DATA_SINK_CONSUME_UNDERFLOW = 12, + USB_AOAP_PROTOCOL_VERSION = 13, + USB_AOAP_DEVICE_NOT_FOUND = 14, + SSL_READ_CERTIFICATE = 15, + SSL_READ_PRIVATE_KEY = 16, + SSL_METHOD = 17, + SSL_CONTEXT_CREATION = 18, + SSL_USE_CERTIFICATE = 19, + SSL_USE_PRIVATE_KEY = 20, + SSL_HANDLER_CREATION = 21, + SSL_READ_BIO_CREATION = 22, + SSL_WRITE_BIO_CREATION = 23, + SSL_HANDSHAKE = 24, + SSL_WRITE = 25, + SSL_READ = 26, + SSL_BIO_READ = 27, + SSL_BIO_WRITE = 28, + MESSENGER_INTERTWINED_CHANNELS = 29, + OPERATION_ABORTED = 30, + OPERATION_IN_PROGRESS = 31, + PARSE_PAYLOAD = 32, + TCP_TRANSFER = 33 + }; -} + } } diff --git a/include/aasdk/IO/IOContextWrapper.hpp b/include/aasdk/IO/IOContextWrapper.hpp index cf813a08..031e0894 100644 --- a/include/aasdk/IO/IOContextWrapper.hpp +++ b/include/aasdk/IO/IOContextWrapper.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -22,51 +21,43 @@ #include -namespace aasdk -{ -namespace io -{ +namespace aasdk { + namespace io { -class IOContextWrapper -{ -public: - IOContextWrapper(); - explicit IOContextWrapper(boost::asio::io_service& ioService); - explicit IOContextWrapper(boost::asio::io_service::strand& strand); + class IOContextWrapper { + public: + IOContextWrapper(); - template - void post(CompletionHandlerType&& handler) - { - if(ioService_ != nullptr) - { - ioService_->post(std::move(handler)); - } - else if(strand_ != nullptr) - { - strand_->post(std::move(handler)); - } - } + explicit IOContextWrapper(boost::asio::io_service &ioService); - template - void dispatch(CompletionHandlerType&& handler) - { - if(ioService_ != nullptr) - { - ioService_->dispatch(std::move(handler)); + explicit IOContextWrapper(boost::asio::io_service::strand &strand); + + template + void post(CompletionHandlerType &&handler) { + if (ioService_ != nullptr) { + ioService_->post(std::move(handler)); + } else if (strand_ != nullptr) { + strand_->post(std::move(handler)); } - else if(strand_ != nullptr) - { - strand_->dispatch(std::move(handler)); + } + + template + void dispatch(CompletionHandlerType &&handler) { + if (ioService_ != nullptr) { + ioService_->dispatch(std::move(handler)); + } else if (strand_ != nullptr) { + strand_->dispatch(std::move(handler)); } - } + } + + void reset(); - void reset(); - bool isActive() const; + bool isActive() const; -private: - boost::asio::io_service* ioService_; - boost::asio::io_service::strand* strand_; -}; + private: + boost::asio::io_service *ioService_; + boost::asio::io_service::strand *strand_; + }; -} + } } \ No newline at end of file diff --git a/include/aasdk/IO/Promise.hpp b/include/aasdk/IO/Promise.hpp index 7ab0d94a..9f279262 100644 --- a/include/aasdk/IO/Promise.hpp +++ b/include/aasdk/IO/Promise.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -25,335 +24,291 @@ #include -namespace aasdk -{ -namespace io -{ +namespace aasdk { + namespace io { -template -class Promise: boost::noncopyable -{ -public: - typedef ResolveArgumentType ValueType; - typedef ErrorArgumentType ErrorType; - typedef std::function ResolveHandler; - typedef std::function RejectHandler; - typedef std::shared_ptr Pointer; + template + class Promise : boost::noncopyable { + public: + typedef ResolveArgumentType ValueType; + typedef ErrorArgumentType ErrorType; + typedef std::function ResolveHandler; + typedef std::function RejectHandler; + typedef std::shared_ptr Pointer; - static Pointer defer(boost::asio::io_service& ioService) - { + static Pointer defer(boost::asio::io_service &ioService) { return std::make_shared(ioService); - } + } - static Pointer defer(boost::asio::io_service::strand& strand) - { + static Pointer defer(boost::asio::io_service::strand &strand) { return std::make_shared(strand); - } + } - Promise(boost::asio::io_service& ioService) - : ioContextWrapper_(ioService) - { + Promise(boost::asio::io_service &ioService) + : ioContextWrapper_(ioService) { - } + } - Promise(boost::asio::io_service::strand& strand) - : ioContextWrapper_(strand) - { + Promise(boost::asio::io_service::strand &strand) + : ioContextWrapper_(strand) { - } + } - void then(ResolveHandler resolveHandler, RejectHandler rejectHandler = RejectHandler()) - { + void then(ResolveHandler resolveHandler, RejectHandler rejectHandler = RejectHandler()) { std::lock_guard lock(mutex_); resolveHandler_ = std::move(resolveHandler); rejectHandler_ = std::move(rejectHandler); - } + } - void resolve(ResolveArgumentType argument) - { + void resolve(ResolveArgumentType argument) { std::lock_guard lock(mutex_); - if(resolveHandler_ != nullptr && this->isPending()) - { - ioContextWrapper_.post([argument = std::move(argument), resolveHandler = std::move(resolveHandler_)]() mutable { + if (resolveHandler_ != nullptr && this->isPending()) { + ioContextWrapper_.post( + [argument = std::move(argument), resolveHandler = std::move(resolveHandler_)]() mutable { resolveHandler(std::move(argument)); - }); + }); } ioContextWrapper_.reset(); rejectHandler_ = RejectHandler(); - } + } - void reject(ErrorArgumentType error) - { + void reject(ErrorArgumentType error) { std::lock_guard lock(mutex_); - if(rejectHandler_ != nullptr && this->isPending()) - { - ioContextWrapper_.post([error = std::move(error), rejectHandler = std::move(rejectHandler_)]() mutable { - rejectHandler(std::move(error)); - }); + if (rejectHandler_ != nullptr && this->isPending()) { + ioContextWrapper_.post([error = std::move(error), rejectHandler = std::move(rejectHandler_)]() mutable { + rejectHandler(std::move(error)); + }); } ioContextWrapper_.reset(); resolveHandler_ = ResolveHandler(); - } + } -private: - bool isPending() const - { + private: + bool isPending() const { return ioContextWrapper_.isActive(); - } - - ResolveHandler resolveHandler_; - RejectHandler rejectHandler_; - IOContextWrapper ioContextWrapper_; - std::mutex mutex_; -}; - -template -class Promise: boost::noncopyable -{ -public: - typedef ErrorArgumentType ErrorType; - typedef std::function ResolveHandler; - typedef std::function RejectHandler; - typedef std::shared_ptr Pointer; - - static Pointer defer(boost::asio::io_service& ioService) - { + } + + ResolveHandler resolveHandler_; + RejectHandler rejectHandler_; + IOContextWrapper ioContextWrapper_; + std::mutex mutex_; + }; + + template + class Promise : boost::noncopyable { + public: + typedef ErrorArgumentType ErrorType; + typedef std::function ResolveHandler; + typedef std::function RejectHandler; + typedef std::shared_ptr Pointer; + + static Pointer defer(boost::asio::io_service &ioService) { return std::make_shared(ioService); - } + } - static Pointer defer(boost::asio::io_service::strand& strand) - { + static Pointer defer(boost::asio::io_service::strand &strand) { return std::make_shared(strand); - } + } - Promise(boost::asio::io_service& ioService) - : ioContextWrapper_(ioService) - { + Promise(boost::asio::io_service &ioService) + : ioContextWrapper_(ioService) { - } + } - Promise(boost::asio::io_service::strand& strand) - : ioContextWrapper_(strand) - { + Promise(boost::asio::io_service::strand &strand) + : ioContextWrapper_(strand) { - } + } - void then(ResolveHandler resolveHandler, RejectHandler rejectHandler = RejectHandler()) - { + void then(ResolveHandler resolveHandler, RejectHandler rejectHandler = RejectHandler()) { std::lock_guard lock(mutex_); resolveHandler_ = std::move(resolveHandler); rejectHandler_ = std::move(rejectHandler); - } + } - void resolve() - { + void resolve() { std::lock_guard lock(mutex_); - if(resolveHandler_ != nullptr && this->isPending()) - { - ioContextWrapper_.post([resolveHandler = std::move(resolveHandler_)]() mutable { - resolveHandler(); - }); + if (resolveHandler_ != nullptr && this->isPending()) { + ioContextWrapper_.post([resolveHandler = std::move(resolveHandler_)]() mutable { + resolveHandler(); + }); } ioContextWrapper_.reset(); rejectHandler_ = RejectHandler(); - } + } - void reject(ErrorArgumentType error) - { + void reject(ErrorArgumentType error) { std::lock_guard lock(mutex_); - if(rejectHandler_ != nullptr && this->isPending()) - { - ioContextWrapper_.post([error = std::move(error), rejectHandler = std::move(rejectHandler_)]() mutable { - rejectHandler(std::move(error)); - }); + if (rejectHandler_ != nullptr && this->isPending()) { + ioContextWrapper_.post([error = std::move(error), rejectHandler = std::move(rejectHandler_)]() mutable { + rejectHandler(std::move(error)); + }); } ioContextWrapper_.reset(); resolveHandler_ = ResolveHandler(); - } + } -private: - bool isPending() const - { + private: + bool isPending() const { return ioContextWrapper_.isActive(); - } - - ResolveHandler resolveHandler_; - RejectHandler rejectHandler_; - IOContextWrapper ioContextWrapper_; - std::mutex mutex_; -}; - -template<> -class Promise: boost::noncopyable -{ -public: - typedef std::function ResolveHandler; - typedef std::function RejectHandler; - typedef std::shared_ptr Pointer; - - static Pointer defer(boost::asio::io_service& ioService) - { + } + + ResolveHandler resolveHandler_; + RejectHandler rejectHandler_; + IOContextWrapper ioContextWrapper_; + std::mutex mutex_; + }; + + template<> + class Promise : boost::noncopyable { + public: + typedef std::function ResolveHandler; + typedef std::function RejectHandler; + typedef std::shared_ptr Pointer; + + static Pointer defer(boost::asio::io_service &ioService) { return std::make_shared(ioService); - } + } - static Pointer defer(boost::asio::io_service::strand& strand) - { + static Pointer defer(boost::asio::io_service::strand &strand) { return std::make_shared(strand); - } + } - Promise(boost::asio::io_service& ioService) - : ioContextWrapper_(ioService) - { + Promise(boost::asio::io_service &ioService) + : ioContextWrapper_(ioService) { - } + } - Promise(boost::asio::io_service::strand& strand) - : ioContextWrapper_(strand) - { + Promise(boost::asio::io_service::strand &strand) + : ioContextWrapper_(strand) { - } + } - void then(ResolveHandler resolveHandler, RejectHandler rejectHandler = RejectHandler()) - { + void then(ResolveHandler resolveHandler, RejectHandler rejectHandler = RejectHandler()) { std::lock_guard lock(mutex_); resolveHandler_ = std::move(resolveHandler); rejectHandler_ = std::move(rejectHandler); - } + } - void resolve() - { + void resolve() { std::lock_guard lock(mutex_); - if(resolveHandler_ != nullptr && this->isPending()) - { - ioContextWrapper_.post([resolveHandler = std::move(resolveHandler_)]() mutable { - resolveHandler(); - }); + if (resolveHandler_ != nullptr && this->isPending()) { + ioContextWrapper_.post([resolveHandler = std::move(resolveHandler_)]() mutable { + resolveHandler(); + }); } ioContextWrapper_.reset(); rejectHandler_ = RejectHandler(); - } + } - void reject() - { + void reject() { std::lock_guard lock(mutex_); - if(rejectHandler_ != nullptr && this->isPending()) - { - ioContextWrapper_.post([rejectHandler = std::move(rejectHandler_)]() mutable { - rejectHandler(); - }); + if (rejectHandler_ != nullptr && this->isPending()) { + ioContextWrapper_.post([rejectHandler = std::move(rejectHandler_)]() mutable { + rejectHandler(); + }); } ioContextWrapper_.reset(); resolveHandler_ = ResolveHandler(); - } + } -private: - bool isPending() const - { + private: + bool isPending() const { return ioContextWrapper_.isActive(); - } - - ResolveHandler resolveHandler_; - RejectHandler rejectHandler_; - IOContextWrapper ioContextWrapper_; - std::mutex mutex_; -}; - -template -class Promise: boost::noncopyable -{ -public: - typedef ResolveArgumentType ValueType; - typedef std::function ResolveHandler; - typedef std::function RejectHandler; - typedef std::shared_ptr Pointer; - - static Pointer defer(boost::asio::io_service& ioService) - { + } + + ResolveHandler resolveHandler_; + RejectHandler rejectHandler_; + IOContextWrapper ioContextWrapper_; + std::mutex mutex_; + }; + + template + class Promise : boost::noncopyable { + public: + typedef ResolveArgumentType ValueType; + typedef std::function ResolveHandler; + typedef std::function RejectHandler; + typedef std::shared_ptr Pointer; + + static Pointer defer(boost::asio::io_service &ioService) { return std::make_shared(ioService); - } + } - static Pointer defer(boost::asio::io_service::strand& strand) - { + static Pointer defer(boost::asio::io_service::strand &strand) { return std::make_shared(strand); - } + } - Promise(boost::asio::io_service& ioService) - : ioContextWrapper_(ioService) - { + Promise(boost::asio::io_service &ioService) + : ioContextWrapper_(ioService) { - } + } - Promise(boost::asio::io_service::strand& strand) - : ioContextWrapper_(strand) - { + Promise(boost::asio::io_service::strand &strand) + : ioContextWrapper_(strand) { - } + } - void then(ResolveHandler resolveHandler, RejectHandler rejectHandler = RejectHandler()) - { + void then(ResolveHandler resolveHandler, RejectHandler rejectHandler = RejectHandler()) { std::lock_guard lock(mutex_); resolveHandler_ = std::move(resolveHandler); rejectHandler_ = std::move(rejectHandler); - } + } - void resolve(ResolveArgumentType argument) - { + void resolve(ResolveArgumentType argument) { std::lock_guard lock(mutex_); - if(resolveHandler_ != nullptr && this->isPending()) - { - ioContextWrapper_.post([argument = std::move(argument), resolveHandler = std::move(resolveHandler_)]() mutable { + if (resolveHandler_ != nullptr && this->isPending()) { + ioContextWrapper_.post( + [argument = std::move(argument), resolveHandler = std::move(resolveHandler_)]() mutable { resolveHandler(std::move(argument)); - }); + }); } ioContextWrapper_.reset(); rejectHandler_ = RejectHandler(); - } + } - void reject() - { + void reject() { std::lock_guard lock(mutex_); - if(rejectHandler_ != nullptr && this->isPending()) - { - ioContextWrapper_.post([rejectHandler = std::move(rejectHandler_)]() mutable { - rejectHandler(); - }); + if (rejectHandler_ != nullptr && this->isPending()) { + ioContextWrapper_.post([rejectHandler = std::move(rejectHandler_)]() mutable { + rejectHandler(); + }); } ioContextWrapper_.reset(); resolveHandler_ = ResolveHandler(); - } + } -private: - bool isPending() const - { + private: + bool isPending() const { return ioContextWrapper_.isActive(); - } + } - ResolveHandler resolveHandler_; - RejectHandler rejectHandler_; - IOContextWrapper ioContextWrapper_; - std::mutex mutex_; -}; + ResolveHandler resolveHandler_; + RejectHandler rejectHandler_; + IOContextWrapper ioContextWrapper_; + std::mutex mutex_; + }; -} + } } diff --git a/include/aasdk/IO/PromiseLink.hpp b/include/aasdk/IO/PromiseLink.hpp index 1bba5997..6d5c6ff4 100644 --- a/include/aasdk/IO/PromiseLink.hpp +++ b/include/aasdk/IO/PromiseLink.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -24,107 +23,95 @@ #include -namespace aasdk -{ -namespace io -{ +namespace aasdk { + namespace io { -template -class PromiseLink: public std::enable_shared_from_this> -{ -public: - typedef std::shared_ptr> Pointer; - typedef std::function TransformFunctor; + template + class PromiseLink + : public std::enable_shared_from_this> { + public: + typedef std::shared_ptr> Pointer; + typedef std::function TransformFunctor; - PromiseLink(typename Promise::Pointer promise, TransformFunctor transformFunctor) - : promise_(std::move(promise)) - , transformFunctor_(std::make_shared(std::move(transformFunctor))) - { + PromiseLink(typename Promise::Pointer promise, TransformFunctor transformFunctor) + : promise_(std::move(promise)), + transformFunctor_(std::make_shared(std::move(transformFunctor))) { - } + } - static void forward(Promise& source, typename Promise::Pointer destination, - TransformFunctor transformFunctor = [](SourceResolveArgumentType&& argument) { return std::move(argument); }) - { - auto link = std::make_shared>(std::forward::Pointer>(destination), - std::forward(transformFunctor)); + static void forward(Promise &source, + typename Promise::Pointer destination, + TransformFunctor transformFunctor = []( + SourceResolveArgumentType &&argument) { return std::move(argument); }) { + auto link = std::make_shared>( + std::forward::Pointer>(destination), + std::forward(transformFunctor)); source.then(link->getResolveHandler(), link->getRejectHandler()); - } + } -private: - using std::enable_shared_from_this>::shared_from_this; + private: + using std::enable_shared_from_this>::shared_from_this; - void resolve(SourceResolveArgumentType argument) - { - if(transformFunctor_ != nullptr) - { - promise_->resolve((*transformFunctor_)(std::move(argument))); - transformFunctor_.reset(); + void resolve(SourceResolveArgumentType argument) { + if (transformFunctor_ != nullptr) { + promise_->resolve((*transformFunctor_)(std::move(argument))); + transformFunctor_.reset(); } - } + } - void reject(const error::Error& e) - { + void reject(const error::Error &e) { promise_->reject(e); - } + } - typename Promise::ResolveHandler getResolveHandler() - { + typename Promise::ResolveHandler getResolveHandler() { return std::bind(&PromiseLink::resolve, this->shared_from_this(), std::placeholders::_1); - } + } - typename Promise::RejectHandler getRejectHandler() - { + typename Promise::RejectHandler getRejectHandler() { return std::bind(&PromiseLink::reject, this->shared_from_this(), std::placeholders::_1); - } + } - typename Promise::Pointer promise_; - std::shared_ptr transformFunctor_; -}; + typename Promise::Pointer promise_; + std::shared_ptr transformFunctor_; + }; -template<> -class PromiseLink: public std::enable_shared_from_this> -{ -public: - typedef std::shared_ptr> Pointer; + template<> + class PromiseLink : public std::enable_shared_from_this> { + public: + typedef std::shared_ptr> Pointer; - PromiseLink(typename Promise::Pointer promise) - : promise_(std::move(promise)) - { + PromiseLink(typename Promise::Pointer promise) + : promise_(std::move(promise)) { - } + } - static void forward(Promise& source, typename Promise::Pointer destination) - { - auto link = std::make_shared>(std::forward::Pointer>(destination)); + static void forward(Promise &source, typename Promise::Pointer destination) { + auto link = std::make_shared>( + std::forward::Pointer>(destination)); source.then(link->getResolveHandler(), link->getRejectHandler()); - } + } -private: - using std::enable_shared_from_this>::shared_from_this; + private: + using std::enable_shared_from_this>::shared_from_this; - void resolve() - { + void resolve() { promise_->resolve(); - } + } - void reject(const error::Error& e) - { + void reject(const error::Error &e) { promise_->reject(e); - } + } - Promise::ResolveHandler getResolveHandler() - { + Promise::ResolveHandler getResolveHandler() { return std::bind(&PromiseLink::resolve, this->shared_from_this()); - } + } - Promise::RejectHandler getRejectHandler() - { + Promise::RejectHandler getRejectHandler() { return std::bind(&PromiseLink::reject, this->shared_from_this(), std::placeholders::_1); - } + } - typename Promise::Pointer promise_; -}; + typename Promise::Pointer promise_; + }; -} + } } diff --git a/include/aasdk/Messenger/ChannelId.hpp b/include/aasdk/Messenger/ChannelId.hpp index 29b70c91..85a0126f 100644 --- a/include/aasdk/Messenger/ChannelId.hpp +++ b/include/aasdk/Messenger/ChannelId.hpp @@ -1,48 +1,56 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include - -namespace aasdk -{ -namespace messenger -{ - -enum class ChannelId -{ +/* + * TODO: Switch to Dynamic ChannelId's - P5 + * In AA, Channel Id's are dynamic. We use ChannelId here for a static implementation, which, while acceptable, + * may cause more channels to be open than needs to be. OpenAuto should register a ChannelId and ChannelName + * (for debugging) with AASDK. + */ + +namespace aasdk::messenger { + enum class ChannelId { CONTROL, - INPUT, SENSOR, - VIDEO, - MEDIA_AUDIO, - SPEECH_AUDIO, - SYSTEM_AUDIO, - AV_INPUT, + MEDIA_SINK, + MEDIA_SINK_VIDEO, + MEDIA_SINK_MEDIA_AUDIO, + MEDIA_SINK_GUIDANCE_AUDIO, + MEDIA_SINK_SYSTEM_AUDIO, + MEDIA_SINK_TELEPHONY_AUDIO, + INPUT_SOURCE, + MEDIA_SOURCE_MICROPHONE, BLUETOOTH, - NAVIGATION, - MEDIA_STATUS, + RADIO, + NAVIGATION_STATUS, + MEDIA_PLAYBACK_STATUS, + PHONE_STATUS, + MEDIA_BROWSER, + VENDOR_EXTENSION, + GENERIC_NOTIFICATION, + WIFI_PROJECTION, NONE = 255 -}; + }; -std::string channelIdToString(ChannelId channelId); + std::string channelIdToString(ChannelId channelId); } -} + diff --git a/include/aasdk/Messenger/ChannelReceiveMessageQueue.hpp b/include/aasdk/Messenger/ChannelReceiveMessageQueue.hpp index 35511789..80866fa0 100644 --- a/include/aasdk/Messenger/ChannelReceiveMessageQueue.hpp +++ b/include/aasdk/Messenger/ChannelReceiveMessageQueue.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -23,24 +22,23 @@ #include +namespace aasdk { + namespace messenger { -namespace aasdk -{ -namespace messenger -{ + class ChannelReceiveMessageQueue { + public: + void push(Message::Pointer message); -class ChannelReceiveMessageQueue -{ -public: - void push(Message::Pointer message); - Message::Pointer pop(ChannelId channelId); - bool empty(ChannelId channelId) const; - void clear(); + Message::Pointer pop(ChannelId channelId); -private: - typedef std::queue MessageQueue; - std::unordered_map queue_; -}; + bool empty(ChannelId channelId) const; -} + void clear(); + + private: + typedef std::queue MessageQueue; + std::unordered_map queue_; + }; + + } } diff --git a/include/aasdk/Messenger/ChannelReceivePromiseQueue.hpp b/include/aasdk/Messenger/ChannelReceivePromiseQueue.hpp index 4f8df635..b7f81afd 100644 --- a/include/aasdk/Messenger/ChannelReceivePromiseQueue.hpp +++ b/include/aasdk/Messenger/ChannelReceivePromiseQueue.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -23,25 +22,28 @@ #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -class ChannelReceivePromiseQueue -{ -public: - void push(ChannelId channelId, ReceivePromise::Pointer promise); - ReceivePromise::Pointer pop(ChannelId channelId); - bool isPending(ChannelId channelId) const; - size_t size() const; - bool empty() const; - void clear(); - ReceivePromise::Pointer pop(); + class ChannelReceivePromiseQueue { + public: + void push(ChannelId channelId, ReceivePromise::Pointer promise); -private: - std::unordered_map> queue_; -}; + ReceivePromise::Pointer pop(ChannelId channelId); -} + bool isPending(ChannelId channelId) const; + + size_t size() const; + + bool empty() const; + + void clear(); + + ReceivePromise::Pointer pop(); + + private: + std::unordered_map> queue_; + }; + + } } diff --git a/include/aasdk/Messenger/Cryptor.hpp b/include/aasdk/Messenger/Cryptor.hpp index d8b178a0..cf2e8e0f 100644 --- a/include/aasdk/Messenger/Cryptor.hpp +++ b/include/aasdk/Messenger/Cryptor.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -23,43 +22,47 @@ #include -namespace aasdk -{ -namespace messenger -{ - -class Cryptor: public ICryptor -{ -public: - Cryptor(transport::ISSLWrapper::Pointer sslWrapper); - - void init() override; - void deinit() override; - bool doHandshake() override; - size_t encrypt(common::Data& output, const common::DataConstBuffer& buffer) override; - size_t decrypt(common::Data& output, const common::DataConstBuffer& buffer, int length) override; - - common::Data readHandshakeBuffer() override; - void writeHandshakeBuffer(const common::DataConstBuffer& buffer) override; - bool isActive() const override; - -private: - size_t read(common::Data& output); - void write(const common::DataConstBuffer& buffer); - - transport::ISSLWrapper::Pointer sslWrapper_; - size_t maxBufferSize_; - X509* certificate_; - EVP_PKEY* privateKey_; - SSL_CTX* context_; - SSL* ssl_; - transport::ISSLWrapper::BIOs bIOs_; - bool isActive_; - - const static std::string cCertificate; - const static std::string cPrivateKey; - mutable std::mutex mutex_; -}; +namespace aasdk { + namespace messenger { -} + class Cryptor : public ICryptor { + public: + Cryptor(transport::ISSLWrapper::Pointer sslWrapper); + + void init() override; + + void deinit() override; + + bool doHandshake() override; + + size_t encrypt(common::Data &output, const common::DataConstBuffer &buffer) override; + + size_t decrypt(common::Data &output, const common::DataConstBuffer &buffer, int length) override; + + common::Data readHandshakeBuffer() override; + + void writeHandshakeBuffer(const common::DataConstBuffer &buffer) override; + + bool isActive() const override; + + private: + size_t read(common::Data &output); + + void write(const common::DataConstBuffer &buffer); + + transport::ISSLWrapper::Pointer sslWrapper_; + size_t maxBufferSize_; + X509 *certificate_; + EVP_PKEY *privateKey_; + SSL_CTX *context_; + SSL *ssl_; + transport::ISSLWrapper::BIOs bIOs_; + bool isActive_; + + const static std::string cCertificate; + const static std::string cPrivateKey; + mutable std::mutex mutex_; + }; + + } } diff --git a/include/aasdk/Messenger/EncryptionType.hpp b/include/aasdk/Messenger/EncryptionType.hpp index 2165b76c..f2f22cbc 100644 --- a/include/aasdk/Messenger/EncryptionType.hpp +++ b/include/aasdk/Messenger/EncryptionType.hpp @@ -1,34 +1,30 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -enum class EncryptionType -{ - PLAIN, - ENCRYPTED = 1 << 3 -}; + enum class EncryptionType { + PLAIN, + ENCRYPTED = 1 << 3 + }; -} + } } diff --git a/include/aasdk/Messenger/FrameHeader.hpp b/include/aasdk/Messenger/FrameHeader.hpp index 75fe34ed..bd1b2eb9 100644 --- a/include/aasdk/Messenger/FrameHeader.hpp +++ b/include/aasdk/Messenger/FrameHeader.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -25,31 +24,33 @@ #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -class FrameHeader -{ -public: - FrameHeader(const common::DataConstBuffer& buffer); - FrameHeader(ChannelId channelId, FrameType frameType, EncryptionType encryptionType, MessageType messageType); + class FrameHeader { + public: + FrameHeader(const common::DataConstBuffer &buffer); - ChannelId getChannelId() const; - FrameType getType() const; - EncryptionType getEncryptionType() const; - MessageType getMessageType() const; - common::Data getData() const; + FrameHeader(ChannelId channelId, FrameType frameType, EncryptionType encryptionType, MessageType messageType); - static constexpr size_t getSizeOf() { return 2; } + ChannelId getChannelId() const; -private: - ChannelId channelId_; - FrameType frameType_; - EncryptionType encryptionType_; - MessageType messageType_; -}; + FrameType getType() const; -} + EncryptionType getEncryptionType() const; + + MessageType getMessageType() const; + + common::Data getData() const; + + static constexpr size_t getSizeOf() { return 2; } + + private: + ChannelId channelId_; + FrameType frameType_; + EncryptionType encryptionType_; + MessageType messageType_; + }; + + } } diff --git a/include/aasdk/Messenger/FrameSize.hpp b/include/aasdk/Messenger/FrameSize.hpp index d9b06378..e334c8f9 100644 --- a/include/aasdk/Messenger/FrameSize.hpp +++ b/include/aasdk/Messenger/FrameSize.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -22,29 +21,30 @@ #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -class FrameSize -{ -public: - FrameSize(size_t frameSize, size_t totalSize); - FrameSize(size_t frameSize); - FrameSize(const common::DataConstBuffer& buffer); + class FrameSize { + public: + FrameSize(size_t frameSize, size_t totalSize); - common::Data getData() const; - size_t getFrameSize() const; - size_t getTotalSize() const; + FrameSize(size_t frameSize); - static size_t getSizeOf(FrameSizeType type); + FrameSize(const common::DataConstBuffer &buffer); -private: - FrameSizeType frameSizeType_; - size_t frameSize_; - size_t totalSize_; -}; + common::Data getData() const; -} + size_t getFrameSize() const; + + size_t getTotalSize() const; + + static size_t getSizeOf(FrameSizeType type); + + private: + FrameSizeType frameSizeType_; + size_t frameSize_; + size_t totalSize_; + }; + + } } diff --git a/include/aasdk/Messenger/FrameSizeType.hpp b/include/aasdk/Messenger/FrameSizeType.hpp index c74b524f..c6c3a51f 100644 --- a/include/aasdk/Messenger/FrameSizeType.hpp +++ b/include/aasdk/Messenger/FrameSizeType.hpp @@ -1,34 +1,30 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -enum class FrameSizeType -{ - SHORT, - EXTENDED -}; + enum class FrameSizeType { + SHORT, + EXTENDED + }; -} + } } diff --git a/include/aasdk/Messenger/FrameType.hpp b/include/aasdk/Messenger/FrameType.hpp index 08252948..fc5fef19 100644 --- a/include/aasdk/Messenger/FrameType.hpp +++ b/include/aasdk/Messenger/FrameType.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -22,20 +21,17 @@ #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -enum class FrameType -{ - MIDDLE = 0, - FIRST = 1 << 0, - LAST = 1 << 1, - BULK = FIRST | LAST -}; + enum class FrameType { + MIDDLE = 0, + FIRST = 1 << 0, + LAST = 1 << 1, + BULK = FIRST | LAST + }; -std::string frameTypeToString(FrameType frameType); + std::string frameTypeToString(FrameType frameType); -} + } } diff --git a/include/aasdk/Messenger/ICryptor.hpp b/include/aasdk/Messenger/ICryptor.hpp index bc2ba1f6..230258b0 100644 --- a/include/aasdk/Messenger/ICryptor.hpp +++ b/include/aasdk/Messenger/ICryptor.hpp @@ -1,49 +1,51 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include #include +namespace aasdk::messenger { -namespace aasdk -{ -namespace messenger -{ - -class ICryptor -{ -public: + class ICryptor { + public: typedef std::shared_ptr Pointer; ICryptor() = default; + virtual ~ICryptor() = default; virtual void init() = 0; + virtual void deinit() = 0; + virtual bool doHandshake() = 0; - virtual size_t encrypt(common::Data& output, const common::DataConstBuffer& buffer) = 0; - virtual size_t decrypt(common::Data& output, const common::DataConstBuffer& buffer, int length) = 0; + + virtual size_t encrypt(common::Data &output, const common::DataConstBuffer &buffer) = 0; + + virtual size_t decrypt(common::Data &output, const common::DataConstBuffer &buffer, int length) = 0; + virtual common::Data readHandshakeBuffer() = 0; - virtual void writeHandshakeBuffer(const common::DataConstBuffer& buffer) = 0; + + virtual void writeHandshakeBuffer(const common::DataConstBuffer &buffer) = 0; + virtual bool isActive() const = 0; -}; + }; } -} + diff --git a/include/aasdk/Messenger/IMessageInStream.hpp b/include/aasdk/Messenger/IMessageInStream.hpp index 0d9e7981..ec05d3f8 100644 --- a/include/aasdk/Messenger/IMessageInStream.hpp +++ b/include/aasdk/Messenger/IMessageInStream.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -22,21 +21,19 @@ #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -class IMessageInStream -{ -public: - typedef std::shared_ptr Pointer; + class IMessageInStream { + public: + typedef std::shared_ptr Pointer; - IMessageInStream() = default; - virtual ~IMessageInStream() = default; + IMessageInStream() = default; - virtual void startReceive(ReceivePromise::Pointer promise) = 0; -}; + virtual ~IMessageInStream() = default; -} + virtual void startReceive(ReceivePromise::Pointer promise) = 0; + }; + + } } diff --git a/include/aasdk/Messenger/IMessageOutStream.hpp b/include/aasdk/Messenger/IMessageOutStream.hpp index 6db1437a..d036eafb 100644 --- a/include/aasdk/Messenger/IMessageOutStream.hpp +++ b/include/aasdk/Messenger/IMessageOutStream.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -23,21 +22,19 @@ #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -class IMessageOutStream -{ -public: - typedef std::shared_ptr Pointer; + class IMessageOutStream { + public: + typedef std::shared_ptr Pointer; - IMessageOutStream() = default; - virtual ~IMessageOutStream() = default; + IMessageOutStream() = default; - virtual void stream(Message::Pointer message, SendPromise::Pointer promise) = 0; -}; + virtual ~IMessageOutStream() = default; -} + virtual void stream(Message::Pointer message, SendPromise::Pointer promise) = 0; + }; + + } } diff --git a/include/aasdk/Messenger/IMessenger.hpp b/include/aasdk/Messenger/IMessenger.hpp index 1f1236d2..be1644bf 100644 --- a/include/aasdk/Messenger/IMessenger.hpp +++ b/include/aasdk/Messenger/IMessenger.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -25,23 +24,23 @@ #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -class IMessenger -{ -public: - IMessenger() = default; - virtual ~IMessenger() = default; + class IMessenger { + public: + IMessenger() = default; - typedef std::shared_ptr Pointer; + virtual ~IMessenger() = default; - virtual void enqueueReceive(ChannelId channelId, ReceivePromise::Pointer promise) = 0; - virtual void enqueueSend(Message::Pointer message, SendPromise::Pointer promise) = 0; - virtual void stop() = 0; -}; + typedef std::shared_ptr Pointer; -} + virtual void enqueueReceive(ChannelId channelId, ReceivePromise::Pointer promise) = 0; + + virtual void enqueueSend(Message::Pointer message, SendPromise::Pointer promise) = 0; + + virtual void stop() = 0; + }; + + } } diff --git a/include/aasdk/Messenger/Message.hpp b/include/aasdk/Messenger/Message.hpp index a17b5a61..db6f4eee 100644 --- a/include/aasdk/Messenger/Message.hpp +++ b/include/aasdk/Messenger/Message.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -27,38 +26,42 @@ #include #include +namespace aasdk::messenger { -namespace aasdk -{ -namespace messenger -{ - -class Message: boost::noncopyable -{ -public: + class Message : boost::noncopyable { + public: typedef std::shared_ptr Pointer; Message(ChannelId channelId, EncryptionType encryptionType, MessageType type); - Message(Message&& other); - Message& operator=(Message&& other); + + Message(Message &&other); + + Message &operator=(Message &&other); ChannelId getChannelId() const; + EncryptionType getEncryptionType() const; + MessageType getType() const; - common::Data& getPayload(); - const common::Data& getPayload() const; - void insertPayload(const common::Data& payload); - void insertPayload(const google::protobuf::Message& message); - void insertPayload(const common::DataConstBuffer& buffer); - void insertPayload(common::DataBuffer& buffer); + common::Data &getPayload(); + + const common::Data &getPayload() const; -private: + void insertPayload(const common::Data &payload); + + void insertPayload(const google::protobuf::Message &message); + + void insertPayload(const common::DataConstBuffer &buffer); + + void insertPayload(common::DataBuffer &buffer); + + private: ChannelId channelId_; EncryptionType encryptionType_; MessageType type_; common::Data payload_; -}; + }; } -} + diff --git a/include/aasdk/Messenger/MessageId.hpp b/include/aasdk/Messenger/MessageId.hpp index 889d2c27..4d9bcc03 100644 --- a/include/aasdk/Messenger/MessageId.hpp +++ b/include/aasdk/Messenger/MessageId.hpp @@ -1,53 +1,57 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -class MessageId -{ -public: - MessageId(uint16_t id); - MessageId(const common::Data& data); + class MessageId { + public: + MessageId(uint16_t id); - common::Data getData() const; - static constexpr size_t getSizeOf() { return 2; } - uint16_t getId() const; + MessageId(const common::Data &data); - bool operator>(uint16_t id) const; - bool operator<(uint16_t id) const; - bool operator==(uint16_t id) const; - bool operator>=(uint16_t id) const; - bool operator<=(uint16_t id) const; - MessageId& operator=(uint16_t id); + common::Data getData() const; -private: - uint16_t id_; -}; + static constexpr size_t getSizeOf() { return 2; } -std::ostream& operator<<(std::ostream& stream, const aasdk::messenger::MessageId& messageId); + uint16_t getId() const; -} + bool operator>(uint16_t id) const; + + bool operator<(uint16_t id) const; + + bool operator==(uint16_t id) const; + + bool operator>=(uint16_t id) const; + + bool operator<=(uint16_t id) const; + + MessageId &operator=(uint16_t id); + + private: + uint16_t id_; + }; + + std::ostream &operator<<(std::ostream &stream, const aasdk::messenger::MessageId &messageId); + + } } diff --git a/include/aasdk/Messenger/MessageInStream.hpp b/include/aasdk/Messenger/MessageInStream.hpp index 489c5d71..24127bdb 100644 --- a/include/aasdk/Messenger/MessageInStream.hpp +++ b/include/aasdk/Messenger/MessageInStream.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -27,39 +26,40 @@ #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -class MessageInStream: public IMessageInStream, public std::enable_shared_from_this, boost::noncopyable -{ -public: - MessageInStream(boost::asio::io_service& ioService, transport::ITransport::Pointer transport, ICryptor::Pointer cryptor); + class MessageInStream + : public IMessageInStream, public std::enable_shared_from_this, boost::noncopyable { + public: + MessageInStream(boost::asio::io_service &ioService, transport::ITransport::Pointer transport, + ICryptor::Pointer cryptor); - void startReceive(ReceivePromise::Pointer promise) override; + void startReceive(ReceivePromise::Pointer promise) override; -private: - using std::enable_shared_from_this::shared_from_this; + private: + using std::enable_shared_from_this::shared_from_this; - void receiveFrameHeaderHandler(const common::DataConstBuffer& buffer); - void receiveFrameSizeHandler(const common::DataConstBuffer& buffer); - void receiveFramePayloadHandler(const common::DataConstBuffer& buffer); + void receiveFrameHeaderHandler(const common::DataConstBuffer &buffer); - boost::asio::io_service::strand strand_; - transport::ITransport::Pointer transport_; - ICryptor::Pointer cryptor_; + void receiveFrameSizeHandler(const common::DataConstBuffer &buffer); - FrameType thisFrameType_; - ReceivePromise::Pointer promise_; - ReceivePromise::Pointer interleavedPromise_; - Message::Pointer message_; + void receiveFramePayloadHandler(const common::DataConstBuffer &buffer); - std::map messageBuffer_; + boost::asio::io_service::strand strand_; + transport::ITransport::Pointer transport_; + ICryptor::Pointer cryptor_; - int frameSize_; - bool isValidFrame_; -}; + FrameType thisFrameType_; + ReceivePromise::Pointer promise_; + ReceivePromise::Pointer interleavedPromise_; + Message::Pointer message_; -} + std::map messageBuffer_; + + int frameSize_; + bool isValidFrame_; + }; + + } } diff --git a/include/aasdk/Messenger/MessageOutStream.hpp b/include/aasdk/Messenger/MessageOutStream.hpp index 755ea14d..e228f6e7 100644 --- a/include/aasdk/Messenger/MessageOutStream.hpp +++ b/include/aasdk/Messenger/MessageOutStream.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -26,38 +25,42 @@ #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -class MessageOutStream: public IMessageOutStream, public std::enable_shared_from_this, boost::noncopyable -{ -public: - MessageOutStream(boost::asio::io_service& ioService, transport::ITransport::Pointer transport, ICryptor::Pointer cryptor); + class MessageOutStream + : public IMessageOutStream, public std::enable_shared_from_this, boost::noncopyable { + public: + MessageOutStream(boost::asio::io_service &ioService, transport::ITransport::Pointer transport, + ICryptor::Pointer cryptor); - void stream(Message::Pointer message, SendPromise::Pointer promise) override; + void stream(Message::Pointer message, SendPromise::Pointer promise) override; -private: - using std::enable_shared_from_this::shared_from_this; + private: + using std::enable_shared_from_this::shared_from_this; - void streamSplittedMessage(); - common::Data compoundFrame(FrameType frameType, const common::DataConstBuffer& payloadBuffer); - void streamEncryptedFrame(FrameType frameType, const common::DataConstBuffer& payloadBuffer); - void streamPlainFrame(FrameType frameType, const common::DataConstBuffer& payloadBuffer); - void setFrameSize(common::Data& data, FrameType frameType, size_t payloadSize, size_t totalSize); - void reset(); + void streamSplittedMessage(); - boost::asio::io_service::strand strand_; - transport::ITransport::Pointer transport_; - ICryptor::Pointer cryptor_; - Message::Pointer message_; - size_t offset_; - size_t remainingSize_; - SendPromise::Pointer promise_; + common::Data compoundFrame(FrameType frameType, const common::DataConstBuffer &payloadBuffer); - static constexpr size_t cMaxFramePayloadSize = 0x4000; -}; + void streamEncryptedFrame(FrameType frameType, const common::DataConstBuffer &payloadBuffer); -} + void streamPlainFrame(FrameType frameType, const common::DataConstBuffer &payloadBuffer); + + void setFrameSize(common::Data &data, FrameType frameType, size_t payloadSize, size_t totalSize); + + void reset(); + + boost::asio::io_service::strand strand_; + transport::ITransport::Pointer transport_; + ICryptor::Pointer cryptor_; + Message::Pointer message_; + size_t offset_; + size_t remainingSize_; + SendPromise::Pointer promise_; + + static constexpr size_t cMaxFramePayloadSize = 0x4000; + }; + + } } diff --git a/include/aasdk/Messenger/MessageType.hpp b/include/aasdk/Messenger/MessageType.hpp index 73594c98..be8a876f 100644 --- a/include/aasdk/Messenger/MessageType.hpp +++ b/include/aasdk/Messenger/MessageType.hpp @@ -1,38 +1,32 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#pragma once +// 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) +// +// 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 . #pragma once #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -enum class MessageType -{ - SPECIFIC = 0, - CONTROL = 1 << 2 -}; + enum class MessageType { + SPECIFIC = 0, + CONTROL = 1 << 2 + }; -} + } } diff --git a/include/aasdk/Messenger/Messenger.hpp b/include/aasdk/Messenger/Messenger.hpp index b5996cfe..ce1c8df5 100644 --- a/include/aasdk/Messenger/Messenger.hpp +++ b/include/aasdk/Messenger/Messenger.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -27,38 +26,44 @@ #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -class Messenger: public IMessenger, public std::enable_shared_from_this, boost::noncopyable -{ -public: - Messenger(boost::asio::io_service& ioService, IMessageInStream::Pointer messageInStream, IMessageOutStream::Pointer messageOutStream); - void enqueueReceive(ChannelId channelId, ReceivePromise::Pointer promise) override; - void enqueueSend(Message::Pointer message, SendPromise::Pointer promise) override; - void stop() override; + class Messenger : public IMessenger, public std::enable_shared_from_this, boost::noncopyable { + public: + Messenger(boost::asio::io_service &ioService, IMessageInStream::Pointer messageInStream, + IMessageOutStream::Pointer messageOutStream); -private: - using std::enable_shared_from_this::shared_from_this; - typedef std::list> ChannelSendQueue; - void doSend(); - void inStreamMessageHandler(Message::Pointer message); - void outStreamMessageHandler(ChannelSendQueue::iterator queueElement); - void rejectReceivePromiseQueue(const error::Error& e); - void rejectSendPromiseQueue(const error::Error& e); + void enqueueReceive(ChannelId channelId, ReceivePromise::Pointer promise) override; - boost::asio::io_service::strand receiveStrand_; - boost::asio::io_service::strand sendStrand_; - IMessageInStream::Pointer messageInStream_; - IMessageOutStream::Pointer messageOutStream_; + void enqueueSend(Message::Pointer message, SendPromise::Pointer promise) override; - ChannelReceivePromiseQueue channelReceivePromiseQueue_; - ChannelReceiveMessageQueue channelReceiveMessageQueue_; - ChannelSendQueue channelSendPromiseQueue_; + void stop() override; -}; + private: + using std::enable_shared_from_this::shared_from_this; + typedef std::list> ChannelSendQueue; -} + void doSend(); + + void inStreamMessageHandler(Message::Pointer message); + + void outStreamMessageHandler(ChannelSendQueue::iterator queueElement); + + void rejectReceivePromiseQueue(const error::Error &e); + + void rejectSendPromiseQueue(const error::Error &e); + + boost::asio::io_service::strand receiveStrand_; + boost::asio::io_service::strand sendStrand_; + IMessageInStream::Pointer messageInStream_; + IMessageOutStream::Pointer messageOutStream_; + + ChannelReceivePromiseQueue channelReceivePromiseQueue_; + ChannelReceiveMessageQueue channelReceiveMessageQueue_; + ChannelSendQueue channelSendPromiseQueue_; + + }; + + } } diff --git a/include/aasdk/Messenger/Promise.hpp b/include/aasdk/Messenger/Promise.hpp index 79222eb5..fdbaf8cb 100644 --- a/include/aasdk/Messenger/Promise.hpp +++ b/include/aasdk/Messenger/Promise.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -22,13 +21,11 @@ #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -typedef io::Promise ReceivePromise; -typedef io::Promise SendPromise; + typedef io::Promise ReceivePromise; + typedef io::Promise SendPromise; -} + } } diff --git a/include/aasdk/Messenger/ServiceId.hpp b/include/aasdk/Messenger/ServiceId.hpp new file mode 100644 index 00000000..00dfd8fa --- /dev/null +++ b/include/aasdk/Messenger/ServiceId.hpp @@ -0,0 +1,44 @@ +// 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) +// +// 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 . + +#pragma once + +#include + +namespace aasdk { + namespace messenger { + enum class ServiceId { + CONTROL, + SENSOR, + MEDIA_SINK, + INPUT_SOURCE, + MEDIA_SOURCE, + BLUETOOTH, + RADIO, + NAVIGATION_STATUS, + MEDIA_PLAYBACK_STATUS, + PHONE_STATUS, + MEDIA_BROWSER, + VENDOR_EXTENSION, + GENERIC_NOTIFICATION, + WIFI_PROJECTION, + NONE = 255 + }; + + std::string serviceIdToString(ServiceId serviceId); + } +} diff --git a/include/aasdk/Messenger/Timestamp.hpp b/include/aasdk/Messenger/Timestamp.hpp index 994ec16d..b95eced8 100644 --- a/include/aasdk/Messenger/Timestamp.hpp +++ b/include/aasdk/Messenger/Timestamp.hpp @@ -1,45 +1,43 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -class Timestamp -{ -public: - typedef uint64_t ValueType; + class Timestamp { + public: + typedef uint64_t ValueType; - Timestamp(ValueType stamp); - Timestamp(const common::DataConstBuffer& buffer); + Timestamp(ValueType stamp); - common::Data getData() const; - ValueType getValue() const; + Timestamp(const common::DataConstBuffer &buffer); -private: - ValueType stamp_; -}; + common::Data getData() const; -} + ValueType getValue() const; + + private: + ValueType stamp_; + }; + + } } diff --git a/include/aasdk/TCP/ITCPEndpoint.hpp b/include/aasdk/TCP/ITCPEndpoint.hpp index b196c9d7..931cdd92 100644 --- a/include/aasdk/TCP/ITCPEndpoint.hpp +++ b/include/aasdk/TCP/ITCPEndpoint.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -23,24 +22,23 @@ #include -namespace aasdk -{ -namespace tcp -{ +namespace aasdk { + namespace tcp { -class ITCPEndpoint -{ -public: - typedef std::shared_ptr Pointer; - typedef io::Promise Promise; - typedef std::shared_ptr SocketPointer; + class ITCPEndpoint { + public: + typedef std::shared_ptr Pointer; + typedef io::Promise Promise; + typedef std::shared_ptr SocketPointer; - virtual ~ITCPEndpoint() = default; + virtual ~ITCPEndpoint() = default; - virtual void send(common::DataConstBuffer buffer, Promise::Pointer promise) = 0; - virtual void receive(common::DataBuffer buffer, Promise::Pointer promise) = 0; - virtual void stop() = 0; -}; + virtual void send(common::DataConstBuffer buffer, Promise::Pointer promise) = 0; -} + virtual void receive(common::DataBuffer buffer, Promise::Pointer promise) = 0; + + virtual void stop() = 0; + }; + + } } diff --git a/include/aasdk/TCP/ITCPWrapper.hpp b/include/aasdk/TCP/ITCPWrapper.hpp index 82d8914a..9f30bdb9 100644 --- a/include/aasdk/TCP/ITCPWrapper.hpp +++ b/include/aasdk/TCP/ITCPWrapper.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -23,25 +22,29 @@ #include -namespace aasdk -{ -namespace tcp -{ +namespace aasdk { + namespace tcp { -class ITCPWrapper -{ -public: - typedef std::function Handler; - typedef std::function ConnectHandler; + class ITCPWrapper { + public: + typedef std::function Handler; + typedef std::function ConnectHandler; - virtual ~ITCPWrapper() = default; + virtual ~ITCPWrapper() = default; - virtual void asyncWrite(boost::asio::ip::tcp::socket& socket, common::DataConstBuffer buffer, Handler handler) = 0; - virtual void asyncRead(boost::asio::ip::tcp::socket& socket, common::DataBuffer buffer, Handler handler) = 0; - virtual void close(boost::asio::ip::tcp::socket& socket) = 0; - virtual void asyncConnect(boost::asio::ip::tcp::socket& socket, const std::string& hostname, uint16_t port, ConnectHandler handler) = 0; - virtual boost::system::error_code connect(boost::asio::ip::tcp::socket& socket, const std::string& hostname, uint16_t port) = 0; -}; + virtual void + asyncWrite(boost::asio::ip::tcp::socket &socket, common::DataConstBuffer buffer, Handler handler) = 0; -} + virtual void asyncRead(boost::asio::ip::tcp::socket &socket, common::DataBuffer buffer, Handler handler) = 0; + + virtual void close(boost::asio::ip::tcp::socket &socket) = 0; + + virtual void asyncConnect(boost::asio::ip::tcp::socket &socket, const std::string &hostname, uint16_t port, + ConnectHandler handler) = 0; + + virtual boost::system::error_code + connect(boost::asio::ip::tcp::socket &socket, const std::string &hostname, uint16_t port) = 0; + }; + + } } diff --git a/include/aasdk/TCP/TCPEndpoint.hpp b/include/aasdk/TCP/TCPEndpoint.hpp index f9bd27f0..507d508f 100644 --- a/include/aasdk/TCP/TCPEndpoint.hpp +++ b/include/aasdk/TCP/TCPEndpoint.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -23,28 +22,28 @@ #include -namespace aasdk -{ -namespace tcp -{ +namespace aasdk { + namespace tcp { -class TCPEndpoint: public ITCPEndpoint, public std::enable_shared_from_this -{ -public: - TCPEndpoint(ITCPWrapper& tcpWrapper, SocketPointer socket); + class TCPEndpoint : public ITCPEndpoint, public std::enable_shared_from_this { + public: + TCPEndpoint(ITCPWrapper &tcpWrapper, SocketPointer socket); - void send(common::DataConstBuffer buffer, Promise::Pointer promise) override; - void receive(common::DataBuffer buffer, Promise::Pointer promise) override; - void stop() override; + void send(common::DataConstBuffer buffer, Promise::Pointer promise) override; -private: - using std::enable_shared_from_this::shared_from_this; + void receive(common::DataBuffer buffer, Promise::Pointer promise) override; - void asyncOperationHandler(const boost::system::error_code& ec, size_t bytesTransferred, Promise::Pointer promise); + void stop() override; - ITCPWrapper& tcpWrapper_; - SocketPointer socket_; -}; + private: + using std::enable_shared_from_this::shared_from_this; -} + void + asyncOperationHandler(const boost::system::error_code &ec, size_t bytesTransferred, Promise::Pointer promise); + + ITCPWrapper &tcpWrapper_; + SocketPointer socket_; + }; + + } } diff --git a/include/aasdk/TCP/TCPWrapper.hpp b/include/aasdk/TCP/TCPWrapper.hpp index 1c453bc4..baecea7e 100644 --- a/include/aasdk/TCP/TCPWrapper.hpp +++ b/include/aasdk/TCP/TCPWrapper.hpp @@ -1,40 +1,42 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include -namespace aasdk -{ -namespace tcp -{ +namespace aasdk { + namespace tcp { -class TCPWrapper: public ITCPWrapper -{ -public: - void asyncWrite(boost::asio::ip::tcp::socket& socket, common::DataConstBuffer buffer, Handler handler) override; - void asyncRead(boost::asio::ip::tcp::socket& socket, common::DataBuffer buffer, Handler handler) override; - void close(boost::asio::ip::tcp::socket& socket) override; - void asyncConnect(boost::asio::ip::tcp::socket& socket, const std::string& hostname, uint16_t port, ConnectHandler handler) override; - boost::system::error_code connect(boost::asio::ip::tcp::socket& socket, const std::string& hostname, uint16_t port) override; -}; + class TCPWrapper : public ITCPWrapper { + public: + void asyncWrite(boost::asio::ip::tcp::socket &socket, common::DataConstBuffer buffer, Handler handler) override; -} + void asyncRead(boost::asio::ip::tcp::socket &socket, common::DataBuffer buffer, Handler handler) override; + + void close(boost::asio::ip::tcp::socket &socket) override; + + void asyncConnect(boost::asio::ip::tcp::socket &socket, const std::string &hostname, uint16_t port, + ConnectHandler handler) override; + + boost::system::error_code + connect(boost::asio::ip::tcp::socket &socket, const std::string &hostname, uint16_t port) override; + }; + + } } diff --git a/include/aasdk/Transport/DataSink.hpp b/include/aasdk/Transport/DataSink.hpp index 12d0287c..8bb60304 100644 --- a/include/aasdk/Transport/DataSink.hpp +++ b/include/aasdk/Transport/DataSink.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -23,27 +22,25 @@ #include +namespace aasdk { + namespace transport { -namespace aasdk -{ -namespace transport -{ + class DataSink { + public: + DataSink(); -class DataSink -{ -public: - DataSink(); + common::DataBuffer fill(); - common::DataBuffer fill(); - void commit(common::Data::size_type size); + void commit(common::Data::size_type size); - common::Data::size_type getAvailableSize(); - common::Data consume(common::Data::size_type size); + common::Data::size_type getAvailableSize(); -private: - boost::circular_buffer data_; - static constexpr common::Data::size_type cChunkSize = 16384; -}; + common::Data consume(common::Data::size_type size); -} + private: + boost::circular_buffer data_; + static constexpr common::Data::size_type cChunkSize = 16384; + }; + + } } diff --git a/include/aasdk/Transport/ISSLWrapper.hpp b/include/aasdk/Transport/ISSLWrapper.hpp index 13289a6f..884af093 100644 --- a/include/aasdk/Transport/ISSLWrapper.hpp +++ b/include/aasdk/Transport/ISSLWrapper.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -22,47 +21,66 @@ #include -namespace aasdk -{ -namespace transport -{ - -class ISSLWrapper -{ -public: - typedef std::pair BIOs; - typedef std::shared_ptr Pointer; - - ISSLWrapper() = default; - virtual ~ISSLWrapper() = default; - - virtual X509* readCertificate(const std::string& certificate) = 0; - virtual EVP_PKEY* readPrivateKey(const std::string& privateKey) = 0; - virtual const SSL_METHOD* getMethod() = 0; - virtual SSL_CTX* createContext(const SSL_METHOD* method) = 0; - virtual bool useCertificate(SSL_CTX* context, X509* certificate) = 0; - virtual bool usePrivateKey(SSL_CTX* context, EVP_PKEY* privateKey) = 0; - virtual SSL* createInstance(SSL_CTX* context) = 0; - virtual bool checkPrivateKey(SSL* ssl) = 0; - virtual std::pair createBIOs() = 0; - virtual void setBIOs(SSL* ssl, const BIOs& bIOs, size_t maxBufferSize) = 0; - virtual void setConnectState(SSL* ssl) = 0; - virtual int doHandshake(SSL* ssl) = 0; - virtual void free(SSL* ssl) = 0; - virtual void free(SSL_CTX* context) = 0; - virtual void free(BIO* bio) = 0; - virtual void free(X509* certificate) = 0; - virtual void free(EVP_PKEY* privateKey) = 0; - - virtual size_t bioCtrlPending(BIO* b) = 0; - virtual int bioRead(BIO *b, void *data, int len) = 0; - virtual int bioWrite(BIO *b, const void *data, int len) = 0; - - virtual int getAvailableBytes(const SSL* ssl) = 0; - virtual int sslRead(SSL *ssl, void *buf, int num) = 0; - virtual int sslWrite(SSL *ssl, const void *buf, int num) = 0; - virtual int getError(SSL* ssl, int returnCode) = 0; -}; +namespace aasdk { + namespace transport { -} + class ISSLWrapper { + public: + typedef std::pair BIOs; + typedef std::shared_ptr Pointer; + + ISSLWrapper() = default; + + virtual ~ISSLWrapper() = default; + + virtual X509 *readCertificate(const std::string &certificate) = 0; + + virtual EVP_PKEY *readPrivateKey(const std::string &privateKey) = 0; + + virtual const SSL_METHOD *getMethod() = 0; + + virtual SSL_CTX *createContext(const SSL_METHOD *method) = 0; + + virtual bool useCertificate(SSL_CTX *context, X509 *certificate) = 0; + + virtual bool usePrivateKey(SSL_CTX *context, EVP_PKEY *privateKey) = 0; + + virtual SSL *createInstance(SSL_CTX *context) = 0; + + virtual bool checkPrivateKey(SSL *ssl) = 0; + + virtual std::pair createBIOs() = 0; + + virtual void setBIOs(SSL *ssl, const BIOs &bIOs, size_t maxBufferSize) = 0; + + virtual void setConnectState(SSL *ssl) = 0; + + virtual int doHandshake(SSL *ssl) = 0; + + virtual void free(SSL *ssl) = 0; + + virtual void free(SSL_CTX *context) = 0; + + virtual void free(BIO *bio) = 0; + + virtual void free(X509 *certificate) = 0; + + virtual void free(EVP_PKEY *privateKey) = 0; + + virtual size_t bioCtrlPending(BIO *b) = 0; + + virtual int bioRead(BIO *b, void *data, int len) = 0; + + virtual int bioWrite(BIO *b, const void *data, int len) = 0; + + virtual int getAvailableBytes(const SSL *ssl) = 0; + + virtual int sslRead(SSL *ssl, void *buf, int num) = 0; + + virtual int sslWrite(SSL *ssl, const void *buf, int num) = 0; + + virtual int getError(SSL *ssl, int returnCode) = 0; + }; + + } } diff --git a/include/aasdk/Transport/ITransport.hpp b/include/aasdk/Transport/ITransport.hpp index e415eb94..f44f9794 100644 --- a/include/aasdk/Transport/ITransport.hpp +++ b/include/aasdk/Transport/ITransport.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -23,25 +22,25 @@ #include -namespace aasdk -{ -namespace transport -{ +namespace aasdk { + namespace transport { -class ITransport -{ -public: - typedef std::shared_ptr Pointer; - typedef io::Promise ReceivePromise; - typedef io::Promise SendPromise; + class ITransport { + public: + typedef std::shared_ptr Pointer; + typedef io::Promise ReceivePromise; + typedef io::Promise SendPromise; - ITransport() = default; - virtual ~ITransport() = default; + ITransport() = default; - virtual void receive(size_t size, ReceivePromise::Pointer promise) = 0; - virtual void send(common::Data data, SendPromise::Pointer promise) = 0; - virtual void stop() = 0; -}; + virtual ~ITransport() = default; -} + virtual void receive(size_t size, ReceivePromise::Pointer promise) = 0; + + virtual void send(common::Data data, SendPromise::Pointer promise) = 0; + + virtual void stop() = 0; + }; + + } } diff --git a/include/aasdk/Transport/SSLWrapper.hpp b/include/aasdk/Transport/SSLWrapper.hpp index f6e0164a..7e8b462f 100644 --- a/include/aasdk/Transport/SSLWrapper.hpp +++ b/include/aasdk/Transport/SSLWrapper.hpp @@ -1,64 +1,82 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include -namespace aasdk -{ -namespace transport -{ - -class SSLWrapper: public ISSLWrapper -{ -public: - SSLWrapper(); - ~SSLWrapper() override; - - X509* readCertificate(const std::string& certificate) override; - EVP_PKEY* readPrivateKey(const std::string& privateKey) override; - const SSL_METHOD* getMethod() override; - SSL_CTX* createContext(const SSL_METHOD* method) override; - bool useCertificate(SSL_CTX* context, X509* certificate) override; - bool usePrivateKey(SSL_CTX* context, EVP_PKEY* privateKey) override; - SSL* createInstance(SSL_CTX* context) override; - bool checkPrivateKey(SSL* ssl) override; - BIOs createBIOs() override; - void setBIOs(SSL* ssl, const BIOs& bIOs, size_t maxBufferSize) override; - void setConnectState(SSL* ssl) override; - int doHandshake(SSL* ssl) override; - int getError(SSL* ssl, int returnCode) override; - - void free(SSL* ssl) override; - void free(SSL_CTX* context) override; - void free(BIO* bio) override; - void free(X509* certificate) override; - void free(EVP_PKEY* privateKey) override; - - size_t bioCtrlPending(BIO* b) override; - int bioRead(BIO *b, void *data, int len) override; - int bioWrite(BIO *b, const void *data, int len) override; - int getAvailableBytes(const SSL* ssl) override; - int sslRead(SSL *ssl, void *buf, int num) override; - int sslWrite(SSL *ssl, const void *buf, int num) override; -}; +namespace aasdk { + namespace transport { -} + class SSLWrapper : public ISSLWrapper { + public: + SSLWrapper(); + + ~SSLWrapper() override; + + X509 *readCertificate(const std::string &certificate) override; + + EVP_PKEY *readPrivateKey(const std::string &privateKey) override; + + const SSL_METHOD *getMethod() override; + + SSL_CTX *createContext(const SSL_METHOD *method) override; + + bool useCertificate(SSL_CTX *context, X509 *certificate) override; + + bool usePrivateKey(SSL_CTX *context, EVP_PKEY *privateKey) override; + + SSL *createInstance(SSL_CTX *context) override; + + bool checkPrivateKey(SSL *ssl) override; + + BIOs createBIOs() override; + + void setBIOs(SSL *ssl, const BIOs &bIOs, size_t maxBufferSize) override; + + void setConnectState(SSL *ssl) override; + + int doHandshake(SSL *ssl) override; + + int getError(SSL *ssl, int returnCode) override; + + void free(SSL *ssl) override; + + void free(SSL_CTX *context) override; + + void free(BIO *bio) override; + + void free(X509 *certificate) override; + + void free(EVP_PKEY *privateKey) override; + + size_t bioCtrlPending(BIO *b) override; + + int bioRead(BIO *b, void *data, int len) override; + + int bioWrite(BIO *b, const void *data, int len) override; + + int getAvailableBytes(const SSL *ssl) override; + + int sslRead(SSL *ssl, void *buf, int num) override; + + int sslWrite(SSL *ssl, const void *buf, int num) override; + }; + + } } diff --git a/include/aasdk/Transport/TCPTransport.hpp b/include/aasdk/Transport/TCPTransport.hpp index a1831adc..28ab0369 100644 --- a/include/aasdk/Transport/TCPTransport.hpp +++ b/include/aasdk/Transport/TCPTransport.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -22,25 +21,24 @@ #include -namespace aasdk -{ -namespace transport -{ +namespace aasdk { + namespace transport { -class TCPTransport: public Transport -{ -public: - TCPTransport(boost::asio::io_service& ioService, tcp::ITCPEndpoint::Pointer tcpEndpoint); + class TCPTransport : public Transport { + public: + TCPTransport(boost::asio::io_service &ioService, tcp::ITCPEndpoint::Pointer tcpEndpoint); - void stop() override; + void stop() override; -private: - void enqueueReceive(common::DataBuffer buffer) override; - void enqueueSend(SendQueue::iterator queueElement) override; - void sendHandler(SendQueue::iterator queueElement, const error::Error& e); + private: + void enqueueReceive(common::DataBuffer buffer) override; - tcp::ITCPEndpoint::Pointer tcpEndpoint_; -}; + void enqueueSend(SendQueue::iterator queueElement) override; -} + void sendHandler(SendQueue::iterator queueElement, const error::Error &e); + + tcp::ITCPEndpoint::Pointer tcpEndpoint_; + }; + + } } diff --git a/include/aasdk/Transport/Transport.hpp b/include/aasdk/Transport/Transport.hpp index ca9d1977..f55e8d70 100644 --- a/include/aasdk/Transport/Transport.hpp +++ b/include/aasdk/Transport/Transport.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -25,39 +24,41 @@ #include -namespace aasdk -{ -namespace transport -{ +namespace aasdk { + namespace transport { -class Transport: public ITransport, public std::enable_shared_from_this, boost::noncopyable -{ -public: - Transport(boost::asio::io_service& ioService); + class Transport : public ITransport, public std::enable_shared_from_this, boost::noncopyable { + public: + Transport(boost::asio::io_service &ioService); - void receive(size_t size, ReceivePromise::Pointer promise) override; - void send(common::Data data, SendPromise::Pointer promise) override; + void receive(size_t size, ReceivePromise::Pointer promise) override; -protected: - typedef std::list> ReceiveQueue; - typedef std::list> SendQueue; + void send(common::Data data, SendPromise::Pointer promise) override; - using std::enable_shared_from_this::shared_from_this; - void receiveHandler(size_t bytesTransferred); - void distributeReceivedData(); - void rejectReceivePromises(const error::Error& e); + protected: + typedef std::list> ReceiveQueue; + typedef std::list> SendQueue; - virtual void enqueueReceive(common::DataBuffer buffer) = 0; - virtual void enqueueSend(SendQueue::iterator queueElement) = 0; + using std::enable_shared_from_this::shared_from_this; - DataSink receivedDataSink_; + void receiveHandler(size_t bytesTransferred); - boost::asio::io_service::strand receiveStrand_; - ReceiveQueue receiveQueue_; + void distributeReceivedData(); - boost::asio::io_service::strand sendStrand_; - SendQueue sendQueue_; -}; + void rejectReceivePromises(const error::Error &e); -} + virtual void enqueueReceive(common::DataBuffer buffer) = 0; + + virtual void enqueueSend(SendQueue::iterator queueElement) = 0; + + DataSink receivedDataSink_; + + boost::asio::io_service::strand receiveStrand_; + ReceiveQueue receiveQueue_; + + boost::asio::io_service::strand sendStrand_; + SendQueue sendQueue_; + }; + + } } diff --git a/include/aasdk/Transport/USBTransport.hpp b/include/aasdk/Transport/USBTransport.hpp index d28cd64a..a0d597df 100644 --- a/include/aasdk/Transport/USBTransport.hpp +++ b/include/aasdk/Transport/USBTransport.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -23,29 +22,29 @@ #include -namespace aasdk -{ -namespace transport -{ +namespace aasdk { + namespace transport { -class USBTransport: public Transport -{ -public: - USBTransport(boost::asio::io_service& ioService, usb::IAOAPDevice::Pointer aoapDevice); + class USBTransport : public Transport { + public: + USBTransport(boost::asio::io_service &ioService, usb::IAOAPDevice::Pointer aoapDevice); - void stop() override; + void stop() override; -private: - void enqueueReceive(common::DataBuffer buffer) override; - void enqueueSend(SendQueue::iterator queueElement) override; - void doSend(SendQueue::iterator queueElement, common::Data::size_type offset); - void sendHandler(SendQueue::iterator queueElement, common::Data::size_type offset, size_t bytesTransferred); + private: + void enqueueReceive(common::DataBuffer buffer) override; - usb::IAOAPDevice::Pointer aoapDevice_; + void enqueueSend(SendQueue::iterator queueElement) override; - static constexpr uint32_t cSendTimeoutMs = 10000; - static constexpr uint32_t cReceiveTimeoutMs = 0; -}; + void doSend(SendQueue::iterator queueElement, common::Data::size_type offset); -} + void sendHandler(SendQueue::iterator queueElement, common::Data::size_type offset, size_t bytesTransferred); + + usb::IAOAPDevice::Pointer aoapDevice_; + + static constexpr uint32_t cSendTimeoutMs = 10000; + static constexpr uint32_t cReceiveTimeoutMs = 0; + }; + + } } diff --git a/include/aasdk/USB/AOAPDevice.hpp b/include/aasdk/USB/AOAPDevice.hpp index 752f232b..59ca0519 100644 --- a/include/aasdk/USB/AOAPDevice.hpp +++ b/include/aasdk/USB/AOAPDevice.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -25,37 +24,40 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class AOAPDevice: public IAOAPDevice, boost::noncopyable -{ -public: - AOAPDevice(IUSBWrapper& usbWrapper, boost::asio::io_service& ioService, DeviceHandle handle, const libusb_interface_descriptor* interfaceDescriptor); - ~AOAPDevice() override; + class AOAPDevice : public IAOAPDevice, boost::noncopyable { + public: + AOAPDevice(IUSBWrapper &usbWrapper, boost::asio::io_service &ioService, DeviceHandle handle, + const libusb_interface_descriptor *interfaceDescriptor); - IUSBEndpoint& getInEndpoint() override; - IUSBEndpoint& getOutEndpoint() override; + ~AOAPDevice() override; - static IAOAPDevice::Pointer create(IUSBWrapper& usbWrapper, boost::asio::io_service& ioService, DeviceHandle handle); + IUSBEndpoint &getInEndpoint() override; -private: - static ConfigDescriptorHandle getConfigDescriptor(IUSBWrapper& usbWrapper, DeviceHandle handle); - static const libusb_interface* getInterface(const ConfigDescriptorHandle& configDescriptorHandle); - static const libusb_interface_descriptor* getInterfaceDescriptor(const libusb_interface* interface); + IUSBEndpoint &getOutEndpoint() override; - IUSBWrapper& usbWrapper_; - DeviceHandle handle_; - const libusb_interface_descriptor* interfaceDescriptor_; - IUSBEndpoint::Pointer inEndpoint_; - IUSBEndpoint::Pointer outEndpoint_; + static IAOAPDevice::Pointer + create(IUSBWrapper &usbWrapper, boost::asio::io_service &ioService, DeviceHandle handle); - static constexpr uint16_t cGoogleVendorId = 0x18D1; - static constexpr uint16_t cAOAPId = 0x2D00; - static constexpr uint16_t cAOAPWithAdbId = 0x2D01; -}; + private: + static ConfigDescriptorHandle getConfigDescriptor(IUSBWrapper &usbWrapper, DeviceHandle handle); -} + static const libusb_interface *getInterface(const ConfigDescriptorHandle &configDescriptorHandle); + + static const libusb_interface_descriptor *getInterfaceDescriptor(const libusb_interface *interface); + + IUSBWrapper &usbWrapper_; + DeviceHandle handle_; + const libusb_interface_descriptor *interfaceDescriptor_; + IUSBEndpoint::Pointer inEndpoint_; + IUSBEndpoint::Pointer outEndpoint_; + + static constexpr uint16_t cGoogleVendorId = 0x18D1; + static constexpr uint16_t cAOAPId = 0x2D00; + static constexpr uint16_t cAOAPWithAdbId = 0x2D01; + }; + + } } diff --git a/include/aasdk/USB/AccessoryModeProtocolVersionQuery.hpp b/include/aasdk/USB/AccessoryModeProtocolVersionQuery.hpp index 16549ae3..89452a24 100644 --- a/include/aasdk/USB/AccessoryModeProtocolVersionQuery.hpp +++ b/include/aasdk/USB/AccessoryModeProtocolVersionQuery.hpp @@ -1,44 +1,44 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class AccessoryModeProtocolVersionQuery: public AccessoryModeQuery, public std::enable_shared_from_this -{ -public: - AccessoryModeProtocolVersionQuery(boost::asio::io_service& ioService, IUSBWrapper& usbWrapper, IUSBEndpoint::Pointer usbEndpoint); - void start(Promise::Pointer promise) override; + class AccessoryModeProtocolVersionQuery + : public AccessoryModeQuery, public std::enable_shared_from_this { + public: + AccessoryModeProtocolVersionQuery(boost::asio::io_service &ioService, IUSBWrapper &usbWrapper, + IUSBEndpoint::Pointer usbEndpoint); -private: - using std::enable_shared_from_this::shared_from_this; - void protocolVersionHandler(size_t bytesTransferred); + void start(Promise::Pointer promise) override; - typedef uint16_t ProtocolVersion; - static constexpr uint32_t ACC_REQ_GET_PROTOCOL = 51; -}; + private: + using std::enable_shared_from_this::shared_from_this; -} + void protocolVersionHandler(size_t bytesTransferred); + + typedef uint16_t ProtocolVersion; + static constexpr uint32_t ACC_REQ_GET_PROTOCOL = 51; + }; + + } } diff --git a/include/aasdk/USB/AccessoryModeQuery.hpp b/include/aasdk/USB/AccessoryModeQuery.hpp index 0d881ff6..62e66351 100644 --- a/include/aasdk/USB/AccessoryModeQuery.hpp +++ b/include/aasdk/USB/AccessoryModeQuery.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -26,26 +25,24 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class AccessoryModeQuery: public IAccessoryModeQuery, boost::noncopyable -{ -public: - AccessoryModeQuery(boost::asio::io_service& ioService, IUSBEndpoint::Pointer usbEndpoint); - void cancel() override; + class AccessoryModeQuery : public IAccessoryModeQuery, boost::noncopyable { + public: + AccessoryModeQuery(boost::asio::io_service &ioService, IUSBEndpoint::Pointer usbEndpoint); -protected: - boost::asio::io_service::strand strand_; - IUSBEndpoint::Pointer usbEndpoint_; - common::Data data_; - Promise::Pointer promise_; + void cancel() override; - static constexpr uint32_t cTransferTimeoutMs = 1000; - static constexpr uint32_t USB_TYPE_VENDOR = 0x40; -}; + protected: + boost::asio::io_service::strand strand_; + IUSBEndpoint::Pointer usbEndpoint_; + common::Data data_; + Promise::Pointer promise_; -} + static constexpr uint32_t cTransferTimeoutMs = 1000; + static constexpr uint32_t USB_TYPE_VENDOR = 0x40; + }; + + } } diff --git a/include/aasdk/USB/AccessoryModeQueryChain.hpp b/include/aasdk/USB/AccessoryModeQueryChain.hpp index d5678137..104aa3e4 100644 --- a/include/aasdk/USB/AccessoryModeQueryChain.hpp +++ b/include/aasdk/USB/AccessoryModeQueryChain.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -23,44 +22,53 @@ #include -namespace aasdk -{ -namespace usb -{ - -class IAccessoryModeQueryFactory; - -class AccessoryModeQueryChain: public IAccessoryModeQueryChain, public std::enable_shared_from_this, boost::noncopyable -{ -public: - AccessoryModeQueryChain(IUSBWrapper& usbWrapper, - boost::asio::io_service& ioService, - IAccessoryModeQueryFactory& queryFactory); - - void start(DeviceHandle handle, Promise::Pointer promise) override; - void cancel() override; - -private: - using std::enable_shared_from_this::shared_from_this; - - void startQuery(AccessoryModeQueryType queryType, IUSBEndpoint::Pointer usbEndpoint, IAccessoryModeQuery::Promise::Pointer queryPromise); - - void protocolVersionQueryHandler(IUSBEndpoint::Pointer usbEndpoint); - void manufacturerQueryHandler(IUSBEndpoint::Pointer usbEndpoint); - void modelQueryHandler(IUSBEndpoint::Pointer usbEndpoint); - void descriptionQueryHandler(IUSBEndpoint::Pointer usbEndpoint); - void versionQueryHandler(IUSBEndpoint::Pointer usbEndpoint); - void uriQueryHandler(IUSBEndpoint::Pointer usbEndpoint); - void serialQueryHandler(IUSBEndpoint::Pointer usbEndpoint); - void startQueryHandler(IUSBEndpoint::Pointer usbEndpoint); - - IUSBWrapper& usbWrapper_; - boost::asio::io_service::strand strand_; - IAccessoryModeQueryFactory& queryFactory_; - DeviceHandle handle_; - Promise::Pointer promise_; - IAccessoryModeQuery::Pointer activeQuery_; -}; +namespace aasdk { + namespace usb { -} + class IAccessoryModeQueryFactory; + + class AccessoryModeQueryChain + : public IAccessoryModeQueryChain, + public std::enable_shared_from_this, + boost::noncopyable { + public: + AccessoryModeQueryChain(IUSBWrapper &usbWrapper, + boost::asio::io_service &ioService, + IAccessoryModeQueryFactory &queryFactory); + + void start(DeviceHandle handle, Promise::Pointer promise) override; + + void cancel() override; + + private: + using std::enable_shared_from_this::shared_from_this; + + void startQuery(AccessoryModeQueryType queryType, IUSBEndpoint::Pointer usbEndpoint, + IAccessoryModeQuery::Promise::Pointer queryPromise); + + void protocolVersionQueryHandler(IUSBEndpoint::Pointer usbEndpoint); + + void manufacturerQueryHandler(IUSBEndpoint::Pointer usbEndpoint); + + void modelQueryHandler(IUSBEndpoint::Pointer usbEndpoint); + + void descriptionQueryHandler(IUSBEndpoint::Pointer usbEndpoint); + + void versionQueryHandler(IUSBEndpoint::Pointer usbEndpoint); + + void uriQueryHandler(IUSBEndpoint::Pointer usbEndpoint); + + void serialQueryHandler(IUSBEndpoint::Pointer usbEndpoint); + + void startQueryHandler(IUSBEndpoint::Pointer usbEndpoint); + + IUSBWrapper &usbWrapper_; + boost::asio::io_service::strand strand_; + IAccessoryModeQueryFactory &queryFactory_; + DeviceHandle handle_; + Promise::Pointer promise_; + IAccessoryModeQuery::Pointer activeQuery_; + }; + + } } diff --git a/include/aasdk/USB/AccessoryModeQueryChainFactory.hpp b/include/aasdk/USB/AccessoryModeQueryChainFactory.hpp index 84747c6b..5a64377d 100644 --- a/include/aasdk/USB/AccessoryModeQueryChainFactory.hpp +++ b/include/aasdk/USB/AccessoryModeQueryChainFactory.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -22,24 +21,22 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class AccessoryModeQueryChainFactory: public IAccessoryModeQueryChainFactory -{ -public: - AccessoryModeQueryChainFactory(IUSBWrapper& usbWrapper, - boost::asio::io_service& ioService, - IAccessoryModeQueryFactory& queryFactory); - IAccessoryModeQueryChain::Pointer create() override; + class AccessoryModeQueryChainFactory : public IAccessoryModeQueryChainFactory { + public: + AccessoryModeQueryChainFactory(IUSBWrapper &usbWrapper, + boost::asio::io_service &ioService, + IAccessoryModeQueryFactory &queryFactory); -private: - IUSBWrapper& usbWrapper_; - boost::asio::io_service& ioService_; - IAccessoryModeQueryFactory& queryFactory_; -}; + IAccessoryModeQueryChain::Pointer create() override; -} + private: + IUSBWrapper &usbWrapper_; + boost::asio::io_service &ioService_; + IAccessoryModeQueryFactory &queryFactory_; + }; + + } } diff --git a/include/aasdk/USB/AccessoryModeQueryFactory.hpp b/include/aasdk/USB/AccessoryModeQueryFactory.hpp index abe2eb5b..f74e40a7 100644 --- a/include/aasdk/USB/AccessoryModeQueryFactory.hpp +++ b/include/aasdk/USB/AccessoryModeQueryFactory.hpp @@ -1,42 +1,40 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class AccessoryModeQueryFactory: public IAccessoryModeQueryFactory -{ -public: - AccessoryModeQueryFactory(usb::IUSBWrapper& usbWrapper, boost::asio::io_service& ioService); - IAccessoryModeQuery::Pointer createQuery(AccessoryModeQueryType queryType, IUSBEndpoint::Pointer usbEndpoint) override; + class AccessoryModeQueryFactory : public IAccessoryModeQueryFactory { + public: + AccessoryModeQueryFactory(usb::IUSBWrapper &usbWrapper, boost::asio::io_service &ioService); -private: - usb::IUSBWrapper& usbWrapper_; - boost::asio::io_service& ioService_; -}; + IAccessoryModeQuery::Pointer + createQuery(AccessoryModeQueryType queryType, IUSBEndpoint::Pointer usbEndpoint) override; -} + private: + usb::IUSBWrapper &usbWrapper_; + boost::asio::io_service &ioService_; + }; + + } } diff --git a/include/aasdk/USB/AccessoryModeQueryType.hpp b/include/aasdk/USB/AccessoryModeQueryType.hpp index 32ea1bc3..81000173 100644 --- a/include/aasdk/USB/AccessoryModeQueryType.hpp +++ b/include/aasdk/USB/AccessoryModeQueryType.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -22,22 +21,19 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -enum class AccessoryModeQueryType -{ - PROTOCOL_VERSION, - SEND_MANUFACTURER, - SEND_MODEL, - SEND_DESCRIPTION, - SEND_VERSION, - SEND_URI, - SEND_SERIAL, - START -}; + enum class AccessoryModeQueryType { + PROTOCOL_VERSION, + SEND_MANUFACTURER, + SEND_MODEL, + SEND_DESCRIPTION, + SEND_VERSION, + SEND_URI, + SEND_SERIAL, + START + }; -} + } } diff --git a/include/aasdk/USB/AccessoryModeSendStringQuery.hpp b/include/aasdk/USB/AccessoryModeSendStringQuery.hpp index f0fb3372..4846bc7d 100644 --- a/include/aasdk/USB/AccessoryModeSendStringQuery.hpp +++ b/include/aasdk/USB/AccessoryModeSendStringQuery.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -23,24 +22,24 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class AccessoryModeSendStringQuery: public AccessoryModeQuery, public std::enable_shared_from_this -{ -public: - AccessoryModeSendStringQuery(boost::asio::io_service& ioService, IUSBWrapper& usbWrapper, IUSBEndpoint::Pointer usbEndpoint, - AccessoryModeSendStringType sendStringType, const std::string& queryValue); - void start(Promise::Pointer promise) override; + class AccessoryModeSendStringQuery + : public AccessoryModeQuery, public std::enable_shared_from_this { + public: + AccessoryModeSendStringQuery(boost::asio::io_service &ioService, IUSBWrapper &usbWrapper, + IUSBEndpoint::Pointer usbEndpoint, + AccessoryModeSendStringType sendStringType, const std::string &queryValue); -private: - using std::enable_shared_from_this::shared_from_this; + void start(Promise::Pointer promise) override; - AccessoryModeSendStringType sendStringType_; - static constexpr uint32_t ACC_REQ_SEND_STRING = 52; -}; + private: + using std::enable_shared_from_this::shared_from_this; -} + AccessoryModeSendStringType sendStringType_; + static constexpr uint32_t ACC_REQ_SEND_STRING = 52; + }; + + } } diff --git a/include/aasdk/USB/AccessoryModeSendStringType.hpp b/include/aasdk/USB/AccessoryModeSendStringType.hpp index 016af9f5..45a5198b 100644 --- a/include/aasdk/USB/AccessoryModeSendStringType.hpp +++ b/include/aasdk/USB/AccessoryModeSendStringType.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -22,20 +21,17 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -enum class AccessoryModeSendStringType -{ - MANUFACTURER, - MODEL, - DESCRIPTION, - VERSION, - URI, - SERIAL -}; + enum class AccessoryModeSendStringType { + MANUFACTURER, + MODEL, + DESCRIPTION, + VERSION, + URI, + SERIAL + }; -} + } } diff --git a/include/aasdk/USB/AccessoryModeStartQuery.hpp b/include/aasdk/USB/AccessoryModeStartQuery.hpp index 0904f4db..d8d5acda 100644 --- a/include/aasdk/USB/AccessoryModeStartQuery.hpp +++ b/include/aasdk/USB/AccessoryModeStartQuery.hpp @@ -1,42 +1,41 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class AccessoryModeStartQuery: public AccessoryModeQuery, public std::enable_shared_from_this -{ -public: - AccessoryModeStartQuery(boost::asio::io_service& ioService, IUSBWrapper& usbWrapper, IUSBEndpoint::Pointer usbEndpoint); - void start(Promise::Pointer promise) override; + class AccessoryModeStartQuery + : public AccessoryModeQuery, public std::enable_shared_from_this { + public: + AccessoryModeStartQuery(boost::asio::io_service &ioService, IUSBWrapper &usbWrapper, + IUSBEndpoint::Pointer usbEndpoint); -private: - using std::enable_shared_from_this::shared_from_this; + void start(Promise::Pointer promise) override; - static constexpr uint32_t ACC_REQ_START = 53; -}; + private: + using std::enable_shared_from_this::shared_from_this; -} + static constexpr uint32_t ACC_REQ_START = 53; + }; + + } } diff --git a/include/aasdk/USB/ConnectedAccessoriesEnumerator.hpp b/include/aasdk/USB/ConnectedAccessoriesEnumerator.hpp index f5fd59e8..3b48dc1b 100644 --- a/include/aasdk/USB/ConnectedAccessoriesEnumerator.hpp +++ b/include/aasdk/USB/ConnectedAccessoriesEnumerator.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -24,33 +23,36 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class ConnectedAccessoriesEnumerator: public IConnectedAccessoriesEnumerator, public std::enable_shared_from_this -{ -public: - ConnectedAccessoriesEnumerator(IUSBWrapper& usbWrapper, boost::asio::io_service& ioService, IAccessoryModeQueryChainFactory& queryChainFactory); + class ConnectedAccessoriesEnumerator + : public IConnectedAccessoriesEnumerator, public std::enable_shared_from_this { + public: + ConnectedAccessoriesEnumerator(IUSBWrapper &usbWrapper, boost::asio::io_service &ioService, + IAccessoryModeQueryChainFactory &queryChainFactory); - void enumerate(Promise::Pointer promise) override; - void cancel() override; + void enumerate(Promise::Pointer promise) override; -private: - using std::enable_shared_from_this::shared_from_this; - void queryNextDevice(); - DeviceHandle getNextDeviceHandle(); - void reset(); + void cancel() override; - IUSBWrapper& usbWrapper_; - boost::asio::io_service::strand strand_; - IAccessoryModeQueryChainFactory& queryChainFactory_; - IAccessoryModeQueryChain::Pointer queryChain_; - Promise::Pointer promise_; - DeviceListHandle deviceListHandle_; - DeviceList::iterator actualDeviceIter_; -}; + private: + using std::enable_shared_from_this::shared_from_this; -} + void queryNextDevice(); + + DeviceHandle getNextDeviceHandle(); + + void reset(); + + IUSBWrapper &usbWrapper_; + boost::asio::io_service::strand strand_; + IAccessoryModeQueryChainFactory &queryChainFactory_; + IAccessoryModeQueryChain::Pointer queryChain_; + Promise::Pointer promise_; + DeviceListHandle deviceListHandle_; + DeviceList::iterator actualDeviceIter_; + }; + + } } diff --git a/include/aasdk/USB/IAOAPDevice.hpp b/include/aasdk/USB/IAOAPDevice.hpp index c32034b7..7fb157d6 100644 --- a/include/aasdk/USB/IAOAPDevice.hpp +++ b/include/aasdk/USB/IAOAPDevice.hpp @@ -1,42 +1,40 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class IAOAPDevice -{ -public: - typedef std::shared_ptr Pointer; + class IAOAPDevice { + public: + typedef std::shared_ptr Pointer; - IAOAPDevice() = default; - virtual ~IAOAPDevice() = default; + IAOAPDevice() = default; - virtual IUSBEndpoint& getInEndpoint() = 0; - virtual IUSBEndpoint& getOutEndpoint() = 0; -}; + virtual ~IAOAPDevice() = default; -} + virtual IUSBEndpoint &getInEndpoint() = 0; + + virtual IUSBEndpoint &getOutEndpoint() = 0; + }; + + } } diff --git a/include/aasdk/USB/IAccessoryModeQuery.hpp b/include/aasdk/USB/IAccessoryModeQuery.hpp index e839d28e..084ac25b 100644 --- a/include/aasdk/USB/IAccessoryModeQuery.hpp +++ b/include/aasdk/USB/IAccessoryModeQuery.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -25,23 +24,22 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class IAccessoryModeQuery -{ -public: - typedef std::shared_ptr Pointer; - typedef io::Promise Promise; + class IAccessoryModeQuery { + public: + typedef std::shared_ptr Pointer; + typedef io::Promise Promise; - IAccessoryModeQuery() = default; - virtual ~IAccessoryModeQuery() = default; + IAccessoryModeQuery() = default; - virtual void start(Promise::Pointer promise) = 0; - virtual void cancel() = 0; -}; + virtual ~IAccessoryModeQuery() = default; -} + virtual void start(Promise::Pointer promise) = 0; + + virtual void cancel() = 0; + }; + + } } diff --git a/include/aasdk/USB/IAccessoryModeQueryChain.hpp b/include/aasdk/USB/IAccessoryModeQueryChain.hpp index 62937f92..15bacc62 100644 --- a/include/aasdk/USB/IAccessoryModeQueryChain.hpp +++ b/include/aasdk/USB/IAccessoryModeQueryChain.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -24,22 +23,22 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class IAccessoryModeQueryChain -{ -public: - typedef std::shared_ptr Pointer; - typedef io::Promise Promise; + class IAccessoryModeQueryChain { + public: + typedef std::shared_ptr Pointer; + typedef io::Promise Promise; - IAccessoryModeQueryChain() = default; - virtual ~IAccessoryModeQueryChain() = default; - virtual void start(DeviceHandle handle, Promise::Pointer promise) = 0; - virtual void cancel() = 0; -}; + IAccessoryModeQueryChain() = default; -} + virtual ~IAccessoryModeQueryChain() = default; + + virtual void start(DeviceHandle handle, Promise::Pointer promise) = 0; + + virtual void cancel() = 0; + }; + + } } diff --git a/include/aasdk/USB/IAccessoryModeQueryChainFactory.hpp b/include/aasdk/USB/IAccessoryModeQueryChainFactory.hpp index 7394af1a..31f0b34f 100644 --- a/include/aasdk/USB/IAccessoryModeQueryChainFactory.hpp +++ b/include/aasdk/USB/IAccessoryModeQueryChainFactory.hpp @@ -1,38 +1,34 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class IAccessoryModeQueryChainFactory -{ -public: - virtual ~IAccessoryModeQueryChainFactory() = default; + class IAccessoryModeQueryChainFactory { + public: + virtual ~IAccessoryModeQueryChainFactory() = default; - virtual IAccessoryModeQueryChain::Pointer create() = 0; -}; + virtual IAccessoryModeQueryChain::Pointer create() = 0; + }; -} + } } diff --git a/include/aasdk/USB/IAccessoryModeQueryFactory.hpp b/include/aasdk/USB/IAccessoryModeQueryFactory.hpp index 22114383..8de624ff 100644 --- a/include/aasdk/USB/IAccessoryModeQueryFactory.hpp +++ b/include/aasdk/USB/IAccessoryModeQueryFactory.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -24,19 +23,18 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class IAccessoryModeQueryFactory -{ -public: - IAccessoryModeQueryFactory() = default; - virtual ~IAccessoryModeQueryFactory() = default; + class IAccessoryModeQueryFactory { + public: + IAccessoryModeQueryFactory() = default; - virtual IAccessoryModeQuery::Pointer createQuery(AccessoryModeQueryType queryType, IUSBEndpoint::Pointer usbEndpoint) = 0; -}; + virtual ~IAccessoryModeQueryFactory() = default; -} + virtual IAccessoryModeQuery::Pointer + createQuery(AccessoryModeQueryType queryType, IUSBEndpoint::Pointer usbEndpoint) = 0; + }; + + } } diff --git a/include/aasdk/USB/IConnectedAccessoriesEnumerator.hpp b/include/aasdk/USB/IConnectedAccessoriesEnumerator.hpp index f4a50054..ecaea6bf 100644 --- a/include/aasdk/USB/IConnectedAccessoriesEnumerator.hpp +++ b/include/aasdk/USB/IConnectedAccessoriesEnumerator.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -22,21 +21,20 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class IConnectedAccessoriesEnumerator -{ -public: - typedef std::shared_ptr Pointer; - typedef io::Promise Promise; + class IConnectedAccessoriesEnumerator { + public: + typedef std::shared_ptr Pointer; + typedef io::Promise Promise; - virtual ~IConnectedAccessoriesEnumerator() = default; - virtual void enumerate(Promise::Pointer promise) = 0; - virtual void cancel() = 0; -}; + virtual ~IConnectedAccessoriesEnumerator() = default; -} + virtual void enumerate(Promise::Pointer promise) = 0; + + virtual void cancel() = 0; + }; + + } } diff --git a/include/aasdk/USB/IUSBEndpoint.hpp b/include/aasdk/USB/IUSBEndpoint.hpp index c25d856d..794874a0 100644 --- a/include/aasdk/USB/IUSBEndpoint.hpp +++ b/include/aasdk/USB/IUSBEndpoint.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -24,27 +23,30 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class IUSBEndpoint -{ -public: - typedef std::shared_ptr Pointer; - typedef io::Promise Promise; + class IUSBEndpoint { + public: + typedef std::shared_ptr Pointer; + typedef io::Promise Promise; - IUSBEndpoint() = default; - virtual ~IUSBEndpoint() = default; + IUSBEndpoint() = default; - virtual uint8_t getAddress() = 0; - virtual void controlTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) = 0; - virtual void bulkTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) = 0; - virtual void interruptTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) = 0; - virtual void cancelTransfers() = 0; - virtual DeviceHandle getDeviceHandle() const = 0; -}; + virtual ~IUSBEndpoint() = default; -} + virtual uint8_t getAddress() = 0; + + virtual void controlTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) = 0; + + virtual void bulkTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) = 0; + + virtual void interruptTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) = 0; + + virtual void cancelTransfers() = 0; + + virtual DeviceHandle getDeviceHandle() const = 0; + }; + + } } diff --git a/include/aasdk/USB/IUSBHub.hpp b/include/aasdk/USB/IUSBHub.hpp index b5c12fe6..d534fb20 100644 --- a/include/aasdk/USB/IUSBHub.hpp +++ b/include/aasdk/USB/IUSBHub.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -25,23 +24,22 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -class IUSBHub -{ -public: - typedef std::shared_ptr Pointer; - typedef io::Promise Promise; + class IUSBHub { + public: + typedef std::shared_ptr Pointer; + typedef io::Promise Promise; - IUSBHub() = default; - virtual ~IUSBHub() = default; + IUSBHub() = default; - virtual void start(Promise::Pointer promise) = 0; - virtual void cancel() = 0; -}; + virtual ~IUSBHub() = default; -} + virtual void start(Promise::Pointer promise) = 0; + + virtual void cancel() = 0; + }; + + } } diff --git a/include/aasdk/USB/IUSBWrapper.hpp b/include/aasdk/USB/IUSBWrapper.hpp index 96331474..3f82b430 100644 --- a/include/aasdk/USB/IUSBWrapper.hpp +++ b/include/aasdk/USB/IUSBWrapper.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -24,58 +23,70 @@ #include -namespace aasdk -{ -namespace usb -{ - -typedef std::shared_ptr DeviceHandle; -typedef std::list DeviceList; -typedef std::shared_ptr DeviceListHandle; -typedef std::shared_ptr ConfigDescriptorHandle; -typedef std::shared_ptr HotplugCallbackHandle; - -class IUSBWrapper -{ -public: - virtual ~IUSBWrapper() = default; - - virtual int releaseInterface(const DeviceHandle& dev_handle, int interface_number) = 0; - virtual libusb_device* getDevice(const DeviceHandle& dev_handle) = 0; - virtual int claimInterface(const DeviceHandle& dev_handle, int interface_number) = 0; - virtual DeviceHandle openDeviceWithVidPid(uint16_t vendor_id, uint16_t product_id) = 0; - virtual int getConfigDescriptor(libusb_device *dev, uint8_t config_index, ConfigDescriptorHandle& config_descriptor_handle) = 0; - - virtual void fillBulkTransfer(libusb_transfer *transfer, - const DeviceHandle& dev_handle, unsigned char endpoint, - unsigned char *buffer, int length, libusb_transfer_cb_fn callback, - void *user_data, unsigned int timeout) = 0; - - virtual void fillInterruptTransfer(libusb_transfer *transfer, - const DeviceHandle& dev_handle, unsigned char endpoint, - unsigned char *buffer, int length, libusb_transfer_cb_fn callback, - void *user_data, unsigned int timeout) = 0; - - virtual void fillControlTransfer( - libusb_transfer *transfer, const DeviceHandle& dev_handle, - unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data, - unsigned int timeout) = 0; - - virtual int submitTransfer(libusb_transfer *transfer) = 0; - virtual int cancelTransfer(libusb_transfer *transfer) = 0; - virtual void freeTransfer(libusb_transfer *transfer) = 0; - - virtual ssize_t getDeviceList(DeviceListHandle& handle) = 0; - virtual int open(libusb_device *dev, DeviceHandle& dev_handle) = 0; - virtual void fillControlSetup(unsigned char *buffer, - uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, - uint16_t wLength) = 0; - virtual int getDeviceDescriptor(libusb_device *dev, libusb_device_descriptor &desc) = 0; - virtual void handleEvents() = 0; - virtual HotplugCallbackHandle hotplugRegisterCallback(libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int product_id, int dev_class, - libusb_hotplug_callback_fn cb_fn, void *user_data) = 0; - virtual libusb_transfer* allocTransfer(int iso_packets) = 0; -}; +namespace aasdk { + namespace usb { -} + typedef std::shared_ptr DeviceHandle; + typedef std::list DeviceList; + typedef std::shared_ptr DeviceListHandle; + typedef std::shared_ptr ConfigDescriptorHandle; + typedef std::shared_ptr HotplugCallbackHandle; + + class IUSBWrapper { + public: + virtual ~IUSBWrapper() = default; + + virtual int releaseInterface(const DeviceHandle &dev_handle, int interface_number) = 0; + + virtual libusb_device *getDevice(const DeviceHandle &dev_handle) = 0; + + virtual int claimInterface(const DeviceHandle &dev_handle, int interface_number) = 0; + + virtual DeviceHandle openDeviceWithVidPid(uint16_t vendor_id, uint16_t product_id) = 0; + + virtual int getConfigDescriptor(libusb_device *dev, uint8_t config_index, + ConfigDescriptorHandle &config_descriptor_handle) = 0; + + virtual void fillBulkTransfer(libusb_transfer *transfer, + const DeviceHandle &dev_handle, unsigned char endpoint, + unsigned char *buffer, int length, libusb_transfer_cb_fn callback, + void *user_data, unsigned int timeout) = 0; + + virtual void fillInterruptTransfer(libusb_transfer *transfer, + const DeviceHandle &dev_handle, unsigned char endpoint, + unsigned char *buffer, int length, libusb_transfer_cb_fn callback, + void *user_data, unsigned int timeout) = 0; + + virtual void fillControlTransfer( + libusb_transfer *transfer, const DeviceHandle &dev_handle, + unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data, + unsigned int timeout) = 0; + + virtual int submitTransfer(libusb_transfer *transfer) = 0; + + virtual int cancelTransfer(libusb_transfer *transfer) = 0; + + virtual void freeTransfer(libusb_transfer *transfer) = 0; + + virtual ssize_t getDeviceList(DeviceListHandle &handle) = 0; + + virtual int open(libusb_device *dev, DeviceHandle &dev_handle) = 0; + + virtual void fillControlSetup(unsigned char *buffer, + uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, + uint16_t wLength) = 0; + + virtual int getDeviceDescriptor(libusb_device *dev, libusb_device_descriptor &desc) = 0; + + virtual void handleEvents() = 0; + + virtual HotplugCallbackHandle + hotplugRegisterCallback(libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int product_id, + int dev_class, + libusb_hotplug_callback_fn cb_fn, void *user_data) = 0; + + virtual libusb_transfer *allocTransfer(int iso_packets) = 0; + }; + + } } diff --git a/include/aasdk/USB/USBEndpoint.hpp b/include/aasdk/USB/USBEndpoint.hpp index c729fe9e..8d30656a 100644 --- a/include/aasdk/USB/USBEndpoint.hpp +++ b/include/aasdk/USB/USBEndpoint.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -25,39 +24,44 @@ #include -namespace aasdk -{ -namespace usb -{ - -class USBEndpoint: public IUSBEndpoint, - public std::enable_shared_from_this, - boost::noncopyable -{ -public: - USBEndpoint(IUSBWrapper& usbWrapper, boost::asio::io_service& ioService, DeviceHandle handle, uint8_t endpointAddress = 0x00); - - void controlTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) override; - void bulkTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) override; - void interruptTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) override; - uint8_t getAddress() override; - void cancelTransfers() override; - DeviceHandle getDeviceHandle() const override; - -private: - typedef std::unordered_map Transfers; - - using std::enable_shared_from_this::shared_from_this; - void transfer(libusb_transfer *transfer, Promise::Pointer promise); - static void transferHandler(libusb_transfer *transfer); - - IUSBWrapper& usbWrapper_; - boost::asio::io_service::strand strand_; - DeviceHandle handle_; - uint8_t endpointAddress_; - Transfers transfers_; - std::shared_ptr self_; -}; +namespace aasdk { + namespace usb { -} + class USBEndpoint : public IUSBEndpoint, + public std::enable_shared_from_this, + boost::noncopyable { + public: + USBEndpoint(IUSBWrapper &usbWrapper, boost::asio::io_service &ioService, DeviceHandle handle, + uint8_t endpointAddress = 0x00); + + void controlTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) override; + + void bulkTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) override; + + void interruptTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) override; + + uint8_t getAddress() override; + + void cancelTransfers() override; + + DeviceHandle getDeviceHandle() const override; + + private: + typedef std::unordered_map Transfers; + + using std::enable_shared_from_this::shared_from_this; + + void transfer(libusb_transfer *transfer, Promise::Pointer promise); + + static void transferHandler(libusb_transfer *transfer); + + IUSBWrapper &usbWrapper_; + boost::asio::io_service::strand strand_; + DeviceHandle handle_; + uint8_t endpointAddress_; + Transfers transfers_; + std::shared_ptr self_; + }; + + } } diff --git a/include/aasdk/USB/USBHub.hpp b/include/aasdk/USB/USBHub.hpp index cffcfc20..1608aa22 100644 --- a/include/aasdk/USB/USBHub.hpp +++ b/include/aasdk/USB/USBHub.hpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once @@ -24,40 +23,43 @@ #include -namespace aasdk -{ -namespace usb -{ - -class IUSBWrapper; - -class USBHub: public IUSBHub, public std::enable_shared_from_this, boost::noncopyable -{ -public: - USBHub(IUSBWrapper& usbWrapper, boost::asio::io_service& ioService, IAccessoryModeQueryChainFactory& queryChainFactory); - - void start(Promise::Pointer promise) override; - void cancel() override; - -private: - typedef std::list QueryChainQueue; - using std::enable_shared_from_this::shared_from_this; - void handleDevice(libusb_device* device); - bool isAOAPDevice(const libusb_device_descriptor& deviceDescriptor) const; - static int hotplugEventsHandler(libusb_context* usbContext, libusb_device* device, libusb_hotplug_event event, void* uerData); - - IUSBWrapper& usbWrapper_; - boost::asio::io_service::strand strand_; - IAccessoryModeQueryChainFactory& queryChainFactory_; - Promise::Pointer hotplugPromise_; - Pointer self_; - HotplugCallbackHandle hotplugHandle_; - QueryChainQueue queryChainQueue_; - - static constexpr uint16_t cGoogleVendorId = 0x18D1; - static constexpr uint16_t cAOAPId = 0x2D00; - static constexpr uint16_t cAOAPWithAdbId = 0x2D01; -}; +namespace aasdk { + namespace usb { -} + class IUSBWrapper; + + class USBHub : public IUSBHub, public std::enable_shared_from_this, boost::noncopyable { + public: + USBHub(IUSBWrapper &usbWrapper, boost::asio::io_service &ioService, + IAccessoryModeQueryChainFactory &queryChainFactory); + + void start(Promise::Pointer promise) override; + + void cancel() override; + + private: + typedef std::list QueryChainQueue; + using std::enable_shared_from_this::shared_from_this; + + void handleDevice(libusb_device *device); + + bool isAOAPDevice(const libusb_device_descriptor &deviceDescriptor) const; + + static int hotplugEventsHandler(libusb_context *usbContext, libusb_device *device, libusb_hotplug_event event, + void *uerData); + + IUSBWrapper &usbWrapper_; + boost::asio::io_service::strand strand_; + IAccessoryModeQueryChainFactory &queryChainFactory_; + Promise::Pointer hotplugPromise_; + Pointer self_; + HotplugCallbackHandle hotplugHandle_; + QueryChainQueue queryChainQueue_; + + static constexpr uint16_t cGoogleVendorId = 0x18D1; + static constexpr uint16_t cAOAPId = 0x2D00; + static constexpr uint16_t cAOAPWithAdbId = 0x2D01; + }; + + } } diff --git a/include/aasdk/USB/USBWrapper.hpp b/include/aasdk/USB/USBWrapper.hpp index d48650e4..7ef3a683 100644 --- a/include/aasdk/USB/USBWrapper.hpp +++ b/include/aasdk/USB/USBWrapper.hpp @@ -1,75 +1,86 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include -namespace aasdk -{ -namespace usb -{ - -class USBWrapper: public IUSBWrapper -{ -public: - USBWrapper(libusb_context* usbContext); - - int releaseInterface(const DeviceHandle& dev_handle, int interface_number) override; - libusb_device* getDevice(const DeviceHandle& dev_handle) override; - int claimInterface(const DeviceHandle& dev_handle, int interface_number) override; - DeviceHandle openDeviceWithVidPid(uint16_t vendor_id, uint16_t product_id) override; - int getConfigDescriptor(libusb_device *dev, uint8_t config_index, ConfigDescriptorHandle& config_descriptor_handle) override; - - void fillBulkTransfer(libusb_transfer *transfer, - const DeviceHandle& dev_handle, unsigned char endpoint, - unsigned char *buffer, int length, libusb_transfer_cb_fn callback, - void *user_data, unsigned int timeout) override; - - void fillInterruptTransfer(libusb_transfer *transfer, - const DeviceHandle& dev_handle, unsigned char endpoint, - unsigned char *buffer, int length, libusb_transfer_cb_fn callback, - void *user_data, unsigned int timeout) override; - - void fillControlTransfer( - libusb_transfer *transfer, const DeviceHandle& dev_handle, - unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data, - unsigned int timeout) override; - - int submitTransfer(libusb_transfer *transfer) override; - int cancelTransfer(libusb_transfer *transfer) override; - void freeTransfer(libusb_transfer *transfer) override; - - ssize_t getDeviceList(DeviceListHandle& handle) override; - int open(libusb_device *dev, DeviceHandle& dev_handle) override; - void fillControlSetup(unsigned char *buffer, - uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, - uint16_t wLength) override; - int getDeviceDescriptor(libusb_device *dev, libusb_device_descriptor &desc) override; - void handleEvents() override; - HotplugCallbackHandle hotplugRegisterCallback(libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int product_id, int dev_class, - libusb_hotplug_callback_fn cb_fn, void *user_data) override; - libusb_transfer* allocTransfer(int iso_packets) override; - -private: - libusb_context* usbContext_; -}; +namespace aasdk { + namespace usb { -} + class USBWrapper : public IUSBWrapper { + public: + USBWrapper(libusb_context *usbContext); + + int releaseInterface(const DeviceHandle &dev_handle, int interface_number) override; + + libusb_device *getDevice(const DeviceHandle &dev_handle) override; + + int claimInterface(const DeviceHandle &dev_handle, int interface_number) override; + + DeviceHandle openDeviceWithVidPid(uint16_t vendor_id, uint16_t product_id) override; + + int getConfigDescriptor(libusb_device *dev, uint8_t config_index, + ConfigDescriptorHandle &config_descriptor_handle) override; + + void fillBulkTransfer(libusb_transfer *transfer, + const DeviceHandle &dev_handle, unsigned char endpoint, + unsigned char *buffer, int length, libusb_transfer_cb_fn callback, + void *user_data, unsigned int timeout) override; + + void fillInterruptTransfer(libusb_transfer *transfer, + const DeviceHandle &dev_handle, unsigned char endpoint, + unsigned char *buffer, int length, libusb_transfer_cb_fn callback, + void *user_data, unsigned int timeout) override; + + void fillControlTransfer( + libusb_transfer *transfer, const DeviceHandle &dev_handle, + unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data, + unsigned int timeout) override; + + int submitTransfer(libusb_transfer *transfer) override; + + int cancelTransfer(libusb_transfer *transfer) override; + + void freeTransfer(libusb_transfer *transfer) override; + + ssize_t getDeviceList(DeviceListHandle &handle) override; + + int open(libusb_device *dev, DeviceHandle &dev_handle) override; + + void fillControlSetup(unsigned char *buffer, + uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, + uint16_t wLength) override; + + int getDeviceDescriptor(libusb_device *dev, libusb_device_descriptor &desc) override; + + void handleEvents() override; + + HotplugCallbackHandle + hotplugRegisterCallback(libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int product_id, + int dev_class, + libusb_hotplug_callback_fn cb_fn, void *user_data) override; + + libusb_transfer *allocTransfer(int iso_packets) override; + + private: + libusb_context *usbContext_; + }; + + } } diff --git a/include/aasdk/Version.hpp b/include/aasdk/Version.hpp index 898cf20e..3a40cebf 100644 --- a/include/aasdk/Version.hpp +++ b/include/aasdk/Version.hpp @@ -1,24 +1,23 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #pragma once #include static const uint16_t AASDK_MAJOR = 1; -static const uint16_t AASDK_MINOR = 1; +static const uint16_t AASDK_MINOR = 6; diff --git a/protobuf/CMakeLists.txt b/protobuf/CMakeLists.txt new file mode 100644 index 00000000..acdf51f7 --- /dev/null +++ b/protobuf/CMakeLists.txt @@ -0,0 +1,116 @@ +cmake_minimum_required(VERSION 3.5) + +#Android Auto Projection Protocol Library +project(aap_protobuf) +message(STATUS "AASDK ProtoBuf Library") + +# Set Compile Versions +set(LIBRARY_BUILD_DATE "20241121") # Binary Release Build Date +set(LIBRARY_BUILD_MAJOR_RELEASE 4) # Binary Release Build Number (increment if released on same day) +set(LIBRARY_BUILD_MINOR_RELEASE 0) # Binary Release Build Number (increment if released on same day) +set(LIBRARY_BUILD_INCREMENTAL 0) # Binary Build Version - Increment for Each Build +set(AAP_PROTO_VERSION 1.6) # Underlying AAP (Android Auto Projection Library Protocol) + +set(CMAKE_CXX_STANDARD 17) + +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Default to Release mode unless overridden with -DCMAKE_BUILD_TYPE=Debug on cmake command +if(NOT CMAKE_BUILD_TYPE) + message(STATUS "Forcing Release build type") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + +# Building on a Mac requires Abseil +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # macOS + # macOS specific command + message(STATUS "MacOS System Detected") + find_package(protobuf REQUIRED CONFIG) + find_package(absl) +else() + # Linux specific command + find_package(Protobuf REQUIRED) +endif() + +include(FindProtobuf) + +# Turn off Path Appending +set(PROTOBUF_GENERATE_CPP_APPEND_PATH OFF) + +# Locate all proto files +file(GLOB_RECURSE source_proto_files ${CMAKE_CURRENT_SOURCE_DIR}/*.proto) + +# Compile ProtoBuf files +protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${source_proto_files}) + +# Generate Library +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # macOS + message(NOTICE "Configuring STATIC Library for MacOS") + add_library(aap_protobuf STATIC ${PROTO_SRCS} ${PROTO_HDRS}) +else() + message(NOTICE "Configuring SHARED Library") + add_library(aap_protobuf SHARED ${PROTO_SRCS} ${PROTO_HDRS}) +endif() + +target_link_libraries(aap_protobuf PUBLIC ${PROTOBUF_LIBRARIES}) +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/aap_protobuf + ${PROTOBUF_INCLUDE_DIR} +) + +set(LIBRARY_BUILD_VERSION_STRING "${LIBRARY_BUILD_MAJOR_RELEASE}.${LIBRARY_BUILD_MINOR_RELEASE}.${LIBRARY_BUILD_INCREMENTAL}+${LIBRARY_BUILD_DATE}") +message(STATUS "Project Version: ${LIBRARY_BUILD_VERSION_STRING}") +set_target_properties(aap_protobuf + PROPERTIES + VERSION ${LIBRARY_BUILD_VERSION_STRING} + SOVERSION ${LIBRARY_BUILD_INCREMENTAL}) + +# Install rules +install(TARGETS aap_protobuf + EXPORT aap_protobufTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) + +target_include_directories(aap_protobuf + PUBLIC + $ + $ +) + +# Install headers explicitly +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/aap_protobuf + DESTINATION include + FILES_MATCHING PATTERN "*.h") + +# Export the targets to a script +install(EXPORT aap_protobufTargets + FILE aap_protobufTargets.cmake + NAMESPACE AAPProto:: + DESTINATION lib/cmake/aap_protobuf +) + +# Create a Config file for FindPackage +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/aap_protobufConfigVersion.cmake" + VERSION 1.0 + COMPATIBILITY AnyNewerVersion +) + +configure_package_config_file(Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/aap_protobufConfig.cmake" + INSTALL_DESTINATION lib/cmake/aap_protobuf +) + +# Install the config files +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/aap_protobufConfigVersion.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/aap_protobufConfig.cmake" + DESTINATION lib/cmake/aap_protobuf) + + diff --git a/protobuf/Config.cmake.in b/protobuf/Config.cmake.in new file mode 100644 index 00000000..2e5c0a98 --- /dev/null +++ b/protobuf/Config.cmake.in @@ -0,0 +1,3 @@ +set(AAP_PROTOBUF_INCLUDE_DIRS @CMAKE_INSTALL_FULL_INCLUDEDIR@) +set(AAP_PROTOBUF_LIB_DIRS @CMAKE_INSTALL_FULL_LIBDIR@) +include("${CMAKE_CURRENT_LIST_DIR}/aap_protobufTargets.cmake") \ No newline at end of file diff --git a/protobuf/README.md b/protobuf/README.md new file mode 100644 index 00000000..a56221b7 --- /dev/null +++ b/protobuf/README.md @@ -0,0 +1,9 @@ +This new build routine provides for installing the ProtoBuffer as a separate library. + +``` +mkdir protobuf/build +cd protobuf/build +cmake .. +make +make install +``` diff --git a/protobuf/aap_protobuf/aaw/MessageId.proto b/protobuf/aap_protobuf/aaw/MessageId.proto new file mode 100644 index 00000000..fd9ce9fe --- /dev/null +++ b/protobuf/aap_protobuf/aaw/MessageId.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +package aap_protobuf.aaw; + +enum MessageId { + WIFI_START_REQUEST = 1; + WIFI_INFO_REQUEST = 2; + WIFI_INFO_RESPONSE = 3; + WIFI_VERSION_REQUEST = 4; + WIFI_VERSION_RESPONSE = 5; + WIFI_CONNECTION_STATUS = 6; + WIFI_START_RESPONSE = 7; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/aaw/Status.proto b/protobuf/aap_protobuf/aaw/Status.proto new file mode 100644 index 00000000..2c595079 --- /dev/null +++ b/protobuf/aap_protobuf/aaw/Status.proto @@ -0,0 +1,19 @@ +syntax="proto2"; + +package aap_protobuf.aaw; + +enum Status { + STATUS_UNSOLICITED_MESSAGE = 1; + STATUS_SUCCESS = 0; + STATUS_NO_COMPATIBLE_VERSION = -1; + STATUS_WIFI_INACCESSIBLE_CHANNEL = -2; + STATUS_WIFI_INCORRECT_CREDENTIALS = -3; + STATUS_PROJECTION_ALREADY_STARTED = -4; + STATUS_WIFI_DISABLED = -5; + STATUS_WIFI_NOT_YET_STARTED = -6; + STATUS_INVALID_HOST = -7; + STATUS_NO_SUPPORTED_WIFI_CHANNELS = -8; + STATUS_INSTRUCT_USER_TO_CHECK_THE_PHONE = -9; + STATUS_PHONE_WIFI_DISABLED = -10; + STATUS_WIFI_NETWORK_UNAVAILABLE = -11; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/aaw/WifiConnectionStatus.proto b/protobuf/aap_protobuf/aaw/WifiConnectionStatus.proto new file mode 100644 index 00000000..4996b99d --- /dev/null +++ b/protobuf/aap_protobuf/aaw/WifiConnectionStatus.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +import "aap_protobuf/aaw/Status.proto"; + +package aap_protobuf.aaw; + +message WifiConnectionStatus { + required Status status = 1; + optional string error_message = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/aaw/WifiInfoRequest.proto b/protobuf/aap_protobuf/aaw/WifiInfoRequest.proto new file mode 100644 index 00000000..3f0da76c --- /dev/null +++ b/protobuf/aap_protobuf/aaw/WifiInfoRequest.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.aaw; + +message WifiInfoRequest { + +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/aaw/WifiInfoResponse.proto b/protobuf/aap_protobuf/aaw/WifiInfoResponse.proto new file mode 100644 index 00000000..336b338b --- /dev/null +++ b/protobuf/aap_protobuf/aaw/WifiInfoResponse.proto @@ -0,0 +1,14 @@ +syntax="proto2"; + +import "aap_protobuf/service/wifiprojection/message/AccessPointType.proto"; +import "aap_protobuf/service/wifiprojection/message/WifiSecurityMode.proto"; + +package aap_protobuf.aaw; + +message WifiInfoResponse { + required string ssid = 1; + required string password = 2; + required string bssid = 3; + required service.wifiprojection.message.WifiSecurityMode security_mode = 4; + optional service.wifiprojection.message.AccessPointType access_point_type = 5; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/aaw/WifiStartRequest.proto b/protobuf/aap_protobuf/aaw/WifiStartRequest.proto new file mode 100644 index 00000000..6617cc7c --- /dev/null +++ b/protobuf/aap_protobuf/aaw/WifiStartRequest.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.aaw; + +message WifiStartRequest { + required string ip_address = 1; + required uint32 port = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/aaw/WifiStartResponse.proto b/protobuf/aap_protobuf/aaw/WifiStartResponse.proto new file mode 100644 index 00000000..fd5e8991 --- /dev/null +++ b/protobuf/aap_protobuf/aaw/WifiStartResponse.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/aaw/Status.proto"; + +package aap_protobuf.aaw; + +message WifiStartResponse { + optional string ip_address = 1; + optional uint32 port = 2; + required Status status = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/aaw/WifiVersionRequest.proto b/protobuf/aap_protobuf/aaw/WifiVersionRequest.proto new file mode 100644 index 00000000..bb8775cf --- /dev/null +++ b/protobuf/aap_protobuf/aaw/WifiVersionRequest.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.aaw; + +message WifiVersionRequest { + +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/aaw/WifiVersionResponse.proto b/protobuf/aap_protobuf/aaw/WifiVersionResponse.proto new file mode 100644 index 00000000..af014e0f --- /dev/null +++ b/protobuf/aap_protobuf/aaw/WifiVersionResponse.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +package aap_protobuf.aaw; + +message WifiVersionResponse { + required uint32 unknown_value_a = 1; + required uint32 unknown_value_b = 2; + optional string unknown_value_c = 3; + required uint32 unknown_value_d = 4; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/channel/control/GalConstants.proto b/protobuf/aap_protobuf/channel/control/GalConstants.proto new file mode 100644 index 00000000..2da68410 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GalConstants.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +enum GalConstants { + WIFI_PORT = 30515; + PROTOCOL_MAJOR_VERSION = 1; + PROTOCOL_MINOR_VERSION = 6; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/channel/control/GalVerificationAudioFocus.proto b/protobuf/aap_protobuf/channel/control/GalVerificationAudioFocus.proto new file mode 100644 index 00000000..379eaf25 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GalVerificationAudioFocus.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/service/control/message/AudioFocusStateType.proto"; + +package aap_protobuf.service.control.message; + +message GalVerificationAudioFocus { + required AudioFocusStateType audio_focus_state = 1; + required int32 channel = 2; + optional bool unsolicited = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/channel/control/GalVerificationBugReportRequest.proto b/protobuf/aap_protobuf/channel/control/GalVerificationBugReportRequest.proto new file mode 100644 index 00000000..fe911960 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GalVerificationBugReportRequest.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message GalVerificationBugReportRequest { + +} diff --git a/protobuf/aap_protobuf/channel/control/GalVerificationBugReportResponse.proto b/protobuf/aap_protobuf/channel/control/GalVerificationBugReportResponse.proto new file mode 100644 index 00000000..ced3ddfe --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GalVerificationBugReportResponse.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message GalVerificationBugReportResponse { + required string bug_report = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/channel/control/GalVerificationDisplayInformationRequest.proto b/protobuf/aap_protobuf/channel/control/GalVerificationDisplayInformationRequest.proto new file mode 100644 index 00000000..0bb6a53f --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GalVerificationDisplayInformationRequest.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message GalVerificationDisplayInformationRequest { + +} diff --git a/protobuf/aap_protobuf/channel/control/GalVerificationDisplayInformationResponse.proto b/protobuf/aap_protobuf/channel/control/GalVerificationDisplayInformationResponse.proto new file mode 100644 index 00000000..e7327f84 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GalVerificationDisplayInformationResponse.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message GalVerificationDisplayInformationResponse { + required int32 native_width = 1; + required int32 native_height = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/channel/control/GalVerificationInjectInput.proto b/protobuf/aap_protobuf/channel/control/GalVerificationInjectInput.proto new file mode 100644 index 00000000..48e26342 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GalVerificationInjectInput.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +import "aap_protobuf/service/inputsource/message/InputReport.proto"; + +package aap_protobuf.service.control.message; + +message GalVerificationInjectInput { + required inputsource.message.InputReport input = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/channel/control/GalVerificationMediaSinkStatus.proto b/protobuf/aap_protobuf/channel/control/GalVerificationMediaSinkStatus.proto new file mode 100644 index 00000000..520e2e93 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GalVerificationMediaSinkStatus.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +import "aap_protobuf/service/media/shared/message/Config.proto"; + +package aap_protobuf.service.control.message; + +message GalVerificationMediaSinkStatus { + required int32 channel = 1; + required media.shared.message.Config.Status status = 2; +} diff --git a/protobuf/aap_protobuf/channel/control/GalVerificationScreenCaptureRequest.proto b/protobuf/aap_protobuf/channel/control/GalVerificationScreenCaptureRequest.proto new file mode 100644 index 00000000..756810eb --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GalVerificationScreenCaptureRequest.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message GalVerificationScreenCaptureRequest { + +} diff --git a/protobuf/aap_protobuf/channel/control/GalVerificationScreenCaptureResponse.proto b/protobuf/aap_protobuf/channel/control/GalVerificationScreenCaptureResponse.proto new file mode 100644 index 00000000..38bdf1d5 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GalVerificationScreenCaptureResponse.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message GalVerificationScreenCaptureResponse { + required bytes screen_capture = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/channel/control/GalVerificationSetSensor.proto b/protobuf/aap_protobuf/channel/control/GalVerificationSetSensor.proto new file mode 100644 index 00000000..2d7df898 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GalVerificationSetSensor.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +import "aap_protobuf/service/sensorsource/message/SensorBatch.proto"; + +package aap_protobuf.service.control.message; + +message GalVerificationSetSensor { + optional sensorsource.message.SensorBatch sensors = 1; +} diff --git a/protobuf/aap_protobuf/channel/control/GalVerificationVendorExtensionMessageId.proto b/protobuf/aap_protobuf/channel/control/GalVerificationVendorExtensionMessageId.proto new file mode 100644 index 00000000..6a7e7f72 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GalVerificationVendorExtensionMessageId.proto @@ -0,0 +1,17 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +enum GalVerificationVendorExtensionMessageId { + GAL_VERIFICATION_SET_SENSOR = 32769; + GAL_VERIFICATION_MEDIA_SINK_STATUS = 32770; + GAL_VERIFICATION_VIDEO_FOCUS = 32771; + GAL_VERIFICATION_AUDIO_FOCUS = 32772; + GAL_VERIFICATION_INJECT_INPUT = 32773; + GAL_VERIFICATION_BUG_REPORT_REQUEST = 32774; + GAL_VERIFICATION_BUG_REPORT_RESPONSE = 32775; + GAL_VERIFICATION_SCREEN_CAPTURE_REQUEST = 32776; + GAL_VERIFICATION_SCREEN_CAPTURE_RESPONSE = 32777; + GAL_VERIFICATION_DISPLAY_INFORMATION_REQUEST = 32778; + GAL_VERIFICATION_DISPLAY_INFORMATION_RESPONSE = 32779; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/channel/control/GalVerificationVideoFocus.proto b/protobuf/aap_protobuf/channel/control/GalVerificationVideoFocus.proto new file mode 100644 index 00000000..d250f98f --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GalVerificationVideoFocus.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/service/media/video/message/VideoFocusMode.proto"; + +package aap_protobuf.service.control.message; + +message GalVerificationVideoFocus { + required media.video.message.VideoFocusMode video_focus_mode = 1; + optional bool deny = 2; + optional bool unsolicited = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/channel/control/GoogleDiagnosticsBugReportRequest.proto b/protobuf/aap_protobuf/channel/control/GoogleDiagnosticsBugReportRequest.proto new file mode 100644 index 00000000..12e2ac95 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GoogleDiagnosticsBugReportRequest.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message GoogleDiagnosticsBugReportRequest { + required int32 token = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/channel/control/GoogleDiagnosticsBugReportResponse.proto b/protobuf/aap_protobuf/channel/control/GoogleDiagnosticsBugReportResponse.proto new file mode 100644 index 00000000..55faa483 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GoogleDiagnosticsBugReportResponse.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message GoogleDiagnosticsBugReportResponse { + optional string bug_report = 1; + repeated int32 tokens = 2; +} + + + + + diff --git a/protobuf/aap_protobuf/channel/control/GoogleDiagnosticsVendorExtensionMessageId.proto b/protobuf/aap_protobuf/channel/control/GoogleDiagnosticsVendorExtensionMessageId.proto new file mode 100644 index 00000000..b768c464 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/GoogleDiagnosticsVendorExtensionMessageId.proto @@ -0,0 +1,4 @@ +enum GoogleDiagnosticsVendorExtensionMessageId { + DIAGNOSTICS_BUG_REPORT_REQUEST = 1; + DIAGNOSTICS_BUG_REPORT_RESPONSE = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/channel/control/InstrumentClusterInput.proto b/protobuf/aap_protobuf/channel/control/InstrumentClusterInput.proto new file mode 100644 index 00000000..49d87a81 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/InstrumentClusterInput.proto @@ -0,0 +1,17 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message InstrumentClusterInput { + required InstrumentClusterAction action = 1; + enum InstrumentClusterAction { + UNKNOWN = 0; + UP = 1; + DOWN = 2; + LEFT = 3; + RIGHT = 4; + ENTER = 5; + BACK = 6; + CALL = 7; + } +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/channel/control/LocationCharacterization.proto b/protobuf/aap_protobuf/channel/control/LocationCharacterization.proto new file mode 100644 index 00000000..507f0741 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/LocationCharacterization.proto @@ -0,0 +1,15 @@ +syntax="proto2"; + +package aap_protobuf.shared; + +enum LocationCharacterization { + PRIOR_LOCATIONS = 1; + GYROSCOPE_FUSION = 2; + ACCELEROMETER_FUSION = 4; + COMPASS_FUSION = 8; + WHEEL_SPEED_FUSION = 16; + STEERING_ANGLE_FUSION = 32; + CAR_SPEED_FUSION = 64; + DEAD_RECKONED = 128; + RAW_GPS_ONLY = 256; +} diff --git a/protobuf/aap_protobuf/channel/control/SessionConfiguration.proto b/protobuf/aap_protobuf/channel/control/SessionConfiguration.proto new file mode 100644 index 00000000..75d9ddb4 --- /dev/null +++ b/protobuf/aap_protobuf/channel/control/SessionConfiguration.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +package aap_protobuf.shared; + +enum SessionConfiguration { + UI_CONFIG_HIDE_CLOCK = 1; + UI_CONFIG_HIDE_PHONE_SIGNAL = 2; + UI_CONFIG_HIDE_BATTERY_LEVEL = 4; + CAN_PLAY_NATIVE_MEDIA_DURING_VR = 8; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/Service.proto b/protobuf/aap_protobuf/service/Service.proto new file mode 100644 index 00000000..f196d82f --- /dev/null +++ b/protobuf/aap_protobuf/service/Service.proto @@ -0,0 +1,37 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/service/sensorsource/SensorSourceService.proto"; +import "aap_protobuf/service/media/sink/MediaSinkService.proto"; +import "aap_protobuf/service/inputsource/InputSourceService.proto"; +import "aap_protobuf/service/media/source/MediaSourceService.proto"; +import "aap_protobuf/service/bluetooth/BluetoothService.proto"; +import "aap_protobuf/service/navigationstatus/NavigationStatusService.proto"; +import "aap_protobuf/service/vendorextension/VendorExtensionService.proto"; +import "aap_protobuf/service/wifiprojection/WifiProjectionService.proto"; +import "aap_protobuf/service/mediabrowser/MediaBrowserService.proto"; +import "aap_protobuf/service/genericnotification/GenericNotificationService.proto"; +import "aap_protobuf/service/phonestatus/PhoneStatusService.proto"; +import "aap_protobuf/service/mediaplayback/MediaPlaybackStatusService.proto"; +import "aap_protobuf/service/radio/RadioService.proto"; + +package aap_protobuf.service; + +message Service +{ + required int32 id = 1; + optional sensorsource.SensorSourceService sensor_source_service = 2; + optional media.sink.MediaSinkService media_sink_service = 3; + optional inputsource.InputSourceService input_source_service = 4; + optional media.source.MediaSourceService media_source_service = 5; + optional bluetooth.BluetoothService bluetooth_service = 6; + optional radio.RadioService radio_service = 7; + optional navigationstatus.NavigationStatusService navigation_status_service = 8; + optional mediaplayback.MediaPlaybackStatusService media_playback_service = 9; + optional phonestatus.PhoneStatusService phone_status_service = 10; + optional mediabrowser.MediaBrowserService media_browser_service = 11; + optional vendorextension.VendorExtensionService vendor_extension_service = 12; + optional genericnotification.GenericNotificationService generic_notification_service = 13; + optional wifiprojection.WifiProjectionService wifi_projection_service = 14; +} diff --git a/protobuf/aap_protobuf/service/bluetooth/BluetoothMessageId.proto b/protobuf/aap_protobuf/service/bluetooth/BluetoothMessageId.proto new file mode 100644 index 00000000..b03e852a --- /dev/null +++ b/protobuf/aap_protobuf/service/bluetooth/BluetoothMessageId.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +package aap_protobuf.service.bluetooth; + +enum BluetoothMessageId +{ + BLUETOOTH_MESSAGE_PAIRING_REQUEST = 32769; + BLUETOOTH_MESSAGE_PAIRING_RESPONSE = 32770; + BLUETOOTH_MESSAGE_AUTHENTICATION_DATA = 32771; + BLUETOOTH_MESSAGE_AUTHENTICATION_RESULT = 32772; +} + + diff --git a/protobuf/aap_protobuf/service/bluetooth/BluetoothService.proto b/protobuf/aap_protobuf/service/bluetooth/BluetoothService.proto new file mode 100644 index 00000000..488ab821 --- /dev/null +++ b/protobuf/aap_protobuf/service/bluetooth/BluetoothService.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/service/bluetooth/message/BluetoothPairingMethod.proto"; + +package aap_protobuf.service.bluetooth; + +message BluetoothService +{ + required string car_address = 1; + repeated message.BluetoothPairingMethod supported_pairing_methods = 2 [packed = true]; +} diff --git a/protobuf/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationData.proto b/protobuf/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationData.proto new file mode 100644 index 00000000..4a8c1868 --- /dev/null +++ b/protobuf/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationData.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +import "aap_protobuf/service/bluetooth/message/BluetoothPairingMethod.proto"; + +package aap_protobuf.service.bluetooth.message; + +message BluetoothAuthenticationData { + required string auth_data = 1; + optional BluetoothPairingMethod pairing_method = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationResult.proto b/protobuf/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationResult.proto new file mode 100644 index 00000000..fc72b1d5 --- /dev/null +++ b/protobuf/aap_protobuf/service/bluetooth/message/BluetoothAuthenticationResult.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +import "aap_protobuf/shared/MessageStatus.proto"; + +package aap_protobuf.service.bluetooth.message; + +message BluetoothAuthenticationResult { + required shared.MessageStatus status = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/bluetooth/message/BluetoothPairingMethod.proto b/protobuf/aap_protobuf/service/bluetooth/message/BluetoothPairingMethod.proto new file mode 100644 index 00000000..e064a893 --- /dev/null +++ b/protobuf/aap_protobuf/service/bluetooth/message/BluetoothPairingMethod.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +package aap_protobuf.service.bluetooth.message; + +enum BluetoothPairingMethod +{ + BLUETOOTH_PAIRING_UNAVAILABLE = -1; + BLUETOOTH_PAIRING_OOB = 1; + BLUETOOTH_PAIRING_NUMERIC_COMPARISON = 2; + BLUETOOTH_PAIRING_PASSKEY_ENTRY = 3; + BLUETOOTH_PAIRING_PIN = 4; +} + diff --git a/protobuf/aap_protobuf/service/bluetooth/message/BluetoothPairingRequest.proto b/protobuf/aap_protobuf/service/bluetooth/message/BluetoothPairingRequest.proto new file mode 100644 index 00000000..796d8065 --- /dev/null +++ b/protobuf/aap_protobuf/service/bluetooth/message/BluetoothPairingRequest.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/service/bluetooth/message/BluetoothPairingMethod.proto"; + +package aap_protobuf.service.bluetooth.message; + +message BluetoothPairingRequest +{ + required string phone_address = 1; + required BluetoothPairingMethod pairing_method = 2; +} diff --git a/protobuf/aap_protobuf/service/bluetooth/message/BluetoothPairingResponse.proto b/protobuf/aap_protobuf/service/bluetooth/message/BluetoothPairingResponse.proto new file mode 100644 index 00000000..348feece --- /dev/null +++ b/protobuf/aap_protobuf/service/bluetooth/message/BluetoothPairingResponse.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/shared/MessageStatus.proto"; + +package aap_protobuf.service.bluetooth.message; + +message BluetoothPairingResponse +{ + required shared.MessageStatus status = 1; + required bool already_paired = 2; +} diff --git a/protobuf/aap_protobuf/service/control/ControlMessageType.proto b/protobuf/aap_protobuf/service/control/ControlMessageType.proto new file mode 100644 index 00000000..8dca71a0 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/ControlMessageType.proto @@ -0,0 +1,35 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +enum ControlMessageType +{ + MESSAGE_VERSION_REQUEST = 1; + MESSAGE_VERSION_RESPONSE = 2; + MESSAGE_ENCAPSULATED_SSL = 3; + MESSAGE_AUTH_COMPLETE = 4; + MESSAGE_SERVICE_DISCOVERY_REQUEST = 5; + MESSAGE_SERVICE_DISCOVERY_RESPONSE = 6; + MESSAGE_CHANNEL_OPEN_REQUEST = 7; + MESSAGE_CHANNEL_OPEN_RESPONSE = 8; + MESSAGE_CHANNEL_CLOSE_NOTIFICATION = 9; + MESSAGE_PING_REQUEST = 11; + MESSAGE_PING_RESPONSE = 12; + MESSAGE_NAV_FOCUS_REQUEST = 13; + MESSAGE_NAV_FOCUS_NOTIFICATION = 14; + MESSAGE_BYEBYE_REQUEST = 15; + MESSAGE_BYEBYE_RESPONSE = 16; + MESSAGE_VOICE_SESSION_NOTIFICATION = 17; + MESSAGE_AUDIO_FOCUS_REQUEST = 18; + MESSAGE_AUDIO_FOCUS_NOTIFICATION = 19; + MESSAGE_CAR_CONNECTED_DEVICES_REQUEST = 20; + MESSAGE_CAR_CONNECTED_DEVICES_RESPONSE = 21; + MESSAGE_USER_SWITCH_REQUEST = 22; + MESSAGE_BATTERY_STATUS_NOTIFICATION = 23; + MESSAGE_CALL_AVAILABILITY_STATUS = 24; + MESSAGE_USER_SWITCH_RESPONSE = 25; + MESSAGE_SERVICE_DISCOVERY_UPDATE = 26; + MESSAGE_UNEXPECTED_MESSAGE = 255; + MESSAGE_FRAMING_ERROR = 65535; +} + diff --git a/protobuf/aap_protobuf/service/control/message/AudioFocusNotification.proto b/protobuf/aap_protobuf/service/control/message/AudioFocusNotification.proto new file mode 100644 index 00000000..8e6c63aa --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/AudioFocusNotification.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +import "aap_protobuf/service/control/message/AudioFocusStateType.proto"; + +package aap_protobuf.service.control.message; + +message AudioFocusNotification { + required AudioFocusStateType focus_state = 1; + optional bool unsolicited = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/AudioFocusRequest.proto b/protobuf/aap_protobuf/service/control/message/AudioFocusRequest.proto new file mode 100644 index 00000000..9562bfda --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/AudioFocusRequest.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +import "aap_protobuf/service/control/message/AudioFocusRequestType.proto"; + +package aap_protobuf.service.control.message; + +message AudioFocusRequest +{ + required AudioFocusRequestType audio_focus_type = 1; +} diff --git a/protobuf/aap_protobuf/service/control/message/AudioFocusRequestNotification.proto b/protobuf/aap_protobuf/service/control/message/AudioFocusRequestNotification.proto new file mode 100644 index 00000000..003c2b0a --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/AudioFocusRequestNotification.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/service/control/message/AudioFocusRequestType.proto"; + +package aap_protobuf.service.control.message; + +message AudioFocusRequestNotification { + required AudioFocusRequestType request = 1; +} + + diff --git a/protobuf/aap_protobuf/service/control/message/AudioFocusRequestType.proto b/protobuf/aap_protobuf/service/control/message/AudioFocusRequestType.proto new file mode 100644 index 00000000..0bd21d68 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/AudioFocusRequestType.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +enum AudioFocusRequestType +{ + AUDIO_FOCUS_GAIN = 1; + AUDIO_FOCUS_GAIN_TRANSIENT = 2; + AUDIO_FOCUS_GAIN_TRANSIENT_MAY_DUCK = 3; + AUDIO_FOCUS_RELEASE = 4; +} + diff --git a/protobuf/aap_protobuf/service/control/message/AudioFocusStateType.proto b/protobuf/aap_protobuf/service/control/message/AudioFocusStateType.proto new file mode 100644 index 00000000..a2b267a5 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/AudioFocusStateType.proto @@ -0,0 +1,16 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +enum AudioFocusStateType +{ + AUDIO_FOCUS_STATE_INVALID = 0; + AUDIO_FOCUS_STATE_GAIN = 1; + AUDIO_FOCUS_STATE_GAIN_TRANSIENT = 2; + AUDIO_FOCUS_STATE_LOSS = 3; + AUDIO_FOCUS_STATE_LOSS_TRANSIENT_CAN_DUCK = 4; + AUDIO_FOCUS_STATE_LOSS_TRANSIENT = 5; + AUDIO_FOCUS_STATE_GAIN_MEDIA_ONLY = 6; + AUDIO_FOCUS_STATE_GAIN_TRANSIENT_GUIDANCE_ONLY = 7; +} + diff --git a/protobuf/aap_protobuf/service/control/message/AuthResponse.proto b/protobuf/aap_protobuf/service/control/message/AuthResponse.proto new file mode 100644 index 00000000..42cf6ea1 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/AuthResponse.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message AuthResponse { + required int32 status = 1; +} diff --git a/protobuf/aap_protobuf/service/control/message/BatteryStatusNotification.proto b/protobuf/aap_protobuf/service/control/message/BatteryStatusNotification.proto new file mode 100644 index 00000000..9bc0ec79 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/BatteryStatusNotification.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message BatteryStatusNotification { + required uint32 battery_level = 1; + optional uint32 time_remaining_s = 2; + optional bool critical_battery = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/ByeByeReason.proto b/protobuf/aap_protobuf/service/control/message/ByeByeReason.proto new file mode 100644 index 00000000..0f478b37 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/ByeByeReason.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +enum ByeByeReason +{ + USER_SELECTION = 1; + DEVICE_SWITCH = 2; + NOT_SUPPORTED = 3; + NOT_CURRENTLY_SUPPORTED = 4; + PROBE_SUPPORTED = 5; +} diff --git a/protobuf/aap_protobuf/service/control/message/ByeByeRequest.proto b/protobuf/aap_protobuf/service/control/message/ByeByeRequest.proto new file mode 100644 index 00000000..94a30b03 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/ByeByeRequest.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +import "aap_protobuf/service/control/message/ByeByeReason.proto"; + +package aap_protobuf.service.control.message; + +message ByeByeRequest +{ + required ByeByeReason reason = 1; +} diff --git a/protobuf/aap_protobuf/service/control/message/ByeByeResponse.proto b/protobuf/aap_protobuf/service/control/message/ByeByeResponse.proto new file mode 100644 index 00000000..90162e12 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/ByeByeResponse.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message ByeByeResponse +{ + +} diff --git a/protobuf/aap_protobuf/service/control/message/CallAvailabilityStatus.proto b/protobuf/aap_protobuf/service/control/message/CallAvailabilityStatus.proto new file mode 100644 index 00000000..4f798ee0 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/CallAvailabilityStatus.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message CallAvailabilityStatus { + optional bool call_available = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/CarConnectedDevices.proto b/protobuf/aap_protobuf/service/control/message/CarConnectedDevices.proto new file mode 100644 index 00000000..87532ec0 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/CarConnectedDevices.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/service/control/message/ConnectedDevice.proto"; + +package aap_protobuf.service.control.message; + +message CarConnectedDevices { + repeated ConnectedDevice connected_devices = 1; + optional bool unsolicited = 2; + optional bool final_list = 3 [default = true]; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/CarConnectedDevicesRequest.proto b/protobuf/aap_protobuf/service/control/message/CarConnectedDevicesRequest.proto new file mode 100644 index 00000000..1b12859d --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/CarConnectedDevicesRequest.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message CarConnectedDevicesRequest { + +} diff --git a/protobuf/aap_protobuf/service/control/message/ChannelCloseNotification.proto b/protobuf/aap_protobuf/service/control/message/ChannelCloseNotification.proto new file mode 100644 index 00000000..1b02c248 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/ChannelCloseNotification.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message ChannelCloseNotification { + +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/ChannelOpenRequest.proto b/protobuf/aap_protobuf/service/control/message/ChannelOpenRequest.proto new file mode 100644 index 00000000..d1a576d3 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/ChannelOpenRequest.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message ChannelOpenRequest +{ + required sint32 priority = 1; + required int32 service_id = 2; +} diff --git a/protobuf/aap_protobuf/service/control/message/ChannelOpenResponse.proto b/protobuf/aap_protobuf/service/control/message/ChannelOpenResponse.proto new file mode 100644 index 00000000..2eb4ddb5 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/ChannelOpenResponse.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +import "aap_protobuf/shared/MessageStatus.proto"; + +package aap_protobuf.service.control.message; + +message ChannelOpenResponse +{ + required shared.MessageStatus status = 1; +} diff --git a/protobuf/aap_protobuf/service/control/message/ConnectedDevice.proto b/protobuf/aap_protobuf/service/control/message/ConnectedDevice.proto new file mode 100644 index 00000000..e3a19a61 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/ConnectedDevice.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message ConnectedDevice { + optional string device_name = 1; + optional int32 device_id = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/ConnectionConfiguration.proto b/protobuf/aap_protobuf/service/control/message/ConnectionConfiguration.proto new file mode 100644 index 00000000..ad3ad9e8 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/ConnectionConfiguration.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +import "aap_protobuf/service/control/message/PingConfiguration.proto"; +import "aap_protobuf/service/control/message/WirelessTcpConfiguration.proto"; + +message ConnectionConfiguration { + optional PingConfiguration ping_configuration = 1; + optional WirelessTcpConfiguration wireless_tcp_configuration = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/DriverPosition.proto b/protobuf/aap_protobuf/service/control/message/DriverPosition.proto new file mode 100644 index 00000000..b239e281 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/DriverPosition.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +enum DriverPosition { + DRIVER_POSITION_LEFT = 0; + DRIVER_POSITION_RIGHT = 1; + DRIVER_POSITION_CENTER = 2; + DRIVER_POSITION_UNKNOWN = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/FragInfo.proto b/protobuf/aap_protobuf/service/control/message/FragInfo.proto new file mode 100644 index 00000000..7aa47a6f --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/FragInfo.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +enum FragInfo { + FRAG_CONTINUATION = 0; + FRAG_FIRST = 1; + FRAG_LAST = 2; + FRAG_UNFRAGMENTED = 3; +} diff --git a/protobuf/aap_protobuf/service/control/message/HeadUnitInfo.proto b/protobuf/aap_protobuf/service/control/message/HeadUnitInfo.proto new file mode 100644 index 00000000..655c6be4 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/HeadUnitInfo.proto @@ -0,0 +1,14 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message HeadUnitInfo { + optional string make = 1; + optional string model = 2; + optional string year = 3; + optional string vehicle_id = 4; + optional string head_unit_make = 5; + optional string head_unit_model = 6; + optional string head_unit_software_build = 7; + optional string head_unit_software_version = 8; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/NavFocusNotification.proto b/protobuf/aap_protobuf/service/control/message/NavFocusNotification.proto new file mode 100644 index 00000000..81c8b3b4 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/NavFocusNotification.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +import "aap_protobuf/service/control/message/NavFocusType.proto"; + +package aap_protobuf.service.control.message; + +message NavFocusNotification { + required NavFocusType focus_type = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/NavFocusRequestNotification.proto b/protobuf/aap_protobuf/service/control/message/NavFocusRequestNotification.proto new file mode 100644 index 00000000..666402d5 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/NavFocusRequestNotification.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +import "aap_protobuf/service/control/message/NavFocusType.proto"; + +package aap_protobuf.service.control.message; + +message NavFocusRequestNotification { + optional NavFocusType focus_type = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/NavFocusType.proto b/protobuf/aap_protobuf/service/control/message/NavFocusType.proto new file mode 100644 index 00000000..e85c4217 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/NavFocusType.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +enum NavFocusType { + NAV_FOCUS_NATIVE = 1; + NAV_FOCUS_PROJECTED = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/PingConfiguration.proto b/protobuf/aap_protobuf/service/control/message/PingConfiguration.proto new file mode 100644 index 00000000..e31946ae --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/PingConfiguration.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message PingConfiguration { + optional uint32 timeout_ms = 1; + optional uint32 interval_ms = 2; + optional uint32 high_latency_threshold_ms = 3; + optional uint32 tracked_ping_count = 4; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/PingRequest.proto b/protobuf/aap_protobuf/service/control/message/PingRequest.proto new file mode 100644 index 00000000..922382bd --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/PingRequest.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message PingRequest { + required int64 timestamp = 1; + optional bool bug_report = 2; + optional bytes data = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/PingResponse.proto b/protobuf/aap_protobuf/service/control/message/PingResponse.proto new file mode 100644 index 00000000..977a80d3 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/PingResponse.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message PingResponse { + required int64 timestamp = 1; + optional bytes data = 2; +} diff --git a/protobuf/aap_protobuf/service/control/message/ServiceDiscoveryRequest.proto b/protobuf/aap_protobuf/service/control/message/ServiceDiscoveryRequest.proto new file mode 100644 index 00000000..7a083245 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/ServiceDiscoveryRequest.proto @@ -0,0 +1,15 @@ +syntax="proto2"; + +import "aap_protobuf/shared/PhoneInfo.proto"; + +package aap_protobuf.service.control.message; + +message ServiceDiscoveryRequest +{ + optional bytes small_icon = 1; + optional bytes medium_icon = 2; + optional bytes large_icon = 3; + optional string label_text = 4; + optional string device_name = 5; + optional shared.PhoneInfo phone_info = 6; +} diff --git a/protobuf/aap_protobuf/service/control/message/ServiceDiscoveryResponse.proto b/protobuf/aap_protobuf/service/control/message/ServiceDiscoveryResponse.proto new file mode 100644 index 00000000..d32dcfe7 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/ServiceDiscoveryResponse.proto @@ -0,0 +1,31 @@ +syntax="proto2"; + +import "aap_protobuf/service/Service.proto"; +import "aap_protobuf/service/control/message/ConnectionConfiguration.proto"; +import "aap_protobuf/service/control/message/DriverPosition.proto"; +import "aap_protobuf/service/control/message/HeadUnitInfo.proto"; + +package aap_protobuf.service.control.message; + +message ServiceDiscoveryResponse +{ + repeated service.Service channels = 1; + optional string make = 2 [deprecated = true]; + optional string model = 3 [deprecated = true]; + optional string year = 4 [deprecated = true]; + optional string vehicle_id = 5 [deprecated = true]; + optional DriverPosition driver_position = 6; + optional string head_unit_make = 7 [deprecated = true]; + optional string head_unit_model = 8 [deprecated = true]; + optional string head_unit_software_build = 9 [deprecated = true]; + optional string head_unit_software_version = 10 [deprecated = true]; + optional bool can_play_native_media_during_vr = 11 [deprecated = true]; + optional int32 session_configuration = 13; + optional string display_name = 14; + optional bool probe_for_support = 15; + optional ConnectionConfiguration connection_configuration = 16; + optional HeadUnitInfo headunit_info = 17; +} + + + diff --git a/protobuf/aap_protobuf/service/control/message/ServiceDiscoveryUpdate.proto b/protobuf/aap_protobuf/service/control/message/ServiceDiscoveryUpdate.proto new file mode 100644 index 00000000..ef032a21 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/ServiceDiscoveryUpdate.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +import "aap_protobuf/service/Service.proto"; + +package aap_protobuf.service.control.message; + +message ServiceDiscoveryUpdate { + optional service.Service service = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/UpdateUiConfigReply.proto b/protobuf/aap_protobuf/service/control/message/UpdateUiConfigReply.proto new file mode 100644 index 00000000..6a44e4cb --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/UpdateUiConfigReply.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +import "aap_protobuf/service/media/shared/message/UiConfig.proto"; + +package aap_protobuf.service.control.message; + +message UpdateUiConfigReply { + optional media.shared.message.UiConfig ui_config = 1; +} diff --git a/protobuf/aap_protobuf/service/control/message/UpdateUiConfigRequest.proto b/protobuf/aap_protobuf/service/control/message/UpdateUiConfigRequest.proto new file mode 100644 index 00000000..c23823fd --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/UpdateUiConfigRequest.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +import "aap_protobuf/service/media/shared/message/UiConfig.proto"; + +package aap_protobuf.service.control.message; + +message UpdateUiConfigRequest { + optional media.shared.message.UiConfig ui_config = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/UserSwitchRequest.proto b/protobuf/aap_protobuf/service/control/message/UserSwitchRequest.proto new file mode 100644 index 00000000..39ce4143 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/UserSwitchRequest.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +import "aap_protobuf/service/control/message/ConnectedDevice.proto"; + +package aap_protobuf.service.control.message; + +message UserSwitchRequest { + optional ConnectedDevice selected_device = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/UserSwitchResponse.proto b/protobuf/aap_protobuf/service/control/message/UserSwitchResponse.proto new file mode 100644 index 00000000..09a2abe8 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/UserSwitchResponse.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/service/control/message/UserSwitchStatus.proto"; +import "aap_protobuf/service/control/message/ConnectedDevice.proto"; + +package aap_protobuf.service.control.message; + +message UserSwitchResponse { + optional UserSwitchStatus status = 1; + optional ConnectedDevice selected_device = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/UserSwitchStatus.proto b/protobuf/aap_protobuf/service/control/message/UserSwitchStatus.proto new file mode 100644 index 00000000..5bd50a42 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/UserSwitchStatus.proto @@ -0,0 +1,16 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +enum UserSwitchStatus { + STATUS_OK = 0; + ERROR_NO_RFCOMM_CONNECTION = -1; + ERROR_BT_CLOSED_BEFORE_START = -2; + ERROR_BT_CLOSED_AFTER_START = -3; + ERROR_INCOMPATIBLE_PHONE_PROTOCOL_VERSION = -4; + ERROR_PHONE_UNABLE_TO_CONNECT_WIFI = -5; + ERROR_MULTIPLE_USER_SWITCH_REQUEST = -6; + ERROR_HU_INTERNAL = -7; + ERROR_INVALID_REQUEST = -8; + ERROR_REQUEST_TIMEOUT = -9; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/VersionRequestOptions.proto b/protobuf/aap_protobuf/service/control/message/VersionRequestOptions.proto new file mode 100644 index 00000000..c5db38d1 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/VersionRequestOptions.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.channel.control.version; + +message VersionRequestOptions { + optional int64 snapshot_version = 1; +} diff --git a/protobuf/aap_protobuf/service/control/message/VersionResponseOptions.proto b/protobuf/aap_protobuf/service/control/message/VersionResponseOptions.proto new file mode 100644 index 00000000..ad8af144 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/VersionResponseOptions.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +import "aap_protobuf/service/control/message/ConnectionConfiguration.proto"; + +message VersionResponseOptions { + optional ConnectionConfiguration connection_configuration = 1; +} + diff --git a/protobuf/aap_protobuf/service/control/message/VoiceSessionNotification.proto b/protobuf/aap_protobuf/service/control/message/VoiceSessionNotification.proto new file mode 100644 index 00000000..0d85a273 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/VoiceSessionNotification.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/service/control/message/VoiceSessionStatus.proto"; + +package aap_protobuf.service.control.message; + +message VoiceSessionNotification +{ + optional VoiceSessionStatus status = 1; + +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/VoiceSessionStatus.proto b/protobuf/aap_protobuf/service/control/message/VoiceSessionStatus.proto new file mode 100644 index 00000000..383aacc9 --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/VoiceSessionStatus.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +enum VoiceSessionStatus { + VOICE_SESSION_START = 1; + VOICE_SESSION_END = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/control/message/WirelessTcpConfiguration.proto b/protobuf/aap_protobuf/service/control/message/WirelessTcpConfiguration.proto new file mode 100644 index 00000000..c26a6f6a --- /dev/null +++ b/protobuf/aap_protobuf/service/control/message/WirelessTcpConfiguration.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.control.message; + +message WirelessTcpConfiguration { + optional uint32 socket_receive_buffer_size_kb = 1; + optional uint32 socket_send_buffer_size_kb = 2; + optional uint32 socket_read_timeout_ms = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/genericnotification/GenericNotificationMessageId.proto b/protobuf/aap_protobuf/service/genericnotification/GenericNotificationMessageId.proto new file mode 100644 index 00000000..26cabdb8 --- /dev/null +++ b/protobuf/aap_protobuf/service/genericnotification/GenericNotificationMessageId.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.genericnotification; + +enum GenericNotificationMessageId { + GENERIC_NOTIFICATION_SUBSCRIBE = 32769; + GENERIC_NOTIFICATION_UNSUBSCRIBE = 32770; + GENERIC_NOTIFICATION_MESSAGE = 32771; + GENERIC_NOTIFICATION_ACK = 32772; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/genericnotification/GenericNotificationService.proto b/protobuf/aap_protobuf/service/genericnotification/GenericNotificationService.proto new file mode 100644 index 00000000..5c18e544 --- /dev/null +++ b/protobuf/aap_protobuf/service/genericnotification/GenericNotificationService.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.genericnotification; + +message GenericNotificationService +{ + +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationAck.proto b/protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationAck.proto new file mode 100644 index 00000000..5855cd53 --- /dev/null +++ b/protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationAck.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.genericnotification.message; + +message GenericNotificationAck { + optional string id = 1; + optional bool handled = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationMessage.proto b/protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationMessage.proto new file mode 100644 index 00000000..4be72e36 --- /dev/null +++ b/protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationMessage.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.genericnotification.message; + +message GenericNotificationMessage { + optional string id = 1; + optional string text = 2; + optional bytes icon = 3; +} diff --git a/protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationSubscribe.proto b/protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationSubscribe.proto new file mode 100644 index 00000000..57d2f886 --- /dev/null +++ b/protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationSubscribe.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.genericnotification.message; + +message GenericNotificationSubscribe { + +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationUnsubscribe.proto b/protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationUnsubscribe.proto new file mode 100644 index 00000000..886fcf92 --- /dev/null +++ b/protobuf/aap_protobuf/service/genericnotification/message/GenericNotificationUnsubscribe.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.genericnotification.message; + +message GenericNotificationUnsubscribe { + +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/inputsource/InputMessageId.proto b/protobuf/aap_protobuf/service/inputsource/InputMessageId.proto new file mode 100644 index 00000000..f3bc9d42 --- /dev/null +++ b/protobuf/aap_protobuf/service/inputsource/InputMessageId.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +package aap_protobuf.service.inputsource; + +enum InputMessageId +{ + INPUT_MESSAGE_INPUT_REPORT = 32769; + INPUT_MESSAGE_KEY_BINDING_REQUEST = 32770; + INPUT_MESSAGE_KEY_BINDING_RESPONSE = 32771; + INPUT_MESSAGE_INPUT_FEEDBACK = 32772; +} diff --git a/protobuf/aap_protobuf/service/inputsource/InputSourceService.proto b/protobuf/aap_protobuf/service/inputsource/InputSourceService.proto new file mode 100644 index 00000000..cd8af503 --- /dev/null +++ b/protobuf/aap_protobuf/service/inputsource/InputSourceService.proto @@ -0,0 +1,33 @@ +syntax="proto2"; + +import "aap_protobuf/service/inputsource/message/FeedbackEvent.proto"; +import "aap_protobuf/service/inputsource/message/TouchScreenType.proto"; + +package aap_protobuf.service.inputsource; + +message InputSourceService { + repeated int32 keycodes_supported = 1 [packed = true]; + + repeated TouchScreen touchscreen = 2; + message TouchScreen { + required int32 width = 1; + required int32 height = 2; + optional message.TouchScreenType type = 3; + optional bool is_secondary = 4; + } + + repeated TouchPad touchpad = 3; + message TouchPad { + required int32 width = 1; + required int32 height = 2; + optional bool ui_navigation = 3; + optional int32 physical_width = 4; + optional int32 physical_height = 5; + optional bool ui_absolute = 6; + optional bool tap_as_select = 7; + optional int32 sensitivity = 8; + } + + repeated message.FeedbackEvent feedback_events_supported = 4; + optional uint32 display_id = 5; +} diff --git a/protobuf/aap_protobuf/service/inputsource/message/AbsoluteEvent.proto b/protobuf/aap_protobuf/service/inputsource/message/AbsoluteEvent.proto new file mode 100644 index 00000000..e40be4d2 --- /dev/null +++ b/protobuf/aap_protobuf/service/inputsource/message/AbsoluteEvent.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +package aap_protobuf.service.inputsource.message; + +message AbsoluteEvent { + repeated Abs data = 1; + message Abs { + required uint32 keycode = 1; + required int32 value = 2; + } +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/inputsource/message/FeedbackEvent.proto b/protobuf/aap_protobuf/service/inputsource/message/FeedbackEvent.proto new file mode 100644 index 00000000..c3a0910c --- /dev/null +++ b/protobuf/aap_protobuf/service/inputsource/message/FeedbackEvent.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +package aap_protobuf.service.inputsource.message; + +enum FeedbackEvent { + FEEDBACK_SELECT = 1; + FEEDBACK_FOCUS_CHANGE = 2; + FEEDBACK_DRAG_SELECT = 3; + FEEDBACK_DRAG_START = 4; + FEEDBACK_DRAG_END = 5; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/inputsource/message/InputFeedback.proto b/protobuf/aap_protobuf/service/inputsource/message/InputFeedback.proto new file mode 100644 index 00000000..45807d15 --- /dev/null +++ b/protobuf/aap_protobuf/service/inputsource/message/InputFeedback.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +import "aap_protobuf/service/inputsource/message/FeedbackEvent.proto"; + +package aap_protobuf.service.inputsource.message; + +message InputFeedback { + optional FeedbackEvent event = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/inputsource/message/InputReport.proto b/protobuf/aap_protobuf/service/inputsource/message/InputReport.proto new file mode 100644 index 00000000..2374b2f3 --- /dev/null +++ b/protobuf/aap_protobuf/service/inputsource/message/InputReport.proto @@ -0,0 +1,19 @@ +syntax="proto2"; + +import "aap_protobuf/service/inputsource/message/TouchEvent.proto"; +import "aap_protobuf/service/inputsource/message/AbsoluteEvent.proto"; +import "aap_protobuf/service/inputsource/message/RelativeEvent.proto"; +import "aap_protobuf/service/inputsource/message/KeyEvent.proto"; + +package aap_protobuf.service.inputsource.message; + +message InputReport +{ + required uint64 timestamp = 1; + optional int32 disp_channel_id = 2 [deprecated = true]; + optional TouchEvent touch_event = 3; + optional KeyEvent key_event = 4; + optional AbsoluteEvent absolute_event = 5; + optional RelativeEvent relative_event = 6; + optional TouchEvent touchpad_event = 7; +} diff --git a/protobuf/aap_protobuf/service/inputsource/message/KeyEvent.proto b/protobuf/aap_protobuf/service/inputsource/message/KeyEvent.proto new file mode 100644 index 00000000..f66f9dbc --- /dev/null +++ b/protobuf/aap_protobuf/service/inputsource/message/KeyEvent.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +package aap_protobuf.service.inputsource.message; + +message KeyEvent { + repeated Key keys = 1; + message Key { + required uint32 keycode = 1; + required bool down = 2; + required uint32 metastate = 3; + optional bool longpress = 4; + } +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/inputsource/message/PointerAction.proto b/protobuf/aap_protobuf/service/inputsource/message/PointerAction.proto new file mode 100644 index 00000000..4bcd0ce1 --- /dev/null +++ b/protobuf/aap_protobuf/service/inputsource/message/PointerAction.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +package aap_protobuf.service.inputsource.message; + +enum PointerAction +{ + ACTION_DOWN = 0; + ACTION_UP = 1; + ACTION_MOVED = 2; + ACTION_POINTER_DOWN = 5; + ACTION_POINTER_UP = 6; +} diff --git a/protobuf/aap_protobuf/service/inputsource/message/RelativeEvent.proto b/protobuf/aap_protobuf/service/inputsource/message/RelativeEvent.proto new file mode 100644 index 00000000..c95e1eba --- /dev/null +++ b/protobuf/aap_protobuf/service/inputsource/message/RelativeEvent.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +package aap_protobuf.service.inputsource.message; + +message RelativeEvent { + repeated Rel data = 1; + message Rel { + required uint32 keycode = 1; + required int32 delta = 2; + } +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/inputsource/message/TouchEvent.proto b/protobuf/aap_protobuf/service/inputsource/message/TouchEvent.proto new file mode 100644 index 00000000..6925ab2a --- /dev/null +++ b/protobuf/aap_protobuf/service/inputsource/message/TouchEvent.proto @@ -0,0 +1,17 @@ +syntax="proto2"; + +import "aap_protobuf/service/inputsource/message/PointerAction.proto"; + +package aap_protobuf.service.inputsource.message; + +message TouchEvent { + repeated Pointer pointer_data = 1; + message Pointer { + required uint32 x = 1; + required uint32 y = 2; + required uint32 pointer_id = 3; + } + + optional uint32 action_index = 2; + optional PointerAction action = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/inputsource/message/TouchScreenType.proto b/protobuf/aap_protobuf/service/inputsource/message/TouchScreenType.proto new file mode 100644 index 00000000..6ae197b0 --- /dev/null +++ b/protobuf/aap_protobuf/service/inputsource/message/TouchScreenType.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.inputsource.message; + +enum TouchScreenType { + CAPACITIVE = 1; + RESISTIVE = 2; + INFRARED = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/media/shared/message/AudioConfiguration.proto b/protobuf/aap_protobuf/service/media/shared/message/AudioConfiguration.proto new file mode 100644 index 00000000..bff47f42 --- /dev/null +++ b/protobuf/aap_protobuf/service/media/shared/message/AudioConfiguration.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.media.shared.message; + +message AudioConfiguration { + required uint32 sampling_rate = 1; + required uint32 number_of_bits = 2; + required uint32 number_of_channels = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/media/shared/message/Config.proto b/protobuf/aap_protobuf/service/media/shared/message/Config.proto new file mode 100644 index 00000000..98f91a7b --- /dev/null +++ b/protobuf/aap_protobuf/service/media/shared/message/Config.proto @@ -0,0 +1,14 @@ +syntax="proto2"; + +package aap_protobuf.service.media.shared.message; + +message Config { + required Status status = 1; + enum Status { + STATUS_WAIT = 1; + STATUS_READY = 2; + } + + optional uint32 max_unacked = 2; + repeated uint32 configuration_indices = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/media/shared/message/Insets.proto b/protobuf/aap_protobuf/service/media/shared/message/Insets.proto new file mode 100644 index 00000000..c627acdc --- /dev/null +++ b/protobuf/aap_protobuf/service/media/shared/message/Insets.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +package aap_protobuf.service.media.shared.message; + +message Insets { + optional uint32 top = 1; + optional uint32 bottom = 2; + optional uint32 left = 3; + optional uint32 right = 4; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/media/shared/message/MediaCodecType.proto b/protobuf/aap_protobuf/service/media/shared/message/MediaCodecType.proto new file mode 100644 index 00000000..fae0860c --- /dev/null +++ b/protobuf/aap_protobuf/service/media/shared/message/MediaCodecType.proto @@ -0,0 +1,14 @@ +syntax="proto2"; + +package aap_protobuf.service.media.shared.message; + +enum MediaCodecType +{ + MEDIA_CODEC_AUDIO_PCM = 1; + MEDIA_CODEC_AUDIO_AAC_LC = 2; + MEDIA_CODEC_VIDEO_H264_BP = 3; + MEDIA_CODEC_AUDIO_AAC_LC_ADTS = 4; + MEDIA_CODEC_VIDEO_VP9 = 5; + MEDIA_CODEC_VIDEO_AV1 = 6; + MEDIA_CODEC_VIDEO_H265 = 7; +} diff --git a/protobuf/aap_protobuf/service/media/shared/message/Setup.proto b/protobuf/aap_protobuf/service/media/shared/message/Setup.proto new file mode 100644 index 00000000..ef9224c6 --- /dev/null +++ b/protobuf/aap_protobuf/service/media/shared/message/Setup.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +import "aap_protobuf/service/media/shared/message/MediaCodecType.proto"; + +package aap_protobuf.service.media.shared.message; + +message Setup +{ + required service.media.shared.message.MediaCodecType type = 1; +} diff --git a/protobuf/aap_protobuf/service/media/shared/message/Start.proto b/protobuf/aap_protobuf/service/media/shared/message/Start.proto new file mode 100644 index 00000000..ff68940d --- /dev/null +++ b/protobuf/aap_protobuf/service/media/shared/message/Start.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.media.shared.message; + +message Start { + required int32 session_id = 1; + required uint32 configuration_index = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/media/shared/message/Stop.proto b/protobuf/aap_protobuf/service/media/shared/message/Stop.proto new file mode 100644 index 00000000..be76bea2 --- /dev/null +++ b/protobuf/aap_protobuf/service/media/shared/message/Stop.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.media.shared.message; + +message Stop +{ + +} diff --git a/protobuf/aap_protobuf/service/media/shared/message/UiConfig.proto b/protobuf/aap_protobuf/service/media/shared/message/UiConfig.proto new file mode 100644 index 00000000..3e7e3ed1 --- /dev/null +++ b/protobuf/aap_protobuf/service/media/shared/message/UiConfig.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +import "aap_protobuf/service/media/shared/message/UiTheme.proto"; +import "aap_protobuf/service/media/shared/message/Insets.proto"; + +package aap_protobuf.service.media.shared.message; + +message UiConfig { + optional Insets margins = 1; + optional Insets content_insets = 2; + optional Insets stable_content_insets = 3; + optional UiTheme ui_theme = 4; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/media/shared/message/UiTheme.proto b/protobuf/aap_protobuf/service/media/shared/message/UiTheme.proto new file mode 100644 index 00000000..e8ee900d --- /dev/null +++ b/protobuf/aap_protobuf/service/media/shared/message/UiTheme.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.media.shared.message; + +enum UiTheme { + UI_THEME_AUTOMATIC = 0; + UI_THEME_LIGHT = 1; + UI_THEME_DARK = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/media/sink/MediaMessageId.proto b/protobuf/aap_protobuf/service/media/sink/MediaMessageId.proto new file mode 100644 index 00000000..dc06d08a --- /dev/null +++ b/protobuf/aap_protobuf/service/media/sink/MediaMessageId.proto @@ -0,0 +1,21 @@ +syntax="proto2"; + +package aap_protobuf.service.media.sink; + +enum MediaMessageId +{ + MEDIA_MESSAGE_DATA = 0; + MEDIA_MESSAGE_CODEC_CONFIG = 1; + MEDIA_MESSAGE_SETUP = 32768; + MEDIA_MESSAGE_START = 32769; + MEDIA_MESSAGE_STOP = 32770; + MEDIA_MESSAGE_CONFIG = 32771; + MEDIA_MESSAGE_ACK = 32772; + MEDIA_MESSAGE_MICROPHONE_REQUEST = 32773; + MEDIA_MESSAGE_MICROPHONE_RESPONSE = 32774; + MEDIA_MESSAGE_VIDEO_FOCUS_REQUEST = 32775; + MEDIA_MESSAGE_VIDEO_FOCUS_NOTIFICATION = 32776; + MEDIA_MESSAGE_UPDATE_UI_CONFIG_REQUEST = 32777; + MEDIA_MESSAGE_UPDATE_UI_CONFIG_REPLY = 32778; + MEDIA_MESSAGE_AUDIO_UNDERFLOW_NOTIFICATION = 32779; +} diff --git a/protobuf/aap_protobuf/service/media/sink/MediaSinkService.proto b/protobuf/aap_protobuf/service/media/sink/MediaSinkService.proto new file mode 100644 index 00000000..4b05861f --- /dev/null +++ b/protobuf/aap_protobuf/service/media/sink/MediaSinkService.proto @@ -0,0 +1,22 @@ +syntax="proto2"; + +import "aap_protobuf/service/media/shared/message/MediaCodecType.proto"; +import "aap_protobuf/service/media/sink/message/AudioStreamType.proto"; +import "aap_protobuf/service/media/shared/message/AudioConfiguration.proto"; +import "aap_protobuf/service/media/sink/message/VideoConfiguration.proto"; +import "aap_protobuf/service/media/sink/message/DisplayType.proto"; +import "aap_protobuf/service/media/sink/message/KeyCode.proto"; + +package aap_protobuf.service.media.sink; + +message MediaSinkService +{ + optional shared.message.MediaCodecType available_type = 1 [default = MEDIA_CODEC_AUDIO_PCM];; + optional message.AudioStreamType audio_type = 2; + repeated shared.message.AudioConfiguration audio_configs = 3; + repeated message.VideoConfiguration video_configs = 4; + optional bool available_while_in_call = 5; + optional uint32 display_id = 6; + optional message.DisplayType display_type = 7; + optional message.KeyCode initial_content_keycode = 8; +} diff --git a/protobuf/aap_protobuf/service/media/sink/message/AudioStreamType.proto b/protobuf/aap_protobuf/service/media/sink/message/AudioStreamType.proto new file mode 100644 index 00000000..22de1712 --- /dev/null +++ b/protobuf/aap_protobuf/service/media/sink/message/AudioStreamType.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +package aap_protobuf.service.media.sink.message; + +enum AudioStreamType +{ + AUDIO_STREAM_GUIDANCE = 1; + AUDIO_STREAM_SYSTEM_AUDIO = 2; + AUDIO_STREAM_MEDIA = 3; + AUDIO_STREAM_TELEPHONY = 4; +} + diff --git a/protobuf/aap_protobuf/service/media/sink/message/AudioUnderflowNotification.proto b/protobuf/aap_protobuf/service/media/sink/message/AudioUnderflowNotification.proto new file mode 100644 index 00000000..b7246a71 --- /dev/null +++ b/protobuf/aap_protobuf/service/media/sink/message/AudioUnderflowNotification.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.media.sink.message; + +message AudioUnderflowNotification { + required int32 session_id = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/media/sink/message/DisplayType.proto b/protobuf/aap_protobuf/service/media/sink/message/DisplayType.proto new file mode 100644 index 00000000..799ee6fb --- /dev/null +++ b/protobuf/aap_protobuf/service/media/sink/message/DisplayType.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.media.sink.message; + +enum DisplayType { + DISPLAY_TYPE_MAIN = 0; + DISPLAY_TYPE_CLUSTER = 1; + DISPLAY_TYPE_AUXILIARY = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/media/sink/message/KeyBindingRequest.proto b/protobuf/aap_protobuf/service/media/sink/message/KeyBindingRequest.proto new file mode 100644 index 00000000..4ceeec08 --- /dev/null +++ b/protobuf/aap_protobuf/service/media/sink/message/KeyBindingRequest.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.media.sink.message; + +message KeyBindingRequest { + repeated int32 keycodes = 1 [packed = true]; +} diff --git a/protobuf/aap_protobuf/service/media/sink/message/KeyBindingResponse.proto b/protobuf/aap_protobuf/service/media/sink/message/KeyBindingResponse.proto new file mode 100644 index 00000000..c00bbea6 --- /dev/null +++ b/protobuf/aap_protobuf/service/media/sink/message/KeyBindingResponse.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +import "aap_protobuf/shared/MessageStatus.proto"; + +package aap_protobuf.service.media.sink.message; + +message KeyBindingResponse { + required int32 status = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/media/sink/message/KeyCode.proto b/protobuf/aap_protobuf/service/media/sink/message/KeyCode.proto new file mode 100644 index 00000000..0207835f --- /dev/null +++ b/protobuf/aap_protobuf/service/media/sink/message/KeyCode.proto @@ -0,0 +1,284 @@ +syntax="proto2"; + +package aap_protobuf.service.media.sink.message; + +enum KeyCode { + KEYCODE_UNKNOWN = 0; + KEYCODE_SOFT_LEFT = 1; + KEYCODE_SOFT_RIGHT = 2; + KEYCODE_HOME = 3; + KEYCODE_BACK = 4; + KEYCODE_CALL = 5; + KEYCODE_ENDCALL = 6; + KEYCODE_0 = 7; + KEYCODE_1 = 8; + KEYCODE_2 = 9; + KEYCODE_3 = 10; + KEYCODE_4 = 11; + KEYCODE_5 = 12; + KEYCODE_6 = 13; + KEYCODE_7 = 14; + KEYCODE_8 = 15; + KEYCODE_9 = 16; + KEYCODE_STAR = 17; + KEYCODE_POUND = 18; + KEYCODE_DPAD_UP = 19; + KEYCODE_DPAD_DOWN = 20; + KEYCODE_DPAD_LEFT = 21; + KEYCODE_DPAD_RIGHT = 22; + KEYCODE_DPAD_CENTER = 23; + KEYCODE_VOLUME_UP = 24; + KEYCODE_VOLUME_DOWN = 25; + KEYCODE_POWER = 26; + KEYCODE_CAMERA = 27; + KEYCODE_CLEAR = 28; + KEYCODE_A = 29; + KEYCODE_B = 30; + KEYCODE_C = 31; + KEYCODE_D = 32; + KEYCODE_E = 33; + KEYCODE_F = 34; + KEYCODE_G = 35; + KEYCODE_H = 36; + KEYCODE_I = 37; + KEYCODE_J = 38; + KEYCODE_K = 39; + KEYCODE_L = 40; + KEYCODE_M = 41; + KEYCODE_N = 42; + KEYCODE_O = 43; + KEYCODE_P = 44; + KEYCODE_Q = 45; + KEYCODE_R = 46; + KEYCODE_S = 47; + KEYCODE_T = 48; + KEYCODE_U = 49; + KEYCODE_V = 50; + KEYCODE_W = 51; + KEYCODE_X = 52; + KEYCODE_Y = 53; + KEYCODE_Z = 54; + KEYCODE_COMMA = 55; + KEYCODE_PERIOD = 56; + KEYCODE_ALT_LEFT = 57; + KEYCODE_ALT_RIGHT = 58; + KEYCODE_SHIFT_LEFT = 59; + KEYCODE_SHIFT_RIGHT = 60; + KEYCODE_TAB = 61; + KEYCODE_SPACE = 62; + KEYCODE_SYM = 63; + KEYCODE_EXPLORER = 64; + KEYCODE_ENVELOPE = 65; + KEYCODE_ENTER = 66; + KEYCODE_DEL = 67; + KEYCODE_GRAVE = 68; + KEYCODE_MINUS = 69; + KEYCODE_EQUALS = 70; + KEYCODE_LEFT_BRACKET = 71; + KEYCODE_RIGHT_BRACKET = 72; + KEYCODE_BACKSLASH = 73; + KEYCODE_SEMICOLON = 74; + KEYCODE_APOSTROPHE = 75; + KEYCODE_SLASH = 76; + KEYCODE_AT = 77; + KEYCODE_NUM = 78; + KEYCODE_HEADSETHOOK = 79; + KEYCODE_FOCUS = 80; + KEYCODE_PLUS = 81; + KEYCODE_MENU = 82; + KEYCODE_NOTIFICATION = 83; + KEYCODE_SEARCH = 84; + KEYCODE_MEDIA_PLAY_PAUSE = 85; + KEYCODE_MEDIA_STOP = 86; + KEYCODE_MEDIA_NEXT = 87; + KEYCODE_MEDIA_PREVIOUS = 88; + KEYCODE_MEDIA_REWIND = 89; + KEYCODE_MEDIA_FAST_FORWARD = 90; + KEYCODE_MUTE = 91; + KEYCODE_PAGE_UP = 92; + KEYCODE_PAGE_DOWN = 93; + KEYCODE_PICTSYMBOLS = 94; + KEYCODE_SWITCH_CHARSET = 95; + KEYCODE_BUTTON_A = 96; + KEYCODE_BUTTON_B = 97; + KEYCODE_BUTTON_C = 98; + KEYCODE_BUTTON_X = 99; + KEYCODE_BUTTON_Y = 100; + KEYCODE_BUTTON_Z = 101; + KEYCODE_BUTTON_L1 = 102; + KEYCODE_BUTTON_R1 = 103; + KEYCODE_BUTTON_L2 = 104; + KEYCODE_BUTTON_R2 = 105; + KEYCODE_BUTTON_THUMBL = 106; + KEYCODE_BUTTON_THUMBR = 107; + KEYCODE_BUTTON_START = 108; + KEYCODE_BUTTON_SELECT = 109; + KEYCODE_BUTTON_MODE = 110; + KEYCODE_ESCAPE = 111; + KEYCODE_FORWARD_DEL = 112; + KEYCODE_CTRL_LEFT = 113; + KEYCODE_CTRL_RIGHT = 114; + KEYCODE_CAPS_LOCK = 115; + KEYCODE_SCROLL_LOCK = 116; + KEYCODE_META_LEFT = 117; + KEYCODE_META_RIGHT = 118; + KEYCODE_FUNCTION = 119; + KEYCODE_SYSRQ = 120; + KEYCODE_BREAK = 121; + KEYCODE_MOVE_HOME = 122; + KEYCODE_MOVE_END = 123; + KEYCODE_INSERT = 124; + KEYCODE_FORWARD = 125; + KEYCODE_MEDIA_PLAY = 126; + KEYCODE_MEDIA_PAUSE = 127; + KEYCODE_MEDIA_CLOSE = 128; + KEYCODE_MEDIA_EJECT = 129; + KEYCODE_MEDIA_RECORD = 130; + KEYCODE_F1 = 131; + KEYCODE_F2 = 132; + KEYCODE_F3 = 133; + KEYCODE_F4 = 134; + KEYCODE_F5 = 135; + KEYCODE_F6 = 136; + KEYCODE_F7 = 137; + KEYCODE_F8 = 138; + KEYCODE_F9 = 139; + KEYCODE_F10 = 140; + KEYCODE_F11 = 141; + KEYCODE_F12 = 142; + KEYCODE_NUM_LOCK = 143; + KEYCODE_NUMPAD_0 = 144; + KEYCODE_NUMPAD_1 = 145; + KEYCODE_NUMPAD_2 = 146; + KEYCODE_NUMPAD_3 = 147; + KEYCODE_NUMPAD_4 = 148; + KEYCODE_NUMPAD_5 = 149; + KEYCODE_NUMPAD_6 = 150; + KEYCODE_NUMPAD_7 = 151; + KEYCODE_NUMPAD_8 = 152; + KEYCODE_NUMPAD_9 = 153; + KEYCODE_NUMPAD_DIVIDE = 154; + KEYCODE_NUMPAD_MULTIPLY = 155; + KEYCODE_NUMPAD_SUBTRACT = 156; + KEYCODE_NUMPAD_ADD = 157; + KEYCODE_NUMPAD_DOT = 158; + KEYCODE_NUMPAD_COMMA = 159; + KEYCODE_NUMPAD_ENTER = 160; + KEYCODE_NUMPAD_EQUALS = 161; + KEYCODE_NUMPAD_LEFT_PAREN = 162; + KEYCODE_NUMPAD_RIGHT_PAREN = 163; + KEYCODE_VOLUME_MUTE = 164; + KEYCODE_INFO = 165; + KEYCODE_CHANNEL_UP = 166; + KEYCODE_CHANNEL_DOWN = 167; + KEYCODE_ZOOM_IN = 168; + KEYCODE_ZOOM_OUT = 169; + KEYCODE_TV = 170; + KEYCODE_WINDOW = 171; + KEYCODE_GUIDE = 172; + KEYCODE_DVR = 173; + KEYCODE_BOOKMARK = 174; + KEYCODE_CAPTIONS = 175; + KEYCODE_SETTINGS = 176; + KEYCODE_TV_POWER = 177; + KEYCODE_TV_INPUT = 178; + KEYCODE_STB_POWER = 179; + KEYCODE_STB_INPUT = 180; + KEYCODE_AVR_POWER = 181; + KEYCODE_AVR_INPUT = 182; + KEYCODE_PROG_RED = 183; + KEYCODE_PROG_GREEN = 184; + KEYCODE_PROG_YELLOW = 185; + KEYCODE_PROG_BLUE = 186; + KEYCODE_APP_SWITCH = 187; + KEYCODE_BUTTON_1 = 188; + KEYCODE_BUTTON_2 = 189; + KEYCODE_BUTTON_3 = 190; + KEYCODE_BUTTON_4 = 191; + KEYCODE_BUTTON_5 = 192; + KEYCODE_BUTTON_6 = 193; + KEYCODE_BUTTON_7 = 194; + KEYCODE_BUTTON_8 = 195; + KEYCODE_BUTTON_9 = 196; + KEYCODE_BUTTON_10 = 197; + KEYCODE_BUTTON_11 = 198; + KEYCODE_BUTTON_12 = 199; + KEYCODE_BUTTON_13 = 200; + KEYCODE_BUTTON_14 = 201; + KEYCODE_BUTTON_15 = 202; + KEYCODE_BUTTON_16 = 203; + KEYCODE_LANGUAGE_SWITCH = 204; + KEYCODE_MANNER_MODE = 205; + KEYCODE_3D_MODE = 206; + KEYCODE_CONTACTS = 207; + KEYCODE_CALENDAR = 208; + KEYCODE_MUSIC = 209; + KEYCODE_CALCULATOR = 210; + KEYCODE_ZENKAKU_HANKAKU = 211; + KEYCODE_EISU = 212; + KEYCODE_MUHENKAN = 213; + KEYCODE_HENKAN = 214; + KEYCODE_KATAKANA_HIRAGANA = 215; + KEYCODE_YEN = 216; + KEYCODE_RO = 217; + KEYCODE_KANA = 218; + KEYCODE_ASSIST = 219; + KEYCODE_BRIGHTNESS_DOWN = 220; + KEYCODE_BRIGHTNESS_UP = 221; + KEYCODE_MEDIA_AUDIO_TRACK = 222; + KEYCODE_SLEEP = 223; + KEYCODE_WAKEUP = 224; + KEYCODE_PAIRING = 225; + KEYCODE_MEDIA_TOP_MENU = 226; + KEYCODE_11 = 227; + KEYCODE_12 = 228; + KEYCODE_LAST_CHANNEL = 229; + KEYCODE_TV_DATA_SERVICE = 230; + KEYCODE_VOICE_ASSIST = 231; + KEYCODE_TV_RADIO_SERVICE = 232; + KEYCODE_TV_TELETEXT = 233; + KEYCODE_TV_NUMBER_ENTRY = 234; + KEYCODE_TV_TERRESTRIAL_ANALOG = 235; + KEYCODE_TV_TERRESTRIAL_DIGITAL = 236; + KEYCODE_TV_SATELLITE = 237; + KEYCODE_TV_SATELLITE_BS = 238; + KEYCODE_TV_SATELLITE_CS = 239; + KEYCODE_TV_SATELLITE_SERVICE = 240; + KEYCODE_TV_NETWORK = 241; + KEYCODE_TV_ANTENNA_CABLE = 242; + KEYCODE_TV_INPUT_HDMI_1 = 243; + KEYCODE_TV_INPUT_HDMI_2 = 244; + KEYCODE_TV_INPUT_HDMI_3 = 245; + KEYCODE_TV_INPUT_HDMI_4 = 246; + KEYCODE_TV_INPUT_COMPOSITE_1 = 247; + KEYCODE_TV_INPUT_COMPOSITE_2 = 248; + KEYCODE_TV_INPUT_COMPONENT_1 = 249; + KEYCODE_TV_INPUT_COMPONENT_2 = 250; + KEYCODE_TV_INPUT_VGA_1 = 251; + KEYCODE_TV_AUDIO_DESCRIPTION = 252; + KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP = 253; + KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN = 254; + KEYCODE_TV_ZOOM_MODE = 255; + KEYCODE_TV_CONTENTS_MENU = 256; + KEYCODE_TV_MEDIA_CONTEXT_MENU = 257; + KEYCODE_TV_TIMER_PROGRAMMING = 258; + KEYCODE_HELP = 259; + KEYCODE_NAVIGATE_PREVIOUS = 260; + KEYCODE_NAVIGATE_NEXT = 261; + KEYCODE_NAVIGATE_IN = 262; + KEYCODE_NAVIGATE_OUT = 263; + KEYCODE_DPAD_UP_LEFT = 268; + KEYCODE_DPAD_DOWN_LEFT = 269; + KEYCODE_DPAD_UP_RIGHT = 270; + KEYCODE_DPAD_DOWN_RIGHT = 271; + KEYCODE_SENTINEL = 65535; + KEYCODE_ROTARY_CONTROLLER = 65536; + KEYCODE_MEDIA = 65537; + KEYCODE_NAVIGATION = 65538; + KEYCODE_RADIO = 65539; + KEYCODE_TEL = 65540; + KEYCODE_PRIMARY_BUTTON = 65541; + KEYCODE_SECONDARY_BUTTON = 65542; + KEYCODE_TERTIARY_BUTTON = 65543; + KEYCODE_TURN_CARD = 65544; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/media/sink/message/VideoCodecResolutionType.proto b/protobuf/aap_protobuf/service/media/sink/message/VideoCodecResolutionType.proto new file mode 100644 index 00000000..510447bf --- /dev/null +++ b/protobuf/aap_protobuf/service/media/sink/message/VideoCodecResolutionType.proto @@ -0,0 +1,15 @@ +syntax="proto2"; + +package aap_protobuf.service.media.sink.message; + +enum VideoCodecResolutionType { + VIDEO_800x480 = 1; + VIDEO_1280x720 = 2; + VIDEO_1920x1080 = 3; + VIDEO_2560x1440 = 4; + VIDEO_3840x2160 = 5; + VIDEO_720x1280 = 6; + VIDEO_1080x1920 = 7; + VIDEO_1440x2560 = 8; + VIDEO_2160x3840 = 9; +} diff --git a/protobuf/aap_protobuf/service/media/sink/message/VideoConfiguration.proto b/protobuf/aap_protobuf/service/media/sink/message/VideoConfiguration.proto new file mode 100644 index 00000000..c2943edc --- /dev/null +++ b/protobuf/aap_protobuf/service/media/sink/message/VideoConfiguration.proto @@ -0,0 +1,22 @@ +syntax="proto2"; + +import "aap_protobuf/service/media/shared/message/MediaCodecType.proto"; +import "aap_protobuf/service/media/sink/message/VideoFrameRateType.proto"; +import "aap_protobuf/service/media/sink/message/VideoCodecResolutionType.proto"; +import "aap_protobuf/service/media/shared/message/UiConfig.proto"; + +package aap_protobuf.service.media.sink.message; + +message VideoConfiguration { + optional VideoCodecResolutionType codec_resolution = 1; + optional VideoFrameRateType frame_rate = 2; + optional uint32 width_margin = 3; + optional uint32 height_margin = 4; + optional uint32 density = 5; + optional uint32 decoder_additional_depth = 6; + optional uint32 viewing_distance = 7; + optional uint32 pixel_aspect_ratio_e4 = 8; + optional uint32 real_density = 9; + optional shared.message.MediaCodecType video_codec_type = 10; + optional shared.message.UiConfig ui_config = 11; +} diff --git a/protobuf/aap_protobuf/service/media/sink/message/VideoFrameRateType.proto b/protobuf/aap_protobuf/service/media/sink/message/VideoFrameRateType.proto new file mode 100644 index 00000000..4abf6b29 --- /dev/null +++ b/protobuf/aap_protobuf/service/media/sink/message/VideoFrameRateType.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.media.sink.message; + +enum VideoFrameRateType { + VIDEO_FPS_60 = 1; + VIDEO_FPS_30 = 2; +} diff --git a/protobuf/aap_protobuf/service/media/source/MediaSourceService.proto b/protobuf/aap_protobuf/service/media/source/MediaSourceService.proto new file mode 100644 index 00000000..ce447593 --- /dev/null +++ b/protobuf/aap_protobuf/service/media/source/MediaSourceService.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +import "aap_protobuf/service/media/shared/message/MediaCodecType.proto"; +import "aap_protobuf/service/media/shared/message/AudioConfiguration.proto"; + +package aap_protobuf.service.media.source; + +message MediaSourceService +{ + optional media.shared.message.MediaCodecType available_type = 1 [default = MEDIA_CODEC_AUDIO_PCM]; + optional media.shared.message.AudioConfiguration audio_config = 2; + optional bool available_while_in_call = 3; +} diff --git a/protobuf/aap_protobuf/service/media/source/message/Ack.proto b/protobuf/aap_protobuf/service/media/source/message/Ack.proto new file mode 100644 index 00000000..b3b58bc7 --- /dev/null +++ b/protobuf/aap_protobuf/service/media/source/message/Ack.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.media.source.message; + +message Ack { + required int32 session_id = 1; + optional uint32 ack = 2; + repeated uint64 receive_timestamp_ns = 3; +} diff --git a/protobuf/aap_protobuf/service/media/source/message/MicrophoneRequest.proto b/protobuf/aap_protobuf/service/media/source/message/MicrophoneRequest.proto new file mode 100644 index 00000000..f2991421 --- /dev/null +++ b/protobuf/aap_protobuf/service/media/source/message/MicrophoneRequest.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +package aap_protobuf.service.media.source.message; + +message MicrophoneRequest { + required bool open = 1; + optional bool anc_enabled = 2; + optional bool ec_enabled = 3; + optional int32 max_unacked = 4; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/media/source/message/MicrophoneResponse.proto b/protobuf/aap_protobuf/service/media/source/message/MicrophoneResponse.proto new file mode 100644 index 00000000..db6ee97a --- /dev/null +++ b/protobuf/aap_protobuf/service/media/source/message/MicrophoneResponse.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.media.source.message; + +message MicrophoneResponse { + required int32 status = 1; + optional int32 session_id = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/media/video/message/VideoFocusMode.proto b/protobuf/aap_protobuf/service/media/video/message/VideoFocusMode.proto new file mode 100644 index 00000000..aa90f33e --- /dev/null +++ b/protobuf/aap_protobuf/service/media/video/message/VideoFocusMode.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +package aap_protobuf.service.media.video.message; + +enum VideoFocusMode +{ + VIDEO_FOCUS_PROJECTED = 1; + VIDEO_FOCUS_NATIVE = 2; + VIDEO_FOCUS_NATIVE_TRANSIENT = 3; + VIDEO_FOCUS_PROJECTED_NO_INPUT_FOCUS = 4; +} + diff --git a/protobuf/aap_protobuf/service/media/video/message/VideoFocusNotification.proto b/protobuf/aap_protobuf/service/media/video/message/VideoFocusNotification.proto new file mode 100644 index 00000000..a7973d1e --- /dev/null +++ b/protobuf/aap_protobuf/service/media/video/message/VideoFocusNotification.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +import "aap_protobuf/service/media/video/message/VideoFocusMode.proto"; + +package aap_protobuf.service.media.video.message; + +message VideoFocusNotification { + optional VideoFocusMode focus = 1; + optional bool unsolicited = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/media/video/message/VideoFocusReason.proto b/protobuf/aap_protobuf/service/media/video/message/VideoFocusReason.proto new file mode 100644 index 00000000..52042db8 --- /dev/null +++ b/protobuf/aap_protobuf/service/media/video/message/VideoFocusReason.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +package aap_protobuf.service.media.video.message; + +enum VideoFocusReason +{ + UNKNOWN = 0; + PHONE_SCREEN_OFF = 1; + LAUNCH_NATIVE = 2; +} + diff --git a/protobuf/aap_protobuf/service/media/video/message/VideoFocusRequestNotification.proto b/protobuf/aap_protobuf/service/media/video/message/VideoFocusRequestNotification.proto new file mode 100644 index 00000000..f0710964 --- /dev/null +++ b/protobuf/aap_protobuf/service/media/video/message/VideoFocusRequestNotification.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +import "aap_protobuf/service/media/video/message/VideoFocusMode.proto"; +import "aap_protobuf/service/media/video/message/VideoFocusReason.proto"; + +package aap_protobuf.service.media.video.message; + +message VideoFocusRequestNotification { + optional int32 disp_channel_id = 1 [deprecated = true]; + optional VideoFocusMode mode = 2; + optional VideoFocusReason reason = 3; +} diff --git a/protobuf/aap_protobuf/service/mediabrowser/MediaBrowserMessageId.proto b/protobuf/aap_protobuf/service/mediabrowser/MediaBrowserMessageId.proto new file mode 100644 index 00000000..f9066e9c --- /dev/null +++ b/protobuf/aap_protobuf/service/mediabrowser/MediaBrowserMessageId.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +package aap_protobuf.service.mediabrowser; + +enum MediaBrowserMessageId { + MEDIA_ROOT_NODE = 32769; + MEDIA_SOURCE_NODE = 32770; + MEDIA_LIST_NODE = 32771; + MEDIA_SONG_NODE = 32772; + MEDIA_GET_NODE = 32773; + MEDIA_BROWSE_INPUT = 32774; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/mediabrowser/MediaBrowserService.proto b/protobuf/aap_protobuf/service/mediabrowser/MediaBrowserService.proto new file mode 100644 index 00000000..8d84de1f --- /dev/null +++ b/protobuf/aap_protobuf/service/mediabrowser/MediaBrowserService.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.mediabrowser; + +message MediaBrowserService +{ + +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/mediabrowser/message/MediaBrowserInput.proto b/protobuf/aap_protobuf/service/mediabrowser/message/MediaBrowserInput.proto new file mode 100644 index 00000000..a0eb21a6 --- /dev/null +++ b/protobuf/aap_protobuf/service/mediabrowser/message/MediaBrowserInput.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +import "aap_protobuf/shared/InstrumentClusterInput.proto"; + +package aap_protobuf.service.mediabrowser.message; + +message MediaBrowserInput { + required shared.InstrumentClusterInput input = 1; + required string path = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/mediabrowser/message/MediaGetNode.proto b/protobuf/aap_protobuf/service/mediabrowser/message/MediaGetNode.proto new file mode 100644 index 00000000..60cf4a40 --- /dev/null +++ b/protobuf/aap_protobuf/service/mediabrowser/message/MediaGetNode.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.mediabrowser.message; + +message MediaGetNode { + required string path = 1; + optional int32 start = 2; + optional bool get_album_art = 3 [default = true]; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/mediabrowser/message/MediaList.proto b/protobuf/aap_protobuf/service/mediabrowser/message/MediaList.proto new file mode 100644 index 00000000..34dc7447 --- /dev/null +++ b/protobuf/aap_protobuf/service/mediabrowser/message/MediaList.proto @@ -0,0 +1,20 @@ +syntax="proto2"; + +package aap_protobuf.service.mediabrowser.message; + +message MediaList { + required string path = 1; + + required Type type = 2; + enum Type { + UNKNOWN = 0; + PLAYLIST = 1; + ALBUM = 2; + ARTIST = 3; + STATION = 4; + GENRE = 5; + } + + optional string name = 3; + optional bytes album_art = 4; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/mediabrowser/message/MediaListNode.proto b/protobuf/aap_protobuf/service/mediabrowser/message/MediaListNode.proto new file mode 100644 index 00000000..9c5d0cfc --- /dev/null +++ b/protobuf/aap_protobuf/service/mediabrowser/message/MediaListNode.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +import "aap_protobuf/service/mediabrowser/message/MediaList.proto"; +import "aap_protobuf/service/mediabrowser/message/MediaSong.proto"; + +package aap_protobuf.service.mediabrowser.message; + +message MediaListNode { + required MediaList list = 1; + optional int32 start = 2; + optional int32 total = 3; + repeated MediaSong songs = 4; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/mediabrowser/message/MediaRootNode.proto b/protobuf/aap_protobuf/service/mediabrowser/message/MediaRootNode.proto new file mode 100644 index 00000000..87a65cef --- /dev/null +++ b/protobuf/aap_protobuf/service/mediabrowser/message/MediaRootNode.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +import "aap_protobuf/service/mediabrowser/message/MediaSource.proto"; + +package aap_protobuf.service.mediabrowser.message; + +message MediaRootNode { + required string path = 1; + repeated MediaSource media_sources = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/mediabrowser/message/MediaSong.proto b/protobuf/aap_protobuf/service/mediabrowser/message/MediaSong.proto new file mode 100644 index 00000000..91f59606 --- /dev/null +++ b/protobuf/aap_protobuf/service/mediabrowser/message/MediaSong.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +package aap_protobuf.service.mediabrowser.message; + +message MediaSong { + required string path = 1; + required string name = 2; + optional string artist = 3; + optional string album = 4; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/mediabrowser/message/MediaSongNode.proto b/protobuf/aap_protobuf/service/mediabrowser/message/MediaSongNode.proto new file mode 100644 index 00000000..1bc08cad --- /dev/null +++ b/protobuf/aap_protobuf/service/mediabrowser/message/MediaSongNode.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/service/mediabrowser/message/MediaSong.proto"; + +package aap_protobuf.service.mediabrowser.message; + +message MediaSongNode { + required MediaSong song = 1; + optional bytes album_art = 2; + optional uint32 duration_seconds = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/mediabrowser/message/MediaSource.proto b/protobuf/aap_protobuf/service/mediabrowser/message/MediaSource.proto new file mode 100644 index 00000000..0a255242 --- /dev/null +++ b/protobuf/aap_protobuf/service/mediabrowser/message/MediaSource.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.mediabrowser.message; + +message MediaSource { + required string path = 1; + required string name = 2; + optional bytes album_art = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/mediabrowser/message/MediaSourceNode.proto b/protobuf/aap_protobuf/service/mediabrowser/message/MediaSourceNode.proto new file mode 100644 index 00000000..eb03c701 --- /dev/null +++ b/protobuf/aap_protobuf/service/mediabrowser/message/MediaSourceNode.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +import "aap_protobuf/service/mediabrowser/message/MediaList.proto"; +import "aap_protobuf/service/mediabrowser/message/MediaSource.proto"; + +package aap_protobuf.service.mediabrowser.message; + +message MediaSourceNode { + required MediaSource source = 1; + optional int32 start = 2; + optional int32 total = 3; + repeated MediaList lists = 4; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/mediaplayback/MediaPlaybackStatusMessageId.proto b/protobuf/aap_protobuf/service/mediaplayback/MediaPlaybackStatusMessageId.proto new file mode 100644 index 00000000..9b010fb0 --- /dev/null +++ b/protobuf/aap_protobuf/service/mediaplayback/MediaPlaybackStatusMessageId.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +package aap_protobuf.service.mediaplayback; + +enum MediaPlaybackStatusMessageId +{ + MEDIA_PLAYBACK_STATUS = 32769; + MEDIA_PLAYBACK_INPUT = 32770; + MEDIA_PLAYBACK_METADATA = 32771; +} diff --git a/protobuf/aap_protobuf/service/mediaplayback/MediaPlaybackStatusService.proto b/protobuf/aap_protobuf/service/mediaplayback/MediaPlaybackStatusService.proto new file mode 100644 index 00000000..0b41276a --- /dev/null +++ b/protobuf/aap_protobuf/service/mediaplayback/MediaPlaybackStatusService.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.mediaplayback; + +message MediaPlaybackStatusService +{ + +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/mediaplayback/message/MediaPlaybackMetadata.proto b/protobuf/aap_protobuf/service/mediaplayback/message/MediaPlaybackMetadata.proto new file mode 100644 index 00000000..66ec83dd --- /dev/null +++ b/protobuf/aap_protobuf/service/mediaplayback/message/MediaPlaybackMetadata.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +package aap_protobuf.service.mediaplayback.message; + +message MediaPlaybackMetadata { + optional string song = 1; + optional string artist = 2; + optional string album = 3; + optional bytes album_art = 4; + optional string playlist = 5; + optional uint32 duration_seconds = 6; + optional int32 rating = 7; +} diff --git a/protobuf/aap_protobuf/service/mediaplayback/message/MediaPlaybackStatus.proto b/protobuf/aap_protobuf/service/mediaplayback/message/MediaPlaybackStatus.proto new file mode 100644 index 00000000..90abd131 --- /dev/null +++ b/protobuf/aap_protobuf/service/mediaplayback/message/MediaPlaybackStatus.proto @@ -0,0 +1,18 @@ +syntax="proto2"; + +package aap_protobuf.service.mediaplayback.message; + +message MediaPlaybackStatus { + optional State state = 1; + enum State { + STOPPED = 1; + PLAYING = 2; + PAUSED = 3; + } + + optional string media_source = 2; + optional uint32 playback_seconds = 3; + optional bool shuffle = 4; + optional bool repeat = 5; + optional bool repeat_one = 6; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/navigationstatus/NavigationStatusMessageId.proto b/protobuf/aap_protobuf/service/navigationstatus/NavigationStatusMessageId.proto new file mode 100644 index 00000000..0d6d6d28 --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/NavigationStatusMessageId.proto @@ -0,0 +1,15 @@ +syntax="proto2"; + +package aap_protobuf.service.navigationstatus; + + +enum NavigationStatusMessageId +{ + INSTRUMENT_CLUSTER_START = 32769; + INSTRUMENT_CLUSTER_STOP = 32770; + INSTRUMENT_CLUSTER_NAVIGATION_STATUS = 32771; + INSTRUMENT_CLUSTER_NAVIGATION_TURN_EVENT = 32772 [deprecated = true]; + INSTRUMENT_CLUSTER_NAVIGATION_DISTANCE_EVENT = 32773 [deprecated = true]; + INSTRUMENT_CLUSTER_NAVIGATION_STATE = 32774; + INSTRUMENT_CLUSTER_NAVIGATION_CURRENT_POSITION = 32775; +} diff --git a/protobuf/aap_protobuf/service/navigationstatus/NavigationStatusService.proto b/protobuf/aap_protobuf/service/navigationstatus/NavigationStatusService.proto new file mode 100644 index 00000000..371b321a --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/NavigationStatusService.proto @@ -0,0 +1,20 @@ +syntax="proto2"; + +package aap_protobuf.service.navigationstatus; + +message NavigationStatusService { + required int32 minimum_interval_ms = 1; + + required InstrumentClusterType type = 2; + enum InstrumentClusterType { + IMAGE = 1; + ENUM = 2; + } + + optional ImageOptions image_options = 3; + message ImageOptions { + required int32 height = 1; + required int32 width = 2; + required int32 colour_depth_bits = 3; + } +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationCue.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationCue.proto new file mode 100644 index 00000000..5b1ed6a8 --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationCue.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationCue { + repeated string alternate_text = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationCurrentPosition.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationCurrentPosition.proto new file mode 100644 index 00000000..df4974b9 --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationCurrentPosition.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +import "aap_protobuf/service/navigationstatus/message/NavigationStepDistance.proto"; +import "aap_protobuf/service/navigationstatus/message/NavigationDestinationDistance.proto"; +import "aap_protobuf/service/navigationstatus/message/NavigationRoad.proto"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationCurrentPosition { + optional NavigationStepDistance step_distance = 1; + repeated NavigationDestinationDistance destination_distances = 2; + optional NavigationRoad current_road = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationDestination.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationDestination.proto new file mode 100644 index 00000000..f38e9dd8 --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationDestination.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationDestination { + optional string address = 1; +} diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationDestinationDistance.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationDestinationDistance.proto new file mode 100644 index 00000000..7c5376c6 --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationDestinationDistance.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/service/navigationstatus/message/NavigationDistance.proto"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationDestinationDistance { + optional NavigationDistance distance = 1; + optional string estimated_time_at_arrival = 2; + optional int64 time_to_arrival_seconds = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationDistance.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationDistance.proto new file mode 100644 index 00000000..cdd13043 --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationDistance.proto @@ -0,0 +1,20 @@ +syntax="proto2"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationDistance { + optional int32 meters = 1; + optional string display_value = 2; + + optional DistanceUnits display_units = 3; + enum DistanceUnits { + UNKNOWN_DISTANCE_UNIT = 0; + METERS = 1; + KILOMETERS = 2; + KILOMETERS_P1 = 3; + MILES = 4; + MILES_P1 = 5; + FEET = 6; + YARDS = 7; + } +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationLane.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationLane.proto new file mode 100644 index 00000000..1216afb3 --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationLane.proto @@ -0,0 +1,24 @@ +syntax="proto2"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationLane { + repeated LaneDirection lane_directions = 1; + message LaneDirection { + optional Shape shape = 1; + enum Shape { + UNKNOWN = 0; + STRAIGHT = 1; + SLIGHT_LEFT = 2; + SLIGHT_RIGHT = 3; + NORMAL_LEFT = 4; + NORMAL_RIGHT = 5; + SHARP_LEFT = 6; + SHARP_RIGHT = 7; + U_TURN_LEFT = 8; + U_TURN_RIGHT = 9; + } + + optional bool is_highlighted = 2; + } +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationManeuver.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationManeuver.proto new file mode 100644 index 00000000..a191d013 --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationManeuver.proto @@ -0,0 +1,55 @@ +syntax="proto2"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationManeuver { + optional NavigationType type = 1; + enum NavigationType { + UNKNOWN = 0; + DEPART = 1; + NAME_CHANGE = 2; + KEEP_LEFT = 3; + KEEP_RIGHT = 4; + TURN_SLIGHT_LEFT = 5; + TURN_SLIGHT_RIGHT = 6; + TURN_NORMAL_LEFT = 7; + TURN_NORMAL_RIGHT = 8; + TURN_SHARP_LEFT = 9; + TURN_SHARP_RIGHT = 10; + U_TURN_LEFT = 11; + U_TURN_RIGHT = 12; + ON_RAMP_SLIGHT_LEFT = 13; + ON_RAMP_SLIGHT_RIGHT = 14; + ON_RAMP_NORMAL_LEFT = 15; + ON_RAMP_NORMAL_RIGHT = 16; + ON_RAMP_SHARP_LEFT = 17; + ON_RAMP_SHARP_RIGHT = 18; + ON_RAMP_U_TURN_LEFT = 19; + ON_RAMP_U_TURN_RIGHT = 20; + OFF_RAMP_SLIGHT_LEFT = 21; + OFF_RAMP_SLIGHT_RIGHT = 22; + OFF_RAMP_NORMAL_LEFT = 23; + OFF_RAMP_NORMAL_RIGHT = 24; + FORK_LEFT = 25; + FORK_RIGHT = 26; + MERGE_LEFT = 27; + MERGE_RIGHT = 28; + MERGE_SIDE_UNSPECIFIED = 29; + ROUNDABOUT_ENTER = 30; + ROUNDABOUT_EXIT = 31; + ROUNDABOUT_ENTER_AND_EXIT_CW = 32; + ROUNDABOUT_ENTER_AND_EXIT_CW_WITH_ANGLE = 33; + ROUNDABOUT_ENTER_AND_EXIT_CCW = 34; + ROUNDABOUT_ENTER_AND_EXIT_CCW_WITH_ANGLE = 35; + STRAIGHT = 36; + FERRY_BOAT = 37; + FERRY_TRAIN = 38; + DESTINATION = 39; + DESTINATION_STRAIGHT = 40; + DESTINATION_LEFT = 41; + DESTINATION_RIGHT = 42; + } + + optional int32 roundabout_exit_number = 2; + optional int32 roundabout_exit_angle = 3; +} diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationNextTurnDistanceEvent.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationNextTurnDistanceEvent.proto new file mode 100644 index 00000000..9f5e12d7 --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationNextTurnDistanceEvent.proto @@ -0,0 +1,22 @@ +syntax="proto2"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationNextTurnDistanceEvent { + option deprecated = true; + required int32 distance_meters = 1; + required int32 time_to_turn_seconds = 2; + optional int32 display_distance_e3 = 3; + + optional DistanceUnits display_distance_unit = 4; + enum DistanceUnits { + UNKNOWN_DISTANCE_UNIT = 0; + METERS = 1; + KILOMETERS = 2; + KILOMETERS_P1 = 3; + MILES = 4; + MILES_P1 = 5; + FEET = 6; + YARDS = 7; + } +} diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationNextTurnEvent.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationNextTurnEvent.proto new file mode 100644 index 00000000..cb41e731 --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationNextTurnEvent.proto @@ -0,0 +1,41 @@ +syntax="proto2"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationNextTurnEvent { + option deprecated = true; + required string road = 1; + + optional TurnSide turn_side = 2; + enum TurnSide { + LEFT = 1; + RIGHT = 2; + UNSPECIFIED = 3; + } + + optional NextTurnEnum event = 3; + enum NextTurnEnum { + UNKNOWN = 0; + DEPART = 1; + NAME_CHANGE = 2; + SLIGHT_TURN = 3; + TURN = 4; + SHARP_TURN = 5; + U_TURN = 6; + ON_RAMP = 7; + OFF_RAMP = 8; + FORK = 9; + MERGE = 10; + ROUNDABOUT_ENTER = 11; + ROUNDABOUT_EXIT = 12; + ROUNDABOUT_ENTER_AND_EXIT = 13; + STRAIGHT = 14; + FERRY_BOAT = 16; + FERRY_TRAIN = 17; + DESTINATION = 19; + } + + optional bytes image = 4; + optional int32 turn_number = 5; + optional int32 turn_angle = 6; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationRoad.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationRoad.proto new file mode 100644 index 00000000..9796b097 --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationRoad.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationRoad { + optional string name = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationState.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationState.proto new file mode 100644 index 00000000..72a18bc5 --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationState.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/service/navigationstatus/message/NavigationStep.proto"; +import "aap_protobuf/service/navigationstatus/message/NavigationDestination.proto"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationState { + repeated NavigationStep steps = 1; + repeated NavigationDestination destinations = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStatus.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStatus.proto new file mode 100644 index 00000000..d67053ff --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStatus.proto @@ -0,0 +1,14 @@ +syntax="proto2"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationStatus +{ + required NavigationStatusEnum status = 1; + enum NavigationStatusEnum { + UNAVAILABLE = 0; + ACTIVE = 1; + INACTIVE = 2; + REROUTING = 3; + } +} diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStatusStart.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStatusStart.proto new file mode 100644 index 00000000..6109792e --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStatusStart.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationStatusStart { + +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStatusStop.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStatusStop.proto new file mode 100644 index 00000000..2c04c6f0 --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStatusStop.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationStatusStop { + +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStep.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStep.proto new file mode 100644 index 00000000..0961bcfd --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStep.proto @@ -0,0 +1,15 @@ +syntax="proto2"; + +import "aap_protobuf/service/navigationstatus/message/NavigationManeuver.proto"; +import "aap_protobuf/service/navigationstatus/message/NavigationRoad.proto"; +import "aap_protobuf/service/navigationstatus/message/NavigationLane.proto"; +import "aap_protobuf/service/navigationstatus/message/NavigationCue.proto"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationStep { + optional NavigationManeuver maneuver = 1; + optional NavigationRoad road = 2; + repeated NavigationLane lanes = 3; + optional NavigationCue cue = 4; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStepDistance.proto b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStepDistance.proto new file mode 100644 index 00000000..b1b212ad --- /dev/null +++ b/protobuf/aap_protobuf/service/navigationstatus/message/NavigationStepDistance.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +import "aap_protobuf/service/navigationstatus/message/NavigationDistance.proto"; + +package aap_protobuf.service.navigationstatus.message; + +message NavigationStepDistance { + optional NavigationDistance distance = 1; + optional int64 time_to_step_seconds = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/phonestatus/PhoneStatusMessageId.proto b/protobuf/aap_protobuf/service/phonestatus/PhoneStatusMessageId.proto new file mode 100644 index 00000000..74fa61e3 --- /dev/null +++ b/protobuf/aap_protobuf/service/phonestatus/PhoneStatusMessageId.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.phonestatus; + +enum PhoneStatusMessageId { + PHONE_STATUS = 32769; + PHONE_STATUS_INPUT = 32770; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/phonestatus/PhoneStatusService.proto b/protobuf/aap_protobuf/service/phonestatus/PhoneStatusService.proto new file mode 100644 index 00000000..0ff7ffc6 --- /dev/null +++ b/protobuf/aap_protobuf/service/phonestatus/PhoneStatusService.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.phonestatus; + +message PhoneStatusService +{ + +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/phonestatus/message/PhoneStatus.proto b/protobuf/aap_protobuf/service/phonestatus/message/PhoneStatus.proto new file mode 100644 index 00000000..6a9ffb11 --- /dev/null +++ b/protobuf/aap_protobuf/service/phonestatus/message/PhoneStatus.proto @@ -0,0 +1,27 @@ +syntax="proto2"; + +package aap_protobuf.service.phonestatus.message; + +message PhoneStatus { + repeated Call calls = 1; + message Call { + required State phone_state = 1; + required uint32 call_duration_seconds = 2; + optional string caller_number = 3; + optional string caller_id = 4; + optional string caller_number_type = 5; + optional bytes caller_thumbnail = 6; + } + + optional uint32 signal_strength = 2; + + enum State { + UNKNOWN = 0; + IN_CALL = 1; + ON_HOLD = 2; + INACTIVE = 3; + INCOMING = 4; + CONFERENCED = 5; + MUTED = 6; + } +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/phonestatus/message/PhoneStatusInput.proto b/protobuf/aap_protobuf/service/phonestatus/message/PhoneStatusInput.proto new file mode 100644 index 00000000..b3a3abf9 --- /dev/null +++ b/protobuf/aap_protobuf/service/phonestatus/message/PhoneStatusInput.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/shared/InstrumentClusterInput.proto"; + +package aap_protobuf.service.phonestatus.message; + +message PhoneStatusInput { + required shared.InstrumentClusterInput input = 1; + optional string caller_number = 2; + optional string caller_id = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/RadioMessageId.proto b/protobuf/aap_protobuf/service/radio/RadioMessageId.proto new file mode 100644 index 00000000..97c260a4 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/RadioMessageId.proto @@ -0,0 +1,33 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio; + +enum RadioMessageId { + RADIO_MESSAGE_ACTIVE_RADIO_NOTIFICATION = 32769; + RADIO_MESSAGE_SELECT_ACTIVE_RADIO_REQUEST = 32770; + RADIO_MESSAGE_STEP_CHANNEL_REQUEST = 32771; + RADIO_MESSAGE_STEP_CHANNEL_RESPONSE = 32772; + RADIO_MESSAGE_SEEK_STATION_REQUEST = 32773; + RADIO_MESSAGE_SEEK_STATION_RESPONSE = 32774; + RADIO_MESSAGE_SCAN_STATIONS_REQUEST = 32775; + RADIO_MESSAGE_SCAN_STATIONS_RESPONSE = 32776; + RADIO_MESSAGE_TUNE_TO_STATION_REQUEST = 32777; + RADIO_MESSAGE_TUNE_TO_STATION_RESPONSE = 32778; + RADIO_MESSAGE_GET_PROGRAM_LIST_REQUEST = 32779; + RADIO_MESSAGE_GET_PROGRAM_LIST_RESPONSE = 32780; + RADIO_MESSAGE_STATION_PRESETS_NOTIFICATION = 32781; + RADIO_MESSAGE_CANCEL_OPERATIONS_REQUEST = 32782; + RADIO_MESSAGE_CANCEL_OPERATIONS_RESPONSE = 32783; + RADIO_MESSAGE_CONFIGURE_CHANNEL_SPACING_REQUEST = 32784; + RADIO_MESSAGE_CONFIGURE_CHANNEL_SPACING_RESPONSE = 32785; + RADIO_MESSAGE_RADIO_STATION_INFO_NOTIFICATION = 32786; + RADIO_MESSAGE_MUTE_RADIO_REQUEST = 32787; + RADIO_MESSAGE_MUTE_RADIO_RESPONSE = 32788; + RADIO_MESSAGE_GET_TRAFFIC_UPDATE_REQUEST = 32789; + RADIO_MESSAGE_GET_TRAFFIC_UPDATE_RESPONSE = 32790; + RADIO_MESSAGE_RADIO_SOURCE_REQUEST = 32791; + RADIO_MESSAGE_RADIO_SOURCE_RESPONSE = 32792; + RADIO_MESSAGE_STATE_NOTIFICATION = 32793; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/RadioService.proto b/protobuf/aap_protobuf/service/radio/RadioService.proto new file mode 100644 index 00000000..3152f200 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/RadioService.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio; + +import "aap_protobuf/service/radio/message/RadioProperties.proto"; + +message RadioService { + repeated message.RadioProperties radio_properties = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/ActiveRadioNotification.proto b/protobuf/aap_protobuf/service/radio/message/ActiveRadioNotification.proto new file mode 100644 index 00000000..749cc5c5 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/ActiveRadioNotification.proto @@ -0,0 +1,14 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/shared/MessageStatus.proto"; +import "aap_protobuf/service/radio/message/RadioStationInfo.proto"; + +package aap_protobuf.service.radio.message; + +message ActiveRadioNotification { + optional shared.MessageStatus status = 1; + required int32 radio_id = 2; + optional message.RadioStationInfo station_info = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/CancelRadioOperationsRequest.proto b/protobuf/aap_protobuf/service/radio/message/CancelRadioOperationsRequest.proto new file mode 100644 index 00000000..1e6b5436 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/CancelRadioOperationsRequest.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message CancelRadioOperationsRequest { + required int32 radio_id = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/CancelRadioOperationsResponse.proto b/protobuf/aap_protobuf/service/radio/message/CancelRadioOperationsResponse.proto new file mode 100644 index 00000000..48c87e4d --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/CancelRadioOperationsResponse.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/shared/MessageStatus.proto"; + +package aap_protobuf.service.radio.message; + +message CancelRadioOperationsResponse { + required shared.MessageStatus status = 1; + required int32 radio_id = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/ConfigureChannelSpacingRequest.proto b/protobuf/aap_protobuf/service/radio/message/ConfigureChannelSpacingRequest.proto new file mode 100644 index 00000000..d70787fd --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/ConfigureChannelSpacingRequest.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message ConfigureChannelSpacingRequest { + required int32 radio_id = 1; + required int32 channel_spacing = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/ConfigureChannelSpacingResponse.proto b/protobuf/aap_protobuf/service/radio/message/ConfigureChannelSpacingResponse.proto new file mode 100644 index 00000000..b1831308 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/ConfigureChannelSpacingResponse.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/shared/MessageStatus.proto"; + +package aap_protobuf.service.radio.message; + +message ConfigureChannelSpacingResponse { + required shared.MessageStatus status = 1; + required int32 radio_id = 2; + required int32 channel_spacing = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/GetProgramListRequest.proto b/protobuf/aap_protobuf/service/radio/message/GetProgramListRequest.proto new file mode 100644 index 00000000..4055b6d5 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/GetProgramListRequest.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message GetProgramListRequest { + required int32 radio_id = 1; +} + diff --git a/protobuf/aap_protobuf/service/radio/message/GetProgramListResponse.proto b/protobuf/aap_protobuf/service/radio/message/GetProgramListResponse.proto new file mode 100644 index 00000000..048e9eb9 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/GetProgramListResponse.proto @@ -0,0 +1,15 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/shared/MessageStatus.proto"; +import "aap_protobuf/service/radio/message/RadioStationInfo.proto"; + +package aap_protobuf.service.radio.message; + +message GetProgramListResponse { + required shared.MessageStatus status = 1; + required int32 radio_id = 2; + required bool completed = 3; + repeated RadioStationInfo program_list = 4; +} diff --git a/protobuf/aap_protobuf/service/radio/message/GetTrafficUpdateRequest.proto b/protobuf/aap_protobuf/service/radio/message/GetTrafficUpdateRequest.proto new file mode 100644 index 00000000..07c7bb09 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/GetTrafficUpdateRequest.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message GetTrafficUpdateRequest { + required int32 radio_id = 1; +} diff --git a/protobuf/aap_protobuf/service/radio/message/GetTrafficUpdateResponse.proto b/protobuf/aap_protobuf/service/radio/message/GetTrafficUpdateResponse.proto new file mode 100644 index 00000000..444f1232 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/GetTrafficUpdateResponse.proto @@ -0,0 +1,14 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/shared/MessageStatus.proto"; +import "aap_protobuf/service/radio/message/TrafficIncident.proto"; + +package aap_protobuf.service.radio.message; + +message GetTrafficUpdateResponse { + required shared.MessageStatus status = 1; + required int32 radio_id = 2; + repeated TrafficIncident incidents = 3; +} diff --git a/protobuf/aap_protobuf/service/radio/message/HdAcquisionState.proto b/protobuf/aap_protobuf/service/radio/message/HdAcquisionState.proto new file mode 100644 index 00000000..1afdc67c --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/HdAcquisionState.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +enum HdAcquisionState { + ANALOG = 0; + ACQUIRING_HD = 1; + ACQUIRED_HD = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/HdRadioArtistExperience.proto b/protobuf/aap_protobuf/service/radio/message/HdRadioArtistExperience.proto new file mode 100644 index 00000000..5cd7e745 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/HdRadioArtistExperience.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message HdRadioArtistExperience { + optional bytes image = 1; +} + + diff --git a/protobuf/aap_protobuf/service/radio/message/HdRadioComment.proto b/protobuf/aap_protobuf/service/radio/message/HdRadioComment.proto new file mode 100644 index 00000000..7c9be604 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/HdRadioComment.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message HdRadioComment { + optional string description = 1; + optional string text = 2; +} + diff --git a/protobuf/aap_protobuf/service/radio/message/HdRadioCommercial.proto b/protobuf/aap_protobuf/service/radio/message/HdRadioCommercial.proto new file mode 100644 index 00000000..d7acb8e9 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/HdRadioCommercial.proto @@ -0,0 +1,16 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message HdRadioCommercial { + optional int32 encoding = 1; + optional string price = 2; + optional string valid = 3; + optional string url = 4; + optional int32 received = 5; + optional string seller = 6; + optional string description = 7; +} + diff --git a/protobuf/aap_protobuf/service/radio/message/HdRadioPsdData.proto b/protobuf/aap_protobuf/service/radio/message/HdRadioPsdData.proto new file mode 100644 index 00000000..aebd61e3 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/HdRadioPsdData.proto @@ -0,0 +1,19 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/service/radio/message/HdRadioComment.proto"; +import "aap_protobuf/service/radio/message/HdRadioCommercial.proto"; +import "aap_protobuf/service/radio/message/HdRadioArtistExperience.proto"; + +package aap_protobuf.service.radio.message; + +message HdRadioPsdData { + optional string title = 1; + optional string artist = 2; + optional string album = 3; + optional string genre = 4; + optional HdRadioComment comment = 5; + optional HdRadioCommercial commercial = 6; + optional HdRadioArtistExperience artist_experience = 7; +} diff --git a/protobuf/aap_protobuf/service/radio/message/HdRadioSisData.proto b/protobuf/aap_protobuf/service/radio/message/HdRadioSisData.proto new file mode 100644 index 00000000..af86ed58 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/HdRadioSisData.proto @@ -0,0 +1,17 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/service/radio/message/Location.proto"; + +package aap_protobuf.service.radio.message; + +message HdRadioSisData { + optional int32 station_id = 1; + optional string station_name_short = 2; + optional string station_name_long = 3; + optional Location station_location = 4; + optional string station_message = 5; + optional string service_info_message = 6; + optional string universal_short_station_name_slogan = 7; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/HdRadioStationInfo.proto b/protobuf/aap_protobuf/service/radio/message/HdRadioStationInfo.proto new file mode 100644 index 00000000..5761f428 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/HdRadioStationInfo.proto @@ -0,0 +1,17 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/service/radio/message/HdRadioSisData.proto"; +import "aap_protobuf/service/radio/message/HdRadioPsdData.proto"; +import "aap_protobuf/service/radio/message/HdAcquisionState.proto"; + +package aap_protobuf.service.radio.message; + +message HdRadioStationInfo { + optional HdAcquisionState acquisition_state = 1; + optional int32 digital_signal_strength = 2; + optional HdRadioPsdData psd = 3; + optional HdRadioSisData sis = 4; +} + diff --git a/protobuf/aap_protobuf/service/radio/message/ItuRegion.proto b/protobuf/aap_protobuf/service/radio/message/ItuRegion.proto new file mode 100644 index 00000000..2bedddfa --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/ItuRegion.proto @@ -0,0 +1,14 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio; + +enum ItuRegion { + RADIO_REGION_NONE = 0; + RADIO_REGION_ITU_1 = 1; + RADIO_REGION_ITU_2 = 2; + RADIO_REGION_OIRT = 3; + RADIO_REGION_JAPAN = 4; + RADIO_REGION_KOREA = 5; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/Location.proto b/protobuf/aap_protobuf/service/radio/message/Location.proto new file mode 100644 index 00000000..4292d6ae --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/Location.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message Location { + required double longitude = 1; + required double latitude = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/MuteRadioRequest.proto b/protobuf/aap_protobuf/service/radio/message/MuteRadioRequest.proto new file mode 100644 index 00000000..9177efb7 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/MuteRadioRequest.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message MuteRadioRequest { + optional int32 radio_id = 1; + required bool mute = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/MuteRadioResponse.proto b/protobuf/aap_protobuf/service/radio/message/MuteRadioResponse.proto new file mode 100644 index 00000000..10a437f9 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/MuteRadioResponse.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/shared/MessageStatus.proto"; + +package aap_protobuf.service.radio.message; + +message MuteRadioResponse { + optional shared.MessageStatus status = 1; + optional int32 radio_id = 2; + optional bool muted = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/RadioProperties.proto b/protobuf/aap_protobuf/service/radio/message/RadioProperties.proto new file mode 100644 index 00000000..90312b2b --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/RadioProperties.proto @@ -0,0 +1,28 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/service/radio/message/RadioType.proto"; +import "aap_protobuf/service/radio/message/Range.proto"; +import "aap_protobuf/service/radio/message/RdsType.proto"; +import "aap_protobuf/service/radio/message/TrafficServiceType.proto"; +import "aap_protobuf/service/radio/message/ItuRegion.proto"; + +package aap_protobuf.service.radio.message; + +message RadioProperties { + required int32 radio_id = 1; + required RadioType type = 2; + repeated Range channel_range = 3; + repeated int32 channel_spacings = 4; + required int32 channel_spacing = 5; + optional bool background_tuner = 6; + optional ItuRegion region = 7; + optional RdsType rds = 8; + optional bool af_switch = 9; + optional bool ta = 10; + optional TrafficServiceType traffic_service = 11; + optional bool audio_loopback = 12; + optional bool mute_capability = 13; + optional int32 station_presets_access = 14; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/RadioSourceRequest.proto b/protobuf/aap_protobuf/service/radio/message/RadioSourceRequest.proto new file mode 100644 index 00000000..1c2fd4c1 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/RadioSourceRequest.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message RadioSourceRequest { + +} diff --git a/protobuf/aap_protobuf/service/radio/message/RadioSourceResponse.proto b/protobuf/aap_protobuf/service/radio/message/RadioSourceResponse.proto new file mode 100644 index 00000000..e7c13beb --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/RadioSourceResponse.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/shared/MessageStatus.proto"; + +package aap_protobuf.service.radio.message; + +message RadioSourceResponse { + optional shared.MessageStatus status = 1; + required bool radio_source_enabled = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/RadioStateNotification.proto b/protobuf/aap_protobuf/service/radio/message/RadioStateNotification.proto new file mode 100644 index 00000000..5e2f7967 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/RadioStateNotification.proto @@ -0,0 +1,19 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/service/radio/message/RadioStationInfo.proto"; +import "aap_protobuf/service/radio/message/StationPresetList.proto"; + +package aap_protobuf.service.radio.message; + +message RadioStateNotification { + required bool radio_source_enabled = 1; + optional bool radio_muted = 2; + required int32 active_radio_id = 3; + required RadioStationInfo station_info = 4; + repeated RadioStationInfo program_list = 5; + repeated StationPresetList station_preset_lists = 6; +} + + diff --git a/protobuf/aap_protobuf/service/radio/message/RadioStationInfo.proto b/protobuf/aap_protobuf/service/radio/message/RadioStationInfo.proto new file mode 100644 index 00000000..450cafff --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/RadioStationInfo.proto @@ -0,0 +1,15 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/service/radio/message/RadioType.proto"; +import "aap_protobuf/service/radio/message/RadioStationMetaData.proto"; + +package aap_protobuf.service.radio.message; + +message RadioStationInfo { + required RadioType type = 1; + required int32 channel = 2; + optional int32 sub_channel = 3; + optional RadioStationMetaData meta_data = 4; +} diff --git a/protobuf/aap_protobuf/service/radio/message/RadioStationInfoNotification.proto b/protobuf/aap_protobuf/service/radio/message/RadioStationInfoNotification.proto new file mode 100644 index 00000000..14173a5d --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/RadioStationInfoNotification.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/service/radio/message/RadioStationInfo.proto"; + +package aap_protobuf.service.radio.message; + +message RadioStationInfoNotification { + required int32 radio_id = 1; + required RadioStationInfo station_info = 2; +} + diff --git a/protobuf/aap_protobuf/service/radio/message/RadioStationMetaData.proto b/protobuf/aap_protobuf/service/radio/message/RadioStationMetaData.proto new file mode 100644 index 00000000..74bdafb9 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/RadioStationMetaData.proto @@ -0,0 +1,19 @@ +syntax="proto2"; + +option optimize_for=SPEED; + + +import "aap_protobuf/service/radio/message/RdsData.proto"; +import "aap_protobuf/service/radio/message/HdRadioStationInfo.proto"; + +package aap_protobuf.service.radio.message; + +message RadioStationMetaData { + optional int32 audio_channels = 1; + optional int32 signal_quality = 2; + optional RdsData rds = 3; + optional HdRadioStationInfo hd_station_info = 4; +} + + + diff --git a/protobuf/aap_protobuf/service/radio/message/RadioType.proto b/protobuf/aap_protobuf/service/radio/message/RadioType.proto new file mode 100644 index 00000000..229e4e7e --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/RadioType.proto @@ -0,0 +1,14 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +enum RadioType { + AM_RADIO = 0; + FM_RADIO = 1; + AM_HD_RADIO = 2; + FM_HD_RADIO = 3; + DAB_RADIO = 4; + XM_RADIO = 5; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/Range.proto b/protobuf/aap_protobuf/service/radio/message/Range.proto new file mode 100644 index 00000000..fb1d271e --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/Range.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message Range { + required int32 min = 1; + required int32 max = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/RdsData.proto b/protobuf/aap_protobuf/service/radio/message/RdsData.proto new file mode 100644 index 00000000..93cfcd82 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/RdsData.proto @@ -0,0 +1,17 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message RdsData { + repeated int32 alternative_frequencies = 1; + optional int32 program_id = 2; + optional int32 music_speech_switch = 3; + optional string program_service_name = 4; + optional int32 program_type = 5; + optional string program_type_name = 6; + optional string radio_text = 7; + optional bool traffic_program_flag = 8; + optional bool traffic_announcement_flag = 9; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/RdsType.proto b/protobuf/aap_protobuf/service/radio/message/RdsType.proto new file mode 100644 index 00000000..47ef633b --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/RdsType.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +enum RdsType { + NO_RDS = 0; + RDS = 1; + RBDS = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/ScanStationsRequest.proto b/protobuf/aap_protobuf/service/radio/message/ScanStationsRequest.proto new file mode 100644 index 00000000..d6db1bbd --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/ScanStationsRequest.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message ScanStationsRequest { + required int32 radio_id = 1; + required bool start = 2; + required bool up = 3; + required bool skip_sub_channel = 4; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/ScanStationsResponse.proto b/protobuf/aap_protobuf/service/radio/message/ScanStationsResponse.proto new file mode 100644 index 00000000..a5469f72 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/ScanStationsResponse.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/shared/MessageStatus.proto"; + +package aap_protobuf.service.radio.message; + +message ScanStationsResponse { + optional shared.MessageStatus status = 1; + required int32 radio_id = 2; + optional bool started = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/SeekStationRequest.proto b/protobuf/aap_protobuf/service/radio/message/SeekStationRequest.proto new file mode 100644 index 00000000..c8650c0e --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/SeekStationRequest.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message SeekStationRequest { + required int32 radio_id = 1; + required bool up = 2; + required bool skip_sub_channel = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/SeekStationResponse.proto b/protobuf/aap_protobuf/service/radio/message/SeekStationResponse.proto new file mode 100644 index 00000000..7ac506af --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/SeekStationResponse.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/shared/MessageStatus.proto"; + +package aap_protobuf.service.radio.message; + +message SeekStationResponse { + optional shared.MessageStatus status = 1; + required int32 radio_id = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/SelectActiveRadioRequest.proto b/protobuf/aap_protobuf/service/radio/message/SelectActiveRadioRequest.proto new file mode 100644 index 00000000..f3461149 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/SelectActiveRadioRequest.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message SelectActiveRadioRequest { + required int32 radio_id = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/StationPreset.proto b/protobuf/aap_protobuf/service/radio/message/StationPreset.proto new file mode 100644 index 00000000..0cab84a6 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/StationPreset.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/service/radio/message/RadioType.proto"; + +package aap_protobuf.service.radio.message; + +message StationPreset { + required RadioType type = 1; + required int32 channel = 2; + optional int32 sub_channel = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/StationPresetList.proto b/protobuf/aap_protobuf/service/radio/message/StationPresetList.proto new file mode 100644 index 00000000..ac9e97a2 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/StationPresetList.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/service/radio/message/StationPreset.proto"; + +package aap_protobuf.service.radio.message; + +message StationPresetList { + optional string name = 1; + repeated int32 restricted_station_types = 2; + repeated StationPreset presets = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/StationPresetsNotification.proto b/protobuf/aap_protobuf/service/radio/message/StationPresetsNotification.proto new file mode 100644 index 00000000..73081ae8 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/StationPresetsNotification.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/service/radio/message/StationPresetList.proto"; + +package aap_protobuf.service.radio.message; + +message StationPresetsNotification { + repeated StationPresetList preset_lists = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/StepChannelRequest.proto b/protobuf/aap_protobuf/service/radio/message/StepChannelRequest.proto new file mode 100644 index 00000000..c700ec20 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/StepChannelRequest.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message StepChannelRequest { + required int32 radio_id = 1; + required bool up = 2; + required bool skip_sub_channel = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/StepChannelResponse.proto b/protobuf/aap_protobuf/service/radio/message/StepChannelResponse.proto new file mode 100644 index 00000000..531b5be4 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/StepChannelResponse.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/shared/MessageStatus.proto"; + +package aap_protobuf.service.radio.message; + +message StepChannelResponse { + optional shared.MessageStatus status = 1; + required int32 radio_id = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/TrafficIncident.proto b/protobuf/aap_protobuf/service/radio/message/TrafficIncident.proto new file mode 100644 index 00000000..ab972ca1 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/TrafficIncident.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/service/radio/message/Location.proto"; + +package aap_protobuf.service.radio.message; + +message TrafficIncident { + required int32 event_code = 1; + required Location location = 2; + required int32 expected_incident_duration = 3; +} diff --git a/protobuf/aap_protobuf/service/radio/message/TrafficServiceType.proto b/protobuf/aap_protobuf/service/radio/message/TrafficServiceType.proto new file mode 100644 index 00000000..ef438789 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/TrafficServiceType.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +enum TrafficServiceType { + NO_TRAFFIC_SERVICE = 0; + TMC_TRAFFIC_SERVICE = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/TuneToStationRequest.proto b/protobuf/aap_protobuf/service/radio/message/TuneToStationRequest.proto new file mode 100644 index 00000000..7f3f51f5 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/TuneToStationRequest.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.radio.message; + +message TuneToStationRequest { + required int32 radio_id = 1; + required int32 channel = 2; + optional int32 sub_channel = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/radio/message/TuneToStationResponse.proto b/protobuf/aap_protobuf/service/radio/message/TuneToStationResponse.proto new file mode 100644 index 00000000..ecaa43f8 --- /dev/null +++ b/protobuf/aap_protobuf/service/radio/message/TuneToStationResponse.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/shared/MessageStatus.proto"; + +package aap_protobuf.service.radio.message; + +message TuneToStationResponse { + required shared.MessageStatus status = 1; + required int32 radio_id = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/SensorMessageId.proto b/protobuf/aap_protobuf/service/sensorsource/SensorMessageId.proto new file mode 100644 index 00000000..ac0616a5 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/SensorMessageId.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource; + +enum SensorMessageId +{ + SENSOR_MESSAGE_REQUEST = 32769; + SENSOR_MESSAGE_RESPONSE = 32770; + SENSOR_MESSAGE_BATCH = 32771; + SENSOR_MESSAGE_ERROR = 32772; +} + diff --git a/protobuf/aap_protobuf/service/sensorsource/SensorSourceService.proto b/protobuf/aap_protobuf/service/sensorsource/SensorSourceService.proto new file mode 100644 index 00000000..8dd8223d --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/SensorSourceService.proto @@ -0,0 +1,15 @@ +syntax="proto2"; + +import "aap_protobuf/service/sensorsource/message/Sensor.proto"; +import "aap_protobuf/service/sensorsource/message/FuelType.proto"; +import "aap_protobuf/service/sensorsource/message/EvConnectorType.proto"; + +package aap_protobuf.service.sensorsource; + +message SensorSourceService +{ + repeated message.Sensor sensors = 1; + optional uint32 location_characterization = 2; + repeated message.FuelType supported_fuel_types = 3; + repeated message.EvConnectorType supported_ev_connector_types = 4; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/AccelerometerData.proto b/protobuf/aap_protobuf/service/sensorsource/message/AccelerometerData.proto new file mode 100644 index 00000000..6f1805b1 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/AccelerometerData.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message AccelerometerData { + optional int32 acceleration_x_e3 = 1; + optional int32 acceleration_y_e3 = 2; + optional int32 acceleration_z_e3 = 3; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/CompassData.proto b/protobuf/aap_protobuf/service/sensorsource/message/CompassData.proto new file mode 100644 index 00000000..89f47f27 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/CompassData.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message CompassData { + required int32 bearing_e6 = 1; + optional int32 pitch_e6 = 2; + optional int32 roll_e6 = 3; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/DeadReckoningData.proto b/protobuf/aap_protobuf/service/sensorsource/message/DeadReckoningData.proto new file mode 100644 index 00000000..1b49fd48 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/DeadReckoningData.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message DeadReckoningData { + optional int32 steering_angle_e1 = 1; + repeated int32 wheel_speed_e3 = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/DiagnosticsData.proto b/protobuf/aap_protobuf/service/sensorsource/message/DiagnosticsData.proto new file mode 100644 index 00000000..82239ba1 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/DiagnosticsData.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message DiagnosticsData { + optional bytes dtc = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/DoorData.proto b/protobuf/aap_protobuf/service/sensorsource/message/DoorData.proto new file mode 100644 index 00000000..eafa5a18 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/DoorData.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message DoorData +{ + optional bool hood_open = 1; + optional bool trunk_open = 2; + repeated bool door_open = 3; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/DrivingStatus.proto b/protobuf/aap_protobuf/service/sensorsource/message/DrivingStatus.proto new file mode 100644 index 00000000..ca87c4b9 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/DrivingStatus.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +enum DrivingStatus +{ + DRIVE_STATUS_UNRESTRICTED = 0; + DRIVE_STATUS_NO_VIDEO = 1; + DRIVE_STATUS_NO_KEYBOARD_INPUT = 2; + DRIVE_STATUS_NO_VOICE_INPUT = 4; + DRIVE_STATUS_NO_CONFIG = 8; + DRIVE_STATUS_LIMIT_MESSAGE_LEN = 16; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/DrivingStatusData.proto b/protobuf/aap_protobuf/service/sensorsource/message/DrivingStatusData.proto new file mode 100644 index 00000000..e5226903 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/DrivingStatusData.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message DrivingStatusData +{ + required int32 status = 1; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/EnvironmentData.proto b/protobuf/aap_protobuf/service/sensorsource/message/EnvironmentData.proto new file mode 100644 index 00000000..6e7ecc04 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/EnvironmentData.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message EnvironmentData { + optional int32 temperature_e3 = 1; + optional int32 pressure_e3 = 2; + optional int32 rain = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/EvConnectorType.proto b/protobuf/aap_protobuf/service/sensorsource/message/EvConnectorType.proto new file mode 100644 index 00000000..f62b1c34 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/EvConnectorType.proto @@ -0,0 +1,17 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +enum EvConnectorType { + EV_CONNECTOR_TYPE_UNKNOWN = 0; + EV_CONNECTOR_TYPE_J1772 = 1; + EV_CONNECTOR_TYPE_MENNEKES = 2; + EV_CONNECTOR_TYPE_CHADEMO = 3; + EV_CONNECTOR_TYPE_COMBO_1 = 4; + EV_CONNECTOR_TYPE_COMBO_2 = 5; + EV_CONNECTOR_TYPE_TESLA_ROADSTER = 6 [deprecated = true]; + EV_CONNECTOR_TYPE_TESLA_HPWC = 7 [deprecated = true]; + EV_CONNECTOR_TYPE_TESLA_SUPERCHARGER = 8; + EV_CONNECTOR_TYPE_GBT = 9; + EV_CONNECTOR_TYPE_OTHER = 101; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/FuelData.proto b/protobuf/aap_protobuf/service/sensorsource/message/FuelData.proto new file mode 100644 index 00000000..8de18880 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/FuelData.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message FuelData { + optional int32 fuel_level = 1; + optional int32 range = 2; + optional bool low_fuel_warning = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/FuelType.proto b/protobuf/aap_protobuf/service/sensorsource/message/FuelType.proto new file mode 100644 index 00000000..d65f0bcc --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/FuelType.proto @@ -0,0 +1,19 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +enum FuelType { + FUEL_TYPE_UNKNOWN = 0; + FUEL_TYPE_UNLEADED = 1; + FUEL_TYPE_LEADED = 2; + FUEL_TYPE_DIESEL_1 = 3; + FUEL_TYPE_DIESEL_2 = 4; + FUEL_TYPE_BIODIESEL = 5; + FUEL_TYPE_E85 = 6; + FUEL_TYPE_LPG = 7; + FUEL_TYPE_CNG = 8; + FUEL_TYPE_LNG = 9; + FUEL_TYPE_ELECTRIC = 10; + FUEL_TYPE_HYDROGEN = 11; + FUEL_TYPE_OTHER = 12; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/Gear.proto b/protobuf/aap_protobuf/service/sensorsource/message/Gear.proto new file mode 100644 index 00000000..5cfbfcfa --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/Gear.proto @@ -0,0 +1,22 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +enum Gear +{ + GEAR_NEUTRAL = 0; + GEAR_1 = 1; + GEAR_2 = 2; + GEAR_3 = 3; + GEAR_4 = 4; + GEAR_5 = 5; + GEAR_6 = 6; + GEAR_7 = 7; + GEAR_8 = 8; + GEAR_9 = 9; + GEAR_10 = 10; + GEAR_DRIVE = 100; + GEAR_PARK = 101; + GEAR_REVERSE = 102; +} + diff --git a/protobuf/aap_protobuf/service/sensorsource/message/GearData.proto b/protobuf/aap_protobuf/service/sensorsource/message/GearData.proto new file mode 100644 index 00000000..967bc8dc --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/GearData.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +import "aap_protobuf/service/sensorsource/message/Gear.proto"; + +package aap_protobuf.service.sensorsource.message; + +message GearData +{ + required Gear gear = 1; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/GpsSatellite.proto b/protobuf/aap_protobuf/service/sensorsource/message/GpsSatellite.proto new file mode 100644 index 00000000..4c1076d0 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/GpsSatellite.proto @@ -0,0 +1,17 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message GpsSatellite { + required int32 prn = 1; + required int32 snr_e3 = 2; + required bool used_in_fix = 3; + optional int32 azimuth_e3 = 4; + optional int32 elevation_e3 = 5; +} + +message GpsSatelliteData { + required int32 number_in_use = 1; + optional int32 number_in_view = 2; + repeated GpsSatellite satellites = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/GyroscopeData.proto b/protobuf/aap_protobuf/service/sensorsource/message/GyroscopeData.proto new file mode 100644 index 00000000..8c3f50ae --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/GyroscopeData.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message GyroscopeData { + optional int32 rotation_speed_x_e3 = 1; + optional int32 rotation_speed_y_e3 = 2; + optional int32 rotation_speed_z_e3 = 3; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/HeadLightState.proto b/protobuf/aap_protobuf/service/sensorsource/message/HeadLightState.proto new file mode 100644 index 00000000..c9335b2f --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/HeadLightState.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +enum HeadLightState { + HEAD_LIGHT_STATE_OFF = 1; + HEAD_LIGHT_STATE_ON = 2; + HEAD_LIGHT_STATE_HIGH = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/HvacData.proto b/protobuf/aap_protobuf/service/sensorsource/message/HvacData.proto new file mode 100644 index 00000000..ad821e23 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/HvacData.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message HvacData { + optional int32 target_temperature_e3 = 1; + optional int32 current_temperature_e3 = 2; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/LightData.proto b/protobuf/aap_protobuf/service/sensorsource/message/LightData.proto new file mode 100644 index 00000000..705ca962 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/LightData.proto @@ -0,0 +1,12 @@ +syntax="proto2"; + +import "aap_protobuf/service/sensorsource/message/HeadLightState.proto"; +import "aap_protobuf/service/sensorsource/message/TurnIndicatorState.proto"; + +package aap_protobuf.service.sensorsource.message; + +message LightData { + optional HeadLightState head_light_state = 1; + optional TurnIndicatorState turn_indicator_state = 2; + optional bool hazard_lights_on = 3; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/LocationData.proto b/protobuf/aap_protobuf/service/sensorsource/message/LocationData.proto new file mode 100644 index 00000000..7bf20596 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/LocationData.proto @@ -0,0 +1,13 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message LocationData { + optional uint64 timestamp = 1 [deprecated = true]; + required int32 latitude_e7 = 2; + required int32 longitude_e7 = 3; + optional uint32 accuracy_e3 = 4; + optional int32 altitude_e2 = 5; + optional int32 speed_e3 = 6; + optional int32 bearing_e6 = 7; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/NightModeData.proto b/protobuf/aap_protobuf/service/sensorsource/message/NightModeData.proto new file mode 100644 index 00000000..bc8c19ca --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/NightModeData.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message NightModeData { + optional bool night_mode = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/OdometerData.proto b/protobuf/aap_protobuf/service/sensorsource/message/OdometerData.proto new file mode 100644 index 00000000..789eee7c --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/OdometerData.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message OdometerData { + required int32 kms_e1 = 1; + optional int32 trip_kms_e1 = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/ParkingBrakeData.proto b/protobuf/aap_protobuf/service/sensorsource/message/ParkingBrakeData.proto new file mode 100644 index 00000000..97cf8c43 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/ParkingBrakeData.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message ParkingBrakeData { + required bool parking_brake = 1; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/PassengerData.proto b/protobuf/aap_protobuf/service/sensorsource/message/PassengerData.proto new file mode 100644 index 00000000..f7f528e3 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/PassengerData.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message PassengerData { + optional bool passenger_present = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/RpmData.proto b/protobuf/aap_protobuf/service/sensorsource/message/RpmData.proto new file mode 100644 index 00000000..bdcc492d --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/RpmData.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message RpmData { + required int32 rpm_e3 = 1; +} + diff --git a/protobuf/aap_protobuf/service/sensorsource/message/Sensor.proto b/protobuf/aap_protobuf/service/sensorsource/message/Sensor.proto new file mode 100644 index 00000000..55f7d773 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/Sensor.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +import "aap_protobuf/service/sensorsource/message/SensorType.proto"; + +package aap_protobuf.service.sensorsource.message; + +message Sensor { + required SensorType sensor_type = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/SensorBatch.proto b/protobuf/aap_protobuf/service/sensorsource/message/SensorBatch.proto new file mode 100644 index 00000000..6ac13936 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/SensorBatch.proto @@ -0,0 +1,52 @@ +syntax="proto2"; + +import "aap_protobuf/service/sensorsource/message/LocationData.proto"; +import "aap_protobuf/service/sensorsource/message/CompassData.proto"; +import "aap_protobuf/service/sensorsource/message/SpeedData.proto"; +import "aap_protobuf/service/sensorsource/message/RpmData.proto"; +import "aap_protobuf/service/sensorsource/message/OdometerData.proto"; +import "aap_protobuf/service/sensorsource/message/FuelData.proto"; +import "aap_protobuf/service/sensorsource/message/ParkingBrakeData.proto"; +import "aap_protobuf/service/sensorsource/message/GearData.proto"; +import "aap_protobuf/service/sensorsource/message/DiagnosticsData.proto"; +import "aap_protobuf/service/sensorsource/message/NightModeData.proto"; +import "aap_protobuf/service/sensorsource/message/EnvironmentData.proto"; +import "aap_protobuf/service/sensorsource/message/HvacData.proto"; +import "aap_protobuf/service/sensorsource/message/DrivingStatusData.proto"; +import "aap_protobuf/service/sensorsource/message/DeadReckoningData.proto"; +import "aap_protobuf/service/sensorsource/message/PassengerData.proto"; +import "aap_protobuf/service/sensorsource/message/DoorData.proto"; +import "aap_protobuf/service/sensorsource/message/LightData.proto"; +import "aap_protobuf/service/sensorsource/message/AccelerometerData.proto"; +import "aap_protobuf/service/sensorsource/message/GyroscopeData.proto"; +import "aap_protobuf/service/sensorsource/message/TirePressureData.proto"; +import "aap_protobuf/service/sensorsource/message/TollCardData.proto"; +import "aap_protobuf/service/sensorsource/message/GpsSatellite.proto"; + + +package aap_protobuf.service.sensorsource.message; + +message SensorBatch { + repeated LocationData location_data = 1; + repeated CompassData compass_data = 2; + repeated SpeedData speed_data = 3; + repeated RpmData rpm_data = 4; + repeated OdometerData odometer_data = 5; + repeated FuelData fuel_data = 6; + repeated ParkingBrakeData parking_brake_data = 7; + repeated GearData gear_data = 8; + repeated DiagnosticsData diagnostics_data = 9; + repeated NightModeData night_mode_data = 10; + repeated EnvironmentData environment_data = 11; + repeated HvacData hvac_data = 12; + repeated DrivingStatusData driving_status_data = 13; + repeated DeadReckoningData dead_reckoning_data = 14; + repeated PassengerData passenger_data = 15; + repeated DoorData door_data = 16; + repeated LightData light_data = 17; + repeated TirePressureData tire_pressure_data = 18; + repeated AccelerometerData accelerometer_data = 19; + repeated GyroscopeData gyroscope_data = 20; + repeated GpsSatelliteData gps_satellite_data = 21; + repeated TollCardData toll_card_data = 22; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/SensorError.proto b/protobuf/aap_protobuf/service/sensorsource/message/SensorError.proto new file mode 100644 index 00000000..6f36159a --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/SensorError.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/service/sensorsource/message/SensorType.proto"; +import "aap_protobuf/service/sensorsource/message/SensorErrorType.proto"; + +package aap_protobuf.service.sensorsource.message; + +message SensorError { + required SensorType sensor_type = 1; + required SensorErrorType sensor_error_type = 2; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/SensorErrorType.proto b/protobuf/aap_protobuf/service/sensorsource/message/SensorErrorType.proto new file mode 100644 index 00000000..e42dc77a --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/SensorErrorType.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +enum SensorErrorType { + SENSOR_OK = 1; + SENSOR_ERROR_TRANSIENT = 2; + SENSOR_ERROR_PERMANENT = 3; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/SensorRequest.proto b/protobuf/aap_protobuf/service/sensorsource/message/SensorRequest.proto new file mode 100644 index 00000000..c36bae9f --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/SensorRequest.proto @@ -0,0 +1,11 @@ +syntax="proto2"; + +import "aap_protobuf/service/sensorsource/message/SensorType.proto"; + +package aap_protobuf.service.sensorsource.message; + +message SensorRequest +{ + required SensorType type = 1; + required int64 min_update_period = 2; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/SensorResponse.proto b/protobuf/aap_protobuf/service/sensorsource/message/SensorResponse.proto new file mode 100644 index 00000000..0b58b971 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/SensorResponse.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +import "aap_protobuf/shared/MessageStatus.proto"; + +package aap_protobuf.service.sensorsource.message; + +message SensorResponse { + required shared.MessageStatus status = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/SensorStartResponseMessage.proto b/protobuf/aap_protobuf/service/sensorsource/message/SensorStartResponseMessage.proto new file mode 100644 index 00000000..9c8de6b0 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/SensorStartResponseMessage.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +import "aap_protobuf/shared/MessageStatus.proto"; + +package aap_protobuf.service.sensorsource.message; + +message SensorStartResponseMessage +{ + required shared.MessageStatus status = 1; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/SensorType.proto b/protobuf/aap_protobuf/service/sensorsource/message/SensorType.proto new file mode 100644 index 00000000..15d9b7dd --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/SensorType.proto @@ -0,0 +1,29 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +enum SensorType +{ + SENSOR_LOCATION = 1; + SENSOR_COMPASS = 2; + SENSOR_SPEED = 3; + SENSOR_RPM = 4; + SENSOR_ODOMETER = 5; + SENSOR_FUEL = 6; + SENSOR_PARKING_BRAKE = 7; + SENSOR_GEAR = 8; + SENSOR_OBDII_DIAGNOSTIC_CODE = 9; + SENSOR_NIGHT_MODE = 10; + SENSOR_ENVIRONMENT_DATA = 11; + SENSOR_HVAC_DATA = 12; + SENSOR_DRIVING_STATUS_DATA = 13; + SENSOR_DEAD_RECKONING_DATA = 14; + SENSOR_PASSENGER_DATA = 15; + SENSOR_DOOR_DATA = 16; + SENSOR_LIGHT_DATA = 17; + SENSOR_TIRE_PRESSURE_DATA = 18; + SENSOR_ACCELEROMETER_DATA = 19; + SENSOR_GYROSCOPE_DATA = 20; + SENSOR_GPS_SATELLITE_DATA = 21; + SENSOR_TOLL_CARD = 22; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/SpeedData.proto b/protobuf/aap_protobuf/service/sensorsource/message/SpeedData.proto new file mode 100644 index 00000000..92174a77 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/SpeedData.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message SpeedData { + required int32 speed_e3 = 1; + optional bool cruise_engaged = 2; + optional int32 cruise_set_speed = 4; +} diff --git a/protobuf/aap_protobuf/service/sensorsource/message/TirePressureData.proto b/protobuf/aap_protobuf/service/sensorsource/message/TirePressureData.proto new file mode 100644 index 00000000..3fe3b0b8 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/TirePressureData.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message TirePressureData { + repeated int32 tire_pressures_e2 = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/TollCardData.proto b/protobuf/aap_protobuf/service/sensorsource/message/TollCardData.proto new file mode 100644 index 00000000..1f892ade --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/TollCardData.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +message TollCardData { + required bool is_card_present = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/sensorsource/message/TurnIndicatorState.proto b/protobuf/aap_protobuf/service/sensorsource/message/TurnIndicatorState.proto new file mode 100644 index 00000000..5fb215a0 --- /dev/null +++ b/protobuf/aap_protobuf/service/sensorsource/message/TurnIndicatorState.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +package aap_protobuf.service.sensorsource.message; + +enum TurnIndicatorState { + TURN_INDICATOR_NONE = 1; + TURN_INDICATOR_LEFT = 2; + TURN_INDICATOR_RIGHT = 3; +} diff --git a/protobuf/aap_protobuf/service/vendorextension/VendorExtensionService.proto b/protobuf/aap_protobuf/service/vendorextension/VendorExtensionService.proto new file mode 100644 index 00000000..197abd51 --- /dev/null +++ b/protobuf/aap_protobuf/service/vendorextension/VendorExtensionService.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +package aap_protobuf.service.vendorextension; + +message VendorExtensionService +{ + required string name = 1; + repeated string package_white_list = 2; + optional bytes data = 3; +} diff --git a/protobuf/aap_protobuf/service/wifiprojection/WifiProjectionMessageId.proto b/protobuf/aap_protobuf/service/wifiprojection/WifiProjectionMessageId.proto new file mode 100644 index 00000000..e5d28364 --- /dev/null +++ b/protobuf/aap_protobuf/service/wifiprojection/WifiProjectionMessageId.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.wifiprojection; + +enum WifiProjectionMessageId { + WIFI_MESSAGE_CREDENTIALS_REQUEST = 32769; + WIFI_MESSAGE_CREDENTIALS_RESPONSE = 32770; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/wifiprojection/WifiProjectionService.proto b/protobuf/aap_protobuf/service/wifiprojection/WifiProjectionService.proto new file mode 100644 index 00000000..f0d0d8ff --- /dev/null +++ b/protobuf/aap_protobuf/service/wifiprojection/WifiProjectionService.proto @@ -0,0 +1,7 @@ +syntax="proto2"; + +package aap_protobuf.service.wifiprojection; + +message WifiProjectionService { + optional string car_wifi_bssid = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/wifiprojection/message/AccessPointType.proto b/protobuf/aap_protobuf/service/wifiprojection/message/AccessPointType.proto new file mode 100644 index 00000000..b66fee1b --- /dev/null +++ b/protobuf/aap_protobuf/service/wifiprojection/message/AccessPointType.proto @@ -0,0 +1,10 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.wifiprojection.message; + +enum AccessPointType { + STATIC = 0; + DYNAMIC = 1; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/wifiprojection/message/WifiCredentialsRequest.proto b/protobuf/aap_protobuf/service/wifiprojection/message/WifiCredentialsRequest.proto new file mode 100644 index 00000000..4568ef1f --- /dev/null +++ b/protobuf/aap_protobuf/service/wifiprojection/message/WifiCredentialsRequest.proto @@ -0,0 +1,9 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.wifiprojection.message; + +message WifiCredentialsRequest { + +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/wifiprojection/message/WifiCredentialsResponse.proto b/protobuf/aap_protobuf/service/wifiprojection/message/WifiCredentialsResponse.proto new file mode 100644 index 00000000..89187fb0 --- /dev/null +++ b/protobuf/aap_protobuf/service/wifiprojection/message/WifiCredentialsResponse.proto @@ -0,0 +1,17 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +import "aap_protobuf/service/wifiprojection/message/AccessPointType.proto"; +import "aap_protobuf/service/wifiprojection/message/WifiSecurityMode.proto"; + + +package aap_protobuf.service.wifiprojection.message; + +message WifiCredentialsResponse { + optional string car_wifi_password = 1; + optional WifiSecurityMode car_wifi_security_mode = 2; + optional string car_wifi_ssid = 3; + repeated int32 supported_wifi_channels = 4; + optional AccessPointType access_point_type = 5; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/service/wifiprojection/message/WifiSecurityMode.proto b/protobuf/aap_protobuf/service/wifiprojection/message/WifiSecurityMode.proto new file mode 100644 index 00000000..b72d3cb1 --- /dev/null +++ b/protobuf/aap_protobuf/service/wifiprojection/message/WifiSecurityMode.proto @@ -0,0 +1,18 @@ +syntax="proto2"; + +option optimize_for=SPEED; + +package aap_protobuf.service.wifiprojection.message; + +enum WifiSecurityMode { + UNKNOWN_SECURITY_MODE = 0; + OPEN = 1; + WEP_64 = 2; + WEP_128 = 3; + WPA_PERSONAL = 4; + WPA2_PERSONAL = 5; + WPA_WPA2_PERSONAL = 6; + WPA_ENTERPRISE = 7; + WPA2_ENTERPRISE = 8; + WPA_WPA2_ENTERPRISE = 9; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/shared/InstrumentClusterInput.proto b/protobuf/aap_protobuf/shared/InstrumentClusterInput.proto new file mode 100644 index 00000000..e1615943 --- /dev/null +++ b/protobuf/aap_protobuf/shared/InstrumentClusterInput.proto @@ -0,0 +1,17 @@ +syntax="proto2"; + +package aap_protobuf.shared; + +message InstrumentClusterInput { + required InstrumentClusterAction action = 1; + enum InstrumentClusterAction { + UNKNOWN = 0; + UP = 1; + DOWN = 2; + LEFT = 3; + RIGHT = 4; + ENTER = 5; + BACK = 6; + CALL = 7; + } +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/shared/MessageStatus.proto b/protobuf/aap_protobuf/shared/MessageStatus.proto new file mode 100644 index 00000000..01b13391 --- /dev/null +++ b/protobuf/aap_protobuf/shared/MessageStatus.proto @@ -0,0 +1,38 @@ +syntax="proto2"; + +package aap_protobuf.shared; + +enum MessageStatus { + STATUS_UNSOLICITED_MESSAGE = 1; + STATUS_SUCCESS = 0; + STATUS_NO_COMPATIBLE_VERSION = -1; + STATUS_CERTIFICATE_ERROR = -2; + STATUS_AUTHENTICATION_FAILURE = -3; + STATUS_INVALID_SERVICE = -4; + STATUS_INVALID_CHANNEL = -5; + STATUS_INVALID_PRIORITY = -6; + STATUS_INTERNAL_ERROR = -7; + STATUS_MEDIA_CONFIG_MISMATCH = -8; + STATUS_INVALID_SENSOR = -9; + STATUS_BLUETOOTH_PAIRING_DELAYED = -10; + STATUS_BLUETOOTH_UNAVAILABLE = -11; + STATUS_BLUETOOTH_INVALID_ADDRESS = -12; + STATUS_BLUETOOTH_INVALID_PAIRING_METHOD = -13; + STATUS_BLUETOOTH_INVALID_AUTH_DATA = -14; + STATUS_BLUETOOTH_AUTH_DATA_MISMATCH = -15; + STATUS_BLUETOOTH_HFP_ANOTHER_CONNECTION = -16; + STATUS_BLUETOOTH_HFP_CONNECTION_FAILURE = -17; + STATUS_KEYCODE_NOT_BOUND = -18; + STATUS_RADIO_INVALID_STATION = -19; + STATUS_INVALID_INPUT = -20; + STATUS_RADIO_STATION_PRESETS_NOT_SUPPORTED = -21; + STATUS_RADIO_COMM_ERROR = -22; + STATUS_AUTHENTICATION_FAILURE_CERT_NOT_YET_VALID = -23; + STATUS_AUTHENTICATION_FAILURE_CERT_EXPIRED = -24; + STATUS_PING_TIMEOUT = -25; + STATUS_COMMAND_NOT_SUPPORTED = -250; + STATUS_FRAMING_ERROR = -251; + STATUS_UNEXPECTED_MESSAGE = -253; + STATUS_BUSY = -254; + STATUS_OUT_OF_MEMORY = -255; +} \ No newline at end of file diff --git a/protobuf/aap_protobuf/shared/PhoneInfo.proto b/protobuf/aap_protobuf/shared/PhoneInfo.proto new file mode 100644 index 00000000..db6b4a11 --- /dev/null +++ b/protobuf/aap_protobuf/shared/PhoneInfo.proto @@ -0,0 +1,8 @@ +syntax="proto2"; + +package aap_protobuf.shared; + +message PhoneInfo { + optional string instance_id = 1; + optional string connectivity_lifetime_id = 2; +} \ No newline at end of file diff --git a/src/Channel/AV/AVInputServiceChannel.cpp b/src/Channel/AV/AVInputServiceChannel.cpp deleted file mode 100644 index 46154492..00000000 --- a/src/Channel/AV/AVInputServiceChannel.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -AVInputServiceChannel::AVInputServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger) - : ServiceChannel(strand, std::move(messenger), messenger::ChannelId::AV_INPUT) -{ - -} - -void AVInputServiceChannel::receive(IAVInputServiceChannelEventHandler::Pointer eventHandler) -{ - auto receivePromise = messenger::ReceivePromise::defer(strand_); - receivePromise->then(std::bind(&AVInputServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler), - std::bind(&IAVInputServiceChannelEventHandler::onChannelError, eventHandler, std::placeholders::_1)); - - messenger_->enqueueReceive(channelId_, std::move(receivePromise)); -} - -void AVInputServiceChannel::sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::CHANNEL_OPEN_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void AVInputServiceChannel::sendAVChannelSetupResponse(const proto::messages::AVChannelSetupResponse& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::AVChannelMessage::SETUP_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -messenger::ChannelId AVInputServiceChannel::getId() const -{ - return channelId_; -} - -void AVInputServiceChannel::messageHandler(messenger::Message::Pointer message, IAVInputServiceChannelEventHandler::Pointer eventHandler) -{ - messenger::MessageId messageId(message->getPayload()); - common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); - - switch(messageId.getId()) - { - case proto::ids::AVChannelMessage::SETUP_REQUEST: - this->handleAVChannelSetupRequest(payload, std::move(eventHandler)); - break; - case proto::ids::AVChannelMessage::AV_INPUT_OPEN_REQUEST: - this->handleAVInputOpenRequest(payload, std::move(eventHandler)); - break; - case proto::ids::AVChannelMessage::AV_MEDIA_ACK_INDICATION: - this->handleAVMediaAckIndication(payload, std::move(eventHandler)); - break; - case proto::ids::ControlMessage::CHANNEL_OPEN_REQUEST: - this->handleChannelOpenRequest(payload, std::move(eventHandler)); - break; - default: - AASDK_LOG(error) << "[AVInputServiceChannel] message not handled: " << messageId.getId(); - this->receive(std::move(eventHandler)); - break; - } -} - -void AVInputServiceChannel::sendAVInputOpenResponse(const proto::messages::AVInputOpenResponse& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::AVChannelMessage::AV_INPUT_OPEN_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void AVInputServiceChannel::sendAVMediaWithTimestampIndication(messenger::Timestamp::ValueType timestamp, const common::Data& data, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::AVChannelMessage::AV_MEDIA_WITH_TIMESTAMP_INDICATION).getData()); - - auto timestampData = messenger::Timestamp(timestamp).getData(); - message->insertPayload(std::move(timestampData)); - message->insertPayload(data); - - this->send(std::move(message), std::move(promise)); -} - -void AVInputServiceChannel::handleAVChannelSetupRequest(const common::DataConstBuffer& payload, IAVInputServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::AVChannelSetupRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onAVChannelSetupRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void AVInputServiceChannel::handleAVInputOpenRequest(const common::DataConstBuffer& payload, IAVInputServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::AVInputOpenRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onAVInputOpenRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void AVInputServiceChannel::handleAVMediaAckIndication(const common::DataConstBuffer& payload, IAVInputServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::AVMediaAckIndication indication; - if(indication.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onAVMediaAckIndication(indication); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void AVInputServiceChannel::handleChannelOpenRequest(const common::DataConstBuffer& payload, IAVInputServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::ChannelOpenRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onChannelOpenRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -} -} -} diff --git a/src/Channel/AV/AudioServiceChannel.cpp b/src/Channel/AV/AudioServiceChannel.cpp deleted file mode 100644 index 2b4da5dc..00000000 --- a/src/Channel/AV/AudioServiceChannel.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -AudioServiceChannel::AudioServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger, messenger::ChannelId channelId) - : ServiceChannel(strand, std::move(messenger), channelId) -{ - -} - -void AudioServiceChannel::receive(IAudioServiceChannelEventHandler::Pointer eventHandler) -{ - auto receivePromise = messenger::ReceivePromise::defer(strand_); - receivePromise->then(std::bind(&AudioServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler), - std::bind(&IAudioServiceChannelEventHandler::onChannelError, eventHandler, std::placeholders::_1)); - - messenger_->enqueueReceive(channelId_, std::move(receivePromise)); -} - -messenger::ChannelId AudioServiceChannel::getId() const -{ - return channelId_; -} - -void AudioServiceChannel::sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::CHANNEL_OPEN_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void AudioServiceChannel::sendAVChannelSetupResponse(const proto::messages::AVChannelSetupResponse& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::AVChannelMessage::SETUP_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void AudioServiceChannel::sendAVMediaAckIndication(const proto::messages::AVMediaAckIndication& indication, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::AVChannelMessage::AV_MEDIA_ACK_INDICATION).getData()); - message->insertPayload(indication); - - this->send(std::move(message), std::move(promise)); -} - -void AudioServiceChannel::messageHandler(messenger::Message::Pointer message, IAudioServiceChannelEventHandler::Pointer eventHandler) -{ - messenger::MessageId messageId(message->getPayload()); - common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); - - switch(messageId.getId()) - { - case proto::ids::AVChannelMessage::SETUP_REQUEST: - this->handleAVChannelSetupRequest(payload, std::move(eventHandler)); - break; - case proto::ids::AVChannelMessage::START_INDICATION: - this->handleStartIndication(payload, std::move(eventHandler)); - break; - case proto::ids::AVChannelMessage::STOP_INDICATION: - this->handleStopIndication(payload, std::move(eventHandler)); - break; - case proto::ids::AVChannelMessage::AV_MEDIA_WITH_TIMESTAMP_INDICATION: - this->handleAVMediaWithTimestampIndication(payload, std::move(eventHandler)); - break; - case proto::ids::AVChannelMessage::AV_MEDIA_INDICATION: - eventHandler->onAVMediaIndication(payload); - break; - case proto::ids::ControlMessage::CHANNEL_OPEN_REQUEST: - this->handleChannelOpenRequest(payload, std::move(eventHandler)); - break; - default: - AASDK_LOG(error) << "[AudioServiceChannel] message not handled: " << messageId.getId(); - this->receive(std::move(eventHandler)); - break; - } -} - -void AudioServiceChannel::handleAVChannelSetupRequest(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::AVChannelSetupRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onAVChannelSetupRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void AudioServiceChannel::handleStartIndication(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::AVChannelStartIndication indication; - if(indication.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onAVChannelStartIndication(indication); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void AudioServiceChannel::handleStopIndication(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::AVChannelStopIndication indication; - if(indication.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onAVChannelStopIndication(indication); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void AudioServiceChannel::handleChannelOpenRequest(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::ChannelOpenRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onChannelOpenRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void AudioServiceChannel::handleAVMediaWithTimestampIndication(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler) -{ - if(payload.size >= sizeof(messenger::Timestamp::ValueType)) - { - messenger::Timestamp timestamp(payload); - eventHandler->onAVMediaWithTimestampIndication(timestamp.getValue(), common::DataConstBuffer(payload.cdata, payload.size, sizeof(messenger::Timestamp::ValueType))); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -} -} -} diff --git a/src/Channel/AV/MediaAudioServiceChannel.cpp b/src/Channel/AV/MediaAudioServiceChannel.cpp deleted file mode 100644 index 07187efb..00000000 --- a/src/Channel/AV/MediaAudioServiceChannel.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -MediaAudioServiceChannel::MediaAudioServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger) - : AudioServiceChannel(strand, std::move(messenger), messenger::ChannelId::MEDIA_AUDIO) -{ - -} - -} -} -} diff --git a/src/Channel/AV/MediaStatusServiceChannel.cpp b/src/Channel/AV/MediaStatusServiceChannel.cpp deleted file mode 100644 index d5563b1a..00000000 --- a/src/Channel/AV/MediaStatusServiceChannel.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -MediaStatusServiceChannel::MediaStatusServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger) - : ServiceChannel(strand, std::move(messenger), messenger::ChannelId::MEDIA_STATUS) -{ - -} - -void MediaStatusServiceChannel::receive(IMediaStatusServiceChannelEventHandler::Pointer eventHandler) -{ - auto receivePromise = messenger::ReceivePromise::defer(strand_); - receivePromise->then(std::bind(&MediaStatusServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler), - std::bind(&IMediaStatusServiceChannelEventHandler::onChannelError, eventHandler,std::placeholders::_1)); - - messenger_->enqueueReceive(channelId_, std::move(receivePromise)); -} - -messenger::ChannelId MediaStatusServiceChannel::getId() const -{ - return channelId_; -} - -void MediaStatusServiceChannel::sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) -{ - AASDK_LOG(info) << "[MediaStatusServiceChannel] channel open response "; - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::CHANNEL_OPEN_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - - -void MediaStatusServiceChannel::messageHandler(messenger::Message::Pointer message, IMediaStatusServiceChannelEventHandler::Pointer eventHandler) -{ - messenger::MessageId messageId(message->getPayload()); - common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); - - switch(messageId.getId()) - { - case proto::ids::ControlMessage::CHANNEL_OPEN_REQUEST: - this->handleChannelOpenRequest(payload, std::move(eventHandler)); - break; - - case proto::ids::MediaInfoChannelMessage::METADATA: - this->handleMetadataUpdate(payload, std::move(eventHandler)); - break; - - case proto::ids::MediaInfoChannelMessage::PLAYBACK: - this->handlePlaybackUpdate(payload, std::move(eventHandler)); - break; - - default: - AASDK_LOG(error) << "[MediaStatusServiceChannel] message not handled: " << messageId.getId() << " : " << dump(payload); - this->receive(std::move(eventHandler)); - break; - } - - - -} - -void MediaStatusServiceChannel::handleMetadataUpdate(const common::DataConstBuffer& payload, IMediaStatusServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::MediaInfoChannelMetadataData metadata; - if(metadata.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onMetadataUpdate(metadata); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - AASDK_LOG(error) << "[MediaStatusServiceChannel] encountered error with message: " << dump(payload); - } - -} - - -void MediaStatusServiceChannel::handlePlaybackUpdate(const common::DataConstBuffer& payload, IMediaStatusServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::MediaInfoChannelPlaybackData playback; - if(playback.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onPlaybackUpdate(playback); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - AASDK_LOG(error) << "[MediaStatusServiceChannel] encountered error with message: " << dump(payload); - } - -} - -void MediaStatusServiceChannel::handleChannelOpenRequest(const common::DataConstBuffer& payload, IMediaStatusServiceChannelEventHandler::Pointer eventHandler) -{ - AASDK_LOG(info) << "[MediaStatusServiceChannel] channel open request "; - - proto::messages::ChannelOpenRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onChannelOpenRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - - -} -} -} diff --git a/src/Channel/AV/SpeechAudioServiceChannel.cpp b/src/Channel/AV/SpeechAudioServiceChannel.cpp deleted file mode 100644 index 0aa2bafd..00000000 --- a/src/Channel/AV/SpeechAudioServiceChannel.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -SpeechAudioServiceChannel::SpeechAudioServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger) - : AudioServiceChannel(strand, std::move(messenger), messenger::ChannelId::SPEECH_AUDIO) -{ - -} - -} -} -} diff --git a/src/Channel/AV/SystemAudioServiceChannel.cpp b/src/Channel/AV/SystemAudioServiceChannel.cpp deleted file mode 100644 index d8bc042c..00000000 --- a/src/Channel/AV/SystemAudioServiceChannel.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -SystemAudioServiceChannel::SystemAudioServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger) - : AudioServiceChannel(strand, std::move(messenger), messenger::ChannelId::SYSTEM_AUDIO) -{ - -} - -} -} -} diff --git a/src/Channel/AV/VideoServiceChannel.cpp b/src/Channel/AV/VideoServiceChannel.cpp deleted file mode 100644 index ee781576..00000000 --- a/src/Channel/AV/VideoServiceChannel.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace av -{ - -VideoServiceChannel::VideoServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger) - : ServiceChannel(strand, std::move(messenger), messenger::ChannelId::VIDEO) -{ - -} - -void VideoServiceChannel::receive(IVideoServiceChannelEventHandler::Pointer eventHandler) -{ - auto receivePromise = messenger::ReceivePromise::defer(strand_); - receivePromise->then(std::bind(&VideoServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler), - std::bind(&IVideoServiceChannelEventHandler::onChannelError, eventHandler, std::placeholders::_1)); - - messenger_->enqueueReceive(channelId_, std::move(receivePromise)); -} - -messenger::ChannelId VideoServiceChannel::getId() const -{ - return channelId_; -} - -void VideoServiceChannel::sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::CHANNEL_OPEN_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void VideoServiceChannel::sendAVChannelSetupResponse(const proto::messages::AVChannelSetupResponse& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::AVChannelMessage::SETUP_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void VideoServiceChannel::sendVideoFocusIndication(const proto::messages::VideoFocusIndication& indication, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::AVChannelMessage::VIDEO_FOCUS_INDICATION).getData()); - message->insertPayload(indication); - - this->send(std::move(message), std::move(promise)); -} - -void VideoServiceChannel::sendAVMediaAckIndication(const proto::messages::AVMediaAckIndication& indication, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::AVChannelMessage::AV_MEDIA_ACK_INDICATION).getData()); - message->insertPayload(indication); - - this->send(std::move(message), std::move(promise)); -} - -void VideoServiceChannel::messageHandler(messenger::Message::Pointer message, IVideoServiceChannelEventHandler::Pointer eventHandler) -{ - messenger::MessageId messageId(message->getPayload()); - common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); - - switch(messageId.getId()) - { - case proto::ids::AVChannelMessage::SETUP_REQUEST: - this->handleAVChannelSetupRequest(payload, std::move(eventHandler)); - break; - case proto::ids::AVChannelMessage::START_INDICATION: - this->handleStartIndication(payload, std::move(eventHandler)); - break; - case proto::ids::AVChannelMessage::STOP_INDICATION: - this->handleStopIndication(payload, std::move(eventHandler)); - break; - case proto::ids::AVChannelMessage::AV_MEDIA_WITH_TIMESTAMP_INDICATION: - this->handleAVMediaWithTimestampIndication(payload, std::move(eventHandler)); - break; - case proto::ids::AVChannelMessage::AV_MEDIA_INDICATION: - eventHandler->onAVMediaIndication(payload); - break; - case proto::ids::ControlMessage::CHANNEL_OPEN_REQUEST: - this->handleChannelOpenRequest(payload, std::move(eventHandler)); - break; - case proto::ids::AVChannelMessage::VIDEO_FOCUS_REQUEST: - this->handleVideoFocusRequest(payload, std::move(eventHandler)); - break; - default: - AASDK_LOG(error) << "[VideoServiceChannel] message not handled: " << messageId.getId(); - this->receive(std::move(eventHandler)); - break; - } -} - -void VideoServiceChannel::handleAVChannelSetupRequest(const common::DataConstBuffer& payload, IVideoServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::AVChannelSetupRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onAVChannelSetupRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void VideoServiceChannel::handleStartIndication(const common::DataConstBuffer& payload, IVideoServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::AVChannelStartIndication indication; - if(indication.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onAVChannelStartIndication(indication); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void VideoServiceChannel::handleStopIndication(const common::DataConstBuffer& payload, IVideoServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::AVChannelStopIndication indication; - if(indication.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onAVChannelStopIndication(indication); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void VideoServiceChannel::handleChannelOpenRequest(const common::DataConstBuffer& payload, IVideoServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::ChannelOpenRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onChannelOpenRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void VideoServiceChannel::handleVideoFocusRequest(const common::DataConstBuffer& payload, IVideoServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::VideoFocusRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onVideoFocusRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void VideoServiceChannel::handleAVMediaWithTimestampIndication(const common::DataConstBuffer& payload, IVideoServiceChannelEventHandler::Pointer eventHandler) -{ - if(payload.size >= sizeof(messenger::Timestamp::ValueType)) - { - messenger::Timestamp timestamp(payload); - eventHandler->onAVMediaWithTimestampIndication(timestamp.getValue(), common::DataConstBuffer(payload.cdata, payload.size, sizeof(messenger::Timestamp::ValueType))); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -} -} -} diff --git a/src/Channel/Bluetooth/BluetoothService.cpp b/src/Channel/Bluetooth/BluetoothService.cpp new file mode 100644 index 00000000..19cbf77c --- /dev/null +++ b/src/Channel/Bluetooth/BluetoothService.cpp @@ -0,0 +1,151 @@ +// 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) +// +// 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 . + +#include +#include "aasdk/Channel/Bluetooth/IBluetoothServiceEventHandler.hpp" +#include "aasdk/Channel/Bluetooth/BluetoothService.hpp" +#include "aasdk/Common/Log.hpp" + +namespace aasdk::channel::bluetooth { + + BluetoothService::BluetoothService(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : Channel(strand, std::move(messenger), messenger::ChannelId::BLUETOOTH) { + + } + + void BluetoothService::receive(IBluetoothServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[BluetoothService] receive()"; + + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&BluetoothService::messageHandler, this->shared_from_this(), std::placeholders::_1, + eventHandler), + std::bind(&IBluetoothServiceEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void BluetoothService::sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[BluetoothService] sendChannelOpenResponse()"; + + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::CONTROL)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void BluetoothService::sendBluetoothPairingResponse( + const aap_protobuf::service::bluetooth::message::BluetoothPairingResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[BluetoothService] sendBluetoothPairingResponse()"; + + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::bluetooth::BluetoothMessageId::BLUETOOTH_MESSAGE_PAIRING_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void BluetoothService::sendBluetoothAuthenticationData( + const aap_protobuf::service::bluetooth::message::BluetoothAuthenticationData &response, + SendPromise::Pointer promise) { + + AASDK_LOG(debug) << "[BluetoothService] sendBluetoothAuthenticationData()"; + + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::bluetooth::BluetoothMessageId::BLUETOOTH_MESSAGE_AUTHENTICATION_DATA).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void BluetoothService::messageHandler(messenger::Message::Pointer message, + IBluetoothServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[BluetoothService] messageHandler()"; + + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + switch (messageId.getId()) { + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_REQUEST: + this->handleChannelOpenRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::bluetooth::BluetoothMessageId::BLUETOOTH_MESSAGE_PAIRING_REQUEST: + this->handleBluetoothPairingRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::bluetooth::BluetoothMessageId::BLUETOOTH_MESSAGE_AUTHENTICATION_RESULT: + this->handleBluetoothAuthenticationResult(payload, std::move(eventHandler)); + break; + default: + AASDK_LOG(error) << "[BluetoothService] Message Id not Handled: " << messageId.getId(); + this->receive(std::move(eventHandler)); + break; + } + } + + void BluetoothService::handleChannelOpenRequest(const common::DataConstBuffer &payload, + IBluetoothServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[BluetoothService] handleChannelOpenRequest()"; + + aap_protobuf::service::control::message::ChannelOpenRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onChannelOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void BluetoothService::handleBluetoothAuthenticationResult(const common::DataConstBuffer &payload, + IBluetoothServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[BluetoothService] handleBluetoothAuthenticationResult()"; + + aap_protobuf::service::bluetooth::message::BluetoothAuthenticationResult request; + + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onBluetoothAuthenticationResult(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void BluetoothService::handleBluetoothPairingRequest(const common::DataConstBuffer &payload, + IBluetoothServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[BluetoothService] handleBluetoothPairingRequest()"; + + aap_protobuf::service::bluetooth::message::BluetoothPairingRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onBluetoothPairingRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + +} + + diff --git a/src/Channel/Bluetooth/BluetoothServiceChannel.cpp b/src/Channel/Bluetooth/BluetoothServiceChannel.cpp deleted file mode 100644 index 32a60b44..00000000 --- a/src/Channel/Bluetooth/BluetoothServiceChannel.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace bluetooth -{ - -BluetoothServiceChannel::BluetoothServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger) - : ServiceChannel(strand, std::move(messenger), messenger::ChannelId::BLUETOOTH) -{ - -} - -void BluetoothServiceChannel::receive(IBluetoothServiceChannelEventHandler::Pointer eventHandler) -{ - AASDK_LOG(info) << "[BluetoothServiceChannel] receive "; - - auto receivePromise = messenger::ReceivePromise::defer(strand_); - receivePromise->then(std::bind(&BluetoothServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler), - std::bind(&IBluetoothServiceChannelEventHandler::onChannelError, eventHandler,std::placeholders::_1)); - - messenger_->enqueueReceive(channelId_, std::move(receivePromise)); -} - -messenger::ChannelId BluetoothServiceChannel::getId() const -{ - return channelId_; -} - -void BluetoothServiceChannel::sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) -{ - AASDK_LOG(info) << "[BluetoothServiceChannel] channel open response "; - - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::CHANNEL_OPEN_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void BluetoothServiceChannel::sendBluetoothPairingResponse(const proto::messages::BluetoothPairingResponse& response, SendPromise::Pointer promise) -{ - AASDK_LOG(info) << "[BluetoothServiceChannel] pairing response "; - - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::BluetoothChannelMessage::PAIRING_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void BluetoothServiceChannel::messageHandler(messenger::Message::Pointer message, IBluetoothServiceChannelEventHandler::Pointer eventHandler) -{ - AASDK_LOG(info) << "[BluetoothServiceChannel] message handler "; - - messenger::MessageId messageId(message->getPayload()); - common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); - - switch(messageId.getId()) - { - case proto::ids::ControlMessage::CHANNEL_OPEN_REQUEST: - this->handleChannelOpenRequest(payload, std::move(eventHandler)); - break; - case proto::ids::BluetoothChannelMessage::PAIRING_REQUEST: - this->handleBluetoothPairingRequest(payload, std::move(eventHandler)); - break; - default: - AASDK_LOG(error) << "[BluetoothServiceChannel] message not handled: " << messageId.getId(); - this->receive(std::move(eventHandler)); - break; - } -} - -void BluetoothServiceChannel::handleChannelOpenRequest(const common::DataConstBuffer& payload, IBluetoothServiceChannelEventHandler::Pointer eventHandler) -{ - AASDK_LOG(info) << "[BluetoothServiceChannel] channel open request "; - - proto::messages::ChannelOpenRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onChannelOpenRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void BluetoothServiceChannel::handleBluetoothPairingRequest(const common::DataConstBuffer& payload, IBluetoothServiceChannelEventHandler::Pointer eventHandler) -{ - AASDK_LOG(info) << "[BluetoothServiceChannel] pairing request "; - - proto::messages::BluetoothPairingRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onBluetoothPairingRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -} -} -} diff --git a/src/Channel/Channel.cpp b/src/Channel/Channel.cpp new file mode 100644 index 00000000..63167b86 --- /dev/null +++ b/src/Channel/Channel.cpp @@ -0,0 +1,45 @@ +// 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) +// +// 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 . + +#include "aasdk/IO/PromiseLink.hpp" +#include "aasdk/Channel/Channel.hpp" + +namespace aasdk::channel { + Channel::Channel(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger, + messenger::ChannelId channelId) + : strand_(strand), messenger_(std::move(messenger)), channelId_(channelId) { + + } + + messenger::ChannelId Channel::getId() const { + return channelId_; + } + + void Channel::send(messenger::Message::Pointer message, SendPromise::Pointer promise) { +#if BOOST_VERSION < 106600 + auto sendPromise = messenger::SendPromise::defer(strand_.get_io_service()); +#else + auto sendPromise = messenger::SendPromise::defer(strand_.context()); +#endif + + io::PromiseLink<>::forward(*sendPromise, std::move(promise)); + messenger_->enqueueSend(std::move(message), std::move(sendPromise)); + } + +} + diff --git a/src/Channel/Control/ControlServiceChannel.cpp b/src/Channel/Control/ControlServiceChannel.cpp index 39b10c17..f6bbc0a8 100644 --- a/src/Channel/Control/ControlServiceChannel.cpp +++ b/src/Channel/Control/ControlServiceChannel.cpp @@ -1,23 +1,21 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include -#include #include #include #include @@ -25,280 +23,332 @@ #include -namespace aasdk -{ -namespace channel -{ -namespace control -{ +namespace aasdk { + namespace channel { + namespace control { + + ControlServiceChannel::ControlServiceChannel(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : Channel(strand, messenger, messenger::ChannelId::CONTROL) { + + } + + void ControlServiceChannel::sendVersionRequest(SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[ControlServiceChannel] sendVersionRequest()"; + + auto message(std::make_shared(channelId_, messenger::EncryptionType::PLAIN, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_VERSION_REQUEST).getData()); + + common::Data versionBuffer(4, 0); + reinterpret_cast(versionBuffer[0]) = boost::endian::native_to_big(AASDK_MAJOR); + reinterpret_cast(versionBuffer[2]) = boost::endian::native_to_big(AASDK_MINOR); + message->insertPayload(versionBuffer); + this->send(std::move(message), std::move(promise)); + } + + void ControlServiceChannel::sendHandshake(common::Data handshakeBuffer, SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[ControlServiceChannel] sendHandshake()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::PLAIN, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_ENCAPSULATED_SSL).getData()); + message->insertPayload(handshakeBuffer); + + this->send(std::move(message), std::move(promise)); + } + + void ControlServiceChannel::sendAuthComplete(const aap_protobuf::service::control::message::AuthResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[ControlServiceChannel] sendAuthComplete()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::PLAIN, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId(aap_protobuf::service::control::message::ControlMessageType::MESSAGE_AUTH_COMPLETE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void ControlServiceChannel::sendServiceDiscoveryResponse( + const aap_protobuf::service::control::message::ServiceDiscoveryResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[ControlServiceChannel] sendServiceDiscoveryResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload(messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_SERVICE_DISCOVERY_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void + ControlServiceChannel::sendAudioFocusResponse( + const aap_protobuf::service::control::message::AudioFocusNotification &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[ControlServiceChannel] sendAudioFocusResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_AUDIO_FOCUS_NOTIFICATION).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void ControlServiceChannel::sendShutdownRequest( + const aap_protobuf::service::control::message::ByeByeRequest &request, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[ControlServiceChannel] sendShutdownRequest()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId(aap_protobuf::service::control::message::ControlMessageType::MESSAGE_BYEBYE_REQUEST).getData()); + message->insertPayload(request); + + this->send(std::move(message), std::move(promise)); + } + + void ControlServiceChannel::sendShutdownResponse( + const aap_protobuf::service::control::message::ByeByeResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[ControlServiceChannel] sendShutdownResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_BYEBYE_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void ControlServiceChannel::sendNavigationFocusResponse( + const aap_protobuf::service::control::message::NavFocusNotification &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[ControlServiceChannel] sendNavigationFocusResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_NAV_FOCUS_NOTIFICATION).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void + ControlServiceChannel::sendVoiceSessionFocusResponse( + const aap_protobuf::service::control::message::VoiceSessionNotification &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[ControlServiceChannel] sendVoiceSessionFocusResponse()"; + } + + void ControlServiceChannel::sendPingResponse(const aap_protobuf::service::control::message::PingResponse &request, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[ControlServiceChannel] sendPingResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::PLAIN, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId(aap_protobuf::service::control::message::ControlMessageType::MESSAGE_PING_RESPONSE).getData()); + message->insertPayload(request); + + this->send(std::move(message), std::move(promise)); + } + + void ControlServiceChannel::sendPingRequest(const aap_protobuf::service::control::message::PingRequest &request, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[ControlServiceChannel] sendPingRequest()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::PLAIN, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId(aap_protobuf::service::control::message::ControlMessageType::MESSAGE_PING_REQUEST).getData()); + message->insertPayload(request); + + this->send(std::move(message), std::move(promise)); + } + + void ControlServiceChannel::receive(IControlServiceChannelEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[ControlServiceChannel] receive()"; + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&ControlServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, + eventHandler), + std::bind(&IControlServiceChannelEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void ControlServiceChannel::messageHandler(messenger::Message::Pointer message, + IControlServiceChannelEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[ControlServiceChannel] messageHandler()"; + + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + AASDK_LOG(debug) << "[ControlServiceChannel] MessageId: " << messageId.getId(); + + switch (messageId.getId()) { + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_VERSION_RESPONSE: + this->handleVersionResponse(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_ENCAPSULATED_SSL: + eventHandler->onHandshake(payload); + break; + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_SERVICE_DISCOVERY_REQUEST: + this->handleServiceDiscoveryRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_PING_REQUEST: + this->handlePingRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_PING_RESPONSE: + this->handlePingResponse(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_AUDIO_FOCUS_REQUEST: + this->handleAudioFocusRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_NAV_FOCUS_REQUEST: + this->handleNavigationFocusRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_VOICE_SESSION_NOTIFICATION: + this->handleVoiceSessionRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_BATTERY_STATUS_NOTIFICATION: + this->handleBatteryStatusNotification(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_BYEBYE_REQUEST: + this->handleShutdownRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_BYEBYE_RESPONSE: + this->handleShutdownResponse(payload, std::move(eventHandler)); + break; + default: + AASDK_LOG(error) << "[ControlServiceChannel] Message Id not Handled: " << messageId.getId(); + this->receive(std::move(eventHandler)); + break; + } + } + + void ControlServiceChannel::handleVersionResponse(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[ControlServiceChannel] handleVersionResponse()"; + + const size_t elements = payload.size / sizeof(uint16_t); + const uint16_t *versionResponse = reinterpret_cast(payload.cdata); + + aap_protobuf::shared::MessageStatus status = static_cast(boost::endian::big_to_native( + versionResponse[2])); + AASDK_LOG(info) << "[ControlServiceChannel] Handling Version - Major: " << versionResponse[0] << " Minor: " + << versionResponse[1] << "Status: " << status; + + eventHandler->onVersionResponse(versionResponse[0], versionResponse[1], status); + } + + void ControlServiceChannel::handleServiceDiscoveryRequest(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[ControlServiceChannel] handleServiceDiscoveryRequest()"; + aap_protobuf::service::control::message::ServiceDiscoveryRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onServiceDiscoveryRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void ControlServiceChannel::handleAudioFocusRequest(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[ControlServiceChannel] handleAudioFocusRequest()"; + aap_protobuf::service::control::message::AudioFocusRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onAudioFocusRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void ControlServiceChannel::handleVoiceSessionRequest(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[ControlServiceChannel] handleVoiceSessionRequest()"; + aap_protobuf::service::control::message::VoiceSessionNotification request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onVoiceSessionRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void ControlServiceChannel::handleBatteryStatusNotification(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[ControlServiceChannel] handleBatteryStatusNotification()"; + + aap_protobuf::service::control::message::BatteryStatusNotification request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onBatteryStatusNotification(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void ControlServiceChannel::handleShutdownRequest(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[ControlServiceChannel] handleShutdownRequest()"; + aap_protobuf::service::control::message::ByeByeRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onByeByeRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void ControlServiceChannel::handleShutdownResponse(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[ControlServiceChannel] handleShutdownResponse()"; + aap_protobuf::service::control::message::ByeByeResponse response; + if (response.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onByeByeResponse(response); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void ControlServiceChannel::handleNavigationFocusRequest(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[ControlServiceChannel] handleNavigationFocusRequest()"; + aap_protobuf::service::control::message::NavFocusRequestNotification request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onNavigationFocusRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void ControlServiceChannel::handlePingRequest(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[ControlServiceChannel] handlePingRequest()"; + aap_protobuf::service::control::message::PingRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onPingRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void ControlServiceChannel::handlePingResponse(const common::DataConstBuffer &payload, + IControlServiceChannelEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[ControlServiceChannel] handlePingResponse()"; + aap_protobuf::service::control::message::PingResponse response; + if (response.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onPingResponse(response); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } -ControlServiceChannel::ControlServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger) - : ServiceChannel(strand, messenger, messenger::ChannelId::CONTROL) -{ - -} - -void ControlServiceChannel::sendVersionRequest(SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::PLAIN, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::VERSION_REQUEST).getData()); - - common::Data versionBuffer(4, 0); - reinterpret_cast(versionBuffer[0]) = boost::endian::native_to_big(AASDK_MAJOR); - reinterpret_cast(versionBuffer[2]) = boost::endian::native_to_big(AASDK_MINOR); - message->insertPayload(versionBuffer); - - this->send(std::move(message), std::move(promise)); -} - -void ControlServiceChannel::sendHandshake(common::Data handshakeBuffer, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::PLAIN, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::SSL_HANDSHAKE).getData()); - message->insertPayload(handshakeBuffer); - - this->send(std::move(message), std::move(promise)); -} - -void ControlServiceChannel::sendAuthComplete(const proto::messages::AuthCompleteIndication& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::PLAIN, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::AUTH_COMPLETE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void ControlServiceChannel::sendServiceDiscoveryResponse(const proto::messages::ServiceDiscoveryResponse& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::SERVICE_DISCOVERY_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void ControlServiceChannel::sendAudioFocusResponse(const proto::messages::AudioFocusResponse& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::AUDIO_FOCUS_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void ControlServiceChannel::sendShutdownRequest(const proto::messages::ShutdownRequest& request, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::SHUTDOWN_REQUEST).getData()); - message->insertPayload(request); - - this->send(std::move(message), std::move(promise)); -} - -void ControlServiceChannel::sendShutdownResponse(const proto::messages::ShutdownResponse& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::SHUTDOWN_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void ControlServiceChannel::sendNavigationFocusResponse(const proto::messages::NavigationFocusResponse& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::NAVIGATION_FOCUS_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void ControlServiceChannel::sendPingResponse(const proto::messages::PingResponse& request, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::PLAIN, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::PING_RESPONSE).getData()); - message->insertPayload(request); - - this->send(std::move(message), std::move(promise)); -} - -void ControlServiceChannel::sendPingRequest(const proto::messages::PingRequest& request, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::PLAIN, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::PING_REQUEST).getData()); - message->insertPayload(request); - - this->send(std::move(message), std::move(promise)); -} - -void ControlServiceChannel::receive(IControlServiceChannelEventHandler::Pointer eventHandler) -{ - auto receivePromise = messenger::ReceivePromise::defer(strand_); - receivePromise->then(std::bind(&ControlServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler), - std::bind(&IControlServiceChannelEventHandler::onChannelError, eventHandler, std::placeholders::_1)); - - messenger_->enqueueReceive(channelId_, std::move(receivePromise)); -} - -void ControlServiceChannel::messageHandler(messenger::Message::Pointer message, IControlServiceChannelEventHandler::Pointer eventHandler) -{ - messenger::MessageId messageId(message->getPayload()); - common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); - - switch(messageId.getId()) - { - case proto::ids::ControlMessage::VERSION_RESPONSE: - this->handleVersionResponse(payload, std::move(eventHandler)); - break; - case proto::ids::ControlMessage::SSL_HANDSHAKE: - eventHandler->onHandshake(payload); - break; - case proto::ids::ControlMessage::SERVICE_DISCOVERY_REQUEST: - this->handleServiceDiscoveryRequest(payload, std::move(eventHandler)); - break; - case proto::ids::ControlMessage::AUDIO_FOCUS_REQUEST: - this->handleAudioFocusRequest(payload, std::move(eventHandler)); - break; - case proto::ids::ControlMessage::SHUTDOWN_REQUEST: - this->handleShutdownRequest(payload, std::move(eventHandler)); - break; - case proto::ids::ControlMessage::SHUTDOWN_RESPONSE: - this->handleShutdownResponse(payload, std::move(eventHandler)); - break; - case proto::ids::ControlMessage::NAVIGATION_FOCUS_REQUEST: - this->handleNavigationFocusRequest(payload, std::move(eventHandler)); - break; - case proto::ids::ControlMessage::PING_REQUEST: - this->handlePingRequest(payload, std::move(eventHandler)); - break; - case proto::ids::ControlMessage::PING_RESPONSE: - this->handlePingResponse(payload, std::move(eventHandler)); - break; - case proto::ids::ControlMessage::VOICE_SESSION_REQUEST: - this->handleVoiceSessionRequest(payload, std::move(eventHandler)); - break; - default: - AASDK_LOG(error) << "[ControlServiceChannel] message not handled: " << messageId.getId(); - this->receive(std::move(eventHandler)); - break; } -} - -void ControlServiceChannel::handleVersionResponse(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler) -{ - const size_t elements = payload.size / sizeof(uint16_t); - const uint16_t* versionResponse = reinterpret_cast(payload.cdata); - - uint16_t majorCode = elements > 0 ? boost::endian::big_to_native(versionResponse[0]) : 0; - uint16_t minorCode = elements > 1 ? boost::endian::big_to_native(versionResponse[1]) : 0; - proto::enums::VersionResponseStatus::Enum status = elements > 2 ? static_cast(versionResponse[2]) : proto::enums::VersionResponseStatus::MISMATCH; - - eventHandler->onVersionResponse(majorCode, minorCode, status); -} - -void ControlServiceChannel::handleServiceDiscoveryRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::ServiceDiscoveryRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onServiceDiscoveryRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void ControlServiceChannel::handleAudioFocusRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::AudioFocusRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onAudioFocusRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void ControlServiceChannel::handleVoiceSessionRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::VoiceSessionRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onVoiceSessionRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void ControlServiceChannel::handleShutdownRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::ShutdownRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onShutdownRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void ControlServiceChannel::handleShutdownResponse(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::ShutdownResponse response; - if(response.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onShutdownResponse(response); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void ControlServiceChannel::handleNavigationFocusRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::NavigationFocusRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onNavigationFocusRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} -void ControlServiceChannel::handlePingRequest(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::PingRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onPingRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} -void ControlServiceChannel::handlePingResponse(const common::DataConstBuffer& payload, IControlServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::PingResponse response; - if(response.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onPingResponse(response); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -} -} + } } diff --git a/src/Channel/GenericNotification/GenericNotification.cpp b/src/Channel/GenericNotification/GenericNotification.cpp new file mode 100644 index 00000000..3ddc88b0 --- /dev/null +++ b/src/Channel/GenericNotification/GenericNotification.cpp @@ -0,0 +1,90 @@ +// 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) +// +// 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 . + +#include +#include +#include "aasdk/Common/Log.hpp" + +/* + * This is a Generic Notification channel - not much is known at this point. + */ + + +namespace aasdk::channel::genericnotification { + + GenericNotificationService::GenericNotificationService(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : Channel(strand, std::move(messenger), messenger::ChannelId::GENERIC_NOTIFICATION) { + + } + + void GenericNotificationService::receive(IGenericNotificationServiceEventHandler::Pointer eventHandler) { + + AASDK_LOG(debug) << "[GenericNotificationService] Receive"; + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&GenericNotificationService::messageHandler, this->shared_from_this(), std::placeholders::_1, + eventHandler), + std::bind(&IGenericNotificationServiceEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void GenericNotificationService::sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) { + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::CONTROL)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void GenericNotificationService::messageHandler(messenger::Message::Pointer message, + IGenericNotificationServiceEventHandler::Pointer eventHandler) { + + AASDK_LOG(debug) << "[GenericNotificationService] messageHandler()"; + + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + switch (messageId.getId()) { + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_REQUEST: + this->handleChannelOpenRequest(payload, std::move(eventHandler)); + break; + default: + AASDK_LOG(error) << "[GenericNotificationService] Message Id not Handled: " << messageId.getId(); + this->receive(std::move(eventHandler)); + break; + } + } + + void GenericNotificationService::handleChannelOpenRequest(const common::DataConstBuffer &payload, + IGenericNotificationServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[GenericNotificationService] handleChannelOpenRequest()"; + aap_protobuf::service::control::message::ChannelOpenRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onChannelOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } +} + + diff --git a/src/Channel/Input/InputServiceChannel.cpp b/src/Channel/Input/InputServiceChannel.cpp deleted file mode 100644 index f60017ea..00000000 --- a/src/Channel/Input/InputServiceChannel.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace input -{ - -InputServiceChannel::InputServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger) - : ServiceChannel(strand, std::move(messenger), messenger::ChannelId::INPUT) -{ - -} - -void InputServiceChannel::receive(IInputServiceChannelEventHandler::Pointer eventHandler) -{ - auto receivePromise = messenger::ReceivePromise::defer(strand_); - receivePromise->then(std::bind(&InputServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler), - std::bind(&IInputServiceChannelEventHandler::onChannelError, eventHandler, std::placeholders::_1)); - - messenger_->enqueueReceive(channelId_, std::move(receivePromise)); -} - -messenger::ChannelId InputServiceChannel::getId() const -{ - return channelId_; -} - -void InputServiceChannel::sendInputEventIndication(const proto::messages::InputEventIndication& indication, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::InputChannelMessage::INPUT_EVENT_INDICATION).getData()); - message->insertPayload(indication); - - this->send(std::move(message), std::move(promise)); -} - -void InputServiceChannel::sendBindingResponse(const proto::messages::BindingResponse& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::InputChannelMessage::BINDING_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void InputServiceChannel::sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::CHANNEL_OPEN_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void InputServiceChannel::messageHandler(messenger::Message::Pointer message, IInputServiceChannelEventHandler::Pointer eventHandler) -{ - messenger::MessageId messageId(message->getPayload()); - common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); - - switch(messageId.getId()) - { - case proto::ids::InputChannelMessage::BINDING_REQUEST: - this->handleBindingRequest(payload, std::move(eventHandler)); - break; - case proto::ids::ControlMessage::CHANNEL_OPEN_REQUEST: - this->handleChannelOpenRequest(payload, std::move(eventHandler)); - break; - default: - AASDK_LOG(error) << "[InputServiceChannel] message not handled: " << messageId.getId(); - this->receive(std::move(eventHandler)); - break; - } -} - -void InputServiceChannel::handleBindingRequest(const common::DataConstBuffer& payload, IInputServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::BindingRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onBindingRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void InputServiceChannel::handleChannelOpenRequest(const common::DataConstBuffer& payload, IInputServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::ChannelOpenRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onChannelOpenRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -} -} -} diff --git a/src/Channel/InputSource/InputSourceService.cpp b/src/Channel/InputSource/InputSourceService.cpp new file mode 100644 index 00000000..1ced7a7d --- /dev/null +++ b/src/Channel/InputSource/InputSourceService.cpp @@ -0,0 +1,127 @@ +// 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) +// +// 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 . + +#include +#include "aasdk/Channel/InputSource/InputSourceService.hpp" +#include "aasdk/Channel/InputSource/IInputSourceServiceEventHandler.hpp" +#include "aasdk/Common/Log.hpp" + + +namespace aasdk::channel::inputsource { + + InputSourceService::InputSourceService(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : Channel(strand, std::move(messenger), messenger::ChannelId::INPUT_SOURCE) { + + } + + void InputSourceService::receive(IInputSourceServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[InputSourceService] receive()"; + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&InputSourceService::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler), + std::bind(&IInputSourceServiceEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void + InputSourceService::sendInputReport( + const aap_protobuf::service::inputsource::message::InputReport &indication, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[InputSourceService] sendInputReport()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload(messenger::MessageId( + aap_protobuf::service::inputsource::InputMessageId::INPUT_MESSAGE_INPUT_REPORT).getData()); + message->insertPayload(indication); + + this->send(std::move(message), std::move(promise)); + } + + void + InputSourceService::sendKeyBindingResponse(const aap_protobuf::service::media::sink::message::KeyBindingResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[InputSourceService] sendKeyBindingResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload(messenger::MessageId( + aap_protobuf::service::inputsource::InputMessageId::INPUT_MESSAGE_KEY_BINDING_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void InputSourceService::sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[InputSourceService] sendChannelOpenResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::CONTROL)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void InputSourceService::messageHandler(messenger::Message::Pointer message, + IInputSourceServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[InputSourceService] messageHandler()"; + + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + switch (messageId.getId()) { + case aap_protobuf::service::inputsource::InputMessageId::INPUT_MESSAGE_KEY_BINDING_REQUEST: + this->handleKeyBindingRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_REQUEST: + this->handleChannelOpenRequest(payload, std::move(eventHandler)); + break; + default: + AASDK_LOG(error) << "[InputSourceService] Message Id not Handled: " << messageId.getId(); + this->receive(std::move(eventHandler)); + break; + } + } + + void InputSourceService::handleKeyBindingRequest(const common::DataConstBuffer &payload, + IInputSourceServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[InputSourceService] handleKeyBindingRequest()"; + aap_protobuf::service::media::sink::message::KeyBindingRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onKeyBindingRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void InputSourceService::handleChannelOpenRequest(const common::DataConstBuffer &payload, + IInputSourceServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[InputSourceService] handleChannelOpenRequest()"; + aap_protobuf::service::control::message::ChannelOpenRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onChannelOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + +} + + diff --git a/src/Channel/MediaBrowser/MediaBrowserService.cpp b/src/Channel/MediaBrowser/MediaBrowserService.cpp new file mode 100644 index 00000000..d0284994 --- /dev/null +++ b/src/Channel/MediaBrowser/MediaBrowserService.cpp @@ -0,0 +1,96 @@ + +// 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) +// +// 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 . + +#include +#include +#include +#include "aasdk/Common/Log.hpp" + +/* + * This is a Media Browser channel that could be used for integration onto another Raspberry Pi/Other Device to add an additional screen for notification and control purposes - such as updating the LCD screen on older Vauxhall/Opel/GM Cars + */ + +namespace aasdk::channel::mediabrowser { + + MediaBrowserService::MediaBrowserService(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : Channel(strand, std::move(messenger), messenger::ChannelId::MEDIA_BROWSER) { + + } + + void MediaBrowserService::receive(IMediaBrowserServiceEventHandler::Pointer eventHandler) { + + AASDK_LOG(debug) << "[MediaBrowserService] receive()"; + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&MediaBrowserService::messageHandler, this->shared_from_this(), std::placeholders::_1, + eventHandler), + std::bind(&IMediaBrowserServiceEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void MediaBrowserService::sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[MediaBrowserService] sendChannelOpenResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::CONTROL)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void MediaBrowserService::messageHandler(messenger::Message::Pointer message, + IMediaBrowserServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[MediaBrowserService] messageHandler()"; + + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + switch (messageId.getId()) { + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_REQUEST: + this->handleChannelOpenRequest(payload, std::move(eventHandler)); + case aap_protobuf::service::mediabrowser::MediaBrowserMessageId::MEDIA_ROOT_NODE: + case aap_protobuf::service::mediabrowser::MediaBrowserMessageId::MEDIA_SOURCE_NODE: + case aap_protobuf::service::mediabrowser::MediaBrowserMessageId::MEDIA_LIST_NODE: + case aap_protobuf::service::mediabrowser::MediaBrowserMessageId::MEDIA_SONG_NODE: + case aap_protobuf::service::mediabrowser::MediaBrowserMessageId::MEDIA_GET_NODE: + case aap_protobuf::service::mediabrowser::MediaBrowserMessageId::MEDIA_BROWSE_INPUT: + default: + AASDK_LOG(error) << "[MediaBrowserService] Message Id not Handled: " << messageId.getId(); + this->receive(std::move(eventHandler)); + break; + } + } + + void MediaBrowserService::handleChannelOpenRequest(const common::DataConstBuffer &payload, + IMediaBrowserServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[MediaBrowserService] handleChannelOpenRequest()"; + aap_protobuf::service::control::message::ChannelOpenRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onChannelOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } +} + + diff --git a/src/Channel/MediaPlaybackStatus/MediaPlaybackStatusService.cpp b/src/Channel/MediaPlaybackStatus/MediaPlaybackStatusService.cpp new file mode 100644 index 00000000..9c239178 --- /dev/null +++ b/src/Channel/MediaPlaybackStatus/MediaPlaybackStatusService.cpp @@ -0,0 +1,132 @@ +// 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) +// +// 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 . + +#include +#include "aasdk/Channel/MediaPlaybackStatus/MediaPlaybackStatusService.hpp" +#include "aasdk/Channel/MediaPlaybackStatus/IMediaPlaybackStatusServiceEventHandler.hpp" +#include "aasdk/Common/Log.hpp" + +/* + * This is a Media Playback Status channel that could be used for integration onto another Raspberry Pi/Other Device to add an additional screen for notification and control purposes - such as updating the LCD screen on older Vauxhall/Opel/GM Cars + */ + +namespace aasdk::channel::mediaplaybackstatus { + + MediaPlaybackStatusService::MediaPlaybackStatusService(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : Channel(strand, std::move(messenger), messenger::ChannelId::MEDIA_PLAYBACK_STATUS) { + + } + + void MediaPlaybackStatusService::receive(IMediaPlaybackStatusServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[MediaPlaybackStatusService] receive()"; + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&MediaPlaybackStatusService::messageHandler, this->shared_from_this(), std::placeholders::_1, + eventHandler), + std::bind(&IMediaPlaybackStatusServiceEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void MediaPlaybackStatusService::sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[MediaPlaybackStatusService] sendChannelOpenResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::CONTROL)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + + void MediaPlaybackStatusService::messageHandler(messenger::Message::Pointer message, + IMediaPlaybackStatusServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[MediaPlaybackStatusService] messageHandler()"; + + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + switch (messageId.getId()) { + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_REQUEST: + this->handleChannelOpenRequest(payload, std::move(eventHandler)); + break; + + case aap_protobuf::service::mediaplayback::MediaPlaybackStatusMessageId::MEDIA_PLAYBACK_METADATA: + this->handleMetadataUpdate(payload, std::move(eventHandler)); + break; + + case aap_protobuf::service::mediaplayback::MediaPlaybackStatusMessageId::MEDIA_PLAYBACK_STATUS: + this->handlePlaybackUpdate(payload, std::move(eventHandler)); + break; + + default: + AASDK_LOG(error) << "[MediaPlaybackStatusService] Message Id not Handled: " << messageId.getId() << " : " + << dump(payload); + this->receive(std::move(eventHandler)); + break; + } + + + } + + void MediaPlaybackStatusService::handleMetadataUpdate(const common::DataConstBuffer &payload, + IMediaPlaybackStatusServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[MediaPlaybackStatusService] handleMetadataUpdate()"; + aap_protobuf::service::mediaplayback::message::MediaPlaybackMetadata metadata; + if (metadata.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onMetadataUpdate(metadata); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + AASDK_LOG(error) << "[MediaPlaybackStatusService] encountered error with message: " << dump(payload); + } + + } + + + void MediaPlaybackStatusService::handlePlaybackUpdate(const common::DataConstBuffer &payload, + IMediaPlaybackStatusServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[MediaPlaybackStatusService] handlePlaybackUpdate()"; + aap_protobuf::service::mediaplayback::message::MediaPlaybackStatus playback; + if (playback.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onPlaybackUpdate(playback); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + AASDK_LOG(error) << "[MediaPlaybackStatusService] encountered error with message: " << dump(payload); + } + + } + + void MediaPlaybackStatusService::handleChannelOpenRequest(const common::DataConstBuffer &payload, + IMediaPlaybackStatusServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[MediaPlaybackStatusService] handleChannelOpenRequest()"; + + aap_protobuf::service::control::message::ChannelOpenRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onChannelOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + +} + + diff --git a/src/Channel/MediaSink/Audio/AudioMediaSinkService.cpp b/src/Channel/MediaSink/Audio/AudioMediaSinkService.cpp new file mode 100644 index 00000000..f58761c2 --- /dev/null +++ b/src/Channel/MediaSink/Audio/AudioMediaSinkService.cpp @@ -0,0 +1,180 @@ +// 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) +// +// 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 . + +#include +#include +#include +#include "aasdk/Common/Log.hpp" + +/* + * TODO: Merge Audio and Video Sink Service - P4 + * A lot of AudioMediaSinkService and VideoMediaSinkService, share code in common with each other. + * It would be recommended to merge these at some point for consistent MediaSink handling. This was attempted + * previously, but caused messy code due to some of the callbacks and handlers specific to Video + */ +namespace aasdk::channel::mediasink::audio { + + AudioMediaSinkService::AudioMediaSinkService(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger, + messenger::ChannelId channelId) + : Channel(strand, std::move(messenger), channelId) { + + } + + void AudioMediaSinkService::receive(IAudioMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[AudioMediaSinkService] receive()"; + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&AudioMediaSinkService::messageHandler, this->shared_from_this(), std::placeholders::_1, + eventHandler), + std::bind(&IAudioMediaSinkServiceEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void AudioMediaSinkService::sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[AudioMediaSinkService] sendChannelOpenResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::CONTROL)); + message->insertPayload( + messenger::MessageId(aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void AudioMediaSinkService::sendChannelSetupResponse( + const aap_protobuf::service::media::shared::message::Config &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[AudioMediaSinkService] sendChannelSetupResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_CONFIG).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void AudioMediaSinkService::sendMediaAckIndication( + const aap_protobuf::service::media::source::message::Ack &indication, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[AudioMediaSinkService] sendMediaAckIndication()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_ACK).getData()); + message->insertPayload(indication); + + this->send(std::move(message), std::move(promise)); + } + + void AudioMediaSinkService::messageHandler(messenger::Message::Pointer message, + IAudioMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[AudioMediaSinkService] messageHandler()"; + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + // Setup, Start, Stop, Config, Data + + switch (messageId.getId()) { + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_REQUEST: + this->handleChannelOpenRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_SETUP: + this->handleChannelSetupRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_START: + this->handleStartIndication(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_STOP: + this->handleStopIndication(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_CODEC_CONFIG: + eventHandler->onMediaIndication(payload); + break; + case aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_DATA: + this->handleMediaWithTimestampIndication(payload, std::move(eventHandler)); + break; + default: + AASDK_LOG(error) << "[AudioMediaSinkService] Message Id not Handled: " << messageId.getId(); + this->receive(std::move(eventHandler)); + break; + } + } + + void AudioMediaSinkService::handleChannelOpenRequest(const common::DataConstBuffer &payload, + IAudioMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[AudioMediaSinkService] handleChannelOpenRequest()"; + aap_protobuf::service::control::message::ChannelOpenRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onChannelOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void AudioMediaSinkService::handleChannelSetupRequest(const common::DataConstBuffer &payload, + IAudioMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[AudioMediaSinkService] handleChannelSetupRequest()"; + aap_protobuf::service::media::shared::message::Setup request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onMediaChannelSetupRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD, 0)); + } + } + + void AudioMediaSinkService::handleStartIndication(const common::DataConstBuffer &payload, + IAudioMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[AudioMediaSinkService] handleStartIndication()"; + aap_protobuf::service::media::shared::message::Start indication; + if (indication.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onMediaChannelStartIndication(indication); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void AudioMediaSinkService::handleStopIndication(const common::DataConstBuffer &payload, + IAudioMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[AudioMediaSinkService] handleStopIndication()"; + aap_protobuf::service::media::shared::message::Stop indication; + if (indication.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onMediaChannelStopIndication(indication); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void AudioMediaSinkService::handleMediaWithTimestampIndication(const common::DataConstBuffer &payload, + IAudioMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[AudioMediaSinkService] handleMediaWithTimestampIndication()"; + if (payload.size >= sizeof(messenger::Timestamp::ValueType)) { + messenger::Timestamp timestamp(payload); + eventHandler->onMediaWithTimestampIndication(timestamp.getValue(), + common::DataConstBuffer(payload.cdata, payload.size, + sizeof(messenger::Timestamp::ValueType))); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } +} + diff --git a/src/Channel/MediaSink/Audio/Channel/GuidanceAudioChannel.cpp b/src/Channel/MediaSink/Audio/Channel/GuidanceAudioChannel.cpp new file mode 100644 index 00000000..cb356df8 --- /dev/null +++ b/src/Channel/MediaSink/Audio/Channel/GuidanceAudioChannel.cpp @@ -0,0 +1,29 @@ +// 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) +// +// 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 . + +#include "aasdk/Channel/MediaSink/Audio/Channel/GuidanceAudioChannel.hpp" + +namespace aasdk::channel::mediasink::audio::channel { + GuidanceAudioChannel::GuidanceAudioChannel(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : AudioMediaSinkService(strand, std::move(messenger), messenger::ChannelId::MEDIA_SINK_GUIDANCE_AUDIO) { + + } +} + + + diff --git a/src/Channel/MediaSink/Audio/Channel/MediaAudioChannel.cpp b/src/Channel/MediaSink/Audio/Channel/MediaAudioChannel.cpp new file mode 100644 index 00000000..bd18fdc1 --- /dev/null +++ b/src/Channel/MediaSink/Audio/Channel/MediaAudioChannel.cpp @@ -0,0 +1,30 @@ +// 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) +// +// 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 . + +#include "aasdk/Channel/MediaSink/Audio/Channel/MediaAudioChannel.hpp" + +namespace aasdk::channel::mediasink::audio::channel { + + MediaAudioChannel::MediaAudioChannel(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : AudioMediaSinkService(strand, std::move(messenger), messenger::ChannelId::MEDIA_SINK_MEDIA_AUDIO) { + + } +} + + + diff --git a/src/Channel/MediaSink/Audio/Channel/SystemAudioChannel.cpp b/src/Channel/MediaSink/Audio/Channel/SystemAudioChannel.cpp new file mode 100644 index 00000000..49851d4f --- /dev/null +++ b/src/Channel/MediaSink/Audio/Channel/SystemAudioChannel.cpp @@ -0,0 +1,31 @@ +// 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) +// +// 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 . + +#include "aasdk/Channel/MediaSink/Audio/Channel/SystemAudioChannel.hpp" + +namespace aasdk::channel::mediasink::audio::channel { + + SystemAudioChannel::SystemAudioChannel(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : AudioMediaSinkService(strand, std::move(messenger), messenger::ChannelId::MEDIA_SINK_SYSTEM_AUDIO) { + + } +} + + + + diff --git a/src/Channel/MediaSink/Audio/Channel/TelephonyAudioChannel.cpp b/src/Channel/MediaSink/Audio/Channel/TelephonyAudioChannel.cpp new file mode 100644 index 00000000..249561e2 --- /dev/null +++ b/src/Channel/MediaSink/Audio/Channel/TelephonyAudioChannel.cpp @@ -0,0 +1,27 @@ +// 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) +// +// 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 . + +#include "aasdk/Channel/MediaSink/Audio/Channel/TelephonyAudioChannel.hpp" + +namespace aasdk::channel::mediasink::audio::channel { + + TelephonyAudioChannel::TelephonyAudioChannel(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : AudioMediaSinkService(strand, std::move(messenger), messenger::ChannelId::MEDIA_SINK_TELEPHONY_AUDIO) { + + } +} diff --git a/src/Channel/MediaSink/Video/Channel/VideoChannel.cpp b/src/Channel/MediaSink/Video/Channel/VideoChannel.cpp new file mode 100644 index 00000000..192f7358 --- /dev/null +++ b/src/Channel/MediaSink/Video/Channel/VideoChannel.cpp @@ -0,0 +1,27 @@ +// 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) +// +// 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 . + +#include "aasdk/Channel/MediaSink/Video/Channel/VideoChannel.hpp" + +namespace aasdk::channel::mediasink::video::channel { + + VideoChannel::VideoChannel(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : VideoMediaSinkService(strand, std::move(messenger), messenger::ChannelId::MEDIA_SINK_VIDEO) { + + } +} \ No newline at end of file diff --git a/src/Channel/MediaSink/Video/VideoMediaSinkService.cpp b/src/Channel/MediaSink/Video/VideoMediaSinkService.cpp new file mode 100644 index 00000000..963e3d2d --- /dev/null +++ b/src/Channel/MediaSink/Video/VideoMediaSinkService.cpp @@ -0,0 +1,204 @@ +// 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) +// +// 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 . + +#include +#include +#include +#include "aasdk/Common/Log.hpp" + +/* + * TODO: Merge Audio and Video Sink Service - P4 + * A lot of AudioMediaSinkService and VideoMediaSinkService, share code in common with each other. + * It would be recommended to merge these at some point for consistent MediaSink handling. This was attempted + * previously, but caused messy code due to some of the callbacks and handlers specific to Video + */ +namespace aasdk::channel::mediasink::video { + + VideoMediaSinkService::VideoMediaSinkService(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger, + messenger::ChannelId channelId) + : Channel(strand, std::move(messenger), channelId) { + + } + + void VideoMediaSinkService::receive(IVideoMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[VideoMediaSinkService] receive()"; + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&VideoMediaSinkService::messageHandler, this->shared_from_this(), std::placeholders::_1, + eventHandler), + std::bind(&IVideoMediaSinkServiceEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void VideoMediaSinkService::sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[VideoMediaSinkService] sendChannelOpenResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::CONTROL)); + message->insertPayload( + messenger::MessageId(aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void VideoMediaSinkService::sendChannelSetupResponse( + const aap_protobuf::service::media::shared::message::Config &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[VideoMediaSinkService] sendChannelSetupResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_CONFIG).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void VideoMediaSinkService::sendMediaAckIndication( + const aap_protobuf::service::media::source::message::Ack &indication, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[VideoMediaSinkService] sendMediaAckIndication()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_ACK).getData()); + message->insertPayload(indication); + + this->send(std::move(message), std::move(promise)); + } + + void VideoMediaSinkService::sendVideoFocusIndication( + const aap_protobuf::service::media::video::message::VideoFocusNotification &indication, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[VideoMediaSinkService] sendVideoFocusIndication()"; + + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); + message->insertPayload(messenger::MessageId(aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_VIDEO_FOCUS_NOTIFICATION).getData()); + message->insertPayload(indication); + + this->send(std::move(message), std::move(promise)); + } + + void VideoMediaSinkService::messageHandler(messenger::Message::Pointer message, + IVideoMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[VideoMediaSinkService] messageHandler()"; + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + switch (messageId.getId()) { + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_REQUEST: + this->handleChannelOpenRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_SETUP: + this->handleChannelSetupRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_START: + this->handleStartIndication(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_STOP: + this->handleStopIndication(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_CODEC_CONFIG: + eventHandler->onMediaIndication(payload); + break; + case aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_DATA: + this->handleMediaWithTimestampIndication(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_VIDEO_FOCUS_REQUEST: + this->handleVideoFocusRequest(payload, std::move(eventHandler)); + break; + default: + AASDK_LOG(error) << "[VideoMediaSinkService] Message Id not Handled: " << messageId.getId(); + this->receive(std::move(eventHandler)); + break; + } + } + + void VideoMediaSinkService::handleChannelSetupRequest(const common::DataConstBuffer &payload, + IVideoMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[VideoMediaSinkService] handleChannelSetupRequest()"; + aap_protobuf::service::media::shared::message::Setup request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onMediaChannelSetupRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void VideoMediaSinkService::handleStartIndication(const common::DataConstBuffer &payload, + IVideoMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[VideoMediaSinkService] handleStartIndication()"; + aap_protobuf::service::media::shared::message::Start indication; + if (indication.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onMediaChannelStartIndication(indication); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void VideoMediaSinkService::handleStopIndication(const common::DataConstBuffer &payload, + IVideoMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[VideoMediaSinkService] handleStopIndication()"; + aap_protobuf::service::media::shared::message::Stop indication; + if (indication.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onMediaChannelStopIndication(indication); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void VideoMediaSinkService::handleChannelOpenRequest(const common::DataConstBuffer &payload, + IVideoMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[VideoMediaSinkService] handleChannelOpenRequest()"; + aap_protobuf::service::control::message::ChannelOpenRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onChannelOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void VideoMediaSinkService::handleMediaWithTimestampIndication(const common::DataConstBuffer &payload, + IVideoMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[VideoMediaSinkService] handleMediaWithTimestampIndication()"; + if (payload.size >= sizeof(messenger::Timestamp::ValueType)) { + messenger::Timestamp timestamp(payload); + eventHandler->onMediaWithTimestampIndication(timestamp.getValue(), + common::DataConstBuffer(payload.cdata, payload.size, + sizeof(messenger::Timestamp::ValueType))); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void VideoMediaSinkService::handleVideoFocusRequest(const common::DataConstBuffer &payload, + IVideoMediaSinkServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[VideoMediaSinkService] handleVideoFocusRequest()"; + aap_protobuf::service::media::video::message::VideoFocusRequestNotification request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onVideoFocusRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } +} + diff --git a/src/Channel/MediaSource/Audio/MicrophoneAudioChannel.cpp b/src/Channel/MediaSource/Audio/MicrophoneAudioChannel.cpp new file mode 100644 index 00000000..1b25ba73 --- /dev/null +++ b/src/Channel/MediaSource/Audio/MicrophoneAudioChannel.cpp @@ -0,0 +1,27 @@ +// 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) +// +// 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 . + +#include "aasdk/Channel/MediaSource/Audio/MicrophoneAudioChannel.hpp" + +namespace aasdk::channel::mediasource::audio { + + MicrophoneAudioChannel::MicrophoneAudioChannel(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : MediaSourceService(strand, std::move(messenger), messenger::ChannelId::MEDIA_SOURCE_MICROPHONE) { + + } +} diff --git a/src/Channel/MediaSource/MediaSourceService.cpp b/src/Channel/MediaSource/MediaSourceService.cpp new file mode 100644 index 00000000..fc48318a --- /dev/null +++ b/src/Channel/MediaSource/MediaSourceService.cpp @@ -0,0 +1,173 @@ +// 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) +// +// 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 . + +#include +#include "aasdk/Messenger/Timestamp.hpp" +#include "aasdk/Channel/MediaSource/IMediaSourceServiceEventHandler.hpp" +#include "aasdk/Channel/MediaSource/MediaSourceService.hpp" +#include "aasdk/Common/Log.hpp" + + +namespace aasdk::channel::mediasource { + + MediaSourceService::MediaSourceService(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger, + messenger::ChannelId channelId) + : Channel(strand, std::move(messenger), channelId) { + + } + + void MediaSourceService::receive(IMediaSourceServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[MediaSourceService] receive()"; + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&MediaSourceService::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler), + std::bind(&IMediaSourceServiceEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void MediaSourceService::sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[MediaSourceService] sendChannelOpenResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::CONTROL)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + + void MediaSourceService::sendChannelSetupResponse( + const aap_protobuf::service::media::shared::message::Config &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[MediaSourceService] sendChannelSetupResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_SETUP).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void MediaSourceService::messageHandler(messenger::Message::Pointer message, + IMediaSourceServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[MediaSourceService] messageHandler()"; + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + switch (messageId.getId()) { + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_REQUEST: + this->handleChannelOpenRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_SETUP: + this->handleAVChannelSetupRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_MICROPHONE_REQUEST: + this->handleAVInputOpenRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_ACK: + this->handleAVMediaAckIndication(payload, std::move(eventHandler)); + break; + default: + AASDK_LOG(error) << "[MediaSourceService] Message Id not Handled: " << messageId.getId(); + this->receive(std::move(eventHandler)); + break; + } + } + + void MediaSourceService::sendMicrophoneOpenResponse( + const aap_protobuf::service::media::source::message::MicrophoneResponse &response, SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[MediaSourceService] sendMicrophoneOpenResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + + message->insertPayload(messenger::MessageId( + aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_MICROPHONE_REQUEST).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void MediaSourceService::sendMediaSourceWithTimestampIndication(messenger::Timestamp::ValueType timestamp, + const common::Data &data, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[MediaSourceService] sendMediaSourceWithTimestampIndication()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload(messenger::MessageId( + aap_protobuf::service::media::sink::MediaMessageId::MEDIA_MESSAGE_CODEC_CONFIG).getData()); + + auto timestampData = messenger::Timestamp(timestamp).getData(); + message->insertPayload(std::move(timestampData)); + message->insertPayload(data); + + this->send(std::move(message), std::move(promise)); + } + + void MediaSourceService::handleAVChannelSetupRequest(const common::DataConstBuffer &payload, + IMediaSourceServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[MediaSourceService] handleAVChannelSetupRequest()"; + aap_protobuf::service::media::shared::message::Setup request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onMediaChannelSetupRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void MediaSourceService::handleAVInputOpenRequest(const common::DataConstBuffer &payload, + IMediaSourceServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[MediaSourceService] handleAVInputOpenRequest()"; + aap_protobuf::service::media::source::message::MicrophoneRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onMediaSourceOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void MediaSourceService::handleAVMediaAckIndication(const common::DataConstBuffer &payload, + IMediaSourceServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[MediaSourceService] handleAVMediaAckIndication()"; + aap_protobuf::service::media::source::message::Ack indication; + if (indication.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onMediaChannelAckIndication(indication); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void MediaSourceService::handleChannelOpenRequest(const common::DataConstBuffer &payload, + IMediaSourceServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[MediaSourceService] handleChannelOpenRequest()"; + aap_protobuf::service::control::message::ChannelOpenRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onChannelOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + +} + + diff --git a/src/Channel/Navigation/NavigationStatusServiceChannel.cpp b/src/Channel/Navigation/NavigationStatusServiceChannel.cpp deleted file mode 100644 index 726837a8..00000000 --- a/src/Channel/Navigation/NavigationStatusServiceChannel.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace navigation -{ - -NavigationStatusServiceChannel::NavigationStatusServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger) - : ServiceChannel(strand, std::move(messenger), messenger::ChannelId::NAVIGATION) -{ - -} - -void NavigationStatusServiceChannel::receive(INavigationStatusServiceChannelEventHandler::Pointer eventHandler) -{ - AASDK_LOG(info) << "[NavigationStatusServiceChannel] receive "; - - auto receivePromise = messenger::ReceivePromise::defer(strand_); - receivePromise->then(std::bind(&NavigationStatusServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler), - std::bind(&INavigationStatusServiceChannelEventHandler::onChannelError, eventHandler,std::placeholders::_1)); - - messenger_->enqueueReceive(channelId_, std::move(receivePromise)); -} - -messenger::ChannelId NavigationStatusServiceChannel::getId() const -{ - return channelId_; -} - -void NavigationStatusServiceChannel::sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) -{ - AASDK_LOG(info) << "[NavigationStatusServiceChannel] channel open response "; - - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::CHANNEL_OPEN_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - - -void NavigationStatusServiceChannel::messageHandler(messenger::Message::Pointer message, INavigationStatusServiceChannelEventHandler::Pointer eventHandler) -{ - AASDK_LOG(info) << "[NavigationStatusServiceChannel] message handler "; - - messenger::MessageId messageId(message->getPayload()); - common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); - - switch(messageId.getId()) - { - case proto::ids::ControlMessage::CHANNEL_OPEN_REQUEST: - this->handleChannelOpenRequest(payload, std::move(eventHandler)); - break; - case proto::ids::NavigationChannelMessage::STATUS: - this->handleStatusUpdate(payload, std::move(eventHandler)); - break; - case proto::ids::NavigationChannelMessage::TURN_EVENT: - this->handleTurnEvent(payload, std::move(eventHandler)); - break; - case proto::ids::NavigationChannelMessage::DISTANCE_EVENT: - this->handleDistanceEvent(payload, std::move(eventHandler)); - break; - - - default: - AASDK_LOG(error) << "[NavigationStatusServiceChannel] message not handled: " << messageId.getId() << " : " << dump(payload); - this->receive(std::move(eventHandler)); - break; - } -} - -void NavigationStatusServiceChannel::handleChannelOpenRequest(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler) -{ - AASDK_LOG(info) << "[NavigationStatusServiceChannel] channel open request "; - - proto::messages::ChannelOpenRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onChannelOpenRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void NavigationStatusServiceChannel::handleStatusUpdate(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::NavigationStatus navStatus; - if(navStatus.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onStatusUpdate(navStatus); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - AASDK_LOG(error) << "[NavigationStatusServiceChannel] encountered error with message: " << dump(payload); - } - -} - -void NavigationStatusServiceChannel::handleTurnEvent(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::NavigationTurnEvent turnEvent; - if(turnEvent.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onTurnEvent(turnEvent); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - AASDK_LOG(error) << "[NavigationStatusServiceChannel] encountered error with message: " << dump(payload); - } - -} - -void NavigationStatusServiceChannel::handleDistanceEvent(const common::DataConstBuffer& payload, INavigationStatusServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::NavigationDistanceEvent distanceEvent; - if(distanceEvent.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onDistanceEvent(distanceEvent); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - AASDK_LOG(error) << "[NavigationStatusServiceChannel] encountered error with message: " << dump(payload); - } - -} - -} -} -} diff --git a/src/Channel/NavigationStatus/NavigationStatusService.cpp b/src/Channel/NavigationStatus/NavigationStatusService.cpp new file mode 100644 index 00000000..d55e84ae --- /dev/null +++ b/src/Channel/NavigationStatus/NavigationStatusService.cpp @@ -0,0 +1,143 @@ +// 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) +// +// 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 . + +#include +#include "aasdk/Channel/NavigationStatus/INavigationStatusServiceEventHandler.hpp" +#include "aasdk/Channel/NavigationStatus/NavigationStatusService.hpp" +#include "aasdk/Common/Log.hpp" + +/* + * This is a Navigation Status channel that could be used for integration onto another Raspberry Pi/Other Device to add an additional screen for notification and control purposes - such as updating the LCD screen on older Vauxhall/Opel/GM Cars + */ + +namespace aasdk::channel::navigationstatus { + + NavigationStatusService::NavigationStatusService(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : Channel(strand, std::move(messenger), messenger::ChannelId::NAVIGATION_STATUS) { + + } + + void NavigationStatusService::receive(INavigationStatusServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[NavigationStatusService] receive()"; + + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&NavigationStatusService::messageHandler, this->shared_from_this(), std::placeholders::_1, + eventHandler), + std::bind(&INavigationStatusServiceEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void NavigationStatusService::sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[NavigationStatusService] sendChannelOpenResponse()"; + + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::CONTROL)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + + void NavigationStatusService::messageHandler(messenger::Message::Pointer message, + INavigationStatusServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[NavigationStatusService] messageHandler()"; + + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + switch (messageId.getId()) { + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_REQUEST: + this->handleChannelOpenRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::navigationstatus::NavigationStatusMessageId::INSTRUMENT_CLUSTER_NAVIGATION_STATUS: + this->handleStatusUpdate(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::navigationstatus::NavigationStatusMessageId::INSTRUMENT_CLUSTER_NAVIGATION_TURN_EVENT: + this->handleTurnEvent(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::navigationstatus::NavigationStatusMessageId::INSTRUMENT_CLUSTER_NAVIGATION_DISTANCE_EVENT: + this->handleDistanceEvent(payload, std::move(eventHandler)); + break; + default: + AASDK_LOG(error) << "[NavigationStatusService] Message Id not Handled: " << messageId.getId() << " : " + << dump(payload); + this->receive(std::move(eventHandler)); + break; + } + } + + void NavigationStatusService::handleChannelOpenRequest(const common::DataConstBuffer &payload, + INavigationStatusServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[NavigationStatusService] handleChannelOpenRequest()"; + + aap_protobuf::service::control::message::ChannelOpenRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onChannelOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void NavigationStatusService::handleStatusUpdate(const common::DataConstBuffer &payload, + INavigationStatusServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[NavigationStatusService] handleStatusUpdate()"; + aap_protobuf::service::navigationstatus::message::NavigationStatus navStatus; + if (navStatus.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onStatusUpdate(navStatus); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + AASDK_LOG(error) << "[NavigationStatusService] encountered error with message: " << dump(payload); + } + + } + + void NavigationStatusService::handleTurnEvent(const common::DataConstBuffer &payload, + INavigationStatusServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[NavigationStatusService] handleTurnEvent()"; + aap_protobuf::service::navigationstatus::message::NavigationNextTurnEvent turnEvent; + if (turnEvent.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onTurnEvent(turnEvent); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + AASDK_LOG(error) << "[NavigationStatusService] encountered error with message: " << dump(payload); + } + + } + + void NavigationStatusService::handleDistanceEvent(const common::DataConstBuffer &payload, + INavigationStatusServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[NavigationStatusService] handleDistanceEvent()"; + aap_protobuf::service::navigationstatus::message::NavigationNextTurnDistanceEvent distanceEvent; + if (distanceEvent.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onDistanceEvent(distanceEvent); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + AASDK_LOG(error) << "[NavigationStatusService] encountered error with message: " << dump(payload); + } + + } + +} + + diff --git a/src/Channel/PhoneStatus/PhoneStatusService.cpp b/src/Channel/PhoneStatus/PhoneStatusService.cpp new file mode 100644 index 00000000..943de295 --- /dev/null +++ b/src/Channel/PhoneStatus/PhoneStatusService.cpp @@ -0,0 +1,93 @@ + +// 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) +// +// 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 . + +#include +#include +#include +#include "aasdk/Common/Log.hpp" + +/* + * This is a Phone Status channel that could be used for integration onto another Raspberry Pi/Other Device to add an additional screen for notification and control purposes. + */ + +namespace aasdk::channel::phonestatus { + + PhoneStatusService::PhoneStatusService(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : Channel(strand, std::move(messenger), messenger::ChannelId::PHONE_STATUS) { + + } + + void PhoneStatusService::receive(IPhoneStatusServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[PhoneStatusService] receive()"; + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&PhoneStatusService::messageHandler, this->shared_from_this(), std::placeholders::_1, + eventHandler), + std::bind(&IPhoneStatusServiceEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void PhoneStatusService::sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[PhoneStatusService] sendChannelOpenResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::CONTROL)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void PhoneStatusService::messageHandler(messenger::Message::Pointer message, + IPhoneStatusServiceEventHandler::Pointer eventHandler) { + + AASDK_LOG(debug) << "[PhoneStatusService] messageHandler()"; + + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + switch (messageId.getId()) { + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_REQUEST: + this->handleChannelOpenRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::phonestatus::PhoneStatusMessageId::PHONE_STATUS: + case aap_protobuf::service::phonestatus::PhoneStatusMessageId::PHONE_STATUS_INPUT: + default: + AASDK_LOG(error) << "[PhoneStatusService] Message Id not Handled: " << messageId.getId(); + this->receive(std::move(eventHandler)); + break; + } + } + + void PhoneStatusService::handleChannelOpenRequest(const common::DataConstBuffer &payload, + IPhoneStatusServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[PhoneStatusService] handleChannelOpenRequest()"; + aap_protobuf::service::control::message::ChannelOpenRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onChannelOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } +} + + diff --git a/src/Channel/Radio/RadioService.cpp b/src/Channel/Radio/RadioService.cpp new file mode 100644 index 00000000..fe11f01d --- /dev/null +++ b/src/Channel/Radio/RadioService.cpp @@ -0,0 +1,116 @@ +// 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) +// +// 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 . + +#include +#include +#include +#include "aasdk/Common/Log.hpp" + +/* + * This is a Radio channel that could be used for integration onto another Raspberry Pi/Other Device to integrate with third party systems or head units to help control the radio if necessary. + */ + +namespace aasdk::channel::radio { + + RadioService::RadioService(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : Channel(strand, std::move(messenger), messenger::ChannelId::RADIO) { + + } + + void RadioService::receive(IRadioServiceEventHandler::Pointer eventHandler) { + + AASDK_LOG(debug) << "[RadioService] receive()"; + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&RadioService::messageHandler, this->shared_from_this(), std::placeholders::_1, + eventHandler), + std::bind(&IRadioServiceEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void RadioService::sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[RadioService] sendChannelOpenResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::CONTROL)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void RadioService::messageHandler(messenger::Message::Pointer message, + IRadioServiceEventHandler::Pointer eventHandler) { + + AASDK_LOG(debug) << "[RadioService] messageHandler()"; + + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + switch (messageId.getId()) { + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_REQUEST: + this->handleChannelOpenRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_ACTIVE_RADIO_NOTIFICATION: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_SELECT_ACTIVE_RADIO_REQUEST: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_STEP_CHANNEL_REQUEST: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_STEP_CHANNEL_RESPONSE: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_SEEK_STATION_REQUEST: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_SEEK_STATION_RESPONSE: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_SCAN_STATIONS_REQUEST: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_SCAN_STATIONS_RESPONSE: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_TUNE_TO_STATION_REQUEST: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_TUNE_TO_STATION_RESPONSE: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_GET_PROGRAM_LIST_REQUEST: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_GET_PROGRAM_LIST_RESPONSE: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_STATION_PRESETS_NOTIFICATION: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_CANCEL_OPERATIONS_REQUEST: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_CANCEL_OPERATIONS_RESPONSE: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_CONFIGURE_CHANNEL_SPACING_REQUEST: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_CONFIGURE_CHANNEL_SPACING_RESPONSE: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_RADIO_STATION_INFO_NOTIFICATION: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_MUTE_RADIO_REQUEST: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_MUTE_RADIO_RESPONSE: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_GET_TRAFFIC_UPDATE_REQUEST: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_GET_TRAFFIC_UPDATE_RESPONSE: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_RADIO_SOURCE_REQUEST: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_RADIO_SOURCE_RESPONSE: + case aap_protobuf::service::radio::RadioMessageId::RADIO_MESSAGE_STATE_NOTIFICATION: + default: + AASDK_LOG(error) << "[RadioService] Message Id not Handled: " << messageId.getId(); + this->receive(std::move(eventHandler)); + break; + } + } + + void RadioService::handleChannelOpenRequest(const common::DataConstBuffer &payload, + IRadioServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[RadioService] handleChannelOpenRequest()"; + aap_protobuf::service::control::message::ChannelOpenRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onChannelOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } +} + + diff --git a/src/Channel/Sensor/SensorServiceChannel.cpp b/src/Channel/Sensor/SensorServiceChannel.cpp deleted file mode 100644 index 6fe896c9..00000000 --- a/src/Channel/Sensor/SensorServiceChannel.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#include -#include -#include -#include -#include -#include - - -namespace aasdk -{ -namespace channel -{ -namespace sensor -{ - -SensorServiceChannel::SensorServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger) - : ServiceChannel(strand, std::move(messenger), messenger::ChannelId::SENSOR) -{ - -} - -void SensorServiceChannel::receive(ISensorServiceChannelEventHandler::Pointer eventHandler) -{ - auto receivePromise = messenger::ReceivePromise::defer(strand_); - receivePromise->then(std::bind(&SensorServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler), - std::bind(&ISensorServiceChannelEventHandler::onChannelError, eventHandler, std::placeholders::_1)); - - messenger_->enqueueReceive(channelId_, std::move(receivePromise)); -} - -messenger::ChannelId SensorServiceChannel::getId() const -{ - return channelId_; -} - -void SensorServiceChannel::sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL)); - message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::CHANNEL_OPEN_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void SensorServiceChannel::messageHandler(messenger::Message::Pointer message, ISensorServiceChannelEventHandler::Pointer eventHandler) -{ - messenger::MessageId messageId(message->getPayload()); - common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); - - switch(messageId.getId()) - { - case proto::ids::SensorChannelMessage::SENSOR_START_REQUEST: - this->handleSensorStartRequest(payload, std::move(eventHandler)); - break; - case proto::ids::ControlMessage::CHANNEL_OPEN_REQUEST: - this->handleChannelOpenRequest(payload, std::move(eventHandler)); - break; - default: - AASDK_LOG(error) << "[SensorServiceChannel] message not handled: " << messageId.getId(); - this->receive(std::move(eventHandler)); - break; - } -} - -void SensorServiceChannel::sendSensorEventIndication(const proto::messages::SensorEventIndication& indication, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::SensorChannelMessage::SENSOR_EVENT_INDICATION).getData()); - message->insertPayload(indication); - - this->send(std::move(message), std::move(promise)); -} - -void SensorServiceChannel::sendSensorStartResponse(const proto::messages::SensorStartResponseMessage& response, SendPromise::Pointer promise) -{ - auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC)); - message->insertPayload(messenger::MessageId(proto::ids::SensorChannelMessage::SENSOR_START_RESPONSE).getData()); - message->insertPayload(response); - - this->send(std::move(message), std::move(promise)); -} - -void SensorServiceChannel::handleSensorStartRequest(const common::DataConstBuffer& payload, ISensorServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::SensorStartRequestMessage request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onSensorStartRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -void SensorServiceChannel::handleChannelOpenRequest(const common::DataConstBuffer& payload, ISensorServiceChannelEventHandler::Pointer eventHandler) -{ - proto::messages::ChannelOpenRequest request; - if(request.ParseFromArray(payload.cdata, payload.size)) - { - eventHandler->onChannelOpenRequest(request); - } - else - { - eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); - } -} - -} -} -} diff --git a/src/Channel/SensorSource/SensorSourceService.cpp b/src/Channel/SensorSource/SensorSourceService.cpp new file mode 100644 index 00000000..7b3a79c2 --- /dev/null +++ b/src/Channel/SensorSource/SensorSourceService.cpp @@ -0,0 +1,127 @@ +// 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) +// +// 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 . + +#include +#include +#include +#include "aasdk/Common/Log.hpp" + + +namespace aasdk::channel::sensorsource { + + SensorSourceService::SensorSourceService(boost::asio::io_service::strand &strand, messenger::IMessenger::Pointer messenger) + : Channel(strand, std::move(messenger), messenger::ChannelId::SENSOR) { + + } + + void SensorSourceService::receive(ISensorSourceServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[SensorSourceService] receive()"; + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&SensorSourceService::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler), + std::bind(&ISensorSourceServiceEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void SensorSourceService::sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[SensorSourceService] sendChannelOpenResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::CONTROL)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void + SensorSourceService::messageHandler(messenger::Message::Pointer message, ISensorSourceServiceEventHandler::Pointer eventHandler) { + + AASDK_LOG(debug) << "[SensorSourceService] messageHandler()"; + + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + switch (messageId.getId()) { + case aap_protobuf::service::sensorsource::SensorMessageId::SENSOR_MESSAGE_REQUEST: + this->handleSensorStartRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_REQUEST: + this->handleChannelOpenRequest(payload, std::move(eventHandler)); + break; + default: + AASDK_LOG(error) << "[SensorSourceService] Message Id not Handled: " << messageId.getId(); + this->receive(std::move(eventHandler)); + break; + } + } + + void + SensorSourceService::sendSensorEventIndication(const aap_protobuf::service::sensorsource::message::SensorBatch &indication, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[SensorSourceService] sendSensorEventIndication()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId(aap_protobuf::service::sensorsource::SensorMessageId::SENSOR_MESSAGE_BATCH).getData()); + message->insertPayload(indication); + + this->send(std::move(message), std::move(promise)); + } + + void + SensorSourceService::sendSensorStartResponse( + const aap_protobuf::service::sensorsource::message::SensorStartResponseMessage &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[SensorSourceService] sendSensorStartResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload( + messenger::MessageId(aap_protobuf::service::sensorsource::SensorMessageId::SENSOR_MESSAGE_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void SensorSourceService::handleSensorStartRequest(const common::DataConstBuffer &payload, + ISensorSourceServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[SensorSourceService] handleSensorStartRequest()"; + aap_protobuf::service::sensorsource::message::SensorRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onSensorStartRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void SensorSourceService::handleChannelOpenRequest(const common::DataConstBuffer &payload, + ISensorSourceServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[SensorSourceService] handleChannelOpenRequest()"; + aap_protobuf::service::control::message::ChannelOpenRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onChannelOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + +} + + diff --git a/src/Channel/ServiceChannel.cpp b/src/Channel/ServiceChannel.cpp deleted file mode 100644 index 950811b8..00000000 --- a/src/Channel/ServiceChannel.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#include -#include - - -namespace aasdk -{ -namespace channel -{ - -ServiceChannel::ServiceChannel(boost::asio::io_service::strand& strand, - messenger::IMessenger::Pointer messenger, - messenger::ChannelId channelId) - : strand_(strand) - , messenger_(std::move(messenger)) - , channelId_(channelId) -{ - -} - -void ServiceChannel::send(messenger::Message::Pointer message, SendPromise::Pointer promise) -{ -#if BOOST_VERSION < 106600 - auto sendPromise = messenger::SendPromise::defer(strand_.get_io_service()); -#else - auto sendPromise = messenger::SendPromise::defer(strand_.context()); -#endif - - io::PromiseLink<>::forward(*sendPromise, std::move(promise)); - messenger_->enqueueSend(std::move(message), std::move(sendPromise)); -} - -} -} diff --git a/src/Channel/VendorExtension/VendorExtensionService.cpp b/src/Channel/VendorExtension/VendorExtensionService.cpp new file mode 100644 index 00000000..371b6e23 --- /dev/null +++ b/src/Channel/VendorExtension/VendorExtensionService.cpp @@ -0,0 +1,90 @@ +// 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) +// +// 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 . + +#include +#include +#include "aasdk/Common/Log.hpp" + +/* + * This is a Vendor Extension channel to link to a known Vendor App on the Mobile Phone. + */ + +namespace aasdk::channel::vendorextension { + + VendorExtensionService::VendorExtensionService(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : Channel(strand, std::move(messenger), messenger::ChannelId::VENDOR_EXTENSION) { + + } + + void VendorExtensionService::receive(IVendorExtensionServiceEventHandler::Pointer eventHandler) { + + AASDK_LOG(debug) << "[VendorExtensionService] receive()"; + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&VendorExtensionService::messageHandler, this->shared_from_this(), std::placeholders::_1, + eventHandler), + std::bind(&IVendorExtensionServiceEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void VendorExtensionService::sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[VendorExtensionService] sendChannelOpenResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::CONTROL)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void VendorExtensionService::messageHandler(messenger::Message::Pointer message, + IVendorExtensionServiceEventHandler::Pointer eventHandler) { + + AASDK_LOG(debug) << "[VendorExtensionService] remessageHandlerceive()"; + + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + switch (messageId.getId()) { + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_REQUEST: + this->handleChannelOpenRequest(payload, std::move(eventHandler)); + break; + default: + AASDK_LOG(error) << "[VendorExtensionService] Message Id not Handled: " << messageId.getId(); + this->receive(std::move(eventHandler)); + break; + } + } + + void VendorExtensionService::handleChannelOpenRequest(const common::DataConstBuffer &payload, + IVendorExtensionServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[VendorExtensionService] handleChannelOpenRequest()"; + aap_protobuf::service::control::message::ChannelOpenRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onChannelOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } +} + + diff --git a/src/Channel/WifiProjection/WifiProjectionService.cpp b/src/Channel/WifiProjection/WifiProjectionService.cpp new file mode 100644 index 00000000..25e70945 --- /dev/null +++ b/src/Channel/WifiProjection/WifiProjectionService.cpp @@ -0,0 +1,116 @@ +// 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) +// +// 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 . + +#include +#include +#include +#include "aasdk/Common/Log.hpp" + + +namespace aasdk::channel::wifiprojection { + + WifiProjectionService::WifiProjectionService(boost::asio::io_service::strand &strand, + messenger::IMessenger::Pointer messenger) + : Channel(strand, std::move(messenger), messenger::ChannelId::WIFI_PROJECTION) { + + } + + void WifiProjectionService::receive(IWifiProjectionServiceEventHandler::Pointer eventHandler) { + + AASDK_LOG(debug) << "[WifiProjectionService] receive()"; + auto receivePromise = messenger::ReceivePromise::defer(strand_); + receivePromise->then( + std::bind(&WifiProjectionService::messageHandler, this->shared_from_this(), std::placeholders::_1, + eventHandler), + std::bind(&IWifiProjectionServiceEventHandler::onChannelError, eventHandler, std::placeholders::_1)); + + messenger_->enqueueReceive(channelId_, std::move(receivePromise)); + } + + void WifiProjectionService::sendChannelOpenResponse(const aap_protobuf::service::control::message::ChannelOpenResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[WifiProjectionService] sendChannelOpenResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::CONTROL)); + message->insertPayload( + messenger::MessageId( + aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void WifiProjectionService::sendWifiCredentialsResponse( + const aap_protobuf::service::wifiprojection::message::WifiCredentialsResponse &response, + SendPromise::Pointer promise) { + AASDK_LOG(debug) << "[WifiProjectionService] sendWifiCredentialsResponse()"; + auto message(std::make_shared(channelId_, messenger::EncryptionType::ENCRYPTED, + messenger::MessageType::SPECIFIC)); + message->insertPayload(messenger::MessageId( + aap_protobuf::service::wifiprojection::WifiProjectionMessageId::WIFI_MESSAGE_CREDENTIALS_RESPONSE).getData()); + message->insertPayload(response); + + this->send(std::move(message), std::move(promise)); + } + + void WifiProjectionService::messageHandler(messenger::Message::Pointer message, + IWifiProjectionServiceEventHandler::Pointer eventHandler) { + + AASDK_LOG(debug) << "[WifiProjectionService] messageHandler()"; + + messenger::MessageId messageId(message->getPayload()); + common::DataConstBuffer payload(message->getPayload(), messageId.getSizeOf()); + + switch (messageId.getId()) { + case aap_protobuf::service::control::message::ControlMessageType::MESSAGE_CHANNEL_OPEN_REQUEST: + this->handleChannelOpenRequest(payload, std::move(eventHandler)); + break; + case aap_protobuf::service::wifiprojection::WifiProjectionMessageId::WIFI_MESSAGE_CREDENTIALS_REQUEST: + this->handleWifiCredentialsRequest(payload, std::move(eventHandler)); + break; + default: + AASDK_LOG(error) << "[WifiProjectionService] Message Id not Handled: " << messageId.getId(); + this->receive(std::move(eventHandler)); + break; + } + } + + void WifiProjectionService::handleChannelOpenRequest(const common::DataConstBuffer &payload, + IWifiProjectionServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[WifiProjectionService] handleChannelOpenRequest()"; + aap_protobuf::service::control::message::ChannelOpenRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onChannelOpenRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } + + void WifiProjectionService::handleWifiCredentialsRequest(const common::DataConstBuffer &payload, + IWifiProjectionServiceEventHandler::Pointer eventHandler) { + AASDK_LOG(debug) << "[WifiProjectionService] handleWifiCredentialsRequest()"; + + aap_protobuf::service::wifiprojection::message::WifiCredentialsRequest request; + if (request.ParseFromArray(payload.cdata, payload.size)) { + eventHandler->onWifiCredentialsRequest(request); + } else { + eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD)); + } + } +} + + diff --git a/src/Common/Data.cpp b/src/Common/Data.cpp index ec689f10..80f378d3 100644 --- a/src/Common/Data.cpp +++ b/src/Common/Data.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -24,142 +23,112 @@ #include -namespace aasdk -{ -namespace common -{ +namespace aasdk { + namespace common { -DataBuffer::DataBuffer() - : data(nullptr) - , size(0) -{ + DataBuffer::DataBuffer() + : data(nullptr), size(0) { -} + } -DataBuffer::DataBuffer(Data::value_type* _data, Data::size_type _size, Data::size_type offset) -{ - if(offset > _size || _data == nullptr || _size == 0) - { + DataBuffer::DataBuffer(Data::value_type *_data, Data::size_type _size, Data::size_type offset) { + if (offset > _size || _data == nullptr || _size == 0) { data = nullptr; size = 0; - } - else if(offset <= _size) - { + } else if (offset <= _size) { data = _data + offset; size = _size - offset; + } } -} -DataBuffer::DataBuffer(void* _data, Data::size_type _size, Data::size_type offset) - : DataBuffer(reinterpret_cast(_data), _size, offset) -{ + DataBuffer::DataBuffer(void *_data, Data::size_type _size, Data::size_type offset) + : DataBuffer(reinterpret_cast(_data), _size, offset) { -} + } -DataBuffer::DataBuffer(Data& _data, Data::size_type offset) - : DataBuffer(_data.empty() ? nullptr : &_data[0], _data.size(), offset > _data.size() ? 0 : offset) -{ + DataBuffer::DataBuffer(Data &_data, Data::size_type offset) + : DataBuffer(_data.empty() ? nullptr : &_data[0], _data.size(), offset > _data.size() ? 0 : offset) { -} + } -bool DataBuffer::operator==(const std::nullptr_t&) const -{ - return data == nullptr || size == 0; -} + bool DataBuffer::operator==(const std::nullptr_t &) const { + return data == nullptr || size == 0; + } -bool DataBuffer::operator==(const DataBuffer& buffer) const -{ - return data == buffer.data && size == buffer.size; -} + bool DataBuffer::operator==(const DataBuffer &buffer) const { + return data == buffer.data && size == buffer.size; + } -DataConstBuffer::DataConstBuffer() - : cdata(nullptr) - , size(0) -{ + DataConstBuffer::DataConstBuffer() + : cdata(nullptr), size(0) { -} + } -DataConstBuffer::DataConstBuffer(const DataBuffer& other) - : cdata(other.data) - , size(other.size) -{ -} + DataConstBuffer::DataConstBuffer(const DataBuffer &other) + : cdata(other.data), size(other.size) { + } -DataConstBuffer::DataConstBuffer(const Data::value_type* _data, Data::size_type _size, Data::size_type offset) -{ - if(offset > _size || _data == nullptr || _size == 0) - { + DataConstBuffer::DataConstBuffer(const Data::value_type *_data, Data::size_type _size, Data::size_type offset) { + if (offset > _size || _data == nullptr || _size == 0) { cdata = nullptr; size = 0; - } - else if(offset <= _size) - { + } else if (offset <= _size) { cdata = _data + offset; size = _size - offset; + } } -} -DataConstBuffer::DataConstBuffer(const void* _data, Data::size_type _size, Data::size_type offset) - : DataConstBuffer(reinterpret_cast(_data), _size, offset) -{ + DataConstBuffer::DataConstBuffer(const void *_data, Data::size_type _size, Data::size_type offset) + : DataConstBuffer(reinterpret_cast(_data), _size, offset) { -} + } -DataConstBuffer::DataConstBuffer(const Data& _data, Data::size_type offset) - : DataConstBuffer(_data.empty() ? nullptr : &_data[0], _data.size(), offset > _data.size() ? 0 : offset) -{ + DataConstBuffer::DataConstBuffer(const Data &_data, Data::size_type offset) + : DataConstBuffer(_data.empty() ? nullptr : &_data[0], _data.size(), offset > _data.size() ? 0 : offset) { -} + } -bool DataConstBuffer::operator==(const std::nullptr_t&) const -{ - return cdata == nullptr || size == 0; -} + bool DataConstBuffer::operator==(const std::nullptr_t &) const { + return cdata == nullptr || size == 0; + } -bool DataConstBuffer::operator==(const DataConstBuffer& buffer) const -{ - return cdata == buffer.cdata && size == buffer.size; -} + bool DataConstBuffer::operator==(const DataConstBuffer &buffer) const { + return cdata == buffer.cdata && size == buffer.size; + } -common::Data createData(const DataConstBuffer& buffer) -{ - common::Data data; - copy(data, buffer); - return data; -} + common::Data createData(const DataConstBuffer &buffer) { + common::Data data; + copy(data, buffer); + return data; + } -std::string dump(const Data& data) -{ - return dump(DataConstBuffer(data)); -} + std::string dump(const Data &data) { + return dump(DataConstBuffer(data)); + } -std::string uint8_to_hex_string(const uint8_t *v, const size_t s) { - std::stringstream ss; + std::string uint8_to_hex_string(const uint8_t *v, const size_t s) { + std::stringstream ss; - ss << std::hex << std::setfill('0'); + ss << std::hex << std::setfill('0'); - for (int i = 0; i < s; i++) { - ss << " "; - ss << std::hex << std::setw(2) << static_cast(v[i]); - } + for (int i = 0; i < s; i++) { + ss << " "; + ss << std::hex << std::setw(2) << static_cast(v[i]); + } - return ss.str(); -} + return ss.str(); + } -std::string dump(const DataConstBuffer& buffer) -{ - if(buffer.size == 0) - { + std::string dump(const DataConstBuffer &buffer) { + if (buffer.size == 0) { return "[0] null"; - } - else - { + } else { std::string hexDump = "[" + uint8_to_hex_string(buffer.cdata, buffer.size) + " ] "; //boost::algorithm::hex(bufferBegin(buffer), bufferEnd(buffer), back_inserter(hexDump)); return hexDump; + } } -} -} + } } diff --git a/src/Error/Error.cpp b/src/Error/Error.cpp index 22f451a8..afe4aafb 100644 --- a/src/Error/Error.cpp +++ b/src/Error/Error.cpp @@ -1,78 +1,66 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include +#include -namespace aasdk -{ -namespace error -{ +namespace aasdk { + namespace error { -Error::Error() - : code_(ErrorCode::NONE) - , nativeCode_(0) -{ + Error::Error() + : code_(ErrorCode::NONE), nativeCode_(0) { -} + } -Error::Error(ErrorCode code, uint32_t nativeCode) - : code_(code) - , nativeCode_(nativeCode) -{ - message_ = "AaSdk error code: " + std::to_string(static_cast(code_)) - + ", native code: " + std::to_string(nativeCode_); -} + Error::Error(ErrorCode code, uint32_t nativeCode, std::string information) + : code_(code), nativeCode_(nativeCode), information_(std::move(information)) { + message_ = "AASDK Error: " + std::to_string(static_cast(code_)) + + ", Native Code: " + std::to_string(nativeCode_); + + ", Additional Information: " + information_; + } -ErrorCode Error::getCode() const -{ - return code_; -} + ErrorCode Error::getCode() const { + return code_; + } -uint32_t Error::getNativeCode() const -{ - return nativeCode_; -} + uint32_t Error::getNativeCode() const { + return nativeCode_; + } -const char* Error::what() const noexcept -{ - return message_.c_str(); -} + const char *Error::what() const noexcept { + return message_.c_str(); + } -bool Error::operator!() const -{ - return code_ == ErrorCode::NONE; -} + bool Error::operator!() const { + return code_ == ErrorCode::NONE; + } -bool Error::operator==(const Error& other) const -{ - return code_ == other.code_ && nativeCode_ == other.nativeCode_; -} + bool Error::operator==(const Error &other) const { + return code_ == other.code_ && nativeCode_ == other.nativeCode_; + } -bool Error::operator==(const ErrorCode& code) const -{ - return code_ == code; -} + bool Error::operator==(const ErrorCode &code) const { + return code_ == code; + } -bool Error::operator!=(const ErrorCode& code) const -{ - return !operator==(code); -} + bool Error::operator!=(const ErrorCode &code) const { + return !operator==(code); + } -} + } } diff --git a/src/IO/IOContextWrapper.cpp b/src/IO/IOContextWrapper.cpp index 0a07731c..318cbdc3 100644 --- a/src/IO/IOContextWrapper.cpp +++ b/src/IO/IOContextWrapper.cpp @@ -1,60 +1,49 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include -namespace aasdk -{ -namespace io -{ +namespace aasdk { + namespace io { -IOContextWrapper::IOContextWrapper() - : ioService_(nullptr) - , strand_(nullptr) -{ + IOContextWrapper::IOContextWrapper() + : ioService_(nullptr), strand_(nullptr) { -} + } -IOContextWrapper::IOContextWrapper(boost::asio::io_service& ioService) - : ioService_(&ioService) - , strand_(nullptr) -{ + IOContextWrapper::IOContextWrapper(boost::asio::io_service &ioService) + : ioService_(&ioService), strand_(nullptr) { -} + } -IOContextWrapper::IOContextWrapper(boost::asio::io_service::strand& strand) - : ioService_(nullptr) - , strand_(&strand) -{ + IOContextWrapper::IOContextWrapper(boost::asio::io_service::strand &strand) + : ioService_(nullptr), strand_(&strand) { -} + } -void IOContextWrapper::reset() -{ - ioService_ = nullptr; - strand_ = nullptr; -} + void IOContextWrapper::reset() { + ioService_ = nullptr; + strand_ = nullptr; + } -bool IOContextWrapper::isActive() const -{ - return ioService_ != nullptr || strand_ != nullptr; -} + bool IOContextWrapper::isActive() const { + return ioService_ != nullptr || strand_ != nullptr; + } -} + } } diff --git a/src/Main.ut.cpp b/src/Main.ut.cpp index 2b542059..f1f79276 100644 --- a/src/Main.ut.cpp +++ b/src/Main.ut.cpp @@ -1,21 +1,20 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ -#define BOOST_TEST_MODULE aasdk_ut +// 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) +// +// 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 . -#include +#define BOOST_TEST_MODULE aasdk_ut#include diff --git a/src/Messenger/ChannelId.cpp b/src/Messenger/ChannelId.cpp index 66ca3ca8..8df0a745 100644 --- a/src/Messenger/ChannelId.cpp +++ b/src/Messenger/ChannelId.cpp @@ -1,59 +1,71 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include +namespace aasdk::messenger { -namespace aasdk -{ -namespace messenger -{ - -std::string channelIdToString(ChannelId channelId) -{ - switch(channelId) - { - case ChannelId::CONTROL: + std::string channelIdToString(ChannelId channelId) { + switch (channelId) { + case ChannelId::CONTROL: return "CONTROL"; - case ChannelId::INPUT: - return "INPUT"; - case ChannelId::SENSOR: + case ChannelId::SENSOR: return "SENSOR"; - case ChannelId::VIDEO: - return "VIDEO"; - case ChannelId::MEDIA_AUDIO: - return "MEDIA_AUDIO"; - case ChannelId::SPEECH_AUDIO: - return "SPEECH_AUDIO"; - case ChannelId::SYSTEM_AUDIO: - return "SYSTEM_AUDIO"; - case ChannelId::AV_INPUT: - return "AV_INPUT"; - case ChannelId::BLUETOOTH: + case ChannelId::MEDIA_SINK: + return "MEDIA_SINK"; + case ChannelId::MEDIA_SINK_VIDEO: + return "MEDIA_SINK_VIDEO"; + case ChannelId::MEDIA_SINK_MEDIA_AUDIO: + return "MEDIA_SINK_MEDIA_AUDIO"; + case ChannelId::MEDIA_SINK_GUIDANCE_AUDIO: + return "MEDIA_SINK_GUIDANCE_AUDIO"; + case ChannelId::MEDIA_SINK_SYSTEM_AUDIO: + return "MEDIA_SINK_SYSTEM_AUDIO"; + case ChannelId::MEDIA_SINK_TELEPHONY_AUDIO: + return "MEDIA_SINK_TELEPHONY_AUDIO"; + case ChannelId::INPUT_SOURCE: + return "INPUT_SOURCE"; + case ChannelId::MEDIA_SOURCE_MICROPHONE: + return "MEDIA_SOURCE_MICROPHONE"; + case ChannelId::BLUETOOTH: return "BLUETOOTH"; - case ChannelId::NAVIGATION: - return "NAVIGATION"; - case ChannelId::NONE: + case ChannelId::RADIO: + return "RADIO"; + case ChannelId::NAVIGATION_STATUS: + return "NAVIGATION_STATUS"; + case ChannelId::MEDIA_PLAYBACK_STATUS: + return "MEDIA_PLAYBACK_STATUS"; + case ChannelId::PHONE_STATUS: + return "PHONE_STATUS"; + case ChannelId::MEDIA_BROWSER: + return "MEDIA_BROWSER"; + case ChannelId::VENDOR_EXTENSION: + return "VENDOR_EXTENSION"; + case ChannelId::GENERIC_NOTIFICATION: + return "GENERIC_NOTIFICATION"; + case ChannelId::WIFI_PROJECTION: + return "WIFI_PROJECTION"; + case ChannelId::NONE: return "NONE"; - default: + default: return "(null)"; } -} + } } -} + + diff --git a/src/Messenger/ChannelReceiveMessageQueue.cpp b/src/Messenger/ChannelReceiveMessageQueue.cpp index 4dc46f36..7f28a0ac 100644 --- a/src/Messenger/ChannelReceiveMessageQueue.cpp +++ b/src/Messenger/ChannelReceiveMessageQueue.cpp @@ -1,65 +1,55 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk::messenger { -void ChannelReceiveMessageQueue::push(Message::Pointer message) -{ + void ChannelReceiveMessageQueue::push(Message::Pointer message) { const auto channelId = message->getChannelId(); - if(queue_.count(channelId) == 0) - { - queue_.emplace(std::make_pair(channelId, MessageQueue())); + if (queue_.count(channelId) == 0) { + queue_.emplace(std::make_pair(channelId, MessageQueue())); } - auto& channelQueue = queue_.at(channelId); + auto &channelQueue = queue_.at(channelId); channelQueue.emplace(std::move(message)); -} + } -Message::Pointer ChannelReceiveMessageQueue::pop(ChannelId channelId) -{ - auto& channelQueue = queue_.at(channelId); + Message::Pointer ChannelReceiveMessageQueue::pop(ChannelId channelId) { + auto &channelQueue = queue_.at(channelId); auto message(std::move(channelQueue.front())); channelQueue.pop(); - if(channelQueue.empty()) - { - queue_.erase(channelId); + if (channelQueue.empty()) { + queue_.erase(channelId); } return message; -} + } -bool ChannelReceiveMessageQueue::empty(ChannelId channelId) const -{ + bool ChannelReceiveMessageQueue::empty(ChannelId channelId) const { return queue_.count(channelId) == 0; -} + } -void ChannelReceiveMessageQueue::clear() -{ + void ChannelReceiveMessageQueue::clear() { queue_.clear(); -} + } } -} + diff --git a/src/Messenger/ChannelReceivePromiseQueue.cpp b/src/Messenger/ChannelReceivePromiseQueue.cpp index dca99f3d..798caa09 100644 --- a/src/Messenger/ChannelReceivePromiseQueue.cpp +++ b/src/Messenger/ChannelReceivePromiseQueue.cpp @@ -1,72 +1,61 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -void ChannelReceivePromiseQueue::push(ChannelId channelId, ReceivePromise::Pointer promise) -{ - queue_[channelId].push(std::move(promise)); -} + void ChannelReceivePromiseQueue::push(ChannelId channelId, ReceivePromise::Pointer promise) { + queue_[channelId].push(std::move(promise)); + } -ReceivePromise::Pointer ChannelReceivePromiseQueue::pop(ChannelId channelId) -{ - auto& channelQueue = queue_.at(channelId); - auto promise = std::move(channelQueue.front()); - channelQueue.pop(); + ReceivePromise::Pointer ChannelReceivePromiseQueue::pop(ChannelId channelId) { + auto &channelQueue = queue_.at(channelId); + auto promise = std::move(channelQueue.front()); + channelQueue.pop(); - if(channelQueue.empty()) - { + if (channelQueue.empty()) { queue_.erase(channelId); - } + } - return promise; -} + return promise; + } -bool ChannelReceivePromiseQueue::isPending(ChannelId channelId) const -{ - return queue_.count(channelId) > 0 && !queue_.at(channelId).empty(); -} + bool ChannelReceivePromiseQueue::isPending(ChannelId channelId) const { + return queue_.count(channelId) > 0 && !queue_.at(channelId).empty(); + } -size_t ChannelReceivePromiseQueue::size() const -{ - return queue_.size(); -} + size_t ChannelReceivePromiseQueue::size() const { + return queue_.size(); + } -bool ChannelReceivePromiseQueue::empty() const -{ - return this->size() == 0; -} + bool ChannelReceivePromiseQueue::empty() const { + return this->size() == 0; + } -void ChannelReceivePromiseQueue::clear() -{ - queue_.clear(); -} + void ChannelReceivePromiseQueue::clear() { + queue_.clear(); + } -ReceivePromise::Pointer ChannelReceivePromiseQueue::pop() -{ - return this->pop(queue_.begin()->first); -} + ReceivePromise::Pointer ChannelReceivePromiseQueue::pop() { + return this->pop(queue_.begin()->first); + } -} + } } diff --git a/src/Messenger/Cryptor.cpp b/src/Messenger/Cryptor.cpp index fca0a25f..a278730d 100644 --- a/src/Messenger/Cryptor.cpp +++ b/src/Messenger/Cryptor.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -22,263 +21,221 @@ #include #include -namespace aasdk -{ -namespace messenger -{ - -Cryptor::Cryptor(transport::ISSLWrapper::Pointer sslWrapper) - : sslWrapper_(std::move(sslWrapper)) - , maxBufferSize_(1024 * 20) - , certificate_(nullptr) - , privateKey_(nullptr) - , context_(nullptr) - , ssl_(nullptr) - , isActive_(false) -{ +namespace aasdk { + namespace messenger { -} + Cryptor::Cryptor(transport::ISSLWrapper::Pointer sslWrapper) + : sslWrapper_(std::move(sslWrapper)), maxBufferSize_(1024 * 20), certificate_(nullptr), privateKey_(nullptr), + context_(nullptr), ssl_(nullptr), isActive_(false) { + + } -void Cryptor::init() -{ - std::lock_guard lock(mutex_); + void Cryptor::init() { + std::lock_guard lock(mutex_); - certificate_ = sslWrapper_->readCertificate(cCertificate); + certificate_ = sslWrapper_->readCertificate(cCertificate); - if(certificate_ == nullptr) - { + if (certificate_ == nullptr) { throw error::Error(error::ErrorCode::SSL_READ_CERTIFICATE); - } + } - privateKey_ = sslWrapper_->readPrivateKey(cPrivateKey); + privateKey_ = sslWrapper_->readPrivateKey(cPrivateKey); - if(privateKey_ == nullptr) - { + if (privateKey_ == nullptr) { throw error::Error(error::ErrorCode::SSL_READ_PRIVATE_KEY); - } + } - auto method = sslWrapper_->getMethod(); + auto method = sslWrapper_->getMethod(); - if(method == nullptr) - { + if (method == nullptr) { throw error::Error(error::ErrorCode::SSL_METHOD); - } + } - context_ = sslWrapper_->createContext(method); + context_ = sslWrapper_->createContext(method); - if(context_ == nullptr) - { + if (context_ == nullptr) { throw error::Error(error::ErrorCode::SSL_CONTEXT_CREATION); - } + } - if(!sslWrapper_->useCertificate(context_, certificate_)) - { + if (!sslWrapper_->useCertificate(context_, certificate_)) { throw error::Error(error::ErrorCode::SSL_USE_CERTIFICATE); - } + } - if(!sslWrapper_->usePrivateKey(context_, privateKey_)) - { + if (!sslWrapper_->usePrivateKey(context_, privateKey_)) { throw error::Error(error::ErrorCode::SSL_USE_PRIVATE_KEY); - } + } - ssl_ = sslWrapper_->createInstance(context_); + ssl_ = sslWrapper_->createInstance(context_); - if(ssl_ == nullptr) - { + if (ssl_ == nullptr) { throw error::Error(error::ErrorCode::SSL_HANDLER_CREATION); - } + } - bIOs_ = sslWrapper_->createBIOs(); + bIOs_ = sslWrapper_->createBIOs(); - if(bIOs_.first == nullptr) - { + if (bIOs_.first == nullptr) { throw error::Error(error::ErrorCode::SSL_READ_BIO_CREATION); - } + } - if(bIOs_.second == nullptr) - { + if (bIOs_.second == nullptr) { throw error::Error(error::ErrorCode::SSL_WRITE_BIO_CREATION); - } + } - sslWrapper_->setBIOs(ssl_, bIOs_, maxBufferSize_); + sslWrapper_->setBIOs(ssl_, bIOs_, maxBufferSize_); - sslWrapper_->setConnectState(ssl_); -} + sslWrapper_->setConnectState(ssl_); + } -void Cryptor::deinit() -{ - std::lock_guard lock(mutex_); + void Cryptor::deinit() { + std::lock_guard lock(mutex_); - if(ssl_ != nullptr) - { + if (ssl_ != nullptr) { sslWrapper_->free(ssl_); ssl_ = nullptr; - } + } - bIOs_ = std::make_pair(nullptr, nullptr); + bIOs_ = std::make_pair(nullptr, nullptr); - if(context_ != nullptr) - { + if (context_ != nullptr) { sslWrapper_->free(context_); context_ = nullptr; - } + } - if(certificate_ != nullptr) - { + if (certificate_ != nullptr) { sslWrapper_->free(certificate_); certificate_ = nullptr; - } + } - if(privateKey_ != nullptr) - { + if (privateKey_ != nullptr) { sslWrapper_->free(privateKey_); privateKey_ = nullptr; + } } -} -bool Cryptor::doHandshake() -{ - std::lock_guard lock(mutex_); + bool Cryptor::doHandshake() { + std::lock_guard lock(mutex_); - auto result = sslWrapper_->doHandshake(ssl_); - if(result == SSL_ERROR_WANT_READ) - { + auto result = sslWrapper_->doHandshake(ssl_); + if (result == SSL_ERROR_WANT_READ) { return false; - } - else if(result == SSL_ERROR_NONE) - { + } else if (result == SSL_ERROR_NONE) { isActive_ = true; return true; - } - else - { + } else { throw error::Error(error::ErrorCode::SSL_HANDSHAKE, result); + } } -} -size_t Cryptor::encrypt(common::Data& output, const common::DataConstBuffer& buffer) -{ - std::lock_guard lock(mutex_); + size_t Cryptor::encrypt(common::Data &output, const common::DataConstBuffer &buffer) { + std::lock_guard lock(mutex_); - size_t totalWrittenBytes = 0; + size_t totalWrittenBytes = 0; - while(totalWrittenBytes < buffer.size) - { + while (totalWrittenBytes < buffer.size) { const common::DataConstBuffer currentBuffer(buffer.cdata, buffer.size, totalWrittenBytes); const auto writeSize = sslWrapper_->sslWrite(ssl_, currentBuffer.cdata, currentBuffer.size); - if(writeSize <= 0) - { - throw error::Error(error::ErrorCode::SSL_WRITE, sslWrapper_->getError(ssl_, writeSize)); + if (writeSize <= 0) { + throw error::Error(error::ErrorCode::SSL_WRITE, sslWrapper_->getError(ssl_, writeSize)); } totalWrittenBytes += writeSize; - } + } - return this->read(output); -} + return this->read(output); + } -size_t Cryptor::decrypt(common::Data& output, const common::DataConstBuffer& buffer, int frameLength) -{ - int overhead = 29; - int length = frameLength - overhead; - std::lock_guard lock(mutex_); + size_t Cryptor::decrypt(common::Data &output, const common::DataConstBuffer &buffer, int frameLength) { + int overhead = 29; + int length = frameLength - overhead; + std::lock_guard lock(mutex_); - this->write(buffer); - const size_t beginOffset = output.size(); + this->write(buffer); + const size_t beginOffset = output.size(); - size_t totalReadSize = 0; // Initialise - size_t availableBytes = length; - size_t readBytes = (length - totalReadSize) > 2048 ? 2048 : length - totalReadSize; // Calculate How many Bytes to Read - output.resize(output.size() + readBytes); // Resize Output to match the bytes we want to read + size_t totalReadSize = 0; // Initialise + size_t availableBytes = length; + size_t readBytes = (length - totalReadSize) > 2048 ? 2048 : length - + totalReadSize; // Calculate How many Bytes to Read + output.resize(output.size() + + readBytes); // Resize Output to match the bytes we want to read - // We try to be a bit more explicit here, using the frame length from the frame itself rather than just blindly reading from the SSL buffer. + // We try to be a bit more explicit here, using the frame length from the frame itself rather than just blindly reading from the SSL buffer. - while(readBytes > 0) - { - const auto& currentBuffer = common::DataBuffer(output, totalReadSize + beginOffset); + while (readBytes > 0) { + const auto ¤tBuffer = common::DataBuffer(output, totalReadSize + beginOffset); auto readSize = sslWrapper_->sslRead(ssl_, currentBuffer.data, currentBuffer.size); - if(readSize <= 0) - { - throw error::Error(error::ErrorCode::SSL_READ, sslWrapper_->getError(ssl_, readSize)); + if (readSize <= 0) { + throw error::Error(error::ErrorCode::SSL_READ, sslWrapper_->getError(ssl_, readSize)); } totalReadSize += readSize; availableBytes = sslWrapper_->getAvailableBytes(ssl_); readBytes = (length - totalReadSize) > 2048 ? 2048 : length - totalReadSize; output.resize(output.size() + readBytes); - } + } - return totalReadSize; -} + return totalReadSize; + } -common::Data Cryptor::readHandshakeBuffer() -{ - std::lock_guard lock(mutex_); + common::Data Cryptor::readHandshakeBuffer() { + std::lock_guard lock(mutex_); - common::Data output; - this->read(output); - return output; -} + common::Data output; + this->read(output); + return output; + } -void Cryptor::writeHandshakeBuffer(const common::DataConstBuffer& buffer) -{ - std::lock_guard lock(mutex_); + void Cryptor::writeHandshakeBuffer(const common::DataConstBuffer &buffer) { + std::lock_guard lock(mutex_); - this->write(buffer); -} + this->write(buffer); + } -size_t Cryptor::read(common::Data& output) -{ - const auto pendingSize = sslWrapper_->bioCtrlPending(bIOs_.second); + size_t Cryptor::read(common::Data &output) { + const auto pendingSize = sslWrapper_->bioCtrlPending(bIOs_.second); - size_t beginOffset = output.size(); - output.resize(beginOffset + pendingSize); - size_t totalReadSize = 0; + size_t beginOffset = output.size(); + output.resize(beginOffset + pendingSize); + size_t totalReadSize = 0; - while(totalReadSize < pendingSize) - { - const auto& currentBuffer = common::DataBuffer(output, totalReadSize + beginOffset); + while (totalReadSize < pendingSize) { + const auto ¤tBuffer = common::DataBuffer(output, totalReadSize + beginOffset); const auto readSize = sslWrapper_->bioRead(bIOs_.second, currentBuffer.data, currentBuffer.size); - if(readSize <= 0) - { - throw error::Error(error::ErrorCode::SSL_BIO_READ, sslWrapper_->getError(ssl_, readSize)); + if (readSize <= 0) { + throw error::Error(error::ErrorCode::SSL_BIO_READ, sslWrapper_->getError(ssl_, readSize)); } totalReadSize += readSize; - } + } - return totalReadSize; -} + return totalReadSize; + } -void Cryptor::write(const common::DataConstBuffer& buffer) -{ - size_t totalWrittenBytes = 0; + void Cryptor::write(const common::DataConstBuffer &buffer) { + size_t totalWrittenBytes = 0; - while(totalWrittenBytes < buffer.size) - { + while (totalWrittenBytes < buffer.size) { const common::DataConstBuffer currentBuffer(buffer.cdata, buffer.size, totalWrittenBytes); const auto writeSize = sslWrapper_->bioWrite(bIOs_.first, currentBuffer.cdata, currentBuffer.size); - if(writeSize <= 0) - { - throw error::Error(error::ErrorCode::SSL_BIO_WRITE, sslWrapper_->getError(ssl_, writeSize)); + if (writeSize <= 0) { + throw error::Error(error::ErrorCode::SSL_BIO_WRITE, sslWrapper_->getError(ssl_, writeSize)); } totalWrittenBytes += writeSize; + } } -} -bool Cryptor::isActive() const -{ - std::lock_guard lock(mutex_); + bool Cryptor::isActive() const { + std::lock_guard lock(mutex_); - return isActive_; -} + return isActive_; + } -const std::string Cryptor::cCertificate = "-----BEGIN CERTIFICATE-----\n\ + const std::string Cryptor::cCertificate = "-----BEGIN CERTIFICATE-----\n\ MIIDKjCCAhICARswDQYJKoZIhvcNAQELBQAwWzELMAkGA1UEBhMCVVMxEzARBgNV\n\ BAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxHzAdBgNVBAoM\n\ Fkdvb2dsZSBBdXRvbW90aXZlIExpbmswJhcRMTQwNzA0MDAwMDAwLTA3MDAXETQ1\n\ @@ -298,7 +255,7 @@ YmsbkPVNYZn37FlY7e2Z4FUphh0A7yME2Eh/e57QxWrJ1wubdzGnX8mrABc67ADU\n\ U5r9tlTRqMs7FGOk6QS2Cxp4pqeVQsrPts4OEwyPUyb3LfFNo3+sP111D9zEow==\n\ -----END CERTIFICATE-----\n"; -const std::string Cryptor::cPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\n\ + const std::string Cryptor::cPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\n\ MIIEowIBAAKCAQEAz3XWY2dR/H5Ym3G6TToY7uRdFb+BdRU1AGRsAVmZV1U28ugR\n\ A22GLZfxYI7Bfqfqgw/FTYwYme+Jw/fqQGp8eF9DYW+qV/tiOOGAEeHSWopKFU/E\n\ i91q0GNVDvprKbkfcamSKAsaSZ7KJWhU7yhzdwnVs73rAVGaTuQlthwSNDJqQ4M8\n\ @@ -326,5 +283,5 @@ eCXS4VrhEf4/HYMWP7GB5MFUOEVtlLiLM05ruUL7CrphdfgayDXVcTPfk75lLhmu\n\ KAwp3tIHPoJOQiKNQ3/qks5km/9dujUGU2ARiU3qmxLMdgegFz8e\n\ -----END RSA PRIVATE KEY-----\n"; -} + } } diff --git a/src/Messenger/FrameHeader.cpp b/src/Messenger/FrameHeader.cpp index f47f0b96..ecc0855d 100644 --- a/src/Messenger/FrameHeader.cpp +++ b/src/Messenger/FrameHeader.cpp @@ -1,76 +1,65 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -FrameHeader::FrameHeader(const common::DataConstBuffer& buffer) -{ - channelId_ = static_cast(buffer.cdata[0]); - frameType_ = static_cast(buffer.cdata[1] & static_cast(FrameType::BULK)); - encryptionType_ = static_cast(buffer.cdata[1] & static_cast(EncryptionType::ENCRYPTED)); - messageType_ = static_cast(buffer.cdata[1] & static_cast(MessageType::CONTROL)); -} + FrameHeader::FrameHeader(const common::DataConstBuffer &buffer) { + channelId_ = static_cast(buffer.cdata[0]); + frameType_ = static_cast(buffer.cdata[1] & static_cast(FrameType::BULK)); + encryptionType_ = static_cast(buffer.cdata[1] & static_cast(EncryptionType::ENCRYPTED)); + messageType_ = static_cast(buffer.cdata[1] & static_cast(MessageType::CONTROL)); + } -FrameHeader::FrameHeader(ChannelId channelId, FrameType frameType, EncryptionType encryptionType, MessageType messageType) - : channelId_(channelId) - , frameType_(frameType) - , encryptionType_(encryptionType) - , messageType_(messageType) -{ + FrameHeader::FrameHeader(ChannelId channelId, FrameType frameType, EncryptionType encryptionType, + MessageType messageType) + : channelId_(channelId), frameType_(frameType), encryptionType_(encryptionType), messageType_(messageType) { -} + } -ChannelId FrameHeader::getChannelId() const -{ - return channelId_; -} + ChannelId FrameHeader::getChannelId() const { + return channelId_; + } -FrameType FrameHeader::getType() const -{ - return frameType_; -} + FrameType FrameHeader::getType() const { + return frameType_; + } -EncryptionType FrameHeader::getEncryptionType() const -{ - return encryptionType_; -} + EncryptionType FrameHeader::getEncryptionType() const { + return encryptionType_; + } -MessageType FrameHeader::getMessageType() const -{ - return messageType_; -} + MessageType FrameHeader::getMessageType() const { + return messageType_; + } -common::Data FrameHeader::getData() const -{ - common::Data data; + common::Data FrameHeader::getData() const { + common::Data data; - data.push_back(static_cast(channelId_)); - data.push_back(static_cast(encryptionType_) | static_cast(messageType_) | static_cast(frameType_)); + data.push_back(static_cast(channelId_)); + data.push_back(static_cast(encryptionType_) | static_cast(messageType_) | + static_cast(frameType_)); - return data; -} + return data; + } -} + } } diff --git a/src/Messenger/FrameSize.cpp b/src/Messenger/FrameSize.cpp index e92f35a3..349647a1 100644 --- a/src/Messenger/FrameSize.cpp +++ b/src/Messenger/FrameSize.cpp @@ -1,95 +1,78 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -FrameSize::FrameSize(size_t frameSize, size_t totalSize) - : frameSizeType_(FrameSizeType::EXTENDED) - , frameSize_(frameSize) - , totalSize_(totalSize) -{ + FrameSize::FrameSize(size_t frameSize, size_t totalSize) + : frameSizeType_(FrameSizeType::EXTENDED), frameSize_(frameSize), totalSize_(totalSize) { -} + } -FrameSize::FrameSize(size_t frameSize) - : frameSizeType_(FrameSizeType::SHORT) - , frameSize_(frameSize) - , totalSize_(0) -{ + FrameSize::FrameSize(size_t frameSize) + : frameSizeType_(FrameSizeType::SHORT), frameSize_(frameSize), totalSize_(0) { -} + } -FrameSize::FrameSize(const common::DataConstBuffer& buffer) -{ - if(buffer.size >= 2) - { + FrameSize::FrameSize(const common::DataConstBuffer &buffer) { + if (buffer.size >= 2) { frameSizeType_ = FrameSizeType::SHORT; - frameSize_ = boost::endian::big_to_native(reinterpret_cast(buffer.cdata[0])); + frameSize_ = boost::endian::big_to_native(reinterpret_cast(buffer.cdata[0])); totalSize_ = frameSize_; - } + } - if(buffer.size >= 6) - { + if (buffer.size >= 6) { frameSizeType_ = FrameSizeType::EXTENDED; - totalSize_ = boost::endian::big_to_native(reinterpret_cast(buffer.cdata[2])); + totalSize_ = boost::endian::big_to_native(reinterpret_cast(buffer.cdata[2])); + } } -} -common::Data FrameSize::getData() const -{ - common::Data data; + common::Data FrameSize::getData() const { + common::Data data; - uint16_t frameSizeBig = boost::endian::native_to_big(static_cast(frameSize_)); - const common::DataConstBuffer frameSizeBigBuffer(&frameSizeBig, sizeof(frameSizeBig)); - common::copy(data, frameSizeBigBuffer); + uint16_t frameSizeBig = boost::endian::native_to_big(static_cast(frameSize_)); + const common::DataConstBuffer frameSizeBigBuffer(&frameSizeBig, sizeof(frameSizeBig)); + common::copy(data, frameSizeBigBuffer); - if(frameSizeType_ == FrameSizeType::EXTENDED) - { + if (frameSizeType_ == FrameSizeType::EXTENDED) { uint32_t totalSizeBig = boost::endian::native_to_big(static_cast(totalSize_)); const common::DataConstBuffer totalSizeBigBuffer(&totalSizeBig, sizeof(totalSizeBig)); common::copy(data, totalSizeBigBuffer); - } + } - return data; -} + return data; + } -size_t FrameSize::getFrameSize() const -{ - return frameSize_; -} + size_t FrameSize::getFrameSize() const { + return frameSize_; + } -size_t FrameSize::getTotalSize() const -{ - return totalSize_; -} + size_t FrameSize::getTotalSize() const { + return totalSize_; + } -size_t FrameSize::getSizeOf(FrameSizeType type) -{ - return type == FrameSizeType::EXTENDED ? 6 : 2; -} + size_t FrameSize::getSizeOf(FrameSizeType type) { + return type == FrameSizeType::EXTENDED ? 6 : 2; + } -} + } } diff --git a/src/Messenger/FrameType.cpp b/src/Messenger/FrameType.cpp index b4b80a90..c66ff2b5 100644 --- a/src/Messenger/FrameType.cpp +++ b/src/Messenger/FrameType.cpp @@ -1,44 +1,39 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include -namespace aasdk -{ - namespace messenger - { - - std::string frameTypeToString(FrameType frameType) - { - switch(frameType) - { - case FrameType::MIDDLE: - return "MIDDLE"; - case FrameType::FIRST: - return "FIRST"; - case FrameType::LAST: - return "LAST"; - case FrameType::BULK: - return "BULK"; - default: - return "(null)"; - } - } +namespace aasdk { + namespace messenger { + std::string frameTypeToString(FrameType frameType) { + switch (frameType) { + case FrameType::MIDDLE: + return "MIDDLE"; + case FrameType::FIRST: + return "FIRST"; + case FrameType::LAST: + return "LAST"; + case FrameType::BULK: + return "BULK"; + default: + return "(null)"; + } } + + } } diff --git a/src/Messenger/Message.cpp b/src/Messenger/Message.cpp index dfb5c63c..1db68cbf 100644 --- a/src/Messenger/Message.cpp +++ b/src/Messenger/Message.cpp @@ -1,103 +1,84 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -Message::Message(ChannelId channelId, EncryptionType encryptionType, MessageType type) - : channelId_(channelId) - , encryptionType_(encryptionType) - , type_(type) -{ -} + Message::Message(ChannelId channelId, EncryptionType encryptionType, MessageType type) + : channelId_(channelId), encryptionType_(encryptionType), type_(type) { + } -Message::Message(Message&& other) - : channelId_(other.channelId_) - , encryptionType_(other.encryptionType_) - , type_(other.type_) - , payload_(std::move(other.payload_)) -{ + Message::Message(Message &&other) + : channelId_(other.channelId_), encryptionType_(other.encryptionType_), type_(other.type_), + payload_(std::move(other.payload_)) { -} + } -Message& Message::operator=(Message&& other) -{ - channelId_ = std::move(other.channelId_); - encryptionType_ = std::move(other.encryptionType_); - type_ = std::move(other.type_); - payload_ = std::move(other.payload_); + Message &Message::operator=(Message &&other) { + channelId_ = std::move(other.channelId_); + encryptionType_ = std::move(other.encryptionType_); + type_ = std::move(other.type_); + payload_ = std::move(other.payload_); - return *this; -} + return *this; + } -ChannelId Message::getChannelId() const -{ - return channelId_; -} + ChannelId Message::getChannelId() const { + return channelId_; + } -EncryptionType Message::getEncryptionType() const -{ - return encryptionType_; -} + EncryptionType Message::getEncryptionType() const { + return encryptionType_; + } -MessageType Message::getType() const -{ - return type_; -} + MessageType Message::getType() const { + return type_; + } -common::Data& Message::getPayload() -{ - return payload_; -} + common::Data &Message::getPayload() { + return payload_; + } -const common::Data& Message::getPayload() const -{ - return payload_; -} + const common::Data &Message::getPayload() const { + return payload_; + } -void Message::insertPayload(const common::Data& payload) -{ - payload_.insert(payload_.end(), payload.begin(), payload.end()); -} + void Message::insertPayload(const common::Data &payload) { + payload_.insert(payload_.end(), payload.begin(), payload.end()); + } -void Message::insertPayload(const google::protobuf::Message& message) -{ - auto offset = payload_.size(); - payload_.resize(payload_.size() + message.ByteSize()); + void Message::insertPayload(const google::protobuf::Message &message) { + auto offset = payload_.size(); + payload_.resize(payload_.size() + message.ByteSizeLong()); - common::DataBuffer buffer(payload_, offset); - message.SerializeToArray(buffer.data, buffer.size); -} + common::DataBuffer buffer(payload_, offset); + message.SerializeToArray(buffer.data, buffer.size); + } -void Message::insertPayload(const common::DataConstBuffer& buffer) -{ - common::copy(payload_, buffer); -} + void Message::insertPayload(const common::DataConstBuffer &buffer) { + common::copy(payload_, buffer); + } -void Message::insertPayload(common::DataBuffer& buffer) -{ - common::copy(payload_, buffer); -} + void Message::insertPayload(common::DataBuffer &buffer) { + common::copy(payload_, buffer); + } -} + } } diff --git a/src/Messenger/MessageId.cpp b/src/Messenger/MessageId.cpp index 8d1377e0..17e985bc 100644 --- a/src/Messenger/MessageId.cpp +++ b/src/Messenger/MessageId.cpp @@ -1,89 +1,75 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk::messenger { -MessageId::MessageId(uint16_t id): - id_(id) -{ + MessageId::MessageId(uint16_t id) : + id_(id) { -} -MessageId::MessageId(const common::Data& data) -{ - id_ = boost::endian::big_to_native(reinterpret_cast(data[0])); -} + } -uint16_t MessageId::getId() const -{ + MessageId::MessageId(const common::Data &data) { + id_ = boost::endian::big_to_native(reinterpret_cast(data[0])); + } + + uint16_t MessageId::getId() const { return id_; -} + } -common::Data MessageId::getData() const -{ + common::Data MessageId::getData() const { const MessageId messageIdBig = boost::endian::native_to_big(id_); const common::DataConstBuffer messageIdBigBuffer(&messageIdBig, sizeof(messageIdBig)); return common::createData(messageIdBigBuffer); -} + } -bool MessageId::operator>(uint16_t id) const -{ + bool MessageId::operator>(uint16_t id) const { return id > id_; -} + } -bool MessageId::operator<(uint16_t id) const -{ + bool MessageId::operator<(uint16_t id) const { return id < id_; -} + } -bool MessageId::operator==(uint16_t id) const -{ + bool MessageId::operator==(uint16_t id) const { return id == id_; -} + } -MessageId& MessageId::operator=(uint16_t id) -{ + MessageId &MessageId::operator=(uint16_t id) { id_ = id; return *this; -} + } -bool MessageId::operator>=(uint16_t id) const -{ + bool MessageId::operator>=(uint16_t id) const { return id >= id_; -} + } -bool MessageId::operator<=(uint16_t id) const -{ + bool MessageId::operator<=(uint16_t id) const { return id <= id_; -} + } -std::ostream& operator<<(std::ostream& stream, const aasdk::messenger::MessageId& messageId) -{ + std::ostream &operator<<(std::ostream &stream, const aasdk::messenger::MessageId &messageId) { stream << "0x" << std::hex << messageId.getId() << std::dec; return stream; -} + } } -} + diff --git a/src/Messenger/MessageInStream.cpp b/src/Messenger/MessageInStream.cpp index f20992de..39a42af2 100644 --- a/src/Messenger/MessageInStream.cpp +++ b/src/Messenger/MessageInStream.cpp @@ -1,181 +1,178 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include #include #include -namespace aasdk -{ -namespace messenger -{ -MessageInStream::MessageInStream(boost::asio::io_service& ioService, transport::ITransport::Pointer transport, ICryptor::Pointer cryptor) - : strand_(ioService) - , transport_(std::move(transport)) - , cryptor_(std::move(cryptor)) -{ +namespace aasdk::messenger { -} + MessageInStream::MessageInStream(boost::asio::io_service &ioService, transport::ITransport::Pointer transport, + ICryptor::Pointer cryptor) + : strand_(ioService), transport_(std::move(transport)), cryptor_(std::move(cryptor)) { + + } -void MessageInStream::startReceive(ReceivePromise::Pointer promise) -{ + void MessageInStream::startReceive(ReceivePromise::Pointer promise) { + AASDK_LOG(debug) << "[MessageInStream] startReceiveCalled()"; strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable { - if (promise_ == nullptr) { - promise_ = std::move(promise); - auto transportPromise = transport::ITransport::ReceivePromise::defer(strand_); - transportPromise->then( - [this, self = this->shared_from_this()](common::Data data) mutable { - this->receiveFrameHeaderHandler(common::DataConstBuffer(data)); - }, - [this, self = this->shared_from_this()](const error::Error &e) mutable { - promise_->reject(e); - promise_.reset(); - }); - - transport_->receive(FrameHeader::getSizeOf(), std::move(transportPromise)); - } else { - promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); - } + if (promise_ == nullptr) { + promise_ = std::move(promise); + auto transportPromise = transport::ITransport::ReceivePromise::defer(strand_); + transportPromise->then( + [this, self = this->shared_from_this()](common::Data data) mutable { + this->receiveFrameHeaderHandler(common::DataConstBuffer(data)); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + AASDK_LOG(debug) << "[MessageInStream] Rejecting message."; + promise_->reject(e); + promise_.reset(); + }); + + transport_->receive(FrameHeader::getSizeOf(), std::move(transportPromise)); + } else { + promise_.reset(); + AASDK_LOG(debug) << "[MessageInStream] Already Handling Promise"; + promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); + } }); -} + } -void MessageInStream::receiveFrameHeaderHandler(const common::DataConstBuffer& buffer) -{ + void MessageInStream::receiveFrameHeaderHandler(const common::DataConstBuffer &buffer) { FrameHeader frameHeader(buffer); - AASDK_LOG(debug) << "[MessageInStream] Processing Frame Header: Ch " << channelIdToString(frameHeader.getChannelId()) << " Fr " << frameTypeToString(frameHeader.getType()); + AASDK_LOG(debug) << "[MessageInStream] Processing Frame Header: Ch " + << channelIdToString(frameHeader.getChannelId()) << " Fr " + << frameTypeToString(frameHeader.getType()); isValidFrame_ = true; auto bufferedMessage = messageBuffer_.find(frameHeader.getChannelId()); if (bufferedMessage != messageBuffer_.end()) { - // We have found a message... - message_ = std::move(bufferedMessage->second); - messageBuffer_.erase(bufferedMessage); - - AASDK_LOG(debug) << "[MessageInStream] Found existing message."; - - if (frameHeader.getType() == FrameType::FIRST || frameHeader.getType() == FrameType::BULK) { - // If it's first or bulk, we need to override the message anyhow, so we will start again. - // Need to start a new message anyhow - message_ = std::make_shared(frameHeader.getChannelId(), frameHeader.getEncryptionType(), frameHeader.getMessageType()); - } + // We have found a message... + message_ = std::move(bufferedMessage->second); + messageBuffer_.erase(bufferedMessage); + + AASDK_LOG(debug) << "[MessageInStream] Found existing message."; + + if (frameHeader.getType() == FrameType::FIRST || frameHeader.getType() == FrameType::BULK) { + // If it's first or bulk, we need to override the message anyhow, so we will start again. + // Need to start a new message anyhow + message_ = std::make_shared(frameHeader.getChannelId(), frameHeader.getEncryptionType(), + frameHeader.getMessageType()); + } } else { - AASDK_LOG(debug) << "[MessageInStream] Could not find existing message."; - // No Message Found in Buffers and this is a middle or last frame, this an error. - // Still need to process the frame, but we will not resolve at the end. - message_ = std::make_shared(frameHeader.getChannelId(), frameHeader.getEncryptionType(), frameHeader.getMessageType()); - if (frameHeader.getType() == FrameType::MIDDLE || frameHeader.getType() == FrameType::LAST) { - // This is an error - isValidFrame_ = false; - } + AASDK_LOG(debug) << "[MessageInStream] Could not find existing message."; + // No Message Found in Buffers and this is a middle or last frame, this an error. + // Still need to process the frame, but we will not resolve at the end. + message_ = std::make_shared(frameHeader.getChannelId(), frameHeader.getEncryptionType(), + frameHeader.getMessageType()); + if (frameHeader.getType() == FrameType::MIDDLE || frameHeader.getType() == FrameType::LAST) { + // This is an error + isValidFrame_ = false; + } } thisFrameType_ = frameHeader.getType(); - const size_t frameSize = FrameSize::getSizeOf(frameHeader.getType() == FrameType::FIRST ? FrameSizeType::EXTENDED : FrameSizeType::SHORT); + const size_t frameSize = FrameSize::getSizeOf( + frameHeader.getType() == FrameType::FIRST ? FrameSizeType::EXTENDED : FrameSizeType::SHORT); auto transportPromise = transport::ITransport::ReceivePromise::defer(strand_); transportPromise->then( [this, self = this->shared_from_this()](common::Data data) mutable { - this->receiveFrameSizeHandler(common::DataConstBuffer(data)); + this->receiveFrameSizeHandler(common::DataConstBuffer(data)); }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - message_.reset(); - promise_->reject(e); - promise_.reset(); + [this, self = this->shared_from_this()](const error::Error &e) mutable { + AASDK_LOG(debug) << "[MessageInStream] Rejecting message."; + message_.reset(); + promise_->reject(e); + promise_.reset(); }); transport_->receive(frameSize, std::move(transportPromise)); -} + } -void MessageInStream::receiveFrameSizeHandler(const common::DataConstBuffer& buffer) -{ + void MessageInStream::receiveFrameSizeHandler(const common::DataConstBuffer &buffer) { auto transportPromise = transport::ITransport::ReceivePromise::defer(strand_); transportPromise->then( [this, self = this->shared_from_this()](common::Data data) mutable { - this->receiveFramePayloadHandler(common::DataConstBuffer(data)); + this->receiveFramePayloadHandler(common::DataConstBuffer(data)); }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - message_.reset(); - promise_->reject(e); - promise_.reset(); + [this, self = this->shared_from_this()](const error::Error &e) mutable { + AASDK_LOG(debug) << "[MessageInStream] Rejecting message."; + message_.reset(); + promise_->reject(e); + promise_.reset(); }); FrameSize frameSize(buffer); frameSize_ = (int) frameSize.getFrameSize(); transport_->receive(frameSize.getFrameSize(), std::move(transportPromise)); -} - -void MessageInStream::receiveFramePayloadHandler(const common::DataConstBuffer& buffer) -{ - if(message_->getEncryptionType() == EncryptionType::ENCRYPTED) - { - try - { - cryptor_->decrypt(message_->getPayload(), buffer, frameSize_); - } - catch(const error::Error& e) - { - message_.reset(); - promise_->reject(e); - promise_.reset(); - return; - } - } - else - { - message_->insertPayload(buffer); + } + + void MessageInStream::receiveFramePayloadHandler(const common::DataConstBuffer &buffer) { + if (message_->getEncryptionType() == EncryptionType::ENCRYPTED) { + try { + cryptor_->decrypt(message_->getPayload(), buffer, frameSize_); + } + catch (const error::Error &e) { + AASDK_LOG(debug) << "[MessageInStream] Rejecting message."; + message_.reset(); + promise_->reject(e); + promise_.reset(); + return; + } + } else { + message_->insertPayload(buffer); } bool isResolved = false; // If this is the LAST frame or a BULK frame... - if((thisFrameType_ == FrameType::BULK || thisFrameType_ == FrameType::LAST) && isValidFrame_) - { - AASDK_LOG(debug) << "[MessageInStream] Resolving message."; - promise_->resolve(std::move(message_)); - promise_.reset(); - isResolved = true; + if ((thisFrameType_ == FrameType::BULK || thisFrameType_ == FrameType::LAST) && isValidFrame_) { + AASDK_LOG(debug) << "[MessageInStream] Resolving message."; + promise_->resolve(std::move(message_)); + promise_.reset(); + isResolved = true; - currentMessageIndex_--; } else { - // First or Middle message, we'll store in our buffer... - messageBuffer_[message_->getChannelId()] = std::move(message_); + // First or Middle message, we'll store in our buffer... + messageBuffer_[message_->getChannelId()] = std::move(message_); } // If the main promise isn't resolved, then carry on retrieving frame headers. if (!isResolved) { - auto transportPromise = transport::ITransport::ReceivePromise::defer(strand_); - transportPromise->then( - [this, self = this->shared_from_this()](common::Data data) mutable { - this->receiveFrameHeaderHandler(common::DataConstBuffer(data)); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - message_.reset(); - promise_->reject(e); - promise_.reset(); - }); + auto transportPromise = transport::ITransport::ReceivePromise::defer(strand_); + transportPromise->then( + [this, self = this->shared_from_this()](common::Data data) mutable { + this->receiveFrameHeaderHandler(common::DataConstBuffer(data)); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + message_.reset(); + AASDK_LOG(debug) << "[MessageInStream] Rejecting message."; + promise_->reject(e); + promise_.reset(); + }); - transport_->receive(FrameHeader::getSizeOf(), std::move(transportPromise)); + transport_->receive(FrameHeader::getSizeOf(), std::move(transportPromise)); } -} + } } -} + diff --git a/src/Messenger/MessageInStream.ut.cpp b/src/Messenger/MessageInStream.ut.cpp index 5769c8e0..542583ee 100644 --- a/src/Messenger/MessageInStream.ut.cpp +++ b/src/Messenger/MessageInStream.ut.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -24,399 +23,421 @@ #include -namespace aasdk -{ -namespace messenger -{ -namespace ut -{ - -using ::testing::_; -using ::testing::SaveArg; -using ::testing::SetArgReferee; -using ::testing::Return; - -class MessageInStreamUnitTest -{ -protected: - MessageInStreamUnitTest() - : transport_(&transportMock_, [](auto*) {}) - , cryptor_(&cryptorMock_, [](auto*) {}) - , receivePromise_(ReceivePromise::defer(ioService_)) - { - receivePromise_->then(std::bind(&ReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, std::placeholders::_1), - std::bind(&ReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, std::placeholders::_1)); - } - - boost::asio::io_service ioService_; - transport::ut::TransportMock transportMock_; - transport::ITransport::Pointer transport_; - CryptorMock cryptorMock_; - ICryptor::Pointer cryptor_; - ReceivePromiseHandlerMock receivePromiseHandlerMock_; - ReceivePromise::Pointer receivePromise_; -}; - +namespace aasdk { + namespace messenger { + namespace ut { + + using ::testing::_; + using ::testing::SaveArg; + using ::testing::SetArgReferee; + using ::testing::Return; -ACTION(ThrowSSLReadException) -{ - throw error::Error(error::ErrorCode::SSL_READ, 123); -} + class MessageInStreamUnitTest { + protected: + MessageInStreamUnitTest() + : transport_(&transportMock_, [](auto *) {}), cryptor_(&cryptorMock_, [](auto *) {}), + receivePromise_(ReceivePromise::defer(ioService_)) { + receivePromise_->then( + std::bind(&ReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, std::placeholders::_1), + std::bind(&ReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, std::placeholders::_1)); + } + + boost::asio::io_service ioService_; + transport::ut::TransportMock transportMock_; + transport::ITransport::Pointer transport_; + CryptorMock cryptorMock_; + ICryptor::Pointer cryptor_; + ReceivePromiseHandlerMock receivePromiseHandlerMock_; + ReceivePromise::Pointer receivePromise_; + }; -BOOST_FIXTURE_TEST_CASE(MessageInStream_ReceivePlainMessage, MessageInStreamUnitTest) -{ - MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); - FrameHeader frameHeader(ChannelId::BLUETOOTH, FrameType::BULK, EncryptionType::PLAIN, MessageType::SPECIFIC); - transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).WillOnce(SaveArg<1>(&frameHeaderTransportPromise)); + ACTION(ThrowSSLReadException) + { + throw error::Error(error::ErrorCode::SSL_READ, 123); + } + + BOOST_FIXTURE_TEST_CASE(MessageInStream_ReceivePlainMessage, MessageInStreamUnitTest) + { + MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); + + FrameHeader frameHeader(ChannelId::BLUETOOTH, FrameType::BULK, EncryptionType::PLAIN, MessageType::SPECIFIC); + transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).WillOnce( + SaveArg<1>(&frameHeaderTransportPromise)); - messageInStream->startReceive(std::move(receivePromise_)); + messageInStream->startReceive(std::move(receivePromise_)); - ioService_.run(); - ioService_.reset(); + ioService_.run(); + ioService_.reset(); - common::Data framePayload(1000, 0x5E); - FrameSize frameSize(framePayload.size()); - transport::ITransport::ReceivePromise::Pointer frameSizeTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::SHORT), _)).WillOnce(SaveArg<1>(&frameSizeTransportPromise)); - frameHeaderTransportPromise->resolve(frameHeader.getData()); + common::Data framePayload(1000, 0x5E); + FrameSize frameSize(framePayload.size()); + transport::ITransport::ReceivePromise::Pointer frameSizeTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::SHORT), _)).WillOnce( + SaveArg<1>(&frameSizeTransportPromise)); + frameHeaderTransportPromise->resolve(frameHeader.getData()); + + ioService_.run(); + ioService_.reset(); + + transport::ITransport::ReceivePromise::Pointer framePayloadTransportPromise; + EXPECT_CALL(transportMock_, receive(framePayload.size(), _)).WillOnce( + SaveArg<1>(&framePayloadTransportPromise)); + frameSizeTransportPromise->resolve(frameSize.getData()); + + ioService_.run(); + ioService_.reset(); + + Message::Pointer message; + EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).WillOnce(SaveArg<0>(&message)); + framePayloadTransportPromise->resolve(framePayload); - ioService_.run(); - ioService_.reset(); + ioService_.run(); - transport::ITransport::ReceivePromise::Pointer framePayloadTransportPromise; - EXPECT_CALL(transportMock_, receive(framePayload.size(), _)).WillOnce(SaveArg<1>(&framePayloadTransportPromise)); - frameSizeTransportPromise->resolve(frameSize.getData()); + BOOST_CHECK(message->getChannelId() == ChannelId::BLUETOOTH); + BOOST_CHECK(message->getEncryptionType() == EncryptionType::PLAIN); + BOOST_CHECK(message->getType() == MessageType::SPECIFIC); - ioService_.run(); - ioService_.reset(); + const auto &payload = message->getPayload(); + BOOST_CHECK_EQUAL_COLLECTIONS(payload.begin(), payload.end(), framePayload.begin(), framePayload.end()); + } - Message::Pointer message; - EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).WillOnce(SaveArg<0>(&message)); - framePayloadTransportPromise->resolve(framePayload); + BOOST_FIXTURE_TEST_CASE(MessageInStream_ReceiveEncryptedMessage, MessageInStreamUnitTest) + { + MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); - ioService_.run(); + FrameHeader frameHeader(ChannelId::VIDEO, FrameType::BULK, EncryptionType::ENCRYPTED, MessageType::CONTROL); + transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).WillOnce( + SaveArg<1>(&frameHeaderTransportPromise)); - BOOST_CHECK(message->getChannelId() == ChannelId::BLUETOOTH); - BOOST_CHECK(message->getEncryptionType() == EncryptionType::PLAIN); - BOOST_CHECK(message->getType() == MessageType::SPECIFIC); + messageInStream->startReceive(std::move(receivePromise_)); - const auto& payload = message->getPayload(); - BOOST_CHECK_EQUAL_COLLECTIONS(payload.begin(), payload.end(), framePayload.begin(), framePayload.end()); -} + ioService_.run(); + ioService_.reset(); -BOOST_FIXTURE_TEST_CASE(MessageInStream_ReceiveEncryptedMessage, MessageInStreamUnitTest) -{ - MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); + common::Data framePayload(1000, 0x5E); + FrameSize frameSize(framePayload.size()); + transport::ITransport::ReceivePromise::Pointer frameSizeTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::SHORT), _)).WillOnce( + SaveArg<1>(&frameSizeTransportPromise)); + frameHeaderTransportPromise->resolve(frameHeader.getData()); + + ioService_.run(); + ioService_.reset(); + + transport::ITransport::ReceivePromise::Promise::Pointer framePayloadTransportPromise; + EXPECT_CALL(transportMock_, receive(framePayload.size(), _)).WillOnce( + SaveArg<1>(&framePayloadTransportPromise)); + + common::Data decryptedPayload(500, 0x5F); + EXPECT_CALL(cryptorMock_, decrypt(_, _)).WillOnce( + DoAll(SetArgReferee<0>(decryptedPayload), Return(decryptedPayload.size()))); + frameSizeTransportPromise->resolve(frameSize.getData()); - FrameHeader frameHeader(ChannelId::VIDEO, FrameType::BULK, EncryptionType::ENCRYPTED, MessageType::CONTROL); - transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).WillOnce(SaveArg<1>(&frameHeaderTransportPromise)); + ioService_.run(); + ioService_.reset(); - messageInStream->startReceive(std::move(receivePromise_)); + Message::Pointer message; + EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).WillOnce(SaveArg<0>(&message)); + framePayloadTransportPromise->resolve(framePayload); - ioService_.run(); - ioService_.reset(); + ioService_.run(); - common::Data framePayload(1000, 0x5E); - FrameSize frameSize(framePayload.size()); - transport::ITransport::ReceivePromise::Pointer frameSizeTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::SHORT), _)).WillOnce(SaveArg<1>(&frameSizeTransportPromise)); - frameHeaderTransportPromise->resolve(frameHeader.getData()); + BOOST_CHECK(message->getChannelId() == ChannelId::VIDEO); + BOOST_CHECK(message->getEncryptionType() == EncryptionType::ENCRYPTED); + BOOST_CHECK(message->getType() == MessageType::CONTROL); - ioService_.run(); - ioService_.reset(); + const auto &payload = message->getPayload(); + BOOST_CHECK_EQUAL_COLLECTIONS(payload.begin(), payload.end(), decryptedPayload.begin(), decryptedPayload.end()); + } - transport::ITransport::ReceivePromise::Promise::Pointer framePayloadTransportPromise; - EXPECT_CALL(transportMock_, receive(framePayload.size(), _)).WillOnce(SaveArg<1>(&framePayloadTransportPromise)); + BOOST_FIXTURE_TEST_CASE(MessageInStream_MessageDecryptionFailed, MessageInStreamUnitTest) + { + MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); - common::Data decryptedPayload(500, 0x5F); - EXPECT_CALL(cryptorMock_, decrypt(_, _)).WillOnce(DoAll(SetArgReferee<0>(decryptedPayload), Return(decryptedPayload.size()))); - frameSizeTransportPromise->resolve(frameSize.getData()); + FrameHeader frameHeader(ChannelId::VIDEO, FrameType::BULK, EncryptionType::ENCRYPTED, MessageType::CONTROL); + transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).WillOnce( + SaveArg<1>(&frameHeaderTransportPromise)); - ioService_.run(); - ioService_.reset(); + messageInStream->startReceive(std::move(receivePromise_)); - Message::Pointer message; - EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).WillOnce(SaveArg<0>(&message)); - framePayloadTransportPromise->resolve(framePayload); + ioService_.run(); + ioService_.reset(); - ioService_.run(); + common::Data framePayload(1000, 0x5E); + FrameSize frameSize(framePayload.size()); + transport::ITransport::ReceivePromise::Pointer frameSizeTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::SHORT), _)).WillOnce( + SaveArg<1>(&frameSizeTransportPromise)); + frameHeaderTransportPromise->resolve(frameHeader.getData()); - BOOST_CHECK(message->getChannelId() == ChannelId::VIDEO); - BOOST_CHECK(message->getEncryptionType() == EncryptionType::ENCRYPTED); - BOOST_CHECK(message->getType() == MessageType::CONTROL); + ioService_.run(); + ioService_.reset(); - const auto& payload = message->getPayload(); - BOOST_CHECK_EQUAL_COLLECTIONS(payload.begin(), payload.end(), decryptedPayload.begin(), decryptedPayload.end()); -} + transport::ITransport::ReceivePromise::Pointer framePayloadTransportPromise; + EXPECT_CALL(transportMock_, receive(framePayload.size(), _)).WillOnce( + SaveArg<1>(&framePayloadTransportPromise)); -BOOST_FIXTURE_TEST_CASE(MessageInStream_MessageDecryptionFailed, MessageInStreamUnitTest) -{ - MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); + common::Data decryptedPayload(500, 0x5F); + EXPECT_CALL(cryptorMock_, decrypt(_, _)).WillOnce(ThrowSSLReadException()); + frameSizeTransportPromise->resolve(frameSize.getData()); - FrameHeader frameHeader(ChannelId::VIDEO, FrameType::BULK, EncryptionType::ENCRYPTED, MessageType::CONTROL); - transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).WillOnce(SaveArg<1>(&frameHeaderTransportPromise)); + ioService_.run(); + ioService_.reset(); - messageInStream->startReceive(std::move(receivePromise_)); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(error::Error(error::ErrorCode::SSL_READ, 123))); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); + framePayloadTransportPromise->resolve(framePayload); - ioService_.run(); - ioService_.reset(); + ioService_.run(); + } - common::Data framePayload(1000, 0x5E); - FrameSize frameSize(framePayload.size()); - transport::ITransport::ReceivePromise::Pointer frameSizeTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::SHORT), _)).WillOnce(SaveArg<1>(&frameSizeTransportPromise)); - frameHeaderTransportPromise->resolve(frameHeader.getData()); + BOOST_FIXTURE_TEST_CASE(MessageInStream_FramePayloadReceiveFailed, MessageInStreamUnitTest) + { + MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); - ioService_.run(); - ioService_.reset(); + FrameHeader frameHeader(ChannelId::BLUETOOTH, FrameType::BULK, EncryptionType::PLAIN, MessageType::SPECIFIC); + transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).WillOnce( + SaveArg<1>(&frameHeaderTransportPromise)); - transport::ITransport::ReceivePromise::Pointer framePayloadTransportPromise; - EXPECT_CALL(transportMock_, receive(framePayload.size(), _)).WillOnce(SaveArg<1>(&framePayloadTransportPromise)); + messageInStream->startReceive(std::move(receivePromise_)); - common::Data decryptedPayload(500, 0x5F); - EXPECT_CALL(cryptorMock_, decrypt(_, _)).WillOnce(ThrowSSLReadException()); - frameSizeTransportPromise->resolve(frameSize.getData()); + ioService_.run(); + ioService_.reset(); - ioService_.run(); - ioService_.reset(); + common::Data framePayload(1000, 0x5E); + FrameSize frameSize(framePayload.size()); + transport::ITransport::ReceivePromise::Pointer frameSizeTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::SHORT), _)).WillOnce( + SaveArg<1>(&frameSizeTransportPromise)); + frameHeaderTransportPromise->resolve(frameHeader.getData()); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(error::Error(error::ErrorCode::SSL_READ, 123))); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); - framePayloadTransportPromise->resolve(framePayload); + ioService_.run(); + ioService_.reset(); - ioService_.run(); -} + transport::ITransport::ReceivePromise::Pointer framePayloadTransportPromise; + EXPECT_CALL(transportMock_, receive(framePayload.size(), _)).WillOnce( + SaveArg<1>(&framePayloadTransportPromise)); + frameSizeTransportPromise->resolve(frameSize.getData()); -BOOST_FIXTURE_TEST_CASE(MessageInStream_FramePayloadReceiveFailed, MessageInStreamUnitTest) -{ - MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); + ioService_.run(); + ioService_.reset(); - FrameHeader frameHeader(ChannelId::BLUETOOTH, FrameType::BULK, EncryptionType::PLAIN, MessageType::SPECIFIC); - transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).WillOnce(SaveArg<1>(&frameHeaderTransportPromise)); + error::Error e(error::ErrorCode::USB_TRANSFER, 5); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(e)); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); + framePayloadTransportPromise->reject(e); - messageInStream->startReceive(std::move(receivePromise_)); + ioService_.run(); + } - ioService_.run(); - ioService_.reset(); + BOOST_FIXTURE_TEST_CASE(MessageInStream_FramePayloadSizeReceiveFailed, MessageInStreamUnitTest) + { + MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); - common::Data framePayload(1000, 0x5E); - FrameSize frameSize(framePayload.size()); - transport::ITransport::ReceivePromise::Pointer frameSizeTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::SHORT), _)).WillOnce(SaveArg<1>(&frameSizeTransportPromise)); - frameHeaderTransportPromise->resolve(frameHeader.getData()); + FrameHeader frameHeader(ChannelId::BLUETOOTH, FrameType::BULK, EncryptionType::PLAIN, MessageType::SPECIFIC); + transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).WillOnce( + SaveArg<1>(&frameHeaderTransportPromise)); - ioService_.run(); - ioService_.reset(); + messageInStream->startReceive(std::move(receivePromise_)); - transport::ITransport::ReceivePromise::Pointer framePayloadTransportPromise; - EXPECT_CALL(transportMock_, receive(framePayload.size(), _)).WillOnce(SaveArg<1>(&framePayloadTransportPromise)); - frameSizeTransportPromise->resolve(frameSize.getData()); + ioService_.run(); + ioService_.reset(); - ioService_.run(); - ioService_.reset(); + transport::ITransport::ReceivePromise::Pointer frameSizeTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::SHORT), _)).WillOnce( + SaveArg<1>(&frameSizeTransportPromise)); + frameHeaderTransportPromise->resolve(frameHeader.getData()); - error::Error e(error::ErrorCode::USB_TRANSFER, 5); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(e)); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); - framePayloadTransportPromise->reject(e); + ioService_.run(); + ioService_.reset(); - ioService_.run(); -} + error::Error e(error::ErrorCode::USB_TRANSFER, 5); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(e)); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); + frameSizeTransportPromise->reject(e); -BOOST_FIXTURE_TEST_CASE(MessageInStream_FramePayloadSizeReceiveFailed, MessageInStreamUnitTest) -{ - MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); + ioService_.run(); + } - FrameHeader frameHeader(ChannelId::BLUETOOTH, FrameType::BULK, EncryptionType::PLAIN, MessageType::SPECIFIC); - transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).WillOnce(SaveArg<1>(&frameHeaderTransportPromise)); + BOOST_FIXTURE_TEST_CASE(MessageInStream_FrameHeaderReceiveFailed, MessageInStreamUnitTest) + { + MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); - messageInStream->startReceive(std::move(receivePromise_)); + FrameHeader frameHeader(ChannelId::BLUETOOTH, FrameType::BULK, EncryptionType::PLAIN, MessageType::SPECIFIC); + transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).WillOnce( + SaveArg<1>(&frameHeaderTransportPromise)); - ioService_.run(); - ioService_.reset(); + messageInStream->startReceive(std::move(receivePromise_)); - transport::ITransport::ReceivePromise::Pointer frameSizeTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::SHORT), _)).WillOnce(SaveArg<1>(&frameSizeTransportPromise)); - frameHeaderTransportPromise->resolve(frameHeader.getData()); + ioService_.run(); + ioService_.reset(); - ioService_.run(); - ioService_.reset(); + error::Error e(error::ErrorCode::USB_TRANSFER, 5); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(e)); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); + frameHeaderTransportPromise->reject(e); - error::Error e(error::ErrorCode::USB_TRANSFER, 5); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(e)); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); - frameSizeTransportPromise->reject(e); + ioService_.run(); + } - ioService_.run(); -} + BOOST_FIXTURE_TEST_CASE(MessageInStream_ReceiveSplittedMessage, MessageInStreamUnitTest) + { + MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); + FrameHeader frame1Header(ChannelId::BLUETOOTH, FrameType::FIRST, EncryptionType::PLAIN, MessageType::SPECIFIC); -BOOST_FIXTURE_TEST_CASE(MessageInStream_FrameHeaderReceiveFailed, MessageInStreamUnitTest) -{ - MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); + transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).Times(2).WillRepeatedly( + SaveArg<1>(&frameHeaderTransportPromise)); - FrameHeader frameHeader(ChannelId::BLUETOOTH, FrameType::BULK, EncryptionType::PLAIN, MessageType::SPECIFIC); - transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).WillOnce(SaveArg<1>(&frameHeaderTransportPromise)); + messageInStream->startReceive(std::move(receivePromise_)); - messageInStream->startReceive(std::move(receivePromise_)); + ioService_.run(); + ioService_.reset(); - ioService_.run(); - ioService_.reset(); + common::Data frame1Payload(1000, 0x5E); + common::Data frame2Payload(2000, 0x5F); + common::Data expectedPayload(frame1Payload.begin(), frame1Payload.end()); + expectedPayload.insert(expectedPayload.end(), frame2Payload.begin(), frame2Payload.end()); - error::Error e(error::ErrorCode::USB_TRANSFER, 5); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(e)); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); - frameHeaderTransportPromise->reject(e); + transport::ITransport::ReceivePromise::Pointer frame1SizeTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::EXTENDED), _)).WillOnce( + SaveArg<1>(&frame1SizeTransportPromise)); + frameHeaderTransportPromise->resolve(frame1Header.getData()); - ioService_.run(); -} + ioService_.run(); + ioService_.reset(); -BOOST_FIXTURE_TEST_CASE(MessageInStream_ReceiveSplittedMessage, MessageInStreamUnitTest) -{ - MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); - FrameHeader frame1Header(ChannelId::BLUETOOTH, FrameType::FIRST, EncryptionType::PLAIN, MessageType::SPECIFIC); + transport::ITransport::ReceivePromise::Pointer frame1PayloadTransportPromise; + EXPECT_CALL(transportMock_, receive(frame1Payload.size(), _)).WillOnce( + SaveArg<1>(&frame1PayloadTransportPromise)); + FrameSize frame1Size(frame1Payload.size(), frame1Payload.size() + frame2Payload.size()); + frame1SizeTransportPromise->resolve(frame1Size.getData()); - transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).Times(2).WillRepeatedly(SaveArg<1>(&frameHeaderTransportPromise)); + ioService_.run(); + ioService_.reset(); - messageInStream->startReceive(std::move(receivePromise_)); + frame1PayloadTransportPromise->resolve(frame1Payload); - ioService_.run(); - ioService_.reset(); + ioService_.run(); + ioService_.reset(); - common::Data frame1Payload(1000, 0x5E); - common::Data frame2Payload(2000, 0x5F); - common::Data expectedPayload(frame1Payload.begin(), frame1Payload.end()); - expectedPayload.insert(expectedPayload.end(), frame2Payload.begin(), frame2Payload.end()); + transport::ITransport::ReceivePromise::Pointer frame2SizeTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::SHORT), _)).WillOnce( + SaveArg<1>(&frame2SizeTransportPromise)); - transport::ITransport::ReceivePromise::Pointer frame1SizeTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::EXTENDED), _)).WillOnce(SaveArg<1>(&frame1SizeTransportPromise)); - frameHeaderTransportPromise->resolve(frame1Header.getData()); + FrameHeader frame2Header(ChannelId::BLUETOOTH, FrameType::LAST, EncryptionType::PLAIN, MessageType::SPECIFIC); + frameHeaderTransportPromise->resolve(frame2Header.getData()); - ioService_.run(); - ioService_.reset(); + ioService_.run(); + ioService_.reset(); - transport::ITransport::ReceivePromise::Pointer frame1PayloadTransportPromise; - EXPECT_CALL(transportMock_, receive(frame1Payload.size(), _)).WillOnce(SaveArg<1>(&frame1PayloadTransportPromise)); - FrameSize frame1Size(frame1Payload.size(), frame1Payload.size() + frame2Payload.size()); - frame1SizeTransportPromise->resolve(frame1Size.getData()); + transport::ITransport::ReceivePromise::Pointer frame2PayloadTransportPromise; + EXPECT_CALL(transportMock_, receive(frame2Payload.size(), _)).WillOnce( + SaveArg<1>(&frame2PayloadTransportPromise)); + FrameSize frame2Size(frame2Payload.size()); + frame2SizeTransportPromise->resolve(frame2Size.getData()); - ioService_.run(); - ioService_.reset(); + ioService_.run(); + ioService_.reset(); - frame1PayloadTransportPromise->resolve(frame1Payload); + Message::Pointer message; + EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).WillOnce(SaveArg<0>(&message)); + frame2PayloadTransportPromise->resolve(frame2Payload); - ioService_.run(); - ioService_.reset(); + ioService_.run(); - transport::ITransport::ReceivePromise::Pointer frame2SizeTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::SHORT), _)).WillOnce(SaveArg<1>(&frame2SizeTransportPromise)); + BOOST_CHECK(message->getChannelId() == ChannelId::BLUETOOTH); + BOOST_CHECK(message->getEncryptionType() == EncryptionType::PLAIN); + BOOST_CHECK(message->getType() == MessageType::SPECIFIC); - FrameHeader frame2Header(ChannelId::BLUETOOTH, FrameType::LAST, EncryptionType::PLAIN, MessageType::SPECIFIC); - frameHeaderTransportPromise->resolve(frame2Header.getData()); + const auto &payload = message->getPayload(); + BOOST_CHECK_EQUAL_COLLECTIONS(payload.begin(), payload.end(), expectedPayload.begin(), expectedPayload.end()); + } - ioService_.run(); - ioService_.reset(); + BOOST_FIXTURE_TEST_CASE(MessageInStream_IntertwinedChannels, MessageInStreamUnitTest) + { + MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); + FrameHeader frame1Header(ChannelId::BLUETOOTH, FrameType::FIRST, EncryptionType::PLAIN, MessageType::SPECIFIC); - transport::ITransport::ReceivePromise::Pointer frame2PayloadTransportPromise; - EXPECT_CALL(transportMock_, receive(frame2Payload.size(), _)).WillOnce(SaveArg<1>(&frame2PayloadTransportPromise)); - FrameSize frame2Size(frame2Payload.size()); - frame2SizeTransportPromise->resolve(frame2Size.getData()); + transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).Times(2).WillRepeatedly( + SaveArg<1>(&frameHeaderTransportPromise)); - ioService_.run(); - ioService_.reset(); + messageInStream->startReceive(std::move(receivePromise_)); - Message::Pointer message; - EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).WillOnce(SaveArg<0>(&message)); - frame2PayloadTransportPromise->resolve(frame2Payload); + ioService_.run(); + ioService_.reset(); - ioService_.run(); + common::Data frame1Payload(1000, 0x5E); + common::Data frame2Payload(2000, 0x5F); - BOOST_CHECK(message->getChannelId() == ChannelId::BLUETOOTH); - BOOST_CHECK(message->getEncryptionType() == EncryptionType::PLAIN); - BOOST_CHECK(message->getType() == MessageType::SPECIFIC); + transport::ITransport::ReceivePromise::Pointer frame1SizeTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::EXTENDED), _)).WillOnce( + SaveArg<1>(&frame1SizeTransportPromise)); + frameHeaderTransportPromise->resolve(frame1Header.getData()); - const auto& payload = message->getPayload(); - BOOST_CHECK_EQUAL_COLLECTIONS(payload.begin(), payload.end(), expectedPayload.begin(), expectedPayload.end()); -} + ioService_.run(); + ioService_.reset(); -BOOST_FIXTURE_TEST_CASE(MessageInStream_IntertwinedChannels, MessageInStreamUnitTest) -{ - MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); - FrameHeader frame1Header(ChannelId::BLUETOOTH, FrameType::FIRST, EncryptionType::PLAIN, MessageType::SPECIFIC); + transport::ITransport::ReceivePromise::Pointer frame1PayloadTransportPromise; + EXPECT_CALL(transportMock_, receive(frame1Payload.size(), _)).WillOnce( + SaveArg<1>(&frame1PayloadTransportPromise)); + FrameSize frame1Size(frame1Payload.size(), frame1Payload.size() + frame2Payload.size()); + frame1SizeTransportPromise->resolve(frame1Size.getData()); - transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).Times(2).WillRepeatedly(SaveArg<1>(&frameHeaderTransportPromise)); + ioService_.run(); + ioService_.reset(); - messageInStream->startReceive(std::move(receivePromise_)); + frame1PayloadTransportPromise->resolve(frame1Payload); - ioService_.run(); - ioService_.reset(); + ioService_.run(); + ioService_.reset(); - common::Data frame1Payload(1000, 0x5E); - common::Data frame2Payload(2000, 0x5F); + FrameHeader frame2Header(ChannelId::VIDEO, FrameType::LAST, EncryptionType::PLAIN, MessageType::SPECIFIC); - transport::ITransport::ReceivePromise::Pointer frame1SizeTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameSize::getSizeOf(FrameSizeType::EXTENDED), _)).WillOnce(SaveArg<1>(&frame1SizeTransportPromise)); - frameHeaderTransportPromise->resolve(frame1Header.getData()); + EXPECT_CALL(receivePromiseHandlerMock_, + onReject(error::Error(error::ErrorCode::MESSENGER_INTERTWINED_CHANNELS))); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); + frameHeaderTransportPromise->resolve(frame2Header.getData()); - ioService_.run(); - ioService_.reset(); + ioService_.run(); + } - transport::ITransport::ReceivePromise::Pointer frame1PayloadTransportPromise; - EXPECT_CALL(transportMock_, receive(frame1Payload.size(), _)).WillOnce(SaveArg<1>(&frame1PayloadTransportPromise)); - FrameSize frame1Size(frame1Payload.size(), frame1Payload.size() + frame2Payload.size()); - frame1SizeTransportPromise->resolve(frame1Size.getData()); + BOOST_FIXTURE_TEST_CASE(MessageInStream_RejectWhenInProgress, MessageInStreamUnitTest) + { + MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); - ioService_.run(); - ioService_.reset(); + FrameHeader frameHeader(ChannelId::BLUETOOTH, FrameType::BULK, EncryptionType::PLAIN, MessageType::SPECIFIC); + transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; + EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).WillOnce( + SaveArg<1>(&frameHeaderTransportPromise)); - frame1PayloadTransportPromise->resolve(frame1Payload); + messageInStream->startReceive(std::move(receivePromise_)); - ioService_.run(); - ioService_.reset(); + ReceivePromiseHandlerMock secondReceivePromiseHandlerMock; + auto secondReceivePromise = ReceivePromise::defer(ioService_); - FrameHeader frame2Header(ChannelId::VIDEO, FrameType::LAST, EncryptionType::PLAIN, MessageType::SPECIFIC); + secondReceivePromise->then( + std::bind(&ReceivePromiseHandlerMock::onResolve, &secondReceivePromiseHandlerMock, std::placeholders::_1), + std::bind(&ReceivePromiseHandlerMock::onReject, &secondReceivePromiseHandlerMock, std::placeholders::_1)); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(error::Error(error::ErrorCode::MESSENGER_INTERTWINED_CHANNELS))); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); - frameHeaderTransportPromise->resolve(frame2Header.getData()); + EXPECT_CALL(secondReceivePromiseHandlerMock, onReject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS))); + EXPECT_CALL(secondReceivePromiseHandlerMock, onResolve(_)).Times(0); + messageInStream->startReceive(std::move(secondReceivePromise)); + ioService_.run(); + } - ioService_.run(); -} -BOOST_FIXTURE_TEST_CASE(MessageInStream_RejectWhenInProgress, MessageInStreamUnitTest) -{ - MessageInStream::Pointer messageInStream(std::make_shared(ioService_, transport_, cryptor_)); - - FrameHeader frameHeader(ChannelId::BLUETOOTH, FrameType::BULK, EncryptionType::PLAIN, MessageType::SPECIFIC); - transport::ITransport::ReceivePromise::Pointer frameHeaderTransportPromise; - EXPECT_CALL(transportMock_, receive(FrameHeader::getSizeOf(), _)).WillOnce(SaveArg<1>(&frameHeaderTransportPromise)); - - messageInStream->startReceive(std::move(receivePromise_)); - - ReceivePromiseHandlerMock secondReceivePromiseHandlerMock; - auto secondReceivePromise = ReceivePromise::defer(ioService_); - - secondReceivePromise->then(std::bind(&ReceivePromiseHandlerMock::onResolve, &secondReceivePromiseHandlerMock, std::placeholders::_1), - std::bind(&ReceivePromiseHandlerMock::onReject, &secondReceivePromiseHandlerMock, std::placeholders::_1)); - - EXPECT_CALL(secondReceivePromiseHandlerMock, onReject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS))); - EXPECT_CALL(secondReceivePromiseHandlerMock, onResolve(_)).Times(0); - messageInStream->startReceive(std::move(secondReceivePromise)); - ioService_.run(); -} - - -} -} + } + } } diff --git a/src/Messenger/MessageOutStream.cpp b/src/Messenger/MessageOutStream.cpp index 7d2f3e44..03623f0d 100644 --- a/src/Messenger/MessageOutStream.cpp +++ b/src/Messenger/MessageOutStream.cpp @@ -1,156 +1,136 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk { + namespace messenger { -MessageOutStream::MessageOutStream(boost::asio::io_service& ioService, transport::ITransport::Pointer transport, ICryptor::Pointer cryptor) - : strand_(ioService) - , transport_(std::move(transport)) - , cryptor_(std::move(cryptor)) - , offset_(0) - , remainingSize_(0) -{ + MessageOutStream::MessageOutStream(boost::asio::io_service &ioService, transport::ITransport::Pointer transport, + ICryptor::Pointer cryptor) + : strand_(ioService), transport_(std::move(transport)), cryptor_(std::move(cryptor)), offset_(0), + remainingSize_(0) { -} + } -void MessageOutStream::stream(Message::Pointer message, SendPromise::Pointer promise) -{ - strand_.dispatch([this, self = this->shared_from_this(), message = std::move(message), promise = std::move(promise)]() mutable { - if(promise_ != nullptr) - { - promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); - return; + void MessageOutStream::stream(Message::Pointer message, SendPromise::Pointer promise) { + strand_.dispatch([this, self = this->shared_from_this(), message = std::move(message), promise = std::move( + promise)]() mutable { + if (promise_ != nullptr) { + promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); + return; } message_ = std::move(message); promise_ = std::move(promise); - if(message_->getPayload().size() >= cMaxFramePayloadSize) - { - offset_ = 0; - remainingSize_ = message_->getPayload().size(); - this->streamSplittedMessage(); - } - else - { - try - { - auto data(this->compoundFrame(FrameType::BULK, common::DataConstBuffer(message_->getPayload()))); - - auto transportPromise = transport::ITransport::SendPromise::defer(strand_); - io::PromiseLink<>::forward(*transportPromise, std::move(promise_)); - transport_->send(std::move(data), std::move(transportPromise)); - } - catch(const error::Error& e) - { - promise_->reject(e); - promise_.reset(); - } - - this->reset(); + if (message_->getPayload().size() >= cMaxFramePayloadSize) { + offset_ = 0; + remainingSize_ = message_->getPayload().size(); + this->streamSplittedMessage(); + } else { + try { + auto data(this->compoundFrame(FrameType::BULK, common::DataConstBuffer(message_->getPayload()))); + + auto transportPromise = transport::ITransport::SendPromise::defer(strand_); + io::PromiseLink<>::forward(*transportPromise, std::move(promise_)); + transport_->send(std::move(data), std::move(transportPromise)); + } + catch (const error::Error &e) { + promise_->reject(e); + promise_.reset(); + } + + this->reset(); } - }); -} + }); + } -void MessageOutStream::streamSplittedMessage() -{ - try - { - const auto& payload = message_->getPayload(); + void MessageOutStream::streamSplittedMessage() { + try { + const auto &payload = message_->getPayload(); auto ptr = &payload[offset_]; auto size = remainingSize_ < cMaxFramePayloadSize ? remainingSize_ : cMaxFramePayloadSize; - FrameType frameType = offset_ == 0 ? FrameType::FIRST : (remainingSize_ - size > 0 ? FrameType::MIDDLE : FrameType::LAST); + FrameType frameType = + offset_ == 0 ? FrameType::FIRST : (remainingSize_ - size > 0 ? FrameType::MIDDLE : FrameType::LAST); auto data(this->compoundFrame(frameType, common::DataConstBuffer(ptr, size))); auto transportPromise = transport::ITransport::SendPromise::defer(strand_); - if(frameType == FrameType::LAST) - { - this->reset(); - io::PromiseLink<>::forward(*transportPromise, std::move(promise_)); - } - else - { - transportPromise->then([this, self = this->shared_from_this(), size]() mutable { - offset_ += size; - remainingSize_ -= size; - this->streamSplittedMessage(); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - this->reset(); - promise_->reject(e); - promise_.reset(); - }); + if (frameType == FrameType::LAST) { + this->reset(); + io::PromiseLink<>::forward(*transportPromise, std::move(promise_)); + } else { + transportPromise->then([this, self = this->shared_from_this(), size]() mutable { + offset_ += size; + remainingSize_ -= size; + this->streamSplittedMessage(); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + this->reset(); + promise_->reject(e); + promise_.reset(); + }); } transport_->send(std::move(data), std::move(transportPromise)); - } - catch(const error::Error& e) - { + } + catch (const error::Error &e) { this->reset(); promise_->reject(e); promise_.reset(); + } } -} -common::Data MessageOutStream::compoundFrame(FrameType frameType, const common::DataConstBuffer& payloadBuffer) -{ - const FrameHeader frameHeader(message_->getChannelId(), frameType, message_->getEncryptionType(), message_->getType()); - common::Data data(frameHeader.getData()); - data.resize(data.size() + FrameSize::getSizeOf(frameType == FrameType::FIRST ? FrameSizeType::EXTENDED : FrameSizeType::SHORT)); - size_t payloadSize = 0; + common::Data MessageOutStream::compoundFrame(FrameType frameType, const common::DataConstBuffer &payloadBuffer) { + const FrameHeader frameHeader(message_->getChannelId(), frameType, message_->getEncryptionType(), + message_->getType()); + common::Data data(frameHeader.getData()); + data.resize(data.size() + + FrameSize::getSizeOf(frameType == FrameType::FIRST ? FrameSizeType::EXTENDED : FrameSizeType::SHORT)); + size_t payloadSize = 0; - if(message_->getEncryptionType() == EncryptionType::ENCRYPTED) - { + if (message_->getEncryptionType() == EncryptionType::ENCRYPTED) { payloadSize = cryptor_->encrypt(data, payloadBuffer); - } - else - { + } else { data.insert(data.end(), payloadBuffer.cdata, payloadBuffer.cdata + payloadBuffer.size); payloadSize = payloadBuffer.size; - } + } - this->setFrameSize(data, frameType, payloadSize, message_->getPayload().size()); - return data; -} + this->setFrameSize(data, frameType, payloadSize, message_->getPayload().size()); + return data; + } -void MessageOutStream::setFrameSize(common::Data& data, FrameType frameType, size_t payloadSize, size_t totalSize) -{ - const auto& frameSize = frameType == FrameType::FIRST ? FrameSize(payloadSize, totalSize) : FrameSize(payloadSize); - const auto& frameSizeData = frameSize.getData(); - memcpy(&data[FrameHeader::getSizeOf()], &frameSizeData[0], frameSizeData.size()); -} + void MessageOutStream::setFrameSize(common::Data &data, FrameType frameType, size_t payloadSize, size_t totalSize) { + const auto &frameSize = + frameType == FrameType::FIRST ? FrameSize(payloadSize, totalSize) : FrameSize(payloadSize); + const auto &frameSizeData = frameSize.getData(); + memcpy(&data[FrameHeader::getSizeOf()], &frameSizeData[0], frameSizeData.size()); + } -void MessageOutStream::reset() -{ - offset_ = 0; - remainingSize_ = 0; - message_.reset(); -} + void MessageOutStream::reset() { + offset_ = 0; + remainingSize_ = 0; + message_.reset(); + } -} + } } diff --git a/src/Messenger/MessageOutStream.ut.cpp b/src/Messenger/MessageOutStream.ut.cpp index f5610fa5..c9d9bdcc 100644 --- a/src/Messenger/MessageOutStream.ut.cpp +++ b/src/Messenger/MessageOutStream.ut.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -24,204 +23,213 @@ #include -namespace aasdk -{ -namespace messenger -{ -namespace ut -{ - -using ::testing::_; -using ::testing::SaveArg; -using ::testing::SetArgReferee; -using ::testing::Return; - -class MessageOutStreamUnitTest -{ -protected: - MessageOutStreamUnitTest() - : transport_(&transportMock_, [](auto*) {}) - , cryptor_(&cryptorMock_, [](auto*) {}) - , sendPromise_(SendPromise::defer(ioService_)) - { - sendPromise_->then(std::bind(&SendPromiseHandlerMock::onResolve, &sendPromiseHandlerMock_), - std::bind(&SendPromiseHandlerMock::onReject, &sendPromiseHandlerMock_, std::placeholders::_1)); - } - - boost::asio::io_service ioService_; - transport::ut::TransportMock transportMock_; - transport::ITransport::Pointer transport_; - CryptorMock cryptorMock_; - ICryptor::Pointer cryptor_; - SendPromiseHandlerMock sendPromiseHandlerMock_; - SendPromise::Pointer sendPromise_; -}; - -ACTION(ThrowSSLWriteException) -{ - throw error::Error(error::ErrorCode::SSL_WRITE, 32); -} - -BOOST_FIXTURE_TEST_CASE(MessageOutStream_SendPlainMessage, MessageOutStreamUnitTest) -{ - const FrameHeader frameHeader(ChannelId::INPUT, FrameType::BULK, EncryptionType::PLAIN, MessageType::CONTROL); - const common::Data payload(1000, 0x5E); - const FrameSize frameSize(payload.size()); - - const auto& frameHeaderData = frameHeader.getData(); - common::Data expectedData(frameHeaderData.begin(), frameHeaderData.end()); - - const auto& frameSizeData = frameSize.getData(); - expectedData.insert(expectedData.end(), frameSizeData.begin(), frameSizeData.end()); - expectedData.insert(expectedData.end(), payload.begin(), payload.end()); - - transport::ITransport::SendPromise::Pointer transportSendPromise; - EXPECT_CALL(transportMock_, send(expectedData, _)).WillOnce(SaveArg<1>(&transportSendPromise)); - - Message::Pointer message(std::make_shared(ChannelId::INPUT, EncryptionType::PLAIN, MessageType::CONTROL)); - message->insertPayload(payload); - MessageOutStream::Pointer messageOutStream(std::make_shared(ioService_, transport_, cryptor_)); - messageOutStream->stream(message, std::move(sendPromise_)); - - ioService_.run(); - ioService_.reset(); - - EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); - transportSendPromise->resolve(); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(MessageOutStream_SendEncryptedMessage, MessageOutStreamUnitTest) -{ - const FrameHeader frameHeader(ChannelId::VIDEO, FrameType::BULK, EncryptionType::ENCRYPTED, MessageType::CONTROL); - const common::Data encryptedPayload(2000, 0x5F); - const FrameSize frameSize(encryptedPayload.size()); - - const auto& frameHeaderData = frameHeader.getData(); - common::Data expectedData(frameHeaderData.begin(), frameHeaderData.end()); - - const auto& frameSizeData = frameSize.getData(); - expectedData.insert(expectedData.end(), frameSizeData.begin(), frameSizeData.end()); - expectedData.insert(expectedData.end(), encryptedPayload.begin(), encryptedPayload.end()); - - common::Data encryptedData(expectedData.begin(), expectedData.begin() + FrameHeader::getSizeOf() + FrameSize::getSizeOf(FrameSizeType::SHORT)); - encryptedData.insert(encryptedData.end(), encryptedPayload.begin(), encryptedPayload.end()); - transport::ITransport::SendPromise::Pointer transportSendPromise; - EXPECT_CALL(cryptorMock_, encrypt(_, _)).WillOnce(DoAll(SetArgReferee<0>(encryptedData), Return(encryptedPayload.size()))); - EXPECT_CALL(transportMock_, send(expectedData, _)).WillOnce(SaveArg<1>(&transportSendPromise)); - - Message::Pointer message(std::make_shared(ChannelId::VIDEO, EncryptionType::ENCRYPTED, MessageType::CONTROL)); - const common::Data payload(1000, 0x5E); - message->insertPayload(payload); - MessageOutStream::Pointer messageOutStream(std::make_shared(ioService_, transport_, cryptor_)); - messageOutStream->stream(message, std::move(sendPromise_)); - - ioService_.run(); - ioService_.reset(); - - EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); - transportSendPromise->resolve(); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(MessageOutStream_MessageEncryptionFailed, MessageOutStreamUnitTest) -{ - Message::Pointer message(std::make_shared(ChannelId::VIDEO, EncryptionType::ENCRYPTED, MessageType::CONTROL)); - const common::Data payload(1000, 0x5E); - message->insertPayload(payload); - MessageOutStream::Pointer messageOutStream(std::make_shared(ioService_, transport_, cryptor_)); - - EXPECT_CALL(cryptorMock_, encrypt(_, _)).WillOnce(ThrowSSLWriteException()); - EXPECT_CALL(sendPromiseHandlerMock_, onReject(error::Error(error::ErrorCode::SSL_WRITE, 32))); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()).Times(0); - messageOutStream->stream(message, std::move(sendPromise_)); - - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(MessageOutStream_SendError, MessageOutStreamUnitTest) -{ - Message::Pointer message(std::make_shared(ChannelId::VIDEO, EncryptionType::PLAIN, MessageType::CONTROL)); - const common::Data payload(1000, 0x5E); - message->insertPayload(payload); - MessageOutStream::Pointer messageOutStream(std::make_shared(ioService_, transport_, cryptor_)); - - transport::ITransport::SendPromise::Pointer transportSendPromise; - EXPECT_CALL(transportMock_, send(_, _)).WillOnce(SaveArg<1>(&transportSendPromise)); - messageOutStream->stream(message, std::move(sendPromise_)); - - ioService_.run(); - ioService_.reset(); - - const error::Error e(error::ErrorCode::USB_TRANSFER, 513); - EXPECT_CALL(sendPromiseHandlerMock_, onReject(e)); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()).Times(0); +namespace aasdk { + namespace messenger { + namespace ut { + + using ::testing::_; + using ::testing::SaveArg; + using ::testing::SetArgReferee; + using ::testing::Return; + + class MessageOutStreamUnitTest { + protected: + MessageOutStreamUnitTest() + : transport_(&transportMock_, [](auto *) {}), cryptor_(&cryptorMock_, [](auto *) {}), + sendPromise_(SendPromise::defer(ioService_)) { + sendPromise_->then(std::bind(&SendPromiseHandlerMock::onResolve, &sendPromiseHandlerMock_), + std::bind(&SendPromiseHandlerMock::onReject, &sendPromiseHandlerMock_, + std::placeholders::_1)); + } + + boost::asio::io_service ioService_; + transport::ut::TransportMock transportMock_; + transport::ITransport::Pointer transport_; + CryptorMock cryptorMock_; + ICryptor::Pointer cryptor_; + SendPromiseHandlerMock sendPromiseHandlerMock_; + SendPromise::Pointer sendPromise_; + }; + + ACTION(ThrowSSLWriteException) + { + throw error::Error(error::ErrorCode::SSL_WRITE, 32); + } + + BOOST_FIXTURE_TEST_CASE(MessageOutStream_SendPlainMessage, MessageOutStreamUnitTest) + { + const FrameHeader frameHeader(ChannelId::INPUT, FrameType::BULK, EncryptionType::PLAIN, MessageType::CONTROL); + const common::Data payload(1000, 0x5E); + const FrameSize frameSize(payload.size()); + + const auto &frameHeaderData = frameHeader.getData(); + common::Data expectedData(frameHeaderData.begin(), frameHeaderData.end()); + + const auto &frameSizeData = frameSize.getData(); + expectedData.insert(expectedData.end(), frameSizeData.begin(), frameSizeData.end()); + expectedData.insert(expectedData.end(), payload.begin(), payload.end()); + + transport::ITransport::SendPromise::Pointer transportSendPromise; + EXPECT_CALL(transportMock_, send(expectedData, _)).WillOnce(SaveArg<1>(&transportSendPromise)); + + Message::Pointer message( + std::make_shared(ChannelId::INPUT, EncryptionType::PLAIN, MessageType::CONTROL)); + message->insertPayload(payload); + MessageOutStream::Pointer messageOutStream( + std::make_shared(ioService_, transport_, cryptor_)); + messageOutStream->stream(message, std::move(sendPromise_)); + + ioService_.run(); + ioService_.reset(); + + EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); + transportSendPromise->resolve(); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(MessageOutStream_SendEncryptedMessage, MessageOutStreamUnitTest) + { + const FrameHeader + frameHeader(ChannelId::VIDEO, FrameType::BULK, EncryptionType::ENCRYPTED, MessageType::CONTROL); + const common::Data encryptedPayload(2000, 0x5F); + const FrameSize frameSize(encryptedPayload.size()); + + const auto &frameHeaderData = frameHeader.getData(); + common::Data expectedData(frameHeaderData.begin(), frameHeaderData.end()); + + const auto &frameSizeData = frameSize.getData(); + expectedData.insert(expectedData.end(), frameSizeData.begin(), frameSizeData.end()); + expectedData.insert(expectedData.end(), encryptedPayload.begin(), encryptedPayload.end()); + + common::Data encryptedData(expectedData.begin(), expectedData.begin() + FrameHeader::getSizeOf() + + FrameSize::getSizeOf(FrameSizeType::SHORT)); + encryptedData.insert(encryptedData.end(), encryptedPayload.begin(), encryptedPayload.end()); + transport::ITransport::SendPromise::Pointer transportSendPromise; + EXPECT_CALL(cryptorMock_, encrypt(_, _)).WillOnce( + DoAll(SetArgReferee<0>(encryptedData), Return(encryptedPayload.size()))); + EXPECT_CALL(transportMock_, send(expectedData, _)).WillOnce(SaveArg<1>(&transportSendPromise)); + + Message::Pointer message( + std::make_shared(ChannelId::VIDEO, EncryptionType::ENCRYPTED, MessageType::CONTROL)); + const common::Data payload(1000, 0x5E); + message->insertPayload(payload); + MessageOutStream::Pointer messageOutStream( + std::make_shared(ioService_, transport_, cryptor_)); + messageOutStream->stream(message, std::move(sendPromise_)); + + ioService_.run(); + ioService_.reset(); + + EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); + transportSendPromise->resolve(); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(MessageOutStream_MessageEncryptionFailed, MessageOutStreamUnitTest) + { + Message::Pointer message( + std::make_shared(ChannelId::VIDEO, EncryptionType::ENCRYPTED, MessageType::CONTROL)); + const common::Data payload(1000, 0x5E); + message->insertPayload(payload); + MessageOutStream::Pointer messageOutStream( + std::make_shared(ioService_, transport_, cryptor_)); + + EXPECT_CALL(cryptorMock_, encrypt(_, _)).WillOnce(ThrowSSLWriteException()); + EXPECT_CALL(sendPromiseHandlerMock_, onReject(error::Error(error::ErrorCode::SSL_WRITE, 32))); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()).Times(0); + messageOutStream->stream(message, std::move(sendPromise_)); + + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(MessageOutStream_SendError, MessageOutStreamUnitTest) + { + Message::Pointer message( + std::make_shared(ChannelId::VIDEO, EncryptionType::PLAIN, MessageType::CONTROL)); + const common::Data payload(1000, 0x5E); + message->insertPayload(payload); + MessageOutStream::Pointer messageOutStream( + std::make_shared(ioService_, transport_, cryptor_)); + + transport::ITransport::SendPromise::Pointer transportSendPromise; + EXPECT_CALL(transportMock_, send(_, _)).WillOnce(SaveArg<1>(&transportSendPromise)); + messageOutStream->stream(message, std::move(sendPromise_)); + + ioService_.run(); + ioService_.reset(); + + const error::Error e(error::ErrorCode::USB_TRANSFER, 513); + EXPECT_CALL(sendPromiseHandlerMock_, onReject(e)); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()).Times(0); + + transportSendPromise->reject(e); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(MessageOutStream_SendSplittedMessage, MessageOutStreamUnitTest) + { + const size_t maxFramePayloadSize = 0x4000; + + const common::Data frame1Payload(maxFramePayloadSize, 0x5E); + const common::Data frame2Payload(maxFramePayloadSize, 0x5E); + + const FrameHeader frame1Header(ChannelId::VIDEO, FrameType::FIRST, EncryptionType::PLAIN, MessageType::CONTROL); + const auto &frame1HeaderData = frame1Header.getData(); + + const FrameSize frame1Size(frame1Payload.size(), frame1Payload.size() + frame2Payload.size()); + const auto &frame1SizeData = frame1Size.getData(); + + const FrameHeader frame2Header(ChannelId::VIDEO, FrameType::LAST, EncryptionType::PLAIN, MessageType::CONTROL); + const auto &frame2HeaderData = frame2Header.getData(); + + const FrameSize frame2Size(frame2Payload.size()); + const auto &frame2SizeData = frame2Size.getData(); + + Message::Pointer message( + std::make_shared(ChannelId::VIDEO, EncryptionType::PLAIN, MessageType::CONTROL)); + message->insertPayload(frame1Payload); + message->insertPayload(frame2Payload); + + transport::ITransport::SendPromise::Pointer transportSendPromise; + common::Data expectedData1(frame1HeaderData.begin(), frame1HeaderData.end()); + expectedData1.insert(expectedData1.end(), frame1SizeData.begin(), frame1SizeData.end()); + expectedData1.insert(expectedData1.end(), frame1Payload.begin(), frame1Payload.end()); + EXPECT_CALL(transportMock_, send(expectedData1, _)).WillOnce(SaveArg<1>(&transportSendPromise)); + + MessageOutStream::Pointer messageOutStream( + std::make_shared(ioService_, transport_, cryptor_)); + messageOutStream->stream(message, std::move(sendPromise_)); + + ioService_.run(); + ioService_.reset(); + + common::Data expectedData2(frame2HeaderData.begin(), frame2HeaderData.end()); + expectedData2.insert(expectedData2.end(), frame2SizeData.begin(), frame2SizeData.end()); + expectedData2.insert(expectedData2.end(), frame2Payload.begin(), frame2Payload.end()); + EXPECT_CALL(transportMock_, send(expectedData2, _)).WillOnce(SaveArg<1>(&transportSendPromise)); + + auto secondSendPromise = SendPromise::defer(ioService_); + SendPromiseHandlerMock secondSendPromiseHandlerMock; + secondSendPromise->then(std::bind(&SendPromiseHandlerMock::onResolve, &secondSendPromiseHandlerMock), + std::bind(&SendPromiseHandlerMock::onReject, &secondSendPromiseHandlerMock, + std::placeholders::_1)); + + EXPECT_CALL(secondSendPromiseHandlerMock, onResolve()).Times(0); + EXPECT_CALL(secondSendPromiseHandlerMock, onReject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS))); + messageOutStream->stream(message, std::move(secondSendPromise)); + + transportSendPromise->resolve(); + ioService_.run(); + ioService_.reset(); + + EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); + transportSendPromise->resolve(); + ioService_.run(); + } - transportSendPromise->reject(e); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(MessageOutStream_SendSplittedMessage, MessageOutStreamUnitTest) -{ - const size_t maxFramePayloadSize = 0x4000; - - const common::Data frame1Payload(maxFramePayloadSize, 0x5E); - const common::Data frame2Payload(maxFramePayloadSize, 0x5E); - - const FrameHeader frame1Header(ChannelId::VIDEO, FrameType::FIRST, EncryptionType::PLAIN, MessageType::CONTROL); - const auto& frame1HeaderData = frame1Header.getData(); - - const FrameSize frame1Size(frame1Payload.size(), frame1Payload.size() + frame2Payload.size()); - const auto& frame1SizeData = frame1Size.getData(); - - const FrameHeader frame2Header(ChannelId::VIDEO, FrameType::LAST, EncryptionType::PLAIN, MessageType::CONTROL); - const auto& frame2HeaderData = frame2Header.getData(); - - const FrameSize frame2Size(frame2Payload.size()); - const auto& frame2SizeData = frame2Size.getData(); - - Message::Pointer message(std::make_shared(ChannelId::VIDEO, EncryptionType::PLAIN, MessageType::CONTROL)); - message->insertPayload(frame1Payload); - message->insertPayload(frame2Payload); - - transport::ITransport::SendPromise::Pointer transportSendPromise; - common::Data expectedData1(frame1HeaderData.begin(), frame1HeaderData.end()); - expectedData1.insert(expectedData1.end(), frame1SizeData.begin(), frame1SizeData.end()); - expectedData1.insert(expectedData1.end(), frame1Payload.begin(), frame1Payload.end()); - EXPECT_CALL(transportMock_, send(expectedData1, _)).WillOnce(SaveArg<1>(&transportSendPromise)); - - MessageOutStream::Pointer messageOutStream(std::make_shared(ioService_, transport_, cryptor_)); - messageOutStream->stream(message, std::move(sendPromise_)); - - ioService_.run(); - ioService_.reset(); - - common::Data expectedData2(frame2HeaderData.begin(), frame2HeaderData.end()); - expectedData2.insert(expectedData2.end(), frame2SizeData.begin(), frame2SizeData.end()); - expectedData2.insert(expectedData2.end(), frame2Payload.begin(), frame2Payload.end()); - EXPECT_CALL(transportMock_, send(expectedData2, _)).WillOnce(SaveArg<1>(&transportSendPromise)); - - auto secondSendPromise = SendPromise::defer(ioService_); - SendPromiseHandlerMock secondSendPromiseHandlerMock; - secondSendPromise->then(std::bind(&SendPromiseHandlerMock::onResolve, &secondSendPromiseHandlerMock), - std::bind(&SendPromiseHandlerMock::onReject, &secondSendPromiseHandlerMock, std::placeholders::_1)); - - EXPECT_CALL(secondSendPromiseHandlerMock, onResolve()).Times(0); - EXPECT_CALL(secondSendPromiseHandlerMock, onReject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS))); - messageOutStream->stream(message, std::move(secondSendPromise)); - - transportSendPromise->resolve(); - ioService_.run(); - ioService_.reset(); - - EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); - transportSendPromise->resolve(); - ioService_.run(); -} - -} -} + } + } } diff --git a/src/Messenger/Messenger.cpp b/src/Messenger/Messenger.cpp index 367923fb..f5671832 100644 --- a/src/Messenger/Messenger.cpp +++ b/src/Messenger/Messenger.cpp @@ -1,145 +1,131 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - -#include +// 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) +// +// 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 .#include #include #include #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk::messenger { -Messenger::Messenger(boost::asio::io_service& ioService, IMessageInStream::Pointer messageInStream, IMessageOutStream::Pointer messageOutStream) - : receiveStrand_(ioService) - , sendStrand_(ioService) - , messageInStream_(std::move(messageInStream)) - , messageOutStream_(std::move(messageOutStream)) -{ + Messenger::Messenger(boost::asio::io_service &ioService, IMessageInStream::Pointer messageInStream, + IMessageOutStream::Pointer messageOutStream) + : receiveStrand_(ioService), sendStrand_(ioService), messageInStream_(std::move(messageInStream)), + messageOutStream_(std::move(messageOutStream)) { -} + } + + void Messenger::enqueueReceive(ChannelId channelId, ReceivePromise::Pointer promise) { + AASDK_LOG(debug) << "[Messenger::enqueueReceive] Called on channel " << channelIdToString(channelId); -void Messenger::enqueueReceive(ChannelId channelId, ReceivePromise::Pointer promise) -{ // enqueueReceive is called from the service channel. receiveStrand_.dispatch([this, self = this->shared_from_this(), channelId, promise = std::move(promise)]() mutable { - //If there's any messages on the channel, resolve. The channel will call enqueueReceive again. - if(!channelReceiveMessageQueue_.empty(channelId)) - { - promise->resolve(std::move(channelReceiveMessageQueue_.pop(channelId))); - } - else - { - channelReceivePromiseQueue_.push(channelId, std::move(promise)); - - if(channelReceivePromiseQueue_.size() == 1) - { - auto inStreamPromise = ReceivePromise::defer(receiveStrand_); - inStreamPromise->then(std::bind(&Messenger::inStreamMessageHandler, this->shared_from_this(), std::placeholders::_1), - std::bind(&Messenger::rejectReceivePromiseQueue, this->shared_from_this(), std::placeholders::_1)); - messageInStream_->startReceive(std::move(inStreamPromise)); - } + //If there's any messages on the service, resolve. The service will call enqueueReceive again. + if (!channelReceiveMessageQueue_.empty(channelId)) { + AASDK_LOG(debug) << "[Messenger::enqueueReceive] Message queue not empty, resolving message first."; + promise->resolve(std::move(channelReceiveMessageQueue_.pop(channelId))); + } else { + AASDK_LOG(debug) << "[Messenger::enqueueReceive] Push promise to queue."; + channelReceivePromiseQueue_.push(channelId, std::move(promise)); + + if (channelReceivePromiseQueue_.size() == 1) { + AASDK_LOG(debug) << "[Messenger::enqueueReceive] Processing promise."; + auto inStreamPromise = ReceivePromise::defer(receiveStrand_); + inStreamPromise->then( + std::bind(&Messenger::inStreamMessageHandler, this->shared_from_this(), std::placeholders::_1), + std::bind(&Messenger::rejectReceivePromiseQueue, this->shared_from_this(), std::placeholders::_1)); + messageInStream_->startReceive(std::move(inStreamPromise)); } + } }); -} + } -void Messenger::enqueueSend(Message::Pointer message, SendPromise::Pointer promise) -{ - sendStrand_.dispatch([this, self = this->shared_from_this(), message = std::move(message), promise = std::move(promise)]() mutable { - channelSendPromiseQueue_.emplace_back(std::make_pair(std::move(message), std::move(promise))); + void Messenger::enqueueSend(Message::Pointer message, SendPromise::Pointer promise) { + sendStrand_.dispatch( + [this, self = this->shared_from_this(), message = std::move(message), promise = std::move(promise)]() mutable { + channelSendPromiseQueue_.emplace_back(std::make_pair(std::move(message), std::move(promise))); - if(channelSendPromiseQueue_.size() == 1) - { + if (channelSendPromiseQueue_.size() == 1) { this->doSend(); - } - }); -} + } + }); + } -void Messenger::inStreamMessageHandler(Message::Pointer message) -{ + void Messenger::inStreamMessageHandler(Message::Pointer message) { auto channelId = message->getChannelId(); + AASDK_LOG(debug) << "[Messenger::inStreamMessageHandler] Handling message for ChannelId " + << channelIdToString(message->getChannelId()); // If there's a promise on the queue, we resolve the promise with this message.... - if(channelReceivePromiseQueue_.isPending(channelId)) - { - channelReceivePromiseQueue_.pop(channelId)->resolve(std::move(message)); - } - else - { - // Or we push the message to the Message Queue for when we do get a promise - channelReceiveMessageQueue_.push(std::move(message)); + if (channelReceivePromiseQueue_.isPending(channelId)) { + AASDK_LOG(debug) << "[Messenger::inStreamMessageHandler] Pop and resolve message for message queue."; + channelReceivePromiseQueue_.pop(channelId)->resolve(std::move(message)); + } else { + AASDK_LOG(debug) << "[Messenger::inStreamMessageHandler] Pushing message to receive queue."; + // Or we push the message to the Message Queue for when we do get a promise + channelReceiveMessageQueue_.push(std::move(message)); } - if(!channelReceivePromiseQueue_.empty()) - { - auto inStreamPromise = ReceivePromise::defer(receiveStrand_); - inStreamPromise->then(std::bind(&Messenger::inStreamMessageHandler, this->shared_from_this(), std::placeholders::_1), - std::bind(&Messenger::rejectReceivePromiseQueue, this->shared_from_this(), std::placeholders::_1)); - messageInStream_->startReceive(std::move(inStreamPromise)); + if (!channelReceivePromiseQueue_.empty()) { + AASDK_LOG(debug) << "[Messenger::inStreamMessageHandler] Initiate queue for receiving."; + auto inStreamPromise = ReceivePromise::defer(receiveStrand_); + inStreamPromise->then( + std::bind(&Messenger::inStreamMessageHandler, this->shared_from_this(), std::placeholders::_1), + std::bind(&Messenger::rejectReceivePromiseQueue, this->shared_from_this(), std::placeholders::_1)); + messageInStream_->startReceive(std::move(inStreamPromise)); } -} + } -void Messenger::doSend() -{ + void Messenger::doSend() { auto queueElementIter = channelSendPromiseQueue_.begin(); auto outStreamPromise = SendPromise::defer(sendStrand_); outStreamPromise->then(std::bind(&Messenger::outStreamMessageHandler, this->shared_from_this(), queueElementIter), - std::bind(&Messenger::rejectSendPromiseQueue, this->shared_from_this(), std::placeholders::_1)); + std::bind(&Messenger::rejectSendPromiseQueue, this->shared_from_this(), + std::placeholders::_1)); messageOutStream_->stream(std::move(queueElementIter->first), std::move(outStreamPromise)); -} + } -void Messenger::outStreamMessageHandler(ChannelSendQueue::iterator queueElement) -{ + void Messenger::outStreamMessageHandler(ChannelSendQueue::iterator queueElement) { queueElement->second->resolve(); channelSendPromiseQueue_.erase(queueElement); - if(!channelSendPromiseQueue_.empty()) - { - this->doSend(); + if (!channelSendPromiseQueue_.empty()) { + this->doSend(); } -} + } -void Messenger::rejectReceivePromiseQueue(const error::Error& e) -{ - while(!channelReceivePromiseQueue_.empty()) - { - channelReceivePromiseQueue_.pop()->reject(e); + void Messenger::rejectReceivePromiseQueue(const error::Error &e) { + while (!channelReceivePromiseQueue_.empty()) { + channelReceivePromiseQueue_.pop()->reject(e); } -} + } -void Messenger::rejectSendPromiseQueue(const error::Error& e) -{ - while(!channelSendPromiseQueue_.empty()) - { - auto queueElement(std::move(channelSendPromiseQueue_.front())); - channelSendPromiseQueue_.pop_front(); - queueElement.second->reject(e); + void Messenger::rejectSendPromiseQueue(const error::Error &e) { + while (!channelSendPromiseQueue_.empty()) { + auto queueElement(std::move(channelSendPromiseQueue_.front())); + channelSendPromiseQueue_.pop_front(); + queueElement.second->reject(e); } -} + } -void Messenger::stop() -{ + void Messenger::stop() { receiveStrand_.dispatch([this, self = this->shared_from_this()]() { - channelReceiveMessageQueue_.clear(); + channelReceiveMessageQueue_.clear(); }); -} + } } -} + diff --git a/src/Messenger/Messenger.ut.cpp b/src/Messenger/Messenger.ut.cpp index 6dea88e0..d41a7bf0 100644 --- a/src/Messenger/Messenger.ut.cpp +++ b/src/Messenger/Messenger.ut.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -24,207 +23,214 @@ #include -namespace aasdk -{ -namespace messenger -{ -namespace ut -{ - -using ::testing::_; -using ::testing::SaveArg; -using ::testing::Return; - -class MessengerUnitTest -{ -protected: - MessengerUnitTest() - : messageInStream_(&messageInStreamMock_, [](auto*) {}) - , messageOutStream_(&messageOutStreamMock_, [](auto*) {}) - , receivePromise_(ReceivePromise::defer(ioService_)) - , sendPromise_(SendPromise::defer(ioService_)) - { - receivePromise_->then(std::bind(&ReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, std::placeholders::_1), - std::bind(&ReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, std::placeholders::_1)); - - sendPromise_->then(std::bind(&SendPromiseHandlerMock::onResolve, &sendPromiseHandlerMock_), - std::bind(&SendPromiseHandlerMock::onReject, &sendPromiseHandlerMock_, std::placeholders::_1)); - } - - boost::asio::io_service ioService_; - MessageInStreamMock messageInStreamMock_; - IMessageInStream::Pointer messageInStream_; - MessageOutStreamMock messageOutStreamMock_; - IMessageOutStream::Pointer messageOutStream_; - ReceivePromiseHandlerMock receivePromiseHandlerMock_; - ReceivePromise::Pointer receivePromise_; - SendPromiseHandlerMock sendPromiseHandlerMock_; - SendPromise::Pointer sendPromise_; -}; - -BOOST_FIXTURE_TEST_CASE(Messenger_Receive, MessengerUnitTest) -{ - Messenger::Pointer themessenger(std::make_shared(ioService_, messageInStream_, messageOutStream_)); - themessenger->enqueueReceive(ChannelId::MEDIA_AUDIO, std::move(receivePromise_)); - - ReceivePromise::Pointer inStreamReceivePromise; - EXPECT_CALL(messageInStreamMock_, startReceive(_)).WillOnce(SaveArg<0>(&inStreamReceivePromise)); - - ioService_.run(); - ioService_.reset(); - - Message::Pointer message(std::make_shared(ChannelId::MEDIA_AUDIO, EncryptionType::ENCRYPTED, MessageType::SPECIFIC)); - inStreamReceivePromise->resolve(message); - - EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(message)); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(Messenger_DirectReceive, MessengerUnitTest) -{ - Messenger::Pointer themessenger(std::make_shared(ioService_, messageInStream_, messageOutStream_)); - themessenger->enqueueReceive(ChannelId::MEDIA_AUDIO, std::move(receivePromise_)); - - ReceivePromise::Pointer inStreamReceivePromise; - EXPECT_CALL(messageInStreamMock_, startReceive(_)).WillRepeatedly(SaveArg<0>(&inStreamReceivePromise)); - - ioService_.run(); - ioService_.reset(); - - Message::Pointer inputChannelMessage(std::make_shared(ChannelId::INPUT, EncryptionType::ENCRYPTED, MessageType::SPECIFIC)); - inStreamReceivePromise->resolve(inputChannelMessage); - - ioService_.run(); - ioService_.reset(); - - auto secondReceivePromise = ReceivePromise::defer(ioService_); - secondReceivePromise->then(std::bind(&ReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, std::placeholders::_1), - std::bind(&ReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, std::placeholders::_1)); - themessenger->enqueueReceive(ChannelId::INPUT, std::move(secondReceivePromise)); +namespace aasdk { + namespace messenger { + namespace ut { + + using ::testing::_; + using ::testing::SaveArg; + using ::testing::Return; + + class MessengerUnitTest { + protected: + MessengerUnitTest() + : messageInStream_(&messageInStreamMock_, [](auto *) {}), + messageOutStream_(&messageOutStreamMock_, [](auto *) {}), + receivePromise_(ReceivePromise::defer(ioService_)), sendPromise_(SendPromise::defer(ioService_)) { + receivePromise_->then( + std::bind(&ReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, std::placeholders::_1), + std::bind(&ReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, std::placeholders::_1)); + + sendPromise_->then(std::bind(&SendPromiseHandlerMock::onResolve, &sendPromiseHandlerMock_), + std::bind(&SendPromiseHandlerMock::onReject, &sendPromiseHandlerMock_, + std::placeholders::_1)); + } + + boost::asio::io_service ioService_; + MessageInStreamMock messageInStreamMock_; + IMessageInStream::Pointer messageInStream_; + MessageOutStreamMock messageOutStreamMock_; + IMessageOutStream::Pointer messageOutStream_; + ReceivePromiseHandlerMock receivePromiseHandlerMock_; + ReceivePromise::Pointer receivePromise_; + SendPromiseHandlerMock sendPromiseHandlerMock_; + SendPromise::Pointer sendPromise_; + }; + + BOOST_FIXTURE_TEST_CASE(Messenger_Receive, MessengerUnitTest) + { + Messenger::Pointer themessenger(std::make_shared(ioService_, messageInStream_, messageOutStream_)); + themessenger->enqueueReceive(ChannelId::MEDIA_AUDIO, std::move(receivePromise_)); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(inputChannelMessage)); + ReceivePromise::Pointer inStreamReceivePromise; + EXPECT_CALL(messageInStreamMock_, startReceive(_)).WillOnce(SaveArg<0>(&inStreamReceivePromise)); + + ioService_.run(); + ioService_.reset(); - ioService_.run(); - ioService_.reset(); + Message::Pointer message( + std::make_shared(ChannelId::MEDIA_AUDIO, EncryptionType::ENCRYPTED, MessageType::SPECIFIC)); + inStreamReceivePromise->resolve(message); - Message::Pointer audioChannelMessage(std::make_shared(ChannelId::MEDIA_AUDIO, EncryptionType::ENCRYPTED, MessageType::SPECIFIC)); - inStreamReceivePromise->resolve(audioChannelMessage); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(message)); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(Messenger_DirectReceive, MessengerUnitTest) + { + Messenger::Pointer themessenger(std::make_shared(ioService_, messageInStream_, messageOutStream_)); + themessenger->enqueueReceive(ChannelId::MEDIA_AUDIO, std::move(receivePromise_)); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(audioChannelMessage)); - ioService_.run(); -} + ReceivePromise::Pointer inStreamReceivePromise; + EXPECT_CALL(messageInStreamMock_, startReceive(_)).WillRepeatedly(SaveArg<0>(&inStreamReceivePromise)); + + ioService_.run(); + ioService_.reset(); -BOOST_FIXTURE_TEST_CASE(Messenger_OnlyOneReceiveAtATime, MessengerUnitTest) -{ - Messenger::Pointer themessenger(std::make_shared(ioService_, messageInStream_, messageOutStream_)); - themessenger->enqueueReceive(ChannelId::MEDIA_AUDIO, std::move(receivePromise_)); + Message::Pointer inputChannelMessage( + std::make_shared(ChannelId::INPUT, EncryptionType::ENCRYPTED, MessageType::SPECIFIC)); + inStreamReceivePromise->resolve(inputChannelMessage); - ReceivePromise::Pointer inStreamReceivePromise; - EXPECT_CALL(messageInStreamMock_, startReceive(_)).WillOnce(SaveArg<0>(&inStreamReceivePromise)); + ioService_.run(); + ioService_.reset(); + + auto secondReceivePromise = ReceivePromise::defer(ioService_); + secondReceivePromise->then( + std::bind(&ReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, std::placeholders::_1), + std::bind(&ReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, std::placeholders::_1)); + themessenger->enqueueReceive(ChannelId::INPUT, std::move(secondReceivePromise)); + + EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(inputChannelMessage)); - ioService_.run(); - ioService_.reset(); + ioService_.run(); + ioService_.reset(); + + Message::Pointer audioChannelMessage( + std::make_shared(ChannelId::MEDIA_AUDIO, EncryptionType::ENCRYPTED, MessageType::SPECIFIC)); + inStreamReceivePromise->resolve(audioChannelMessage); - auto secondReceivePromise = ReceivePromise::defer(ioService_); - secondReceivePromise->then(std::bind(&ReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, std::placeholders::_1), - std::bind(&ReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, std::placeholders::_1)); - themessenger->enqueueReceive(ChannelId::INPUT, std::move(secondReceivePromise)); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(audioChannelMessage)); + ioService_.run(); + } - ioService_.run(); - ioService_.reset(); + BOOST_FIXTURE_TEST_CASE(Messenger_OnlyOneReceiveAtATime, MessengerUnitTest) + { + Messenger::Pointer themessenger(std::make_shared(ioService_, messageInStream_, messageOutStream_)); + themessenger->enqueueReceive(ChannelId::MEDIA_AUDIO, std::move(receivePromise_)); + + ReceivePromise::Pointer inStreamReceivePromise; + EXPECT_CALL(messageInStreamMock_, startReceive(_)).WillOnce(SaveArg<0>(&inStreamReceivePromise)); + + ioService_.run(); + ioService_.reset(); + + auto secondReceivePromise = ReceivePromise::defer(ioService_); + secondReceivePromise->then( + std::bind(&ReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, std::placeholders::_1), + std::bind(&ReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, std::placeholders::_1)); + themessenger->enqueueReceive(ChannelId::INPUT, std::move(secondReceivePromise)); + + ioService_.run(); + ioService_.reset(); + + const error::Error e(error::ErrorCode::USB_TRANSFER, 41); + inStreamReceivePromise->reject(e); - const error::Error e(error::ErrorCode::USB_TRANSFER, 41); - inStreamReceivePromise->reject(e); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(e)).Times(2); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(e)).Times(2); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); + ioService_.run(); + } - ioService_.run(); -} + BOOST_FIXTURE_TEST_CASE(Messenger_Send, MessengerUnitTest) + { + Messenger::Pointer themessenger(std::make_shared(ioService_, messageInStream_, messageOutStream_)); -BOOST_FIXTURE_TEST_CASE(Messenger_Send, MessengerUnitTest) -{ - Messenger::Pointer themessenger(std::make_shared(ioService_, messageInStream_, messageOutStream_)); + Message::Pointer message( + std::make_shared(ChannelId::MEDIA_AUDIO, EncryptionType::ENCRYPTED, MessageType::SPECIFIC)); + themessenger->enqueueSend(message, std::move(sendPromise_)); - Message::Pointer message(std::make_shared(ChannelId::MEDIA_AUDIO, EncryptionType::ENCRYPTED, MessageType::SPECIFIC)); - themessenger->enqueueSend(message, std::move(sendPromise_)); + SendPromise::Pointer outStreamSendPromise; + EXPECT_CALL(messageOutStreamMock_, stream(message, _)).WillOnce(SaveArg<1>(&outStreamSendPromise)); - SendPromise::Pointer outStreamSendPromise; - EXPECT_CALL(messageOutStreamMock_, stream(message, _)).WillOnce(SaveArg<1>(&outStreamSendPromise)); + ioService_.run(); + ioService_.reset(); - ioService_.run(); - ioService_.reset(); + EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); - EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); + outStreamSendPromise->resolve(); + ioService_.run(); + } - outStreamSendPromise->resolve(); - ioService_.run(); -} + BOOST_FIXTURE_TEST_CASE(Messenger_OnlyOneSendAtATime, MessengerUnitTest) + { + Messenger::Pointer themessenger(std::make_shared(ioService_, messageInStream_, messageOutStream_)); -BOOST_FIXTURE_TEST_CASE(Messenger_OnlyOneSendAtATime, MessengerUnitTest) -{ - Messenger::Pointer themessenger(std::make_shared(ioService_, messageInStream_, messageOutStream_)); + Message::Pointer message( + std::make_shared(ChannelId::MEDIA_AUDIO, EncryptionType::ENCRYPTED, MessageType::SPECIFIC)); + themessenger->enqueueSend(message, std::move(sendPromise_)); - Message::Pointer message(std::make_shared(ChannelId::MEDIA_AUDIO, EncryptionType::ENCRYPTED, MessageType::SPECIFIC)); - themessenger->enqueueSend(message, std::move(sendPromise_)); + SendPromise::Pointer outStreamSendPromise; + EXPECT_CALL(messageOutStreamMock_, stream(message, _)).Times(2).WillRepeatedly( + SaveArg<1>(&outStreamSendPromise)); - SendPromise::Pointer outStreamSendPromise; - EXPECT_CALL(messageOutStreamMock_, stream(message, _)).Times(2).WillRepeatedly(SaveArg<1>(&outStreamSendPromise)); + ioService_.run(); + ioService_.reset(); - ioService_.run(); - ioService_.reset(); + auto secondSendPromise = SendPromise::defer(ioService_); + secondSendPromise->then(std::bind(&SendPromiseHandlerMock::onResolve, &sendPromiseHandlerMock_), + std::bind(&SendPromiseHandlerMock::onReject, &sendPromiseHandlerMock_, + std::placeholders::_1)); + themessenger->enqueueSend(message, std::move(secondSendPromise)); - auto secondSendPromise = SendPromise::defer(ioService_); - secondSendPromise->then(std::bind(&SendPromiseHandlerMock::onResolve, &sendPromiseHandlerMock_), - std::bind(&SendPromiseHandlerMock::onReject, &sendPromiseHandlerMock_, std::placeholders::_1)); - themessenger->enqueueSend(message, std::move(secondSendPromise)); + ioService_.run(); + ioService_.reset(); - ioService_.run(); - ioService_.reset(); + EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()).Times(2); + outStreamSendPromise->resolve(); + ioService_.run(); + ioService_.reset(); - EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()).Times(2); - outStreamSendPromise->resolve(); - ioService_.run(); - ioService_.reset(); + outStreamSendPromise->resolve(); + ioService_.run(); + } - outStreamSendPromise->resolve(); - ioService_.run(); -} + BOOST_FIXTURE_TEST_CASE(Messenger_SendFailed, MessengerUnitTest) + { + Messenger::Pointer themessenger(std::make_shared(ioService_, messageInStream_, messageOutStream_)); -BOOST_FIXTURE_TEST_CASE(Messenger_SendFailed, MessengerUnitTest) -{ - Messenger::Pointer themessenger(std::make_shared(ioService_, messageInStream_, messageOutStream_)); + Message::Pointer message( + std::make_shared(ChannelId::MEDIA_AUDIO, EncryptionType::ENCRYPTED, MessageType::SPECIFIC)); + themessenger->enqueueSend(message, std::move(sendPromise_)); - Message::Pointer message(std::make_shared(ChannelId::MEDIA_AUDIO, EncryptionType::ENCRYPTED, MessageType::SPECIFIC)); - themessenger->enqueueSend(message, std::move(sendPromise_)); + SendPromise::Pointer outStreamSendPromise; + EXPECT_CALL(messageOutStreamMock_, stream(message, _)).WillOnce(SaveArg<1>(&outStreamSendPromise)); - SendPromise::Pointer outStreamSendPromise; - EXPECT_CALL(messageOutStreamMock_, stream(message, _)).WillOnce(SaveArg<1>(&outStreamSendPromise)); + ioService_.run(); + ioService_.reset(); - ioService_.run(); - ioService_.reset(); + auto secondSendPromise = SendPromise::defer(ioService_); + secondSendPromise->then(std::bind(&SendPromiseHandlerMock::onResolve, &sendPromiseHandlerMock_), + std::bind(&SendPromiseHandlerMock::onReject, &sendPromiseHandlerMock_, + std::placeholders::_1)); + themessenger->enqueueSend(message, std::move(secondSendPromise)); - auto secondSendPromise = SendPromise::defer(ioService_); - secondSendPromise->then(std::bind(&SendPromiseHandlerMock::onResolve, &sendPromiseHandlerMock_), - std::bind(&SendPromiseHandlerMock::onReject, &sendPromiseHandlerMock_, std::placeholders::_1)); - themessenger->enqueueSend(message, std::move(secondSendPromise)); + ioService_.run(); + ioService_.reset(); - ioService_.run(); - ioService_.reset(); + error::Error e(error::ErrorCode::USB_TRANSFER, 67); + outStreamSendPromise->reject(e); - error::Error e(error::ErrorCode::USB_TRANSFER, 67); - outStreamSendPromise->reject(e); + EXPECT_CALL(sendPromiseHandlerMock_, onReject(e)).Times(2); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()).Times(0); + ioService_.run(); + } - EXPECT_CALL(sendPromiseHandlerMock_, onReject(e)).Times(2); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()).Times(0); - ioService_.run(); -} - -} -} + } + } } diff --git a/src/Messenger/ServiceId.cpp b/src/Messenger/ServiceId.cpp new file mode 100644 index 00000000..99e71675 --- /dev/null +++ b/src/Messenger/ServiceId.cpp @@ -0,0 +1,60 @@ +// 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) +// +// 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 . + +#include + +namespace aasdk { + namespace messenger { + std::string serviceIdToString(ServiceId serviceId) { + switch (serviceId) { + case ServiceId::CONTROL: + return "CONTROL"; + case ServiceId::SENSOR: + return "SENSOR"; + case ServiceId::MEDIA_SINK: + return "MEDIA_SINK"; + case ServiceId::INPUT_SOURCE: + return "INPUT_SOURCE"; + case ServiceId::MEDIA_SOURCE: + return "MEDIA_SOURCE"; + case ServiceId::BLUETOOTH: + return "BLUETOOTH"; + case ServiceId::RADIO: + return "RADIO"; + case ServiceId::NAVIGATION_STATUS: + return "NAVIGATION_STATUS"; + case ServiceId::MEDIA_PLAYBACK_STATUS: + return "MEDIA_PLAYBACK_STATUS"; + case ServiceId::PHONE_STATUS: + return "PHONE_STATUS"; + case ServiceId::MEDIA_BROWSER: + return "MEDIA_BROWSER"; + case ServiceId::VENDOR_EXTENSION: + return "VENDOR_EXTENSION"; + case ServiceId::GENERIC_NOTIFICATION: + return "GENERIC_NOTIFICATION"; + case ServiceId::WIFI_PROJECTION: + return "WIFI_PROJECTION"; + case ServiceId::NONE: + return "NONE"; + default: + return "(null)"; + } + } + + } +} diff --git a/src/Messenger/Timestamp.cpp b/src/Messenger/Timestamp.cpp index 14e00be2..211139d3 100644 --- a/src/Messenger/Timestamp.cpp +++ b/src/Messenger/Timestamp.cpp @@ -1,53 +1,45 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include -namespace aasdk -{ -namespace messenger -{ +namespace aasdk::messenger { -Timestamp::Timestamp(ValueType stamp) - : stamp_(stamp) -{ + Timestamp::Timestamp(ValueType stamp) + : stamp_(stamp) { -} + } -Timestamp::Timestamp(const common::DataConstBuffer& buffer) -{ - const ValueType& timestampBig = reinterpret_cast(buffer.cdata[0]); + Timestamp::Timestamp(const common::DataConstBuffer &buffer) { + const ValueType ×tampBig = reinterpret_cast(buffer.cdata[0]); stamp_ = boost::endian::big_to_native(timestampBig); -} + } -common::Data Timestamp::getData() const -{ + common::Data Timestamp::getData() const { const ValueType timestampBig = boost::endian::native_to_big(stamp_); const common::DataConstBuffer timestampBuffer(×tampBig, sizeof(timestampBig)); return common::createData(timestampBuffer); -} + } -Timestamp::ValueType Timestamp::getValue() const -{ + Timestamp::ValueType Timestamp::getValue() const { return stamp_; -} + } } -} + diff --git a/src/TCP/TCPEndpoint.cpp b/src/TCP/TCPEndpoint.cpp index b78c2a9a..15e658d8 100644 --- a/src/TCP/TCPEndpoint.cpp +++ b/src/TCP/TCPEndpoint.cpp @@ -1,73 +1,63 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include -namespace aasdk -{ -namespace tcp -{ +namespace aasdk::tcp { -TCPEndpoint::TCPEndpoint(ITCPWrapper& tcpWrapper, SocketPointer socket) - : tcpWrapper_(tcpWrapper) - , socket_(std::move(socket)) -{ + TCPEndpoint::TCPEndpoint(ITCPWrapper &tcpWrapper, SocketPointer socket) + : tcpWrapper_(tcpWrapper), socket_(std::move(socket)) { -} + } -void TCPEndpoint::send(common::DataConstBuffer buffer, Promise::Pointer promise) -{ + void TCPEndpoint::send(common::DataConstBuffer buffer, Promise::Pointer promise) { tcpWrapper_.asyncWrite(*socket_, std::move(buffer), std::bind(&TCPEndpoint::asyncOperationHandler, this->shared_from_this(), std::placeholders::_1, std::placeholders::_2, std::move(promise))); -} + } -void TCPEndpoint::receive(common::DataBuffer buffer, Promise::Pointer promise) -{ + void TCPEndpoint::receive(common::DataBuffer buffer, Promise::Pointer promise) { tcpWrapper_.asyncRead(*socket_, std::move(buffer), std::bind(&TCPEndpoint::asyncOperationHandler, this->shared_from_this(), std::placeholders::_1, std::placeholders::_2, std::move(promise))); -} + } -void TCPEndpoint::stop() -{ + void TCPEndpoint::stop() { tcpWrapper_.close(*socket_); -} - -void TCPEndpoint::asyncOperationHandler(const boost::system::error_code& ec, size_t bytesTransferred, Promise::Pointer promise) -{ - if(!ec) - { - promise->resolve(bytesTransferred); - } - else - { - auto error = ec == boost::asio::error::operation_aborted ? error::Error(error::ErrorCode::OPERATION_ABORTED) : error::Error(error::ErrorCode::TCP_TRANSFER, static_cast(ec.value())); - promise->reject(error); + } + + void TCPEndpoint::asyncOperationHandler(const boost::system::error_code &ec, size_t bytesTransferred, + Promise::Pointer promise) { + if (!ec) { + promise->resolve(bytesTransferred); + } else { + auto error = ec == boost::asio::error::operation_aborted ? error::Error(error::ErrorCode::OPERATION_ABORTED) + : error::Error(error::ErrorCode::TCP_TRANSFER, + static_cast(ec.value())); + promise->reject(error); } -} + } } -} + diff --git a/src/TCP/TCPEndpoint.ut.cpp b/src/TCP/TCPEndpoint.ut.cpp index 56baf7c9..2ecbdbe6 100644 --- a/src/TCP/TCPEndpoint.ut.cpp +++ b/src/TCP/TCPEndpoint.ut.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -22,109 +21,106 @@ #include -namespace aasdk -{ -namespace tcp -{ -namespace ut -{ - -using ::testing::_; -using ::testing::SaveArg; - -class TCPEndpointUnitTest -{ -protected: - TCPEndpointUnitTest() - : socket_(std::make_shared(ioService_)) - , promise_(ITCPEndpoint::Promise::defer(ioService_)) - { - promise_->then(std::bind(&TCPEndpointPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), - std::bind(&TCPEndpointPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); - } +namespace aasdk { + namespace tcp { + namespace ut { - TCPWrapperMock tcpWrapperMock_; - TCPEndpointPromiseHandlerMock promiseHandlerMock_; - boost::asio::io_service ioService_; - ITCPEndpoint::SocketPointer socket_; - ITCPEndpoint::Promise::Pointer promise_; -}; + using ::testing::_; + using ::testing::SaveArg; -BOOST_FIXTURE_TEST_CASE(TCPEndpoint_Receive, TCPEndpointUnitTest) -{ - auto tcpEndpoint = std::make_shared(tcpWrapperMock_, std::move(socket_)); + class TCPEndpointUnitTest { + protected: + TCPEndpointUnitTest() + : socket_(std::make_shared(ioService_)), + promise_(ITCPEndpoint::Promise::defer(ioService_)) { + promise_->then( + std::bind(&TCPEndpointPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), + std::bind(&TCPEndpointPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); + } - common::DataBuffer buffer; - ITCPWrapper::Handler handler; - EXPECT_CALL(tcpWrapperMock_, asyncRead(_, _, _)).WillOnce(DoAll(SaveArg<1>(&buffer), SaveArg<2>(&handler))); + TCPWrapperMock tcpWrapperMock_; + TCPEndpointPromiseHandlerMock promiseHandlerMock_; + boost::asio::io_service ioService_; + ITCPEndpoint::SocketPointer socket_; + ITCPEndpoint::Promise::Pointer promise_; + }; - common::Data actualData(100, 0); - tcpEndpoint->receive(common::DataBuffer(actualData), std::move(promise_)); + BOOST_FIXTURE_TEST_CASE(TCPEndpoint_Receive, TCPEndpointUnitTest) + { + auto tcpEndpoint = std::make_shared(tcpWrapperMock_, std::move(socket_)); - const common::Data expectedData(actualData.size(), 0x5F); - std::copy(expectedData.begin(), expectedData.end(), buffer.data); + common::DataBuffer buffer; + ITCPWrapper::Handler handler; + EXPECT_CALL(tcpWrapperMock_, asyncRead(_, _, _)).WillOnce(DoAll(SaveArg<1>(&buffer), SaveArg<2>(&handler))); - EXPECT_CALL(promiseHandlerMock_, onResolve(expectedData.size())); - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - handler(boost::system::error_code(), expectedData.size()); + common::Data actualData(100, 0); + tcpEndpoint->receive(common::DataBuffer(actualData), std::move(promise_)); - ioService_.run(); + const common::Data expectedData(actualData.size(), 0x5F); + std::copy(expectedData.begin(), expectedData.end(), buffer.data); - BOOST_CHECK_EQUAL_COLLECTIONS(actualData.begin(), actualData.end(), expectedData.begin(), expectedData.end()); -} + EXPECT_CALL(promiseHandlerMock_, onResolve(expectedData.size())); + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + handler(boost::system::error_code(), expectedData.size()); -BOOST_FIXTURE_TEST_CASE(TCPEndpoint_ReceiveError, TCPEndpointUnitTest) -{ - auto tcpEndpoint = std::make_shared(tcpWrapperMock_, std::move(socket_)); + ioService_.run(); - common::DataBuffer buffer; - ITCPWrapper::Handler handler; - EXPECT_CALL(tcpWrapperMock_, asyncRead(_, _, _)).WillOnce(DoAll(SaveArg<1>(&buffer), SaveArg<2>(&handler))); + BOOST_CHECK_EQUAL_COLLECTIONS(actualData.begin(), actualData.end(), expectedData.begin(), expectedData.end()); + } - common::Data actualData(100, 0); - tcpEndpoint->receive(common::DataBuffer(actualData), std::move(promise_)); + BOOST_FIXTURE_TEST_CASE(TCPEndpoint_ReceiveError, TCPEndpointUnitTest) + { + auto tcpEndpoint = std::make_shared(tcpWrapperMock_, std::move(socket_)); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::TCP_TRANSFER, boost::asio::error::bad_descriptor))); - handler(boost::asio::error::bad_descriptor, 0); + common::DataBuffer buffer; + ITCPWrapper::Handler handler; + EXPECT_CALL(tcpWrapperMock_, asyncRead(_, _, _)).WillOnce(DoAll(SaveArg<1>(&buffer), SaveArg<2>(&handler))); - ioService_.run(); -} + common::Data actualData(100, 0); + tcpEndpoint->receive(common::DataBuffer(actualData), std::move(promise_)); -BOOST_FIXTURE_TEST_CASE(TCPEndpoint_Send, TCPEndpointUnitTest) -{ - auto tcpEndpoint = std::make_shared(tcpWrapperMock_, std::move(socket_)); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, + onReject(error::Error(error::ErrorCode::TCP_TRANSFER, boost::asio::error::bad_descriptor))); + handler(boost::asio::error::bad_descriptor, 0); - common::Data actualData(100, 0); - common::DataConstBuffer buffer(actualData); - ITCPWrapper::Handler handler; - EXPECT_CALL(tcpWrapperMock_, asyncWrite(_, buffer, _)).WillOnce(SaveArg<2>(&handler)); - tcpEndpoint->send(common::DataConstBuffer(actualData), std::move(promise_)); + ioService_.run(); + } - EXPECT_CALL(promiseHandlerMock_, onResolve(actualData.size())); - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - handler(boost::system::error_code(), actualData.size()); + BOOST_FIXTURE_TEST_CASE(TCPEndpoint_Send, TCPEndpointUnitTest) + { + auto tcpEndpoint = std::make_shared(tcpWrapperMock_, std::move(socket_)); - ioService_.run(); -} + common::Data actualData(100, 0); + common::DataConstBuffer buffer(actualData); + ITCPWrapper::Handler handler; + EXPECT_CALL(tcpWrapperMock_, asyncWrite(_, buffer, _)).WillOnce(SaveArg<2>(&handler)); + tcpEndpoint->send(common::DataConstBuffer(actualData), std::move(promise_)); -BOOST_FIXTURE_TEST_CASE(TCPEndpoint_SendError, TCPEndpointUnitTest) -{ - auto tcpEndpoint = std::make_shared(tcpWrapperMock_, std::move(socket_)); + EXPECT_CALL(promiseHandlerMock_, onResolve(actualData.size())); + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + handler(boost::system::error_code(), actualData.size()); - common::Data actualData(100, 0); - common::DataConstBuffer buffer(actualData); - ITCPWrapper::Handler handler; - EXPECT_CALL(tcpWrapperMock_, asyncWrite(_, buffer, _)).WillOnce(SaveArg<2>(&handler)); - tcpEndpoint->send(common::DataConstBuffer(actualData), std::move(promise_)); + ioService_.run(); + } - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::OPERATION_ABORTED))); - handler(boost::asio::error::operation_aborted, 0); + BOOST_FIXTURE_TEST_CASE(TCPEndpoint_SendError, TCPEndpointUnitTest) + { + auto tcpEndpoint = std::make_shared(tcpWrapperMock_, std::move(socket_)); - ioService_.run(); -} + common::Data actualData(100, 0); + common::DataConstBuffer buffer(actualData); + ITCPWrapper::Handler handler; + EXPECT_CALL(tcpWrapperMock_, asyncWrite(_, buffer, _)).WillOnce(SaveArg<2>(&handler)); + tcpEndpoint->send(common::DataConstBuffer(actualData), std::move(promise_)); -} -} + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::OPERATION_ABORTED))); + handler(boost::asio::error::operation_aborted, 0); + + ioService_.run(); + } + + } + } } diff --git a/src/TCP/TCPWrapper.cpp b/src/TCP/TCPWrapper.cpp index ae35cb38..5ff59a03 100644 --- a/src/TCP/TCPWrapper.cpp +++ b/src/TCP/TCPWrapper.cpp @@ -1,59 +1,54 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include -namespace aasdk -{ -namespace tcp -{ +namespace aasdk { + namespace tcp { -void TCPWrapper::asyncWrite(boost::asio::ip::tcp::socket& socket, common::DataConstBuffer buffer, Handler handler) -{ - boost::asio::async_write(socket, boost::asio::buffer(buffer.cdata, buffer.size), std::move(handler)); -} + void TCPWrapper::asyncWrite(boost::asio::ip::tcp::socket &socket, common::DataConstBuffer buffer, Handler handler) { + boost::asio::async_write(socket, boost::asio::buffer(buffer.cdata, buffer.size), std::move(handler)); + } -void TCPWrapper::asyncRead(boost::asio::ip::tcp::socket& socket, common::DataBuffer buffer, Handler handler) -{ - socket.async_receive(boost::asio::buffer(buffer.data, buffer.size), std::move(handler)); -} + void TCPWrapper::asyncRead(boost::asio::ip::tcp::socket &socket, common::DataBuffer buffer, Handler handler) { + socket.async_receive(boost::asio::buffer(buffer.data, buffer.size), std::move(handler)); + } -void TCPWrapper::close(boost::asio::ip::tcp::socket& socket) -{ - boost::system::error_code ec; - socket.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec); - socket.close(ec); -} + void TCPWrapper::close(boost::asio::ip::tcp::socket &socket) { + boost::system::error_code ec; + socket.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec); + socket.close(ec); + } -void TCPWrapper::asyncConnect(boost::asio::ip::tcp::socket& socket, const std::string& hostname, uint16_t port, ConnectHandler handler) -{ - socket.async_connect(boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(hostname), port), std::move(handler)); -} + void TCPWrapper::asyncConnect(boost::asio::ip::tcp::socket &socket, const std::string &hostname, uint16_t port, + ConnectHandler handler) { + socket.async_connect(boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(hostname), port), + std::move(handler)); + } -boost::system::error_code TCPWrapper::connect(boost::asio::ip::tcp::socket& socket, const std::string& hostname, uint16_t port) -{ - boost::system::error_code ec; - socket.set_option(boost::asio::ip::tcp::no_delay(true), ec); - socket.connect(boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(hostname), port), ec); - return ec; -} + boost::system::error_code + TCPWrapper::connect(boost::asio::ip::tcp::socket &socket, const std::string &hostname, uint16_t port) { + boost::system::error_code ec; + socket.set_option(boost::asio::ip::tcp::no_delay(true), ec); + socket.connect(boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(hostname), port), ec); + return ec; + } -} + } } diff --git a/src/Transport/DataSink.cpp b/src/Transport/DataSink.cpp index f8891c7d..51e6363e 100644 --- a/src/Transport/DataSink.cpp +++ b/src/Transport/DataSink.cpp @@ -1,73 +1,63 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include #include -namespace aasdk -{ -namespace transport -{ +namespace aasdk { + namespace transport { -DataSink::DataSink() - : data_(common::cStaticDataSize) -{ -} + DataSink::DataSink() + : data_(common::cStaticDataSize) { + } -common::DataBuffer DataSink::fill() -{ - const auto offset = data_.size(); - data_.resize(data_.size() + cChunkSize); + common::DataBuffer DataSink::fill() { + const auto offset = data_.size(); + data_.resize(data_.size() + cChunkSize); - auto ptr = data_.is_linearized() ? &data_[offset] : data_.linearize() + offset; - return common::DataBuffer(ptr, cChunkSize); -} + auto ptr = data_.is_linearized() ? &data_[offset] : data_.linearize() + offset; + return common::DataBuffer(ptr, cChunkSize); + } -void DataSink::commit(common::Data::size_type size) -{ - if(size > cChunkSize) - { + void DataSink::commit(common::Data::size_type size) { + if (size > cChunkSize) { throw error::Error(error::ErrorCode::DATA_SINK_COMMIT_OVERFLOW); - } + } - data_.erase_end((cChunkSize - size)); -} + data_.erase_end((cChunkSize - size)); + } -common::Data::size_type DataSink::getAvailableSize() -{ - return data_.size(); -} + common::Data::size_type DataSink::getAvailableSize() { + return data_.size(); + } -common::Data DataSink::consume(common::Data::size_type size) -{ - if(size > data_.size()) - { + common::Data DataSink::consume(common::Data::size_type size) { + if (size > data_.size()) { throw error::Error(error::ErrorCode::DATA_SINK_CONSUME_UNDERFLOW); - } + } - common::Data data(size, 0); - std::copy(data_.begin(), data_.begin() + size, data.begin()); - data_.erase_begin(size); + common::Data data(size, 0); + std::copy(data_.begin(), data_.begin() + size, data.begin()); + data_.erase_begin(size); - return data; -} + return data; + } -} + } } diff --git a/src/Transport/SSLWrapper.cpp b/src/Transport/SSLWrapper.cpp index f07f9837..a7d042a5 100644 --- a/src/Transport/SSLWrapper.cpp +++ b/src/Transport/SSLWrapper.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -24,176 +23,151 @@ #include #include -namespace aasdk -{ -namespace transport -{ - -SSLWrapper::SSLWrapper() -{ - SSL_library_init(); - SSL_load_error_strings(); - ERR_load_BIO_strings(); - OpenSSL_add_all_algorithms(); -} +namespace aasdk { + namespace transport { + + SSLWrapper::SSLWrapper() { + SSL_library_init(); + SSL_load_error_strings(); + ERR_load_BIO_strings(); + OpenSSL_add_all_algorithms(); + } + + SSLWrapper::~SSLWrapper() { -SSLWrapper::~SSLWrapper() -{ - FIPS_mode_set(0); - ENGINE_cleanup(); - CONF_modules_unload(1); - EVP_cleanup(); - CRYPTO_cleanup_all_ex_data(); + #ifdef FIPS_mode_set + FIPS_mode_set(0); // FIPS_mode_set removed in later versions of OpenSSL. + #endif + ENGINE_cleanup(); + CONF_modules_unload(1); + EVP_cleanup(); + CRYPTO_cleanup_all_ex_data(); #if (OPENSSL_VERSION_NUMBER < 0x10100000L) - ERR_remove_state(0); + ERR_remove_state(0); #endif - ERR_free_strings(); - ERR_load_crypto_strings(); - ERR_load_ERR_strings(); -} + ERR_free_strings(); + ERR_load_crypto_strings(); + ERR_load_ERR_strings(); + } -X509* SSLWrapper::readCertificate(const std::string& certificate) -{ - auto bio = BIO_new_mem_buf(certificate.c_str(), certificate.size()); - X509* x509Certificate = PEM_read_bio_X509_AUX(bio, nullptr, nullptr, nullptr); - BIO_free(bio); + X509 *SSLWrapper::readCertificate(const std::string &certificate) { + auto bio = BIO_new_mem_buf(certificate.c_str(), certificate.size()); + X509 *x509Certificate = PEM_read_bio_X509_AUX(bio, nullptr, nullptr, nullptr); + BIO_free(bio); - return x509Certificate; -} + return x509Certificate; + } -EVP_PKEY* SSLWrapper::readPrivateKey(const std::string& privateKey) -{ - auto bio = BIO_new_mem_buf(privateKey.c_str(), privateKey.size()); - auto result = PEM_read_bio_PrivateKey (bio, nullptr, nullptr, nullptr); - BIO_free(bio); + EVP_PKEY *SSLWrapper::readPrivateKey(const std::string &privateKey) { + auto bio = BIO_new_mem_buf(privateKey.c_str(), privateKey.size()); + auto result = PEM_read_bio_PrivateKey(bio, nullptr, nullptr, nullptr); + BIO_free(bio); - return result; -} + return result; + } -const SSL_METHOD* SSLWrapper::getMethod() -{ + const SSL_METHOD *SSLWrapper::getMethod() { #if (OPENSSL_VERSION_NUMBER < 0x10100000L) - return TLSv1_2_client_method(); + return TLSv1_2_client_method(); #else - return TLS_client_method(); + return TLS_client_method(); #endif -} + } -SSL_CTX* SSLWrapper::createContext(const SSL_METHOD* method) -{ - return SSL_CTX_new(method); -} + SSL_CTX *SSLWrapper::createContext(const SSL_METHOD *method) { + return SSL_CTX_new(method); + } -bool SSLWrapper::useCertificate(SSL_CTX* context, X509* certificate) -{ - return SSL_CTX_use_certificate(context, certificate) == 1; -} + bool SSLWrapper::useCertificate(SSL_CTX *context, X509 *certificate) { + return SSL_CTX_use_certificate(context, certificate) == 1; + } -bool SSLWrapper::usePrivateKey(SSL_CTX* context, EVP_PKEY* privateKey) -{ - return SSL_CTX_use_PrivateKey(context, privateKey) == 1; -} + bool SSLWrapper::usePrivateKey(SSL_CTX *context, EVP_PKEY *privateKey) { + return SSL_CTX_use_PrivateKey(context, privateKey) == 1; + } -SSL* SSLWrapper::createInstance(SSL_CTX* context) -{ - return SSL_new(context); -} + SSL *SSLWrapper::createInstance(SSL_CTX *context) { + return SSL_new(context); + } -bool SSLWrapper::checkPrivateKey(SSL* ssl) -{ - return SSL_check_private_key(ssl) == 1; -} + bool SSLWrapper::checkPrivateKey(SSL *ssl) { + return SSL_check_private_key(ssl) == 1; + } -std::pair SSLWrapper::createBIOs() -{ - auto readBIO = BIO_new(BIO_s_mem()); - auto writeBIO = BIO_new(BIO_s_mem()); - return std::make_pair(readBIO, writeBIO); -} + std::pair SSLWrapper::createBIOs() { + auto readBIO = BIO_new(BIO_s_mem()); + auto writeBIO = BIO_new(BIO_s_mem()); + return std::make_pair(readBIO, writeBIO); + } -void SSLWrapper::setBIOs(SSL* ssl, const BIOs& bIOs, size_t maxBufferSize) -{ - SSL_set_bio(ssl, bIOs.first, bIOs.second); - BIO_set_write_buf_size(bIOs.first, maxBufferSize); - BIO_set_write_buf_size(bIOs.second, maxBufferSize); -} + void SSLWrapper::setBIOs(SSL *ssl, const BIOs &bIOs, size_t maxBufferSize) { + SSL_set_bio(ssl, bIOs.first, bIOs.second); + BIO_set_write_buf_size(bIOs.first, maxBufferSize); + BIO_set_write_buf_size(bIOs.second, maxBufferSize); + } -void SSLWrapper::setConnectState(SSL* ssl) -{ - SSL_set_connect_state(ssl); - SSL_set_verify(ssl, SSL_VERIFY_NONE, nullptr); -} + void SSLWrapper::setConnectState(SSL *ssl) { + SSL_set_connect_state(ssl); + SSL_set_verify(ssl, SSL_VERIFY_NONE, nullptr); + } -int SSLWrapper::doHandshake(SSL* ssl) -{ - auto result = SSL_do_handshake(ssl); - auto errorCode = SSL_get_error(ssl, result); + int SSLWrapper::doHandshake(SSL *ssl) { + auto result = SSL_do_handshake(ssl); + auto errorCode = SSL_get_error(ssl, result); - return errorCode; -} + return errorCode; + } -void SSLWrapper::free(SSL* ssl) -{ - SSL_free(ssl); -} + void SSLWrapper::free(SSL *ssl) { + SSL_free(ssl); + } -void SSLWrapper::free(SSL_CTX* context) -{ - SSL_CTX_free(context); -} + void SSLWrapper::free(SSL_CTX *context) { + SSL_CTX_free(context); + } -void SSLWrapper::free(BIO* bio) -{ - BIO_free(bio); -} + void SSLWrapper::free(BIO *bio) { + BIO_free(bio); + } -void SSLWrapper::free(X509* certificate) -{ - X509_free(certificate); -} + void SSLWrapper::free(X509 *certificate) { + X509_free(certificate); + } -void SSLWrapper::free(EVP_PKEY* privateKey) -{ - EVP_PKEY_free(privateKey); -} + void SSLWrapper::free(EVP_PKEY *privateKey) { + EVP_PKEY_free(privateKey); + } -size_t SSLWrapper::bioCtrlPending(BIO* b) -{ - return BIO_ctrl_pending(b); -} + size_t SSLWrapper::bioCtrlPending(BIO *b) { + return BIO_ctrl_pending(b); + } -int SSLWrapper::bioRead(BIO *b, void *data, int len) -{ - return BIO_read(b, data, len); -} + int SSLWrapper::bioRead(BIO *b, void *data, int len) { + return BIO_read(b, data, len); + } -int SSLWrapper::bioWrite(BIO *b, const void *data, int len) -{ - return BIO_write(b, data, len); -} + int SSLWrapper::bioWrite(BIO *b, const void *data, int len) { + return BIO_write(b, data, len); + } -int SSLWrapper::getAvailableBytes(const SSL* ssl) -{ - return SSL_pending(ssl); -} + int SSLWrapper::getAvailableBytes(const SSL *ssl) { + return SSL_pending(ssl); + } -int SSLWrapper::sslRead(SSL *ssl, void *buf, int num) -{ - return SSL_read(ssl, buf, num); -} + int SSLWrapper::sslRead(SSL *ssl, void *buf, int num) { + return SSL_read(ssl, buf, num); + } -int SSLWrapper::sslWrite(SSL *ssl, const void *buf, int num) -{ - return SSL_write(ssl, buf, num); -} + int SSLWrapper::sslWrite(SSL *ssl, const void *buf, int num) { + return SSL_write(ssl, buf, num); + } -int SSLWrapper::getError(SSL* ssl, int returnCode) -{ - while (auto err = ERR_get_error()) { + int SSLWrapper::getError(SSL *ssl, int returnCode) { + while (auto err = ERR_get_error()) { AASDK_LOG(error) << "[SSLWrapper] SSL Error " << ERR_error_string(err, NULL); + } + return SSL_get_error(ssl, returnCode); } - return SSL_get_error(ssl, returnCode); -} -} + } } diff --git a/src/Transport/TCPTransport.cpp b/src/Transport/TCPTransport.cpp index 3a6a3429..0bb6af11 100644 --- a/src/Transport/TCPTransport.cpp +++ b/src/Transport/TCPTransport.cpp @@ -1,86 +1,73 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include -namespace aasdk -{ -namespace transport -{ +namespace aasdk { + namespace transport { -TCPTransport::TCPTransport(boost::asio::io_service& ioService, tcp::ITCPEndpoint::Pointer tcpEndpoint) - : Transport(ioService) - , tcpEndpoint_(std::move(tcpEndpoint)) -{ + TCPTransport::TCPTransport(boost::asio::io_service &ioService, tcp::ITCPEndpoint::Pointer tcpEndpoint) + : Transport(ioService), tcpEndpoint_(std::move(tcpEndpoint)) { -} + } -void TCPTransport::enqueueReceive(common::DataBuffer buffer) -{ - auto receivePromise = tcp::ITCPEndpoint::Promise::defer(receiveStrand_); - receivePromise->then([this, self = this->shared_from_this()](auto bytesTransferred) { - this->receiveHandler(bytesTransferred); - }, - [this, self = this->shared_from_this()](auto e) { - this->rejectReceivePromises(e); - }); + void TCPTransport::enqueueReceive(common::DataBuffer buffer) { + auto receivePromise = tcp::ITCPEndpoint::Promise::defer(receiveStrand_); + receivePromise->then([this, self = this->shared_from_this()](auto bytesTransferred) { + this->receiveHandler(bytesTransferred); + }, + [this, self = this->shared_from_this()](auto e) { + this->rejectReceivePromises(e); + }); - tcpEndpoint_->receive(buffer, std::move(receivePromise)); -} + tcpEndpoint_->receive(buffer, std::move(receivePromise)); + } -void TCPTransport::enqueueSend(SendQueue::iterator queueElement) -{ - auto sendPromise = tcp::ITCPEndpoint::Promise::defer(sendStrand_); + void TCPTransport::enqueueSend(SendQueue::iterator queueElement) { + auto sendPromise = tcp::ITCPEndpoint::Promise::defer(sendStrand_); - sendPromise->then([this, self = this->shared_from_this(), queueElement](auto) { - this->sendHandler(queueElement, error::Error()); - }, - [this, self = this->shared_from_this(), queueElement](auto e) { - this->sendHandler(queueElement, e); - }); + sendPromise->then([this, self = this->shared_from_this(), queueElement](auto) { + this->sendHandler(queueElement, error::Error()); + }, + [this, self = this->shared_from_this(), queueElement](auto e) { + this->sendHandler(queueElement, e); + }); - tcpEndpoint_->send(common::DataConstBuffer(queueElement->first), std::move(sendPromise)); -} + tcpEndpoint_->send(common::DataConstBuffer(queueElement->first), std::move(sendPromise)); + } -void TCPTransport::stop() -{ - tcpEndpoint_->stop(); -} + void TCPTransport::stop() { + tcpEndpoint_->stop(); + } -void TCPTransport::sendHandler(SendQueue::iterator queueElement, const error::Error& e) -{ - if(!e) - { + void TCPTransport::sendHandler(SendQueue::iterator queueElement, const error::Error &e) { + if (!e) { queueElement->second->resolve(); - } - else - { + } else { queueElement->second->reject(e); - } + } - sendQueue_.erase(queueElement); + sendQueue_.erase(queueElement); - if(!sendQueue_.empty()) - { + if (!sendQueue_.empty()) { this->enqueueSend(sendQueue_.begin()); + } } -} -} + } } diff --git a/src/Transport/TCPTransport.ut.cpp b/src/Transport/TCPTransport.ut.cpp index eb6b9c7c..d9c74e52 100644 --- a/src/Transport/TCPTransport.ut.cpp +++ b/src/Transport/TCPTransport.ut.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -23,255 +22,261 @@ #include -namespace aasdk -{ -namespace transport -{ -namespace ut -{ - -using ::testing::ReturnRef; -using ::testing::SaveArg; -using ::testing::_; -using ::testing::AtLeast; - -class TCPTransportUnitTest -{ -protected: - TCPTransportUnitTest() - : receivePromise_(ITransport::ReceivePromise::defer(ioService_)) - , sendPromise_(ITransport::SendPromise::defer(ioService_)) - , tcpEndpoint_(&tcpEndpointMock_, [](auto*) {}) - { - receivePromise_->then(std::bind(&TransportReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, std::placeholders::_1), - std::bind(&TransportReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, std::placeholders::_1)); - - sendPromise_->then(std::bind(&TransportSendPromiseHandlerMock::onResolve, &sendPromiseHandlerMock_), - std::bind(&TransportSendPromiseHandlerMock::onReject, &sendPromiseHandlerMock_, std::placeholders::_1)); - } +namespace aasdk { + namespace transport { + namespace ut { + + using ::testing::ReturnRef; + using ::testing::SaveArg; + using ::testing::_; + using ::testing::AtLeast; + + class TCPTransportUnitTest { + protected: + TCPTransportUnitTest() + : receivePromise_(ITransport::ReceivePromise::defer(ioService_)), + sendPromise_(ITransport::SendPromise::defer(ioService_)), tcpEndpoint_(&tcpEndpointMock_, [](auto *) {}) { + receivePromise_->then(std::bind(&TransportReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, + std::placeholders::_1), + std::bind(&TransportReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, + std::placeholders::_1)); + + sendPromise_->then(std::bind(&TransportSendPromiseHandlerMock::onResolve, &sendPromiseHandlerMock_), + std::bind(&TransportSendPromiseHandlerMock::onReject, &sendPromiseHandlerMock_, + std::placeholders::_1)); + } + + boost::asio::io_service ioService_; + tcp::ut::TCPEndpointMock tcpEndpointMock_; + TransportReceivePromiseHandlerMock receivePromiseHandlerMock_; + ITransport::ReceivePromise::Pointer receivePromise_; + TransportSendPromiseHandlerMock sendPromiseHandlerMock_; + ITransport::SendPromise::Pointer sendPromise_; + tcp::ITCPEndpoint::Pointer tcpEndpoint_; + }; + + BOOST_FIXTURE_TEST_CASE(TCPTransport_ReceiveAtOnce, TCPTransportUnitTest) + { + const size_t receiveSize = 100; + + tcp::ITCPEndpoint::Promise::Pointer tcpEndpointPromise; + common::DataBuffer dataBuffer; + EXPECT_CALL(tcpEndpointMock_, receive(_, _)).WillOnce( + DoAll(SaveArg<0>(&dataBuffer), SaveArg<1>(&tcpEndpointPromise))); + + auto transport(std::make_shared(ioService_, tcpEndpoint_)); + transport->receive(receiveSize, std::move(receivePromise_)); + ioService_.run(); + ioService_.reset(); - boost::asio::io_service ioService_; - tcp::ut::TCPEndpointMock tcpEndpointMock_; - TransportReceivePromiseHandlerMock receivePromiseHandlerMock_; - ITransport::ReceivePromise::Pointer receivePromise_; - TransportSendPromiseHandlerMock sendPromiseHandlerMock_; - ITransport::SendPromise::Pointer sendPromise_; - tcp::ITCPEndpoint::Pointer tcpEndpoint_; -}; - -BOOST_FIXTURE_TEST_CASE(TCPTransport_ReceiveAtOnce, TCPTransportUnitTest) -{ - const size_t receiveSize = 100; - - tcp::ITCPEndpoint::Promise::Pointer tcpEndpointPromise; - common::DataBuffer dataBuffer; - EXPECT_CALL(tcpEndpointMock_, receive(_, _)).WillOnce(DoAll(SaveArg<0>(&dataBuffer), SaveArg<1>(&tcpEndpointPromise))); - - auto transport(std::make_shared(ioService_, tcpEndpoint_)); - transport->receive(receiveSize, std::move(receivePromise_)); - ioService_.run(); - ioService_.reset(); - - BOOST_TEST(dataBuffer.size >= receiveSize); - common::Data expectedData(receiveSize, 0x5E); - std::copy(expectedData.begin(), expectedData.end(), dataBuffer.data); - - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(expectedData)).Times(1); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); - tcpEndpointPromise->resolve(receiveSize); - ioService_.run(); -} + BOOST_TEST(dataBuffer.size >= receiveSize); + common::Data expectedData(receiveSize, 0x5E); + std::copy(expectedData.begin(), expectedData.end(), dataBuffer.data); -BOOST_FIXTURE_TEST_CASE(TCPTransport_ReceiveInPieces, TCPTransportUnitTest) -{ - const size_t stepsCount = 100; - const size_t receiveSize = 1000 * stepsCount; - const size_t stepSize = receiveSize / stepsCount; + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(expectedData)).Times(1); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); + tcpEndpointPromise->resolve(receiveSize); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(TCPTransport_ReceiveInPieces, TCPTransportUnitTest) + { + const size_t stepsCount = 100; + const size_t receiveSize = 1000 * stepsCount; + const size_t stepSize = receiveSize / stepsCount; - auto transport(std::make_shared(ioService_, tcpEndpoint_)); - transport->receive(receiveSize, std::move(receivePromise_)); + auto transport(std::make_shared(ioService_, tcpEndpoint_)); + transport->receive(receiveSize, std::move(receivePromise_)); - tcp::ITCPEndpoint::Promise::Pointer tcpEndpointPromise; - common::DataBuffer dataBuffer; - EXPECT_CALL(tcpEndpointMock_, receive(_, _)).Times(AtLeast(stepsCount)) + tcp::ITCPEndpoint::Promise::Pointer tcpEndpointPromise; + common::DataBuffer dataBuffer; + EXPECT_CALL(tcpEndpointMock_, receive(_, _)).Times(AtLeast(stepsCount)) .WillRepeatedly(DoAll(SaveArg<0>(&dataBuffer), SaveArg<1>(&tcpEndpointPromise))); - common::Data expectedData(receiveSize, 0x5E); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(expectedData)).Times(1); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); + common::Data expectedData(receiveSize, 0x5E); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(expectedData)).Times(1); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); + + for (size_t i = 0; i < stepsCount; ++i) { + ioService_.run(); + ioService_.reset(); - for(size_t i = 0; i < stepsCount; ++i) - { + BOOST_TEST(dataBuffer.size >= stepSize); + + std::fill(dataBuffer.data, dataBuffer.data + stepSize, 0x5E); + tcpEndpointPromise->resolve(stepSize); + ioService_.run(); + } + } + + BOOST_FIXTURE_TEST_CASE(TCPTransport_OnlyOneReceiveAtATime, TCPTransportUnitTest) + { + const size_t receiveSize = 200; + const size_t stepSize = receiveSize / 2; + + tcp::ITCPEndpoint::Promise::Pointer tcpEndpointPromise; + common::DataBuffer dataBuffer; + EXPECT_CALL(tcpEndpointMock_, receive(_, _)).WillOnce( + DoAll(SaveArg<0>(&dataBuffer), SaveArg<1>(&tcpEndpointPromise))); + + auto transport(std::make_shared(ioService_, tcpEndpoint_)); + transport->receive(stepSize, std::move(receivePromise_)); ioService_.run(); ioService_.reset(); - BOOST_TEST(dataBuffer.size >= stepSize); - + BOOST_TEST(dataBuffer.size >= receiveSize); std::fill(dataBuffer.data, dataBuffer.data + stepSize, 0x5E); - tcpEndpointPromise->resolve(stepSize); + std::fill(dataBuffer.data + stepSize, dataBuffer.data + receiveSize, 0x5F); + + auto secondPromise = ITransport::ReceivePromise::defer(ioService_); + TransportReceivePromiseHandlerMock secondPromiseHandlerMock; + secondPromise->then( + std::bind(&TransportReceivePromiseHandlerMock::onResolve, &secondPromiseHandlerMock, std::placeholders::_1), + std::bind(&TransportReceivePromiseHandlerMock::onReject, &secondPromiseHandlerMock, std::placeholders::_1)); + + transport->receive(stepSize, std::move(secondPromise)); ioService_.run(); - } -} + ioService_.reset(); -BOOST_FIXTURE_TEST_CASE(TCPTransport_OnlyOneReceiveAtATime, TCPTransportUnitTest) -{ - const size_t receiveSize = 200; - const size_t stepSize = receiveSize / 2; + common::Data expectedData(stepSize, 0x5E); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(expectedData)).Times(1); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); - tcp::ITCPEndpoint::Promise::Pointer tcpEndpointPromise; - common::DataBuffer dataBuffer; - EXPECT_CALL(tcpEndpointMock_, receive(_, _)).WillOnce(DoAll(SaveArg<0>(&dataBuffer), SaveArg<1>(&tcpEndpointPromise))); + common::Data secondExpectedData(stepSize, 0x5F); + EXPECT_CALL(secondPromiseHandlerMock, onResolve(secondExpectedData)).Times(1); + EXPECT_CALL(secondPromiseHandlerMock, onReject(_)).Times(0); - auto transport(std::make_shared(ioService_, tcpEndpoint_)); - transport->receive(stepSize, std::move(receivePromise_)); - ioService_.run(); - ioService_.reset(); + tcpEndpointPromise->resolve(receiveSize); + ioService_.run(); + } - BOOST_TEST(dataBuffer.size >= receiveSize); - std::fill(dataBuffer.data, dataBuffer.data + stepSize, 0x5E); - std::fill(dataBuffer.data + stepSize, dataBuffer.data + receiveSize, 0x5F); + BOOST_FIXTURE_TEST_CASE(TCPTransport_ReceiveError, TCPTransportUnitTest) + { + tcp::ITCPEndpoint::Promise::Pointer tcpEndpointPromise; + EXPECT_CALL(tcpEndpointMock_, receive(_, _)).WillOnce(SaveArg<1>(&tcpEndpointPromise)); - auto secondPromise = ITransport::ReceivePromise::defer(ioService_); - TransportReceivePromiseHandlerMock secondPromiseHandlerMock; - secondPromise->then(std::bind(&TransportReceivePromiseHandlerMock::onResolve, &secondPromiseHandlerMock, std::placeholders::_1), - std::bind(&TransportReceivePromiseHandlerMock::onReject, &secondPromiseHandlerMock, std::placeholders::_1)); + auto transport(std::make_shared(ioService_, tcpEndpoint_)); + transport->receive(1000, std::move(receivePromise_)); - transport->receive(stepSize, std::move(secondPromise)); - ioService_.run(); - ioService_.reset(); + auto secondPromise = ITransport::ReceivePromise::defer(ioService_); + secondPromise->then(std::bind(&TransportReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, + std::placeholders::_1), + std::bind(&TransportReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, + std::placeholders::_1)); - common::Data expectedData(stepSize, 0x5E); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(expectedData)).Times(1); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); + transport->receive(1000, std::move(secondPromise)); + ioService_.run(); + ioService_.reset(); - common::Data secondExpectedData(stepSize, 0x5F); - EXPECT_CALL(secondPromiseHandlerMock, onResolve(secondExpectedData)).Times(1); - EXPECT_CALL(secondPromiseHandlerMock, onReject(_)).Times(0); + const error::Error e(error::ErrorCode::TCP_TRANSFER, 11); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(e)).Times(2); - tcpEndpointPromise->resolve(receiveSize); - ioService_.run(); -} + tcpEndpointPromise->reject(e); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(TCPTransport_Send, TCPTransportUnitTest) + { + tcp::ITCPEndpoint::Promise::Pointer tcpEndpointPromise; + common::DataConstBuffer buffer; + EXPECT_CALL(tcpEndpointMock_, send(_, _)).WillOnce(DoAll(SaveArg<0>(&buffer), SaveArg<1>(&tcpEndpointPromise))); + + auto transport(std::make_shared(ioService_, tcpEndpoint_)); + const common::Data expectedData(1000, 0x5E); + transport->send(expectedData, std::move(sendPromise_)); + ioService_.run(); + ioService_.reset(); + + common::Data actualData(buffer.cdata, buffer.cdata + buffer.size); + BOOST_CHECK_EQUAL_COLLECTIONS(actualData.begin(), actualData.end(), expectedData.begin(), expectedData.end()); -BOOST_FIXTURE_TEST_CASE(TCPTransport_ReceiveError, TCPTransportUnitTest) -{ - tcp::ITCPEndpoint::Promise::Pointer tcpEndpointPromise; - EXPECT_CALL(tcpEndpointMock_, receive(_, _)).WillOnce(SaveArg<1>(&tcpEndpointPromise)); + EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); + tcpEndpointPromise->resolve(expectedData.size()); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(TCPTransport_OnlyOneSendAtATime, TCPTransportUnitTest) + { + tcp::ITCPEndpoint::Promise::Pointer tcpEndpointPromise; + common::DataConstBuffer buffer; + EXPECT_CALL(tcpEndpointMock_, send(_, _)).Times(2).WillRepeatedly( + DoAll(SaveArg<0>(&buffer), SaveArg<1>(&tcpEndpointPromise))); + + auto transport(std::make_shared(ioService_, tcpEndpoint_)); + const common::Data expectedData1(1000, 0x5E); + transport->send(expectedData1, std::move(sendPromise_)); + ioService_.run(); + ioService_.reset(); - auto transport(std::make_shared(ioService_, tcpEndpoint_)); - transport->receive(1000, std::move(receivePromise_)); + const common::Data expectedData2(3000, 0x5F); - auto secondPromise = ITransport::ReceivePromise::defer(ioService_); - secondPromise->then(std::bind(&TransportReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, std::placeholders::_1), - std::bind(&TransportReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, std::placeholders::_1)); + auto secondSendPromise = ITransport::SendPromise::defer(ioService_); + TransportSendPromiseHandlerMock secondSendPromiseHandlerMock; + secondSendPromise->then(std::bind(&TransportSendPromiseHandlerMock::onResolve, &secondSendPromiseHandlerMock), + std::bind(&TransportSendPromiseHandlerMock::onReject, &secondSendPromiseHandlerMock, + std::placeholders::_1)); - transport->receive(1000, std::move(secondPromise)); - ioService_.run(); - ioService_.reset(); + transport->send(expectedData2, std::move(secondSendPromise)); + ioService_.run(); + ioService_.reset(); - const error::Error e(error::ErrorCode::TCP_TRANSFER, 11); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(e)).Times(2); + common::Data actualData1(buffer.cdata, buffer.cdata + buffer.size); + BOOST_CHECK_EQUAL_COLLECTIONS(actualData1.begin(), actualData1.end(), expectedData1.begin(), + expectedData1.end()); - tcpEndpointPromise->reject(e); - ioService_.run(); -} + EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); + tcpEndpointPromise->resolve(expectedData1.size()); + ioService_.run(); + ioService_.reset(); -BOOST_FIXTURE_TEST_CASE(TCPTransport_Send, TCPTransportUnitTest) -{ - tcp::ITCPEndpoint::Promise::Pointer tcpEndpointPromise; - common::DataConstBuffer buffer; - EXPECT_CALL(tcpEndpointMock_, send(_, _)).WillOnce(DoAll(SaveArg<0>(&buffer), SaveArg<1>(&tcpEndpointPromise))); - - auto transport(std::make_shared(ioService_, tcpEndpoint_)); - const common::Data expectedData(1000, 0x5E); - transport->send(expectedData, std::move(sendPromise_)); - ioService_.run(); - ioService_.reset(); - - common::Data actualData(buffer.cdata, buffer.cdata + buffer.size); - BOOST_CHECK_EQUAL_COLLECTIONS(actualData.begin(), actualData.end(), expectedData.begin(), expectedData.end()); - - EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); - tcpEndpointPromise->resolve(expectedData.size()); - ioService_.run(); -} + common::Data actualData2(buffer.cdata, buffer.cdata + buffer.size); + BOOST_CHECK_EQUAL_COLLECTIONS(actualData2.begin(), actualData2.end(), expectedData2.begin(), + expectedData2.end()); -BOOST_FIXTURE_TEST_CASE(TCPTransport_OnlyOneSendAtATime, TCPTransportUnitTest) -{ - tcp::ITCPEndpoint::Promise::Pointer tcpEndpointPromise; - common::DataConstBuffer buffer; - EXPECT_CALL(tcpEndpointMock_, send(_, _)).Times(2).WillRepeatedly(DoAll(SaveArg<0>(&buffer), SaveArg<1>(&tcpEndpointPromise))); - - auto transport(std::make_shared(ioService_, tcpEndpoint_)); - const common::Data expectedData1(1000, 0x5E); - transport->send(expectedData1, std::move(sendPromise_)); - ioService_.run(); - ioService_.reset(); - - const common::Data expectedData2(3000, 0x5F); - - auto secondSendPromise = ITransport::SendPromise::defer(ioService_); - TransportSendPromiseHandlerMock secondSendPromiseHandlerMock; - secondSendPromise->then(std::bind(&TransportSendPromiseHandlerMock::onResolve, &secondSendPromiseHandlerMock), - std::bind(&TransportSendPromiseHandlerMock::onReject, &secondSendPromiseHandlerMock, std::placeholders::_1)); - - transport->send(expectedData2, std::move(secondSendPromise)); - ioService_.run(); - ioService_.reset(); - - common::Data actualData1(buffer.cdata, buffer.cdata + buffer.size); - BOOST_CHECK_EQUAL_COLLECTIONS(actualData1.begin(), actualData1.end(), expectedData1.begin(), expectedData1.end()); - - EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); - tcpEndpointPromise->resolve(expectedData1.size()); - ioService_.run(); - ioService_.reset(); - - common::Data actualData2(buffer.cdata, buffer.cdata + buffer.size); - BOOST_CHECK_EQUAL_COLLECTIONS(actualData2.begin(), actualData2.end(), expectedData2.begin(), expectedData2.end()); - - EXPECT_CALL(secondSendPromiseHandlerMock, onReject(_)).Times(0); - EXPECT_CALL(secondSendPromiseHandlerMock, onResolve()); - tcpEndpointPromise->resolve(expectedData2.size()); - ioService_.run(); -} + EXPECT_CALL(secondSendPromiseHandlerMock, onReject(_)).Times(0); + EXPECT_CALL(secondSendPromiseHandlerMock, onResolve()); + tcpEndpointPromise->resolve(expectedData2.size()); + ioService_.run(); + } -BOOST_FIXTURE_TEST_CASE(TCPTransport_SendError, TCPTransportUnitTest) -{ - tcp::ITCPEndpoint::Promise::Pointer tcpEndpointPromise; - EXPECT_CALL(tcpEndpointMock_, send(_, _)).Times(2).WillRepeatedly(SaveArg<1>(&tcpEndpointPromise)); - - auto transport(std::make_shared(ioService_, tcpEndpoint_)); - const common::Data expectedData1(1000, 0x5E); - transport->send(expectedData1, std::move(sendPromise_)); - ioService_.run(); - ioService_.reset(); - - auto secondSendPromise = ITransport::SendPromise::defer(ioService_); - TransportSendPromiseHandlerMock secondSendPromiseHandlerMock; - secondSendPromise->then(std::bind(&TransportSendPromiseHandlerMock::onResolve, &secondSendPromiseHandlerMock), - std::bind(&TransportSendPromiseHandlerMock::onReject, &secondSendPromiseHandlerMock, std::placeholders::_1)); - - const common::Data expectedData2(3000, 0x5F); - transport->send(expectedData2, std::move(secondSendPromise)); - ioService_.run(); - ioService_.reset(); - - const error::Error e(error::ErrorCode::USB_TRANSFER, 15); - EXPECT_CALL(sendPromiseHandlerMock_, onReject(e)); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()).Times(0); - tcpEndpointPromise->reject(e); - ioService_.run(); - ioService_.reset(); - - EXPECT_CALL(secondSendPromiseHandlerMock, onReject(_)).Times(0); - EXPECT_CALL(secondSendPromiseHandlerMock, onResolve()); - tcpEndpointPromise->resolve(expectedData2.size()); - ioService_.run(); -} + BOOST_FIXTURE_TEST_CASE(TCPTransport_SendError, TCPTransportUnitTest) + { + tcp::ITCPEndpoint::Promise::Pointer tcpEndpointPromise; + EXPECT_CALL(tcpEndpointMock_, send(_, _)).Times(2).WillRepeatedly(SaveArg<1>(&tcpEndpointPromise)); -} -} + auto transport(std::make_shared(ioService_, tcpEndpoint_)); + const common::Data expectedData1(1000, 0x5E); + transport->send(expectedData1, std::move(sendPromise_)); + ioService_.run(); + ioService_.reset(); + + auto secondSendPromise = ITransport::SendPromise::defer(ioService_); + TransportSendPromiseHandlerMock secondSendPromiseHandlerMock; + secondSendPromise->then(std::bind(&TransportSendPromiseHandlerMock::onResolve, &secondSendPromiseHandlerMock), + std::bind(&TransportSendPromiseHandlerMock::onReject, &secondSendPromiseHandlerMock, + std::placeholders::_1)); + + const common::Data expectedData2(3000, 0x5F); + transport->send(expectedData2, std::move(secondSendPromise)); + ioService_.run(); + ioService_.reset(); + + const error::Error e(error::ErrorCode::USB_TRANSFER, 15); + EXPECT_CALL(sendPromiseHandlerMock_, onReject(e)); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()).Times(0); + tcpEndpointPromise->reject(e); + ioService_.run(); + ioService_.reset(); + + EXPECT_CALL(secondSendPromiseHandlerMock, onReject(_)).Times(0); + EXPECT_CALL(secondSendPromiseHandlerMock, onResolve()); + tcpEndpointPromise->resolve(expectedData2.size()); + ioService_.run(); + } + + } + } } diff --git a/src/Transport/Transport.cpp b/src/Transport/Transport.cpp index ac170c98..5a6cd61b 100644 --- a/src/Transport/Transport.cpp +++ b/src/Transport/Transport.cpp @@ -1,107 +1,98 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . +#include #include -namespace aasdk -{ -namespace transport -{ +namespace aasdk { + namespace transport { -Transport::Transport(boost::asio::io_service& ioService) - : receiveStrand_(ioService) - , sendStrand_(ioService) -{} + Transport::Transport(boost::asio::io_service &ioService) + : receiveStrand_(ioService), sendStrand_(ioService) {} -void Transport::receive(size_t size, ReceivePromise::Pointer promise) -{ - receiveStrand_.dispatch([this, self = this->shared_from_this(), size, promise = std::move(promise)]() mutable { + void Transport::receive(size_t size, ReceivePromise::Pointer promise) { + AASDK_LOG(debug) << "[Transport] receive()"; + receiveStrand_.dispatch([this, self = this->shared_from_this(), size, promise = std::move(promise)]() mutable { receiveQueue_.emplace_back(std::make_pair(size, std::move(promise))); - if(receiveQueue_.size() == 1) - { - try - { - this->distributeReceivedData(); - } - catch(const error::Error& e) - { - this->rejectReceivePromises(e); - } + if (receiveQueue_.size() == 1) { + try { + AASDK_LOG(debug) << "[Transport] Distribute received data."; + this->distributeReceivedData(); + } + catch (const error::Error &e) { + // Due to the design of the messaging system, we don't really need to raise an error - debug it is + AASDK_LOG(debug) << "[Transport] Reject receive promise."; + this->rejectReceivePromises(e); + } } - }); -} + }); + } -void Transport::receiveHandler(size_t bytesTransferred) -{ - try - { + void Transport::receiveHandler(size_t bytesTransferred) { + try { + AASDK_LOG(debug) << "[Transport] receiveHandler()"; receivedDataSink_.commit(bytesTransferred); this->distributeReceivedData(); - } - catch(const error::Error& e) - { + } + catch (const error::Error &e) { + // Due to the design of the messaging system, we don't really need to raise an error - debug it is + AASDK_LOG(debug) << "[Transport] Rejecting promise."; this->rejectReceivePromises(e); + } } -} -void Transport::distributeReceivedData() -{ - for(auto queueElement = receiveQueue_.begin(); queueElement != receiveQueue_.end();) - { - if(receivedDataSink_.getAvailableSize() < queueElement->first) - { - auto buffer = receivedDataSink_.fill(); - this->enqueueReceive(std::move(buffer)); + void Transport::distributeReceivedData() { + AASDK_LOG(debug) << "[Transport] distributeReceivedData()"; + for (auto queueElement = receiveQueue_.begin(); queueElement != receiveQueue_.end();) { + if (receivedDataSink_.getAvailableSize() < queueElement->first) { + AASDK_LOG(debug) << "[Transport] Receiving from buffer."; + auto buffer = receivedDataSink_.fill(); + this->enqueueReceive(std::move(buffer)); - break; - } - else - { - auto data(receivedDataSink_.consume(queueElement->first)); - queueElement->second->resolve(std::move(data)); - queueElement = receiveQueue_.erase(queueElement); + break; + } else { + auto data(receivedDataSink_.consume(queueElement->first)); + AASDK_LOG(debug) << "[Transport] Resolve and clear message."; + queueElement->second->resolve(std::move(data)); + queueElement = receiveQueue_.erase(queueElement); } + } } -} -void Transport::rejectReceivePromises(const error::Error& e) -{ - for(auto& queueElement : receiveQueue_) - { + void Transport::rejectReceivePromises(const error::Error &e) { + for (auto &queueElement: receiveQueue_) { queueElement.second->reject(e); - } + } - receiveQueue_.clear(); -} + receiveQueue_.clear(); + } -void Transport::send(common::Data data, SendPromise::Pointer promise) -{ - sendStrand_.dispatch([this, self = this->shared_from_this(), data = std::move(data), promise = std::move(promise)]() mutable { - sendQueue_.emplace_back(std::make_pair(std::move(data), std::move(promise))); + void Transport::send(common::Data data, SendPromise::Pointer promise) { + sendStrand_.dispatch( + [this, self = this->shared_from_this(), data = std::move(data), promise = std::move(promise)]() mutable { + sendQueue_.emplace_back(std::make_pair(std::move(data), std::move(promise))); - if(sendQueue_.size() == 1) - { - this->enqueueSend(sendQueue_.begin()); - } - }); -} + if (sendQueue_.size() == 1) { + this->enqueueSend(sendQueue_.begin()); + } + }); + } -} + } } diff --git a/src/Transport/USBTransport.cpp b/src/Transport/USBTransport.cpp index 922fc217..636a8545 100644 --- a/src/Transport/USBTransport.cpp +++ b/src/Transport/USBTransport.cpp @@ -1,94 +1,82 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include -namespace aasdk -{ -namespace transport -{ +namespace aasdk { + namespace transport { -USBTransport::USBTransport(boost::asio::io_service& ioService, usb::IAOAPDevice::Pointer aoapDevice) - : Transport(ioService) - , aoapDevice_(std::move(aoapDevice)) -{} + USBTransport::USBTransport(boost::asio::io_service &ioService, usb::IAOAPDevice::Pointer aoapDevice) + : Transport(ioService), aoapDevice_(std::move(aoapDevice)) {} -void USBTransport::enqueueReceive(common::DataBuffer buffer) -{ - auto usbEndpointPromise = usb::IUSBEndpoint::Promise::defer(receiveStrand_); - usbEndpointPromise->then([this, self = this->shared_from_this()](auto bytesTransferred) { - this->receiveHandler(bytesTransferred); - }, - [this, self = this->shared_from_this()](auto e) { - this->rejectReceivePromises(e); - }); + void USBTransport::enqueueReceive(common::DataBuffer buffer) { + auto usbEndpointPromise = usb::IUSBEndpoint::Promise::defer(receiveStrand_); + usbEndpointPromise->then([this, self = this->shared_from_this()](auto bytesTransferred) { + this->receiveHandler(bytesTransferred); + }, + [this, self = this->shared_from_this()](auto e) { + this->rejectReceivePromises(e); + }); - aoapDevice_->getInEndpoint().bulkTransfer(buffer, cReceiveTimeoutMs, std::move(usbEndpointPromise)); -} + aoapDevice_->getInEndpoint().bulkTransfer(buffer, cReceiveTimeoutMs, std::move(usbEndpointPromise)); + } -void USBTransport::enqueueSend(SendQueue::iterator queueElement) -{ - this->doSend(queueElement, 0); -} + void USBTransport::enqueueSend(SendQueue::iterator queueElement) { + this->doSend(queueElement, 0); + } -void USBTransport::doSend(SendQueue::iterator queueElement, common::Data::size_type offset) -{ - auto usbEndpointPromise = usb::IUSBEndpoint::Promise::defer(sendStrand_); - usbEndpointPromise->then([this, self = this->shared_from_this(), queueElement, offset](size_t bytesTransferred) mutable { + void USBTransport::doSend(SendQueue::iterator queueElement, common::Data::size_type offset) { + auto usbEndpointPromise = usb::IUSBEndpoint::Promise::defer(sendStrand_); + usbEndpointPromise->then( + [this, self = this->shared_from_this(), queueElement, offset](size_t bytesTransferred) mutable { this->sendHandler(queueElement, offset, bytesTransferred); - }, - [this, self = this->shared_from_this(), queueElement](const error::Error& e) mutable { + }, + [this, self = this->shared_from_this(), queueElement](const error::Error &e) mutable { queueElement->second->reject(e); sendQueue_.erase(queueElement); - if(!sendQueue_.empty()) - { - this->doSend(sendQueue_.begin(), 0); + if (!sendQueue_.empty()) { + this->doSend(sendQueue_.begin(), 0); } - }); + }); - aoapDevice_->getOutEndpoint().bulkTransfer(common::DataBuffer(queueElement->first, offset), cSendTimeoutMs, std::move(usbEndpointPromise)); -} + aoapDevice_->getOutEndpoint().bulkTransfer(common::DataBuffer(queueElement->first, offset), cSendTimeoutMs, + std::move(usbEndpointPromise)); + } -void USBTransport::sendHandler(SendQueue::iterator queueElement, common::Data::size_type offset, size_t bytesTransferred) -{ - if(offset + bytesTransferred < queueElement->first.size()) - { + void USBTransport::sendHandler(SendQueue::iterator queueElement, common::Data::size_type offset, + size_t bytesTransferred) { + if (offset + bytesTransferred < queueElement->first.size()) { this->doSend(queueElement, offset + bytesTransferred); - } - else - { + } else { queueElement->second->resolve(); sendQueue_.erase(queueElement); - if(!sendQueue_.empty()) - { - this->doSend(sendQueue_.begin(), 0); + if (!sendQueue_.empty()) { + this->doSend(sendQueue_.begin(), 0); } + } } -} -void USBTransport::stop() -{ - aoapDevice_->getInEndpoint().cancelTransfers(); - aoapDevice_->getOutEndpoint().cancelTransfers(); -} + void USBTransport::stop() { + aoapDevice_->getInEndpoint().cancelTransfers(); + aoapDevice_->getOutEndpoint().cancelTransfers(); + } -} + } } diff --git a/src/Transport/USBTransport.ut.cpp b/src/Transport/USBTransport.ut.cpp index e8a63138..da358a31 100644 --- a/src/Transport/USBTransport.ut.cpp +++ b/src/Transport/USBTransport.ut.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -24,291 +23,301 @@ #include -namespace aasdk -{ -namespace transport -{ -namespace ut -{ - -using ::testing::ReturnRef; -using ::testing::SaveArg; -using ::testing::_; -using ::testing::AtLeast; - -class USBTransportUnitTest -{ -protected: - USBTransportUnitTest() - : receivePromise_(ITransport::ReceivePromise::defer(ioService_)) - , sendPromise_(ITransport::SendPromise::defer(ioService_)) - , aoapDevice_(&aoapDeviceMock_, [](auto*) {}) - { - EXPECT_CALL(aoapDeviceMock_, getInEndpoint()).WillRepeatedly(ReturnRef(inEndpointMock_)); - EXPECT_CALL(aoapDeviceMock_, getOutEndpoint()).WillRepeatedly(ReturnRef(outEndpointMock_)); - - receivePromise_->then(std::bind(&TransportReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, std::placeholders::_1), - std::bind(&TransportReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, std::placeholders::_1)); - - sendPromise_->then(std::bind(&TransportSendPromiseHandlerMock::onResolve, &sendPromiseHandlerMock_), - std::bind(&TransportSendPromiseHandlerMock::onReject, &sendPromiseHandlerMock_, std::placeholders::_1)); - } +namespace aasdk { + namespace transport { + namespace ut { + + using ::testing::ReturnRef; + using ::testing::SaveArg; + using ::testing::_; + using ::testing::AtLeast; + + class USBTransportUnitTest { + protected: + USBTransportUnitTest() + : receivePromise_(ITransport::ReceivePromise::defer(ioService_)), + sendPromise_(ITransport::SendPromise::defer(ioService_)), aoapDevice_(&aoapDeviceMock_, [](auto *) {}) { + EXPECT_CALL(aoapDeviceMock_, getInEndpoint()).WillRepeatedly(ReturnRef(inEndpointMock_)); + EXPECT_CALL(aoapDeviceMock_, getOutEndpoint()).WillRepeatedly(ReturnRef(outEndpointMock_)); + + receivePromise_->then(std::bind(&TransportReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, + std::placeholders::_1), + std::bind(&TransportReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, + std::placeholders::_1)); + + sendPromise_->then(std::bind(&TransportSendPromiseHandlerMock::onResolve, &sendPromiseHandlerMock_), + std::bind(&TransportSendPromiseHandlerMock::onReject, &sendPromiseHandlerMock_, + std::placeholders::_1)); + } + + boost::asio::io_service ioService_; + usb::ut::USBEndpointMock inEndpointMock_; + usb::ut::USBEndpointMock outEndpointMock_; + TransportReceivePromiseHandlerMock receivePromiseHandlerMock_; + ITransport::ReceivePromise::Pointer receivePromise_; + TransportSendPromiseHandlerMock sendPromiseHandlerMock_; + ITransport::SendPromise::Pointer sendPromise_; + usb::ut::AOAPDeviceMock aoapDeviceMock_; + usb::IAOAPDevice::Pointer aoapDevice_; + }; + + BOOST_FIXTURE_TEST_CASE(USBTransport_ReceiveAtOnce, USBTransportUnitTest) + { + const size_t receiveSize = 100; + + usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; + common::DataBuffer dataBuffer; + EXPECT_CALL(inEndpointMock_, bulkTransfer(_, _, _)).WillOnce( + DoAll(SaveArg<0>(&dataBuffer), SaveArg<2>(&usbEndpointPromise))); + + USBTransport::Pointer transport(std::make_shared(ioService_, aoapDevice_)); + transport->receive(receiveSize, std::move(receivePromise_)); + ioService_.run(); + ioService_.reset(); - boost::asio::io_service ioService_; - usb::ut::USBEndpointMock inEndpointMock_; - usb::ut::USBEndpointMock outEndpointMock_; - TransportReceivePromiseHandlerMock receivePromiseHandlerMock_; - ITransport::ReceivePromise::Pointer receivePromise_; - TransportSendPromiseHandlerMock sendPromiseHandlerMock_; - ITransport::SendPromise::Pointer sendPromise_; - usb::ut::AOAPDeviceMock aoapDeviceMock_; - usb::IAOAPDevice::Pointer aoapDevice_; -}; - -BOOST_FIXTURE_TEST_CASE(USBTransport_ReceiveAtOnce, USBTransportUnitTest) -{ - const size_t receiveSize = 100; - - usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; - common::DataBuffer dataBuffer; - EXPECT_CALL(inEndpointMock_, bulkTransfer(_, _, _)).WillOnce(DoAll(SaveArg<0>(&dataBuffer), SaveArg<2>(&usbEndpointPromise))); - - USBTransport::Pointer transport(std::make_shared(ioService_, aoapDevice_)); - transport->receive(receiveSize, std::move(receivePromise_)); - ioService_.run(); - ioService_.reset(); - - BOOST_TEST(dataBuffer.size >= receiveSize); - common::Data expectedData(receiveSize, 0x5E); - std::copy(expectedData.begin(), expectedData.end(), dataBuffer.data); - - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(expectedData)).Times(1); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); - usbEndpointPromise->resolve(receiveSize); - ioService_.run(); -} + BOOST_TEST(dataBuffer.size >= receiveSize); + common::Data expectedData(receiveSize, 0x5E); + std::copy(expectedData.begin(), expectedData.end(), dataBuffer.data); -BOOST_FIXTURE_TEST_CASE(USBTransport_ReceiveInPieces, USBTransportUnitTest) -{ - const size_t stepsCount = 100; - const size_t receiveSize = 1000 * stepsCount; - const size_t stepSize = receiveSize / stepsCount; + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(expectedData)).Times(1); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); + usbEndpointPromise->resolve(receiveSize); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(USBTransport_ReceiveInPieces, USBTransportUnitTest) + { + const size_t stepsCount = 100; + const size_t receiveSize = 1000 * stepsCount; + const size_t stepSize = receiveSize / stepsCount; - USBTransport::Pointer transport(std::make_shared(ioService_, std::move(aoapDevice_))); - transport->receive(receiveSize, std::move(receivePromise_)); + USBTransport::Pointer transport(std::make_shared(ioService_, std::move(aoapDevice_))); + transport->receive(receiveSize, std::move(receivePromise_)); - usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; - common::DataBuffer dataBuffer; - EXPECT_CALL(inEndpointMock_, bulkTransfer(_, _, _)).Times(AtLeast(stepsCount)) + usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; + common::DataBuffer dataBuffer; + EXPECT_CALL(inEndpointMock_, bulkTransfer(_, _, _)).Times(AtLeast(stepsCount)) .WillRepeatedly(DoAll(SaveArg<0>(&dataBuffer), SaveArg<2>(&usbEndpointPromise))); - common::Data expectedData(receiveSize, 0x5E); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(expectedData)).Times(1); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); + common::Data expectedData(receiveSize, 0x5E); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(expectedData)).Times(1); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); + + for (size_t i = 0; i < stepsCount; ++i) { + ioService_.run(); + ioService_.reset(); + + BOOST_TEST(dataBuffer.size >= stepSize); - for(size_t i = 0; i < stepsCount; ++i) - { + std::fill(dataBuffer.data, dataBuffer.data + stepSize, 0x5E); + usbEndpointPromise->resolve(stepSize); + ioService_.run(); + } + } + + BOOST_FIXTURE_TEST_CASE(USBTransport_OnlyOneReceiveAtATime, USBTransportUnitTest) + { + const size_t receiveSize = 200; + const size_t stepSize = receiveSize / 2; + + usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; + common::DataBuffer dataBuffer; + EXPECT_CALL(inEndpointMock_, bulkTransfer(_, _, _)).WillOnce( + DoAll(SaveArg<0>(&dataBuffer), SaveArg<2>(&usbEndpointPromise))); + + USBTransport::Pointer transport(std::make_shared(ioService_, aoapDevice_)); + transport->receive(stepSize, std::move(receivePromise_)); ioService_.run(); ioService_.reset(); - BOOST_TEST(dataBuffer.size >= stepSize); - + BOOST_TEST(dataBuffer.size >= receiveSize); std::fill(dataBuffer.data, dataBuffer.data + stepSize, 0x5E); - usbEndpointPromise->resolve(stepSize); + std::fill(dataBuffer.data + stepSize, dataBuffer.data + receiveSize, 0x5F); + + auto secondPromise = ITransport::ReceivePromise::defer(ioService_); + TransportReceivePromiseHandlerMock secondPromiseHandlerMock; + secondPromise->then( + std::bind(&TransportReceivePromiseHandlerMock::onResolve, &secondPromiseHandlerMock, std::placeholders::_1), + std::bind(&TransportReceivePromiseHandlerMock::onReject, &secondPromiseHandlerMock, std::placeholders::_1)); + + transport->receive(stepSize, std::move(secondPromise)); ioService_.run(); - } -} + ioService_.reset(); -BOOST_FIXTURE_TEST_CASE(USBTransport_OnlyOneReceiveAtATime, USBTransportUnitTest) -{ - const size_t receiveSize = 200; - const size_t stepSize = receiveSize / 2; + common::Data expectedData(stepSize, 0x5E); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(expectedData)).Times(1); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); - usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; - common::DataBuffer dataBuffer; - EXPECT_CALL(inEndpointMock_, bulkTransfer(_, _, _)).WillOnce(DoAll(SaveArg<0>(&dataBuffer), SaveArg<2>(&usbEndpointPromise))); + common::Data secondExpectedData(stepSize, 0x5F); + EXPECT_CALL(secondPromiseHandlerMock, onResolve(secondExpectedData)).Times(1); + EXPECT_CALL(secondPromiseHandlerMock, onReject(_)).Times(0); - USBTransport::Pointer transport(std::make_shared(ioService_, aoapDevice_)); - transport->receive(stepSize, std::move(receivePromise_)); - ioService_.run(); - ioService_.reset(); + usbEndpointPromise->resolve(receiveSize); + ioService_.run(); + } - BOOST_TEST(dataBuffer.size >= receiveSize); - std::fill(dataBuffer.data, dataBuffer.data + stepSize, 0x5E); - std::fill(dataBuffer.data + stepSize, dataBuffer.data + receiveSize, 0x5F); + BOOST_FIXTURE_TEST_CASE(USBTransport_ReceiveError, USBTransportUnitTest) + { + usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; + EXPECT_CALL(inEndpointMock_, bulkTransfer(_, _, _)).WillOnce(SaveArg<2>(&usbEndpointPromise)); - auto secondPromise = ITransport::ReceivePromise::defer(ioService_); - TransportReceivePromiseHandlerMock secondPromiseHandlerMock; - secondPromise->then(std::bind(&TransportReceivePromiseHandlerMock::onResolve, &secondPromiseHandlerMock, std::placeholders::_1), - std::bind(&TransportReceivePromiseHandlerMock::onReject, &secondPromiseHandlerMock, std::placeholders::_1)); + USBTransport::Pointer transport(std::make_shared(ioService_, aoapDevice_)); + transport->receive(1000, std::move(receivePromise_)); - transport->receive(stepSize, std::move(secondPromise)); - ioService_.run(); - ioService_.reset(); + auto secondPromise = ITransport::ReceivePromise::defer(ioService_); + secondPromise->then(std::bind(&TransportReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, + std::placeholders::_1), + std::bind(&TransportReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, + std::placeholders::_1)); - common::Data expectedData(stepSize, 0x5E); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(expectedData)).Times(1); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(_)).Times(0); + transport->receive(1000, std::move(secondPromise)); + ioService_.run(); + ioService_.reset(); - common::Data secondExpectedData(stepSize, 0x5F); - EXPECT_CALL(secondPromiseHandlerMock, onResolve(secondExpectedData)).Times(1); - EXPECT_CALL(secondPromiseHandlerMock, onReject(_)).Times(0); + const error::Error e(error::ErrorCode::USB_TRANSFER, 11); + EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(receivePromiseHandlerMock_, onReject(e)).Times(2); - usbEndpointPromise->resolve(receiveSize); - ioService_.run(); -} + usbEndpointPromise->reject(e); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(USBTransport_Send, USBTransportUnitTest) + { + usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; + common::DataBuffer buffer; + EXPECT_CALL(outEndpointMock_, bulkTransfer(_, _, _)).WillOnce( + DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); + + USBTransport::Pointer transport(std::make_shared(ioService_, aoapDevice_)); + const common::Data expectedData(1000, 0x5E); + transport->send(expectedData, std::move(sendPromise_)); + ioService_.run(); + ioService_.reset(); + + common::Data actualData(buffer.data, buffer.data + buffer.size); + BOOST_CHECK_EQUAL_COLLECTIONS(actualData.begin(), actualData.end(), expectedData.begin(), expectedData.end()); + + EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); + usbEndpointPromise->resolve(expectedData.size()); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(USBTransport_SendInPieces, USBTransportUnitTest) + { + usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; + common::DataBuffer buffer; + EXPECT_CALL(outEndpointMock_, bulkTransfer(_, _, _)).Times(2).WillRepeatedly( + DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); + + const common::Data expectedDataPiece1(1000, 0x5E); + const common::Data expectedDataPiece2(2000, 0x5F); + common::Data expectedData(expectedDataPiece1.begin(), expectedDataPiece1.end()); + expectedData.insert(expectedData.end(), expectedDataPiece2.begin(), expectedDataPiece2.end()); + + USBTransport::Pointer transport(std::make_shared(ioService_, aoapDevice_)); + transport->send(expectedData, std::move(sendPromise_)); + ioService_.run(); + ioService_.reset(); + + common::Data actualDataPiece1(buffer.data, buffer.data + buffer.size); + BOOST_CHECK_EQUAL_COLLECTIONS(actualDataPiece1.begin(), actualDataPiece1.end(), expectedData.begin(), + expectedData.end()); + usbEndpointPromise->resolve(expectedDataPiece1.size()); + ioService_.run(); + ioService_.reset(); -BOOST_FIXTURE_TEST_CASE(USBTransport_ReceiveError, USBTransportUnitTest) -{ - usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; - EXPECT_CALL(inEndpointMock_, bulkTransfer(_, _, _)).WillOnce(SaveArg<2>(&usbEndpointPromise)); + common::Data actualDataPiece2(buffer.data, buffer.data + buffer.size); + BOOST_CHECK_EQUAL_COLLECTIONS(actualDataPiece2.begin(), actualDataPiece2.end(), expectedDataPiece2.begin(), + expectedDataPiece2.end()); + usbEndpointPromise->resolve(expectedDataPiece2.size()); - USBTransport::Pointer transport(std::make_shared(ioService_, aoapDevice_)); - transport->receive(1000, std::move(receivePromise_)); + EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(USBTransport_OnlyOneSendAtATime, USBTransportUnitTest) + { + usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; + common::DataBuffer buffer; + EXPECT_CALL(outEndpointMock_, bulkTransfer(_, _, _)).Times(2).WillRepeatedly( + DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); + + USBTransport::Pointer transport(std::make_shared(ioService_, aoapDevice_)); + const common::Data expectedData1(1000, 0x5E); + transport->send(expectedData1, std::move(sendPromise_)); + ioService_.run(); + ioService_.reset(); - auto secondPromise = ITransport::ReceivePromise::defer(ioService_); - secondPromise->then(std::bind(&TransportReceivePromiseHandlerMock::onResolve, &receivePromiseHandlerMock_, std::placeholders::_1), - std::bind(&TransportReceivePromiseHandlerMock::onReject, &receivePromiseHandlerMock_, std::placeholders::_1)); + const common::Data expectedData2(3000, 0x5F); - transport->receive(1000, std::move(secondPromise)); - ioService_.run(); - ioService_.reset(); + auto secondSendPromise = ITransport::SendPromise::defer(ioService_); + TransportSendPromiseHandlerMock secondSendPromiseHandlerMock; + secondSendPromise->then(std::bind(&TransportSendPromiseHandlerMock::onResolve, &secondSendPromiseHandlerMock), + std::bind(&TransportSendPromiseHandlerMock::onReject, &secondSendPromiseHandlerMock, + std::placeholders::_1)); - const error::Error e(error::ErrorCode::USB_TRANSFER, 11); - EXPECT_CALL(receivePromiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(receivePromiseHandlerMock_, onReject(e)).Times(2); + transport->send(expectedData2, std::move(secondSendPromise)); + ioService_.run(); + ioService_.reset(); - usbEndpointPromise->reject(e); - ioService_.run(); -} + common::Data actualData1(buffer.data, buffer.data + buffer.size); + BOOST_CHECK_EQUAL_COLLECTIONS(actualData1.begin(), actualData1.end(), expectedData1.begin(), + expectedData1.end()); -BOOST_FIXTURE_TEST_CASE(USBTransport_Send, USBTransportUnitTest) -{ - usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; - common::DataBuffer buffer; - EXPECT_CALL(outEndpointMock_, bulkTransfer(_, _, _)).WillOnce(DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); - - USBTransport::Pointer transport(std::make_shared(ioService_, aoapDevice_)); - const common::Data expectedData(1000, 0x5E); - transport->send(expectedData, std::move(sendPromise_)); - ioService_.run(); - ioService_.reset(); - - common::Data actualData(buffer.data, buffer.data + buffer.size); - BOOST_CHECK_EQUAL_COLLECTIONS(actualData.begin(), actualData.end(), expectedData.begin(), expectedData.end()); - - EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); - usbEndpointPromise->resolve(expectedData.size()); - ioService_.run(); -} + EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); + usbEndpointPromise->resolve(expectedData1.size()); + ioService_.run(); + ioService_.reset(); -BOOST_FIXTURE_TEST_CASE(USBTransport_SendInPieces, USBTransportUnitTest) -{ - usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; - common::DataBuffer buffer; - EXPECT_CALL(outEndpointMock_, bulkTransfer(_, _, _)).Times(2).WillRepeatedly(DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); - - const common::Data expectedDataPiece1(1000, 0x5E); - const common::Data expectedDataPiece2(2000, 0x5F); - common::Data expectedData(expectedDataPiece1.begin(), expectedDataPiece1.end()); - expectedData.insert(expectedData.end(), expectedDataPiece2.begin(), expectedDataPiece2.end()); - - USBTransport::Pointer transport(std::make_shared(ioService_, aoapDevice_)); - transport->send(expectedData, std::move(sendPromise_)); - ioService_.run(); - ioService_.reset(); - - common::Data actualDataPiece1(buffer.data, buffer.data + buffer.size); - BOOST_CHECK_EQUAL_COLLECTIONS(actualDataPiece1.begin(), actualDataPiece1.end(), expectedData.begin(), expectedData.end()); - usbEndpointPromise->resolve(expectedDataPiece1.size()); - ioService_.run(); - ioService_.reset(); - - common::Data actualDataPiece2(buffer.data, buffer.data + buffer.size); - BOOST_CHECK_EQUAL_COLLECTIONS(actualDataPiece2.begin(), actualDataPiece2.end(), expectedDataPiece2.begin(), expectedDataPiece2.end()); - usbEndpointPromise->resolve(expectedDataPiece2.size()); - - EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); - ioService_.run(); -} + common::Data actualData2(buffer.data, buffer.data + buffer.size); + BOOST_CHECK_EQUAL_COLLECTIONS(actualData2.begin(), actualData2.end(), expectedData2.begin(), + expectedData2.end()); -BOOST_FIXTURE_TEST_CASE(USBTransport_OnlyOneSendAtATime, USBTransportUnitTest) -{ - usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; - common::DataBuffer buffer; - EXPECT_CALL(outEndpointMock_, bulkTransfer(_, _, _)).Times(2).WillRepeatedly(DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); - - USBTransport::Pointer transport(std::make_shared(ioService_, aoapDevice_)); - const common::Data expectedData1(1000, 0x5E); - transport->send(expectedData1, std::move(sendPromise_)); - ioService_.run(); - ioService_.reset(); - - const common::Data expectedData2(3000, 0x5F); - - auto secondSendPromise = ITransport::SendPromise::defer(ioService_); - TransportSendPromiseHandlerMock secondSendPromiseHandlerMock; - secondSendPromise->then(std::bind(&TransportSendPromiseHandlerMock::onResolve, &secondSendPromiseHandlerMock), - std::bind(&TransportSendPromiseHandlerMock::onReject, &secondSendPromiseHandlerMock, std::placeholders::_1)); - - transport->send(expectedData2, std::move(secondSendPromise)); - ioService_.run(); - ioService_.reset(); - - common::Data actualData1(buffer.data, buffer.data + buffer.size); - BOOST_CHECK_EQUAL_COLLECTIONS(actualData1.begin(), actualData1.end(), expectedData1.begin(), expectedData1.end()); - - EXPECT_CALL(sendPromiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()); - usbEndpointPromise->resolve(expectedData1.size()); - ioService_.run(); - ioService_.reset(); - - common::Data actualData2(buffer.data, buffer.data + buffer.size); - BOOST_CHECK_EQUAL_COLLECTIONS(actualData2.begin(), actualData2.end(), expectedData2.begin(), expectedData2.end()); - - EXPECT_CALL(secondSendPromiseHandlerMock, onReject(_)).Times(0); - EXPECT_CALL(secondSendPromiseHandlerMock, onResolve()); - usbEndpointPromise->resolve(expectedData2.size()); - ioService_.run(); -} + EXPECT_CALL(secondSendPromiseHandlerMock, onReject(_)).Times(0); + EXPECT_CALL(secondSendPromiseHandlerMock, onResolve()); + usbEndpointPromise->resolve(expectedData2.size()); + ioService_.run(); + } -BOOST_FIXTURE_TEST_CASE(USBTransport_SendError, USBTransportUnitTest) -{ - usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; - EXPECT_CALL(outEndpointMock_, bulkTransfer(_, _, _)).Times(2).WillRepeatedly(SaveArg<2>(&usbEndpointPromise)); - - USBTransport::Pointer transport(std::make_shared(ioService_, aoapDevice_)); - const common::Data expectedData1(1000, 0x5E); - transport->send(expectedData1, std::move(sendPromise_)); - ioService_.run(); - ioService_.reset(); - - auto secondSendPromise = ITransport::SendPromise::defer(ioService_); - TransportSendPromiseHandlerMock secondSendPromiseHandlerMock; - secondSendPromise->then(std::bind(&TransportSendPromiseHandlerMock::onResolve, &secondSendPromiseHandlerMock), - std::bind(&TransportSendPromiseHandlerMock::onReject, &secondSendPromiseHandlerMock, std::placeholders::_1)); - - const common::Data expectedData2(3000, 0x5F); - transport->send(expectedData2, std::move(secondSendPromise)); - ioService_.run(); - ioService_.reset(); - - const error::Error e(error::ErrorCode::USB_TRANSFER, 15); - EXPECT_CALL(sendPromiseHandlerMock_, onReject(e)); - EXPECT_CALL(sendPromiseHandlerMock_, onResolve()).Times(0); - usbEndpointPromise->reject(e); - ioService_.run(); - ioService_.reset(); - - EXPECT_CALL(secondSendPromiseHandlerMock, onReject(_)).Times(0); - EXPECT_CALL(secondSendPromiseHandlerMock, onResolve()); - usbEndpointPromise->resolve(expectedData2.size()); - ioService_.run(); -} + BOOST_FIXTURE_TEST_CASE(USBTransport_SendError, USBTransportUnitTest) + { + usb::IUSBEndpoint::Promise::Pointer usbEndpointPromise; + EXPECT_CALL(outEndpointMock_, bulkTransfer(_, _, _)).Times(2).WillRepeatedly(SaveArg<2>(&usbEndpointPromise)); -} -} + USBTransport::Pointer transport(std::make_shared(ioService_, aoapDevice_)); + const common::Data expectedData1(1000, 0x5E); + transport->send(expectedData1, std::move(sendPromise_)); + ioService_.run(); + ioService_.reset(); + + auto secondSendPromise = ITransport::SendPromise::defer(ioService_); + TransportSendPromiseHandlerMock secondSendPromiseHandlerMock; + secondSendPromise->then(std::bind(&TransportSendPromiseHandlerMock::onResolve, &secondSendPromiseHandlerMock), + std::bind(&TransportSendPromiseHandlerMock::onReject, &secondSendPromiseHandlerMock, + std::placeholders::_1)); + + const common::Data expectedData2(3000, 0x5F); + transport->send(expectedData2, std::move(secondSendPromise)); + ioService_.run(); + ioService_.reset(); + + const error::Error e(error::ErrorCode::USB_TRANSFER, 15); + EXPECT_CALL(sendPromiseHandlerMock_, onReject(e)); + EXPECT_CALL(sendPromiseHandlerMock_, onResolve()).Times(0); + usbEndpointPromise->reject(e); + ioService_.run(); + ioService_.reset(); + + EXPECT_CALL(secondSendPromiseHandlerMock, onReject(_)).Times(0); + EXPECT_CALL(secondSendPromiseHandlerMock, onResolve()); + usbEndpointPromise->resolve(expectedData2.size()); + ioService_.run(); + } + + } + } } diff --git a/src/USB/AOAPDevice.cpp b/src/USB/AOAPDevice.cpp index 9be389c4..c169ab1a 100644 --- a/src/USB/AOAPDevice.cpp +++ b/src/USB/AOAPDevice.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -22,104 +21,89 @@ #include -namespace aasdk -{ -namespace usb -{ - -AOAPDevice::AOAPDevice(IUSBWrapper& usbWrapper, boost::asio::io_service& ioService, DeviceHandle handle, const libusb_interface_descriptor* interfaceDescriptor) - : usbWrapper_(usbWrapper) - , handle_(std::move(handle)) - , interfaceDescriptor_(interfaceDescriptor) -{ - if((interfaceDescriptor->endpoint[0].bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN) - { - inEndpoint_ = std::make_shared(usbWrapper_, ioService, handle_, interfaceDescriptor_->endpoint[0].bEndpointAddress); - outEndpoint_ = std::make_shared(usbWrapper_, ioService, handle_, interfaceDescriptor_->endpoint[1].bEndpointAddress); +namespace aasdk { + namespace usb { + + AOAPDevice::AOAPDevice(IUSBWrapper &usbWrapper, boost::asio::io_service &ioService, DeviceHandle handle, + const libusb_interface_descriptor *interfaceDescriptor) + : usbWrapper_(usbWrapper), handle_(std::move(handle)), interfaceDescriptor_(interfaceDescriptor) { + if ((interfaceDescriptor->endpoint[0].bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN) { + inEndpoint_ = std::make_shared(usbWrapper_, ioService, handle_, + interfaceDescriptor_->endpoint[0].bEndpointAddress); + outEndpoint_ = std::make_shared(usbWrapper_, ioService, handle_, + interfaceDescriptor_->endpoint[1].bEndpointAddress); + } else { + inEndpoint_ = std::make_shared(usbWrapper_, ioService, handle_, + interfaceDescriptor_->endpoint[1].bEndpointAddress); + outEndpoint_ = std::make_shared(usbWrapper_, ioService, handle_, + interfaceDescriptor_->endpoint[0].bEndpointAddress); + } } - else - { - inEndpoint_ = std::make_shared(usbWrapper_, ioService, handle_, interfaceDescriptor_->endpoint[1].bEndpointAddress); - outEndpoint_ = std::make_shared(usbWrapper_, ioService, handle_, interfaceDescriptor_->endpoint[0].bEndpointAddress); - } -} -AOAPDevice::~AOAPDevice() -{ - inEndpoint_->cancelTransfers(); - outEndpoint_->cancelTransfers(); - usbWrapper_.releaseInterface(handle_, interfaceDescriptor_->bInterfaceNumber); -} + AOAPDevice::~AOAPDevice() { + inEndpoint_->cancelTransfers(); + outEndpoint_->cancelTransfers(); + usbWrapper_.releaseInterface(handle_, interfaceDescriptor_->bInterfaceNumber); + } -IUSBEndpoint& AOAPDevice::getInEndpoint() -{ - return *inEndpoint_; -} + IUSBEndpoint &AOAPDevice::getInEndpoint() { + return *inEndpoint_; + } -IUSBEndpoint& AOAPDevice::getOutEndpoint() -{ - return *outEndpoint_; -} + IUSBEndpoint &AOAPDevice::getOutEndpoint() { + return *outEndpoint_; + } -IAOAPDevice::Pointer AOAPDevice::create(IUSBWrapper& usbWrapper, boost::asio::io_service& ioService, DeviceHandle handle) -{ - auto configDescriptorHandle = AOAPDevice::getConfigDescriptor(usbWrapper, handle); - auto interface = AOAPDevice::getInterface(configDescriptorHandle); - auto interfaceDescriptor = AOAPDevice::getInterfaceDescriptor(interface); + IAOAPDevice::Pointer + AOAPDevice::create(IUSBWrapper &usbWrapper, boost::asio::io_service &ioService, DeviceHandle handle) { + auto configDescriptorHandle = AOAPDevice::getConfigDescriptor(usbWrapper, handle); + auto interface = AOAPDevice::getInterface(configDescriptorHandle); + auto interfaceDescriptor = AOAPDevice::getInterfaceDescriptor(interface); - if(interfaceDescriptor->bNumEndpoints < 2) - { + if (interfaceDescriptor->bNumEndpoints < 2) { throw error::Error(error::ErrorCode::USB_INVALID_DEVICE_ENDPOINTS); - } + } - auto result = usbWrapper.claimInterface(handle, interfaceDescriptor->bInterfaceNumber); + auto result = usbWrapper.claimInterface(handle, interfaceDescriptor->bInterfaceNumber); - if(result != 0) - { + if (result != 0) { throw error::Error(error::ErrorCode::USB_CLAIM_INTERFACE, result); - } + } - return std::make_unique(usbWrapper, ioService, std::move(handle), interfaceDescriptor); -} + return std::make_unique(usbWrapper, ioService, std::move(handle), interfaceDescriptor); + } -ConfigDescriptorHandle AOAPDevice::getConfigDescriptor(IUSBWrapper& usbWrapper, DeviceHandle handle) -{ - ConfigDescriptorHandle configDescriptorHandle; - libusb_device* device = usbWrapper.getDevice(handle); + ConfigDescriptorHandle AOAPDevice::getConfigDescriptor(IUSBWrapper &usbWrapper, DeviceHandle handle) { + ConfigDescriptorHandle configDescriptorHandle; + libusb_device *device = usbWrapper.getDevice(handle); - auto result = usbWrapper.getConfigDescriptor(device, 0, configDescriptorHandle); - if(result != 0) - { + auto result = usbWrapper.getConfigDescriptor(device, 0, configDescriptorHandle); + if (result != 0) { throw error::Error(error::ErrorCode::USB_OBTAIN_CONFIG_DESCRIPTOR, result); - } + } - if(configDescriptorHandle == nullptr) - { + if (configDescriptorHandle == nullptr) { throw error::Error(error::ErrorCode::USB_INVALID_CONFIG_DESCRIPTOR, result); - } + } - return configDescriptorHandle; -} + return configDescriptorHandle; + } -const libusb_interface* AOAPDevice::getInterface(const ConfigDescriptorHandle& configDescriptorHandle) -{ - if(configDescriptorHandle->bNumInterfaces == 0) - { + const libusb_interface *AOAPDevice::getInterface(const ConfigDescriptorHandle &configDescriptorHandle) { + if (configDescriptorHandle->bNumInterfaces == 0) { throw error::Error(error::ErrorCode::USB_EMPTY_INTERFACES); - } + } - return &(configDescriptorHandle->interface[0]); -} + return &(configDescriptorHandle->interface[0]); + } -const libusb_interface_descriptor* AOAPDevice::getInterfaceDescriptor(const libusb_interface* interface) -{ - if(interface->num_altsetting == 0) - { + const libusb_interface_descriptor *AOAPDevice::getInterfaceDescriptor(const libusb_interface *interface) { + if (interface->num_altsetting == 0) { throw error::Error(error::ErrorCode::USB_OBTAIN_INTERFACE_DESCRIPTOR); - } + } - return &interface->altsetting[0]; -} + return &interface->altsetting[0]; + } -} + } } diff --git a/src/USB/AOAPDevice.ut.cpp b/src/USB/AOAPDevice.ut.cpp index e8f85d2a..5bb8b4dc 100644 --- a/src/USB/AOAPDevice.ut.cpp +++ b/src/USB/AOAPDevice.ut.cpp @@ -1,77 +1,73 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include #include -namespace aasdk -{ -namespace usb -{ -namespace ut -{ +namespace aasdk { + namespace usb { + namespace ut { -BOOST_AUTO_TEST_CASE(AOAPDevice_OutEndpointFirst) -{ - USBWrapperMock usbWrapperMock; - boost::asio::io_service ioService; - USBWrapperMock::DummyDeviceHandle dummyDeviceHandle; - DeviceHandle deviceHandle(reinterpret_cast(&dummyDeviceHandle), [](auto*) {}); + BOOST_AUTO_TEST_CASE(AOAPDevice_OutEndpointFirst) + { + USBWrapperMock usbWrapperMock; + boost::asio::io_service ioService; + USBWrapperMock::DummyDeviceHandle dummyDeviceHandle; + DeviceHandle deviceHandle(reinterpret_cast(&dummyDeviceHandle), [](auto *) {}); - libusb_endpoint_descriptor endpointDescriptor[2]; - endpointDescriptor[0].bEndpointAddress = LIBUSB_ENDPOINT_OUT + 4; - endpointDescriptor[1].bEndpointAddress = LIBUSB_ENDPOINT_IN + 6; + libusb_endpoint_descriptor endpointDescriptor[2]; + endpointDescriptor[0].bEndpointAddress = LIBUSB_ENDPOINT_OUT + 4; + endpointDescriptor[1].bEndpointAddress = LIBUSB_ENDPOINT_IN + 6; - libusb_interface_descriptor interfaceDescriptor; - interfaceDescriptor.bInterfaceNumber = 55; - interfaceDescriptor.bNumEndpoints = 2; - interfaceDescriptor.endpoint = endpointDescriptor; + libusb_interface_descriptor interfaceDescriptor; + interfaceDescriptor.bInterfaceNumber = 55; + interfaceDescriptor.bNumEndpoints = 2; + interfaceDescriptor.endpoint = endpointDescriptor; - EXPECT_CALL(usbWrapperMock, releaseInterface(deviceHandle, interfaceDescriptor.bInterfaceNumber)); - AOAPDevice aoapDevice(usbWrapperMock, ioService, deviceHandle, &interfaceDescriptor); - BOOST_TEST(endpointDescriptor[0].bEndpointAddress == aoapDevice.getOutEndpoint().getAddress()); - BOOST_TEST(endpointDescriptor[1].bEndpointAddress == aoapDevice.getInEndpoint().getAddress()); -} + EXPECT_CALL(usbWrapperMock, releaseInterface(deviceHandle, interfaceDescriptor.bInterfaceNumber)); + AOAPDevice aoapDevice(usbWrapperMock, ioService, deviceHandle, &interfaceDescriptor); + BOOST_TEST(endpointDescriptor[0].bEndpointAddress == aoapDevice.getOutEndpoint().getAddress()); + BOOST_TEST(endpointDescriptor[1].bEndpointAddress == aoapDevice.getInEndpoint().getAddress()); + } -BOOST_AUTO_TEST_CASE(AOAPDevice_InEndpointFirst) -{ - USBWrapperMock usbWrapperMock; - boost::asio::io_service ioService; - USBWrapperMock::DummyDeviceHandle dummyDeviceHandle; - DeviceHandle deviceHandle(reinterpret_cast(&dummyDeviceHandle), [](auto*) {}); + BOOST_AUTO_TEST_CASE(AOAPDevice_InEndpointFirst) + { + USBWrapperMock usbWrapperMock; + boost::asio::io_service ioService; + USBWrapperMock::DummyDeviceHandle dummyDeviceHandle; + DeviceHandle deviceHandle(reinterpret_cast(&dummyDeviceHandle), [](auto *) {}); - libusb_endpoint_descriptor endpointDescriptor[2]; - endpointDescriptor[0].bEndpointAddress = LIBUSB_ENDPOINT_IN + 4; - endpointDescriptor[1].bEndpointAddress = LIBUSB_ENDPOINT_OUT + 6; + libusb_endpoint_descriptor endpointDescriptor[2]; + endpointDescriptor[0].bEndpointAddress = LIBUSB_ENDPOINT_IN + 4; + endpointDescriptor[1].bEndpointAddress = LIBUSB_ENDPOINT_OUT + 6; - libusb_interface_descriptor interfaceDescriptor; - interfaceDescriptor.bInterfaceNumber = 55; - interfaceDescriptor.bNumEndpoints = 2; - interfaceDescriptor.endpoint = endpointDescriptor; + libusb_interface_descriptor interfaceDescriptor; + interfaceDescriptor.bInterfaceNumber = 55; + interfaceDescriptor.bNumEndpoints = 2; + interfaceDescriptor.endpoint = endpointDescriptor; - EXPECT_CALL(usbWrapperMock, releaseInterface(deviceHandle, interfaceDescriptor.bInterfaceNumber)); - AOAPDevice aoapDevice(usbWrapperMock, ioService, deviceHandle, &interfaceDescriptor); - BOOST_TEST(endpointDescriptor[0].bEndpointAddress == aoapDevice.getInEndpoint().getAddress()); - BOOST_TEST(endpointDescriptor[1].bEndpointAddress == aoapDevice.getOutEndpoint().getAddress()); -} + EXPECT_CALL(usbWrapperMock, releaseInterface(deviceHandle, interfaceDescriptor.bInterfaceNumber)); + AOAPDevice aoapDevice(usbWrapperMock, ioService, deviceHandle, &interfaceDescriptor); + BOOST_TEST(endpointDescriptor[0].bEndpointAddress == aoapDevice.getInEndpoint().getAddress()); + BOOST_TEST(endpointDescriptor[1].bEndpointAddress == aoapDevice.getOutEndpoint().getAddress()); + } -} -} + } + } } diff --git a/src/USB/AccessoryModeProtocolVersionQuery.cpp b/src/USB/AccessoryModeProtocolVersionQuery.cpp index bfd0ece6..82115e02 100644 --- a/src/USB/AccessoryModeProtocolVersionQuery.cpp +++ b/src/USB/AccessoryModeProtocolVersionQuery.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -22,57 +21,49 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -AccessoryModeProtocolVersionQuery::AccessoryModeProtocolVersionQuery(boost::asio::io_service& ioService, IUSBWrapper& usbWrapper, IUSBEndpoint::Pointer usbEndpoint) - : AccessoryModeQuery(ioService, std::move(usbEndpoint)) -{ - data_.resize(8 + sizeof(ProtocolVersion)); - usbWrapper.fillControlSetup(&data_[0], LIBUSB_ENDPOINT_IN | USB_TYPE_VENDOR, ACC_REQ_GET_PROTOCOL, 0, 0, sizeof(ProtocolVersion)); -} + AccessoryModeProtocolVersionQuery::AccessoryModeProtocolVersionQuery(boost::asio::io_service &ioService, + IUSBWrapper &usbWrapper, + IUSBEndpoint::Pointer usbEndpoint) + : AccessoryModeQuery(ioService, std::move(usbEndpoint)) { + data_.resize(8 + sizeof(ProtocolVersion)); + usbWrapper.fillControlSetup(&data_[0], LIBUSB_ENDPOINT_IN | USB_TYPE_VENDOR, ACC_REQ_GET_PROTOCOL, 0, 0, + sizeof(ProtocolVersion)); + } -void AccessoryModeProtocolVersionQuery::start(Promise::Pointer promise) -{ - strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable { - if(promise_ != nullptr) - { - promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); - } - else - { - promise_ = std::move(promise); + void AccessoryModeProtocolVersionQuery::start(Promise::Pointer promise) { + strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable { + if (promise_ != nullptr) { + promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); + } else { + promise_ = std::move(promise); - auto usbEndpointPromise = IUSBEndpoint::Promise::defer(strand_); - usbEndpointPromise->then([this, self = this->shared_from_this()](size_t bytesTransferred) mutable { - this->protocolVersionHandler(bytesTransferred); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - promise_->reject(e); - promise_.reset(); - }); - usbEndpoint_->controlTransfer(common::DataBuffer(data_), cTransferTimeoutMs, std::move(usbEndpointPromise)); + auto usbEndpointPromise = IUSBEndpoint::Promise::defer(strand_); + usbEndpointPromise->then([this, self = this->shared_from_this()](size_t bytesTransferred) mutable { + this->protocolVersionHandler(bytesTransferred); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + promise_->reject(e); + promise_.reset(); + }); + usbEndpoint_->controlTransfer(common::DataBuffer(data_), cTransferTimeoutMs, std::move(usbEndpointPromise)); } - }); -} + }); + } -void AccessoryModeProtocolVersionQuery::protocolVersionHandler(size_t bytesTransferred) -{ - ProtocolVersion protocolVersion = static_cast(data_[8]); + void AccessoryModeProtocolVersionQuery::protocolVersionHandler(size_t bytesTransferred) { + ProtocolVersion protocolVersion = static_cast(data_[8]); - if(protocolVersion == 1 || protocolVersion == 2) - { + if (protocolVersion == 1 || protocolVersion == 2) { promise_->resolve(usbEndpoint_); promise_.reset(); - } - else - { + } else { promise_->reject(error::Error(error::ErrorCode::USB_AOAP_PROTOCOL_VERSION)); promise_.reset(); + } } -} -} + } } diff --git a/src/USB/AccessoryModeProtocolVersionQuery.ut.cpp b/src/USB/AccessoryModeProtocolVersionQuery.ut.cpp index e25ea908..523ae13d 100644 --- a/src/USB/AccessoryModeProtocolVersionQuery.ut.cpp +++ b/src/USB/AccessoryModeProtocolVersionQuery.ut.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include diff --git a/src/USB/AccessoryModeQuery.cpp b/src/USB/AccessoryModeQuery.cpp index 9fc9f380..a0bb34b0 100644 --- a/src/USB/AccessoryModeQuery.cpp +++ b/src/USB/AccessoryModeQuery.cpp @@ -1,41 +1,35 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -AccessoryModeQuery::AccessoryModeQuery(boost::asio::io_service& ioService, IUSBEndpoint::Pointer usbEndpoint) - : strand_(ioService) - , usbEndpoint_(std::move(usbEndpoint)) -{ + AccessoryModeQuery::AccessoryModeQuery(boost::asio::io_service &ioService, IUSBEndpoint::Pointer usbEndpoint) + : strand_(ioService), usbEndpoint_(std::move(usbEndpoint)) { -} + } -void AccessoryModeQuery::cancel() -{ - usbEndpoint_->cancelTransfers(); -} + void AccessoryModeQuery::cancel() { + usbEndpoint_->cancelTransfers(); + } -} + } } diff --git a/src/USB/AccessoryModeQueryChain.cpp b/src/USB/AccessoryModeQueryChain.cpp index 5015e0de..cae1b943 100644 --- a/src/USB/AccessoryModeQueryChain.cpp +++ b/src/USB/AccessoryModeQueryChain.cpp @@ -1,209 +1,190 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -AccessoryModeQueryChain::AccessoryModeQueryChain(IUSBWrapper& usbWrapper, - boost::asio::io_service& ioService, - IAccessoryModeQueryFactory& queryFactory) - : usbWrapper_(usbWrapper) - , strand_(ioService) - , queryFactory_(queryFactory) -{ + AccessoryModeQueryChain::AccessoryModeQueryChain(IUSBWrapper &usbWrapper, + boost::asio::io_service &ioService, + IAccessoryModeQueryFactory &queryFactory) + : usbWrapper_(usbWrapper), strand_(ioService), queryFactory_(queryFactory) { -} + } -void AccessoryModeQueryChain::start(DeviceHandle handle, Promise::Pointer promise) -{ - strand_.dispatch([this, self = this->shared_from_this(), handle = std::move(handle), promise = std::move(promise)]() mutable { - if(promise_ != nullptr) - { - promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); - } - else - { - promise_ = std::move(promise); - - auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); - queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { - this->protocolVersionQueryHandler(std::move(usbEndpoint)); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - promise_->reject(e); - promise_.reset(); - }); + void AccessoryModeQueryChain::start(DeviceHandle handle, Promise::Pointer promise) { + strand_.dispatch( + [this, self = this->shared_from_this(), handle = std::move(handle), promise = std::move(promise)]() mutable { + if (promise_ != nullptr) { + promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); + } else { + promise_ = std::move(promise); + + auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); + queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { + this->protocolVersionQueryHandler(std::move(usbEndpoint)); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + promise_->reject(e); + promise_.reset(); + }); #if BOOST_VERSION < 106600 - this->startQuery(AccessoryModeQueryType::PROTOCOL_VERSION, - std::make_shared(usbWrapper_, strand_.get_io_service(), std::move(handle)), - std::move(queryPromise)); + this->startQuery(AccessoryModeQueryType::PROTOCOL_VERSION, + std::make_shared(usbWrapper_, strand_.get_io_service(), std::move(handle)), + std::move(queryPromise)); #else - this->startQuery(AccessoryModeQueryType::PROTOCOL_VERSION, - std::make_shared(usbWrapper_, strand_.context(), std::move(handle)), - std::move(queryPromise)); + this->startQuery(AccessoryModeQueryType::PROTOCOL_VERSION, + std::make_shared(usbWrapper_, strand_.context(), std::move(handle)), + std::move(queryPromise)); #endif + } + }); + } + + void AccessoryModeQueryChain::cancel() { + strand_.dispatch([this, self = this->shared_from_this()]() { + if (activeQuery_ != nullptr) { + activeQuery_->cancel(); + activeQuery_.reset(); } - }); -} - -void AccessoryModeQueryChain::cancel() -{ - strand_.dispatch([this, self = this->shared_from_this()]() { - if(activeQuery_ != nullptr) - { - activeQuery_->cancel(); - activeQuery_.reset(); - } - }); -} - -void AccessoryModeQueryChain::startQuery(AccessoryModeQueryType queryType, IUSBEndpoint::Pointer usbEndpoint, IAccessoryModeQuery::Promise::Pointer queryPromise) -{ - activeQuery_ = queryFactory_.createQuery(queryType, std::move(usbEndpoint)); - activeQuery_->start(std::move(queryPromise)); -} - -void AccessoryModeQueryChain::protocolVersionQueryHandler(IUSBEndpoint::Pointer usbEndpoint) -{ - auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); - queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { - this->manufacturerQueryHandler(std::move(usbEndpoint)); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - promise_->reject(e); - promise_.reset(); - }); - - this->startQuery(AccessoryModeQueryType::SEND_MANUFACTURER, - std::move(usbEndpoint), - std::move(queryPromise)); -} - -void AccessoryModeQueryChain::manufacturerQueryHandler(IUSBEndpoint::Pointer usbEndpoint) -{ - auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); - queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { - this->modelQueryHandler(std::move(usbEndpoint)); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - promise_->reject(e); - promise_.reset(); - }); - - this->startQuery(AccessoryModeQueryType::SEND_MODEL, - std::move(usbEndpoint), - std::move(queryPromise)); -} - -void AccessoryModeQueryChain::modelQueryHandler(IUSBEndpoint::Pointer usbEndpoint) -{ - auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); - queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { - this->descriptionQueryHandler(std::move(usbEndpoint)); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - promise_->reject(e); - promise_.reset(); - }); - - this->startQuery(AccessoryModeQueryType::SEND_DESCRIPTION, - std::move(usbEndpoint), - std::move(queryPromise)); -} - -void AccessoryModeQueryChain::descriptionQueryHandler(IUSBEndpoint::Pointer usbEndpoint) -{ - auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); - queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { - this->versionQueryHandler(std::move(usbEndpoint)); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - promise_->reject(e); - promise_.reset(); - }); - - this->startQuery(AccessoryModeQueryType::SEND_VERSION, - std::move(usbEndpoint), - std::move(queryPromise)); -} - -void AccessoryModeQueryChain::versionQueryHandler(IUSBEndpoint::Pointer usbEndpoint) -{ - auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); - queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { - this->uriQueryHandler(std::move(usbEndpoint)); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - promise_->reject(e); - promise_.reset(); - }); - - this->startQuery(AccessoryModeQueryType::SEND_URI, - std::move(usbEndpoint), - std::move(queryPromise)); -} - -void AccessoryModeQueryChain::uriQueryHandler(IUSBEndpoint::Pointer usbEndpoint) -{ - auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); - queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { - this->serialQueryHandler(std::move(usbEndpoint)); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - promise_->reject(e); - promise_.reset(); - }); - - this->startQuery(AccessoryModeQueryType::SEND_SERIAL, - std::move(usbEndpoint), - std::move(queryPromise)); -} - -void AccessoryModeQueryChain::serialQueryHandler(IUSBEndpoint::Pointer usbEndpoint) -{ - auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); - queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { - this->startQueryHandler(std::move(usbEndpoint)); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - promise_->reject(e); - promise_.reset(); - }); - - this->startQuery(AccessoryModeQueryType::START, - std::move(usbEndpoint), - std::move(queryPromise)); -} - -void AccessoryModeQueryChain::startQueryHandler(IUSBEndpoint::Pointer usbEndpoint) -{ - activeQuery_.reset(); - promise_->resolve(usbEndpoint->getDeviceHandle()); - promise_.reset(); -} - -} + }); + } + + void AccessoryModeQueryChain::startQuery(AccessoryModeQueryType queryType, IUSBEndpoint::Pointer usbEndpoint, + IAccessoryModeQuery::Promise::Pointer queryPromise) { + activeQuery_ = queryFactory_.createQuery(queryType, std::move(usbEndpoint)); + activeQuery_->start(std::move(queryPromise)); + } + + void AccessoryModeQueryChain::protocolVersionQueryHandler(IUSBEndpoint::Pointer usbEndpoint) { + auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); + queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { + this->manufacturerQueryHandler(std::move(usbEndpoint)); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + promise_->reject(e); + promise_.reset(); + }); + + this->startQuery(AccessoryModeQueryType::SEND_MANUFACTURER, + std::move(usbEndpoint), + std::move(queryPromise)); + } + + void AccessoryModeQueryChain::manufacturerQueryHandler(IUSBEndpoint::Pointer usbEndpoint) { + auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); + queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { + this->modelQueryHandler(std::move(usbEndpoint)); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + promise_->reject(e); + promise_.reset(); + }); + + this->startQuery(AccessoryModeQueryType::SEND_MODEL, + std::move(usbEndpoint), + std::move(queryPromise)); + } + + void AccessoryModeQueryChain::modelQueryHandler(IUSBEndpoint::Pointer usbEndpoint) { + auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); + queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { + this->descriptionQueryHandler(std::move(usbEndpoint)); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + promise_->reject(e); + promise_.reset(); + }); + + this->startQuery(AccessoryModeQueryType::SEND_DESCRIPTION, + std::move(usbEndpoint), + std::move(queryPromise)); + } + + void AccessoryModeQueryChain::descriptionQueryHandler(IUSBEndpoint::Pointer usbEndpoint) { + auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); + queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { + this->versionQueryHandler(std::move(usbEndpoint)); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + promise_->reject(e); + promise_.reset(); + }); + + this->startQuery(AccessoryModeQueryType::SEND_VERSION, + std::move(usbEndpoint), + std::move(queryPromise)); + } + + void AccessoryModeQueryChain::versionQueryHandler(IUSBEndpoint::Pointer usbEndpoint) { + auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); + queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { + this->uriQueryHandler(std::move(usbEndpoint)); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + promise_->reject(e); + promise_.reset(); + }); + + this->startQuery(AccessoryModeQueryType::SEND_URI, + std::move(usbEndpoint), + std::move(queryPromise)); + } + + void AccessoryModeQueryChain::uriQueryHandler(IUSBEndpoint::Pointer usbEndpoint) { + auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); + queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { + this->serialQueryHandler(std::move(usbEndpoint)); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + promise_->reject(e); + promise_.reset(); + }); + + this->startQuery(AccessoryModeQueryType::SEND_SERIAL, + std::move(usbEndpoint), + std::move(queryPromise)); + } + + void AccessoryModeQueryChain::serialQueryHandler(IUSBEndpoint::Pointer usbEndpoint) { + auto queryPromise = IAccessoryModeQuery::Promise::defer(strand_); + queryPromise->then([this, self = this->shared_from_this()](IUSBEndpoint::Pointer usbEndpoint) mutable { + this->startQueryHandler(std::move(usbEndpoint)); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + promise_->reject(e); + promise_.reset(); + }); + + this->startQuery(AccessoryModeQueryType::START, + std::move(usbEndpoint), + std::move(queryPromise)); + } + + void AccessoryModeQueryChain::startQueryHandler(IUSBEndpoint::Pointer usbEndpoint) { + activeQuery_.reset(); + promise_->resolve(usbEndpoint->getDeviceHandle()); + promise_.reset(); + } + + } } diff --git a/src/USB/AccessoryModeQueryChain.ut.cpp b/src/USB/AccessoryModeQueryChain.ut.cpp index ab0115e7..fc0cd7d6 100644 --- a/src/USB/AccessoryModeQueryChain.ut.cpp +++ b/src/USB/AccessoryModeQueryChain.ut.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -24,451 +23,508 @@ #include -namespace aasdk -{ -namespace usb -{ -namespace ut -{ - -using ::testing::_; -using ::testing::Return; -using ::testing::SaveArg; -using ::testing::NotNull; - -class AccessoryModeQueryChainUnitTest -{ -protected: - AccessoryModeQueryChainUnitTest() - : deviceHandle_(reinterpret_cast(&dummyDeviceHandle_), [](auto*) {}) - , queryMock_(std::make_shared()) - , promise_(IAccessoryModeQueryChain::Promise::defer(ioService_)) - { - promise_->then(std::bind(&AccessoryModeQueryChainPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), - std::bind(&AccessoryModeQueryChainPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); - } - - boost::asio::io_service ioService_; - USBWrapperMock usbWrapperMock_; - AccessoryModeQueryFactoryMock queryFactoryMock_; - USBWrapperMock::DummyDeviceHandle dummyDeviceHandle_; - DeviceHandle deviceHandle_; - std::shared_ptr queryMock_; - AccessoryModeQueryChainPromiseHandlerMock promiseHandlerMock_; - IAccessoryModeQueryChain::Promise::Pointer promise_; -}; - -BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_QueryAOAPDevice, AccessoryModeQueryChainUnitTest) -{ - AccessoryModeQueryChain::Pointer queryChain(std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); - - IUSBEndpoint::Pointer usbEndpoint; - - IAccessoryModeQuery::Promise::Pointer queryPromise; - EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce(DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); - queryChain->start(deviceHandle_, std::move(promise_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MODEL, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_DESCRIPTION, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_VERSION, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_URI, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_SERIAL, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::START, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(promiseHandlerMock_, onResolve(deviceHandle_)); - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_ProtocolVersionQueryFailed, AccessoryModeQueryChainUnitTest) -{ - AccessoryModeQueryChain::Pointer queryChain(std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); - - IUSBEndpoint::Pointer usbEndpoint; - - IAccessoryModeQuery::Promise::Pointer queryPromise; - EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce(DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); - queryChain->start(deviceHandle_, std::move(promise_)); - - ioService_.run(); - ioService_.reset(); - - const error::Error e(error::ErrorCode::USB_AOAP_PROTOCOL_VERSION); - queryPromise->reject(e); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(e)); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_ManufacturerQueryFailed, AccessoryModeQueryChainUnitTest) -{ - AccessoryModeQueryChain::Pointer queryChain(std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); - - IUSBEndpoint::Pointer usbEndpoint; - - IAccessoryModeQuery::Promise::Pointer queryPromise; - EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce(DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); - queryChain->start(deviceHandle_, std::move(promise_)); - - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - const error::Error e(error::ErrorCode::USB_TRANSFER); - queryPromise->reject(e); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(e)); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_ModelQueryFailed, AccessoryModeQueryChainUnitTest) -{ - AccessoryModeQueryChain::Pointer queryChain(std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); - - IUSBEndpoint::Pointer usbEndpoint; - - IAccessoryModeQuery::Promise::Pointer queryPromise; - EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce(DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); - queryChain->start(deviceHandle_, std::move(promise_)); - - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MODEL, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - const error::Error e(error::ErrorCode::USB_TRANSFER); - queryPromise->reject(e); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(e)); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_DescriptionQueryFailed, AccessoryModeQueryChainUnitTest) -{ - AccessoryModeQueryChain::Pointer queryChain(std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); - - IUSBEndpoint::Pointer usbEndpoint; - - IAccessoryModeQuery::Promise::Pointer queryPromise; - EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce(DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); - queryChain->start(deviceHandle_, std::move(promise_)); - - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); +namespace aasdk { + namespace usb { + namespace ut { + + using ::testing::_; + using ::testing::Return; + using ::testing::SaveArg; + using ::testing::NotNull; + + class AccessoryModeQueryChainUnitTest { + protected: + AccessoryModeQueryChainUnitTest() + : deviceHandle_(reinterpret_cast(&dummyDeviceHandle_), [](auto *) {}), + queryMock_(std::make_shared()), + promise_(IAccessoryModeQueryChain::Promise::defer(ioService_)) { + promise_->then(std::bind(&AccessoryModeQueryChainPromiseHandlerMock::onResolve, &promiseHandlerMock_, + std::placeholders::_1), + std::bind(&AccessoryModeQueryChainPromiseHandlerMock::onReject, &promiseHandlerMock_, + std::placeholders::_1)); + } + + boost::asio::io_service ioService_; + USBWrapperMock usbWrapperMock_; + AccessoryModeQueryFactoryMock queryFactoryMock_; + USBWrapperMock::DummyDeviceHandle dummyDeviceHandle_; + DeviceHandle deviceHandle_; + std::shared_ptr queryMock_; + AccessoryModeQueryChainPromiseHandlerMock promiseHandlerMock_; + IAccessoryModeQueryChain::Promise::Pointer promise_; + }; + + BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_QueryAOAPDevice, AccessoryModeQueryChainUnitTest) + { + AccessoryModeQueryChain::Pointer queryChain( + std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); + + IUSBEndpoint::Pointer usbEndpoint; + + IAccessoryModeQuery::Promise::Pointer queryPromise; + EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce( + DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); + queryChain->start(deviceHandle_, std::move(promise_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MODEL, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_DESCRIPTION, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_VERSION, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_URI, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_SERIAL, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::START, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(promiseHandlerMock_, onResolve(deviceHandle_)); + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_ProtocolVersionQueryFailed, AccessoryModeQueryChainUnitTest) + { + AccessoryModeQueryChain::Pointer queryChain( + std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); + + IUSBEndpoint::Pointer usbEndpoint; + + IAccessoryModeQuery::Promise::Pointer queryPromise; + EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce( + DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); + queryChain->start(deviceHandle_, std::move(promise_)); + + ioService_.run(); + ioService_.reset(); + + const error::Error e(error::ErrorCode::USB_AOAP_PROTOCOL_VERSION); + queryPromise->reject(e); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(e)); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_ManufacturerQueryFailed, AccessoryModeQueryChainUnitTest) + { + AccessoryModeQueryChain::Pointer queryChain( + std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); + + IUSBEndpoint::Pointer usbEndpoint; + + IAccessoryModeQuery::Promise::Pointer queryPromise; + EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce( + DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); + queryChain->start(deviceHandle_, std::move(promise_)); + + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + const error::Error e(error::ErrorCode::USB_TRANSFER); + queryPromise->reject(e); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(e)); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_ModelQueryFailed, AccessoryModeQueryChainUnitTest) + { + AccessoryModeQueryChain::Pointer queryChain( + std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); + + IUSBEndpoint::Pointer usbEndpoint; + + IAccessoryModeQuery::Promise::Pointer queryPromise; + EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce( + DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); + queryChain->start(deviceHandle_, std::move(promise_)); + + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MODEL, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + const error::Error e(error::ErrorCode::USB_TRANSFER); + queryPromise->reject(e); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(e)); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_DescriptionQueryFailed, AccessoryModeQueryChainUnitTest) + { + AccessoryModeQueryChain::Pointer queryChain( + std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); + + IUSBEndpoint::Pointer usbEndpoint; + + IAccessoryModeQuery::Promise::Pointer queryPromise; + EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce( + DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); + queryChain->start(deviceHandle_, std::move(promise_)); + + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MODEL, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_DESCRIPTION, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + const error::Error e(error::ErrorCode::USB_TRANSFER); + queryPromise->reject(e); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(e)); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_VersionQueryFailed, AccessoryModeQueryChainUnitTest) + { + AccessoryModeQueryChain::Pointer queryChain( + std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); + + IUSBEndpoint::Pointer usbEndpoint; + + IAccessoryModeQuery::Promise::Pointer queryPromise; + EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce( + DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); + queryChain->start(deviceHandle_, std::move(promise_)); + + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MODEL, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_DESCRIPTION, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_VERSION, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + const error::Error e(error::ErrorCode::USB_TRANSFER); + queryPromise->reject(e); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(e)); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_URIQueryFailed, AccessoryModeQueryChainUnitTest) + { + AccessoryModeQueryChain::Pointer queryChain( + std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); + + IUSBEndpoint::Pointer usbEndpoint; + + IAccessoryModeQuery::Promise::Pointer queryPromise; + EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce( + DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); + queryChain->start(deviceHandle_, std::move(promise_)); + + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MODEL, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_DESCRIPTION, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_VERSION, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_URI, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + const error::Error e(error::ErrorCode::USB_TRANSFER); + queryPromise->reject(e); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(e)); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_SerialQueryFailed, AccessoryModeQueryChainUnitTest) + { + AccessoryModeQueryChain::Pointer queryChain( + std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); + + IUSBEndpoint::Pointer usbEndpoint; + + IAccessoryModeQuery::Promise::Pointer queryPromise; + EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce( + DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); + queryChain->start(deviceHandle_, std::move(promise_)); + + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MODEL, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_DESCRIPTION, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_VERSION, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_URI, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_SERIAL, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + const error::Error e(error::ErrorCode::USB_TRANSFER); + queryPromise->reject(e); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(e)); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_StartQueryFailed, AccessoryModeQueryChainUnitTest) + { + AccessoryModeQueryChain::Pointer queryChain( + std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); + + IUSBEndpoint::Pointer usbEndpoint; + + IAccessoryModeQuery::Promise::Pointer queryPromise; + EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce( + DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); + queryChain->start(deviceHandle_, std::move(promise_)); + + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MODEL, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_DESCRIPTION, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_VERSION, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_URI, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_SERIAL, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::START, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + const error::Error e(error::ErrorCode::USB_TRANSFER); + queryPromise->reject(e); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(e)); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_Cancel, AccessoryModeQueryChainUnitTest) + { + AccessoryModeQueryChain::Pointer queryChain( + std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); + + IUSBEndpoint::Pointer usbEndpoint; + IAccessoryModeQuery::Promise::Pointer queryPromise; + EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce( + DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); + queryChain->start(deviceHandle_, std::move(promise_)); + + ioService_.run(); + ioService_.reset(); + + queryPromise->resolve(usbEndpoint); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce( + Return(queryMock_)); + ioService_.run(); + ioService_.reset(); + + EXPECT_CALL(*queryMock_, cancel()); + queryChain->cancel(); + + const error::Error e(error::ErrorCode::OPERATION_ABORTED); + queryPromise->reject(e); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(e)); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_RejectWhenInProgress, AccessoryModeQueryChainUnitTest) + { + EXPECT_CALL(*queryMock_, start(_)); + EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce( + Return(queryMock_)); + AccessoryModeQueryChain::Pointer queryChain( + std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); + queryChain->start(deviceHandle_, std::move(promise_)); + + ioService_.run(); + ioService_.reset(); + + auto secondPromise = IAccessoryModeQueryChain::Promise::defer(ioService_); + secondPromise->then(std::bind(&AccessoryModeQueryChainPromiseHandlerMock::onResolve, &promiseHandlerMock_, + std::placeholders::_1), + std::bind(&AccessoryModeQueryChainPromiseHandlerMock::onReject, &promiseHandlerMock_, + std::placeholders::_1)); + + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS))); + queryChain->start(deviceHandle_, std::move(secondPromise)); + + ioService_.run(); + } - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MODEL, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_DESCRIPTION, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - const error::Error e(error::ErrorCode::USB_TRANSFER); - queryPromise->reject(e); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(e)); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_VersionQueryFailed, AccessoryModeQueryChainUnitTest) -{ - AccessoryModeQueryChain::Pointer queryChain(std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); - - IUSBEndpoint::Pointer usbEndpoint; - - IAccessoryModeQuery::Promise::Pointer queryPromise; - EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce(DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); - queryChain->start(deviceHandle_, std::move(promise_)); - - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MODEL, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_DESCRIPTION, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_VERSION, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - const error::Error e(error::ErrorCode::USB_TRANSFER); - queryPromise->reject(e); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(e)); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_URIQueryFailed, AccessoryModeQueryChainUnitTest) -{ - AccessoryModeQueryChain::Pointer queryChain(std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); - - IUSBEndpoint::Pointer usbEndpoint; - - IAccessoryModeQuery::Promise::Pointer queryPromise; - EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce(DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); - queryChain->start(deviceHandle_, std::move(promise_)); - - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MODEL, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_DESCRIPTION, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_VERSION, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_URI, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - const error::Error e(error::ErrorCode::USB_TRANSFER); - queryPromise->reject(e); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(e)); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_SerialQueryFailed, AccessoryModeQueryChainUnitTest) -{ - AccessoryModeQueryChain::Pointer queryChain(std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); - - IUSBEndpoint::Pointer usbEndpoint; - - IAccessoryModeQuery::Promise::Pointer queryPromise; - EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce(DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); - queryChain->start(deviceHandle_, std::move(promise_)); - - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MODEL, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_DESCRIPTION, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_VERSION, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_URI, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_SERIAL, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - const error::Error e(error::ErrorCode::USB_TRANSFER); - queryPromise->reject(e); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(e)); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_StartQueryFailed, AccessoryModeQueryChainUnitTest) -{ - AccessoryModeQueryChain::Pointer queryChain(std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); - - IUSBEndpoint::Pointer usbEndpoint; - - IAccessoryModeQuery::Promise::Pointer queryPromise; - EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce(DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); - queryChain->start(deviceHandle_, std::move(promise_)); - - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MODEL, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_DESCRIPTION, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_VERSION, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_URI, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_SERIAL, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::START, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - const error::Error e(error::ErrorCode::USB_TRANSFER); - queryPromise->reject(e); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(e)); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_Cancel, AccessoryModeQueryChainUnitTest) -{ - AccessoryModeQueryChain::Pointer queryChain(std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); - - IUSBEndpoint::Pointer usbEndpoint; - IAccessoryModeQuery::Promise::Pointer queryPromise; - EXPECT_CALL(*queryMock_, start(_)).WillRepeatedly(SaveArg<0>(&queryPromise)); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce(DoAll(SaveArg<1>(&usbEndpoint), Return(queryMock_))); - queryChain->start(deviceHandle_, std::move(promise_)); - - ioService_.run(); - ioService_.reset(); - - queryPromise->resolve(usbEndpoint); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::SEND_MANUFACTURER, usbEndpoint)).WillOnce(Return(queryMock_)); - ioService_.run(); - ioService_.reset(); - - EXPECT_CALL(*queryMock_, cancel()); - queryChain->cancel(); - - const error::Error e(error::ErrorCode::OPERATION_ABORTED); - queryPromise->reject(e); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(e)); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(AccessoryModeQueryChain_RejectWhenInProgress, AccessoryModeQueryChainUnitTest) -{ - EXPECT_CALL(*queryMock_, start(_)); - EXPECT_CALL(queryFactoryMock_, createQuery(AccessoryModeQueryType::PROTOCOL_VERSION, _)).WillOnce(Return(queryMock_)); - AccessoryModeQueryChain::Pointer queryChain(std::make_shared(usbWrapperMock_, ioService_, queryFactoryMock_)); - queryChain->start(deviceHandle_, std::move(promise_)); - - ioService_.run(); - ioService_.reset(); - - auto secondPromise = IAccessoryModeQueryChain::Promise::defer(ioService_); - secondPromise->then(std::bind(&AccessoryModeQueryChainPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), - std::bind(&AccessoryModeQueryChainPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); - - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS))); - queryChain->start(deviceHandle_, std::move(secondPromise)); - - ioService_.run(); -} - -} -} + } + } } diff --git a/src/USB/AccessoryModeQueryChainFactory.cpp b/src/USB/AccessoryModeQueryChainFactory.cpp index 6aff87ea..36554422 100644 --- a/src/USB/AccessoryModeQueryChainFactory.cpp +++ b/src/USB/AccessoryModeQueryChainFactory.cpp @@ -1,44 +1,37 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -AccessoryModeQueryChainFactory::AccessoryModeQueryChainFactory(IUSBWrapper& usbWrapper, - boost::asio::io_service& ioService, - IAccessoryModeQueryFactory& queryFactory) - : usbWrapper_(usbWrapper) - , ioService_(ioService) - , queryFactory_(queryFactory) -{ + AccessoryModeQueryChainFactory::AccessoryModeQueryChainFactory(IUSBWrapper &usbWrapper, + boost::asio::io_service &ioService, + IAccessoryModeQueryFactory &queryFactory) + : usbWrapper_(usbWrapper), ioService_(ioService), queryFactory_(queryFactory) { -} + } -IAccessoryModeQueryChain::Pointer AccessoryModeQueryChainFactory::create() -{ - return std::make_shared(usbWrapper_, ioService_, queryFactory_); -} + IAccessoryModeQueryChain::Pointer AccessoryModeQueryChainFactory::create() { + return std::make_shared(usbWrapper_, ioService_, queryFactory_); + } -} + } } diff --git a/src/USB/AccessoryModeQueryFactory.cpp b/src/USB/AccessoryModeQueryFactory.cpp index 3f67790c..467ec760 100644 --- a/src/USB/AccessoryModeQueryFactory.cpp +++ b/src/USB/AccessoryModeQueryFactory.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -23,57 +22,54 @@ #include +namespace aasdk { + namespace usb { -namespace aasdk -{ -namespace usb -{ - -AccessoryModeQueryFactory::AccessoryModeQueryFactory(usb::IUSBWrapper& usbWrapper, boost::asio::io_service& ioService) - : usbWrapper_(usbWrapper) - , ioService_(ioService) -{ + 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(ioService_, usbWrapper_, std::move(usbEndpoint)); + IAccessoryModeQuery::Pointer + AccessoryModeQueryFactory::createQuery(AccessoryModeQueryType queryType, IUSBEndpoint::Pointer usbEndpoint) { + switch (queryType) { + case AccessoryModeQueryType::PROTOCOL_VERSION: + return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint)); - case AccessoryModeQueryType::SEND_DESCRIPTION: - return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint), - AccessoryModeSendStringType::DESCRIPTION, "Android Auto"); + case AccessoryModeQueryType::SEND_DESCRIPTION: + return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint), + AccessoryModeSendStringType::DESCRIPTION, + "Android Auto"); - case AccessoryModeQueryType::SEND_MANUFACTURER: - return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint), - AccessoryModeSendStringType::MANUFACTURER, "Android"); + case AccessoryModeQueryType::SEND_MANUFACTURER: + return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint), + AccessoryModeSendStringType::MANUFACTURER, "Android"); - case AccessoryModeQueryType::SEND_MODEL: - return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint), - AccessoryModeSendStringType::MODEL, "Android Auto"); + case AccessoryModeQueryType::SEND_MODEL: + return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint), + AccessoryModeSendStringType::MODEL, "Android Auto"); - case AccessoryModeQueryType::SEND_SERIAL: - return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint), - AccessoryModeSendStringType::SERIAL, "HU-AAAAAA001"); + case AccessoryModeQueryType::SEND_SERIAL: + return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint), + AccessoryModeSendStringType::SERIAL, "HU-AAAAAA001"); - case AccessoryModeQueryType::SEND_URI: - return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint), - AccessoryModeSendStringType::URI, "https://f1xstudio.com"); + case AccessoryModeQueryType::SEND_URI: + return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint), + AccessoryModeSendStringType::URI, + "https://f1xstudio.com"); - case AccessoryModeQueryType::SEND_VERSION: - return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint), - AccessoryModeSendStringType::VERSION, "2.0.1"); + case AccessoryModeQueryType::SEND_VERSION: + return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint), + AccessoryModeSendStringType::VERSION, "2.0.1"); - case AccessoryModeQueryType::START: - return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint)); + case AccessoryModeQueryType::START: + return std::make_shared(ioService_, usbWrapper_, std::move(usbEndpoint)); - default: - return nullptr; + default: + return nullptr; + } } -} -} + } } diff --git a/src/USB/AccessoryModeSendStringQuery.cpp b/src/USB/AccessoryModeSendStringQuery.cpp index d3372913..f3600692 100644 --- a/src/USB/AccessoryModeSendStringQuery.cpp +++ b/src/USB/AccessoryModeSendStringQuery.cpp @@ -1,68 +1,63 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include #include -namespace aasdk -{ -namespace usb -{ - -AccessoryModeSendStringQuery::AccessoryModeSendStringQuery(boost::asio::io_service& ioService, IUSBWrapper& usbWrapper, IUSBEndpoint::Pointer usbEndpoint, - AccessoryModeSendStringType sendStringType, const std::string& queryValue) - : AccessoryModeQuery(ioService, std::move(usbEndpoint)) - , sendStringType_(std::move(sendStringType)) -{ - data_.resize(8); - data_.insert(data_.end(), queryValue.begin(), queryValue.end()); - data_.push_back('\0'); - - usbWrapper.fillControlSetup(&data_[0], LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_SEND_STRING, 0, static_cast(sendStringType_), data_.size() - 8); -} - -void AccessoryModeSendStringQuery::start(Promise::Pointer promise) -{ - strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable { - if(promise_ != nullptr) - { - promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); - } - else - { - promise_ = std::move(promise); - - auto usbEndpointPromise = IUSBEndpoint::Promise::defer(strand_); - usbEndpointPromise->then([this, self = this->shared_from_this()](size_t bytesTransferred) mutable { - promise_->resolve(usbEndpoint_); - promise_.reset(); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - promise_->reject(e); - promise_.reset(); - }); - - usbEndpoint_->controlTransfer(common::DataBuffer(data_), cTransferTimeoutMs, std::move(usbEndpointPromise)); +namespace aasdk { + namespace usb { + + AccessoryModeSendStringQuery::AccessoryModeSendStringQuery(boost::asio::io_service &ioService, + IUSBWrapper &usbWrapper, + IUSBEndpoint::Pointer usbEndpoint, + AccessoryModeSendStringType sendStringType, + const std::string &queryValue) + : AccessoryModeQuery(ioService, std::move(usbEndpoint)), sendStringType_(std::move(sendStringType)) { + data_.resize(8); + data_.insert(data_.end(), queryValue.begin(), queryValue.end()); + data_.push_back('\0'); + + usbWrapper.fillControlSetup(&data_[0], LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_SEND_STRING, 0, + static_cast(sendStringType_), data_.size() - 8); + } + + void AccessoryModeSendStringQuery::start(Promise::Pointer promise) { + strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable { + if (promise_ != nullptr) { + promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); + } else { + promise_ = std::move(promise); + + auto usbEndpointPromise = IUSBEndpoint::Promise::defer(strand_); + usbEndpointPromise->then([this, self = this->shared_from_this()](size_t bytesTransferred) mutable { + promise_->resolve(usbEndpoint_); + promise_.reset(); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + promise_->reject(e); + promise_.reset(); + }); + + usbEndpoint_->controlTransfer(common::DataBuffer(data_), cTransferTimeoutMs, std::move(usbEndpointPromise)); } - }); -} + }); + } -} + } } diff --git a/src/USB/AccessoryModeSendStringQuery.ut.cpp b/src/USB/AccessoryModeSendStringQuery.ut.cpp index d23cdde5..1dbea6a7 100644 --- a/src/USB/AccessoryModeSendStringQuery.ut.cpp +++ b/src/USB/AccessoryModeSendStringQuery.ut.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -23,116 +22,135 @@ #include -namespace aasdk -{ -namespace usb -{ -namespace ut -{ - -using ::testing::_; -using ::testing::SaveArg; -using ::testing::NotNull; - -class AccessoryModeSendStringQueryUnitTest -{ -protected: - AccessoryModeSendStringQueryUnitTest() - : usbEndpointMock_(std::make_shared()) - , usbEndpoint_(usbEndpointMock_.get(), [](auto*) {}) - , promise_(IAccessoryModeQuery::Promise::defer(ioService_)) - { - promise_->then(std::bind(&AccessoryModeQueryPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), - std::bind(&AccessoryModeQueryPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); - } - - boost::asio::io_service ioService_; - USBWrapperMock usbWrapperMock_; - std::shared_ptr usbEndpointMock_; - IUSBEndpoint::Pointer usbEndpoint_; - AccessoryModeQueryPromiseHandlerMock promiseHandlerMock_; - IAccessoryModeQuery::Promise::Pointer promise_; - - static constexpr uint32_t USB_TYPE_VENDOR = 0x40; - static constexpr uint32_t ACC_REQ_SEND_STRING = 52; -}; - -BOOST_FIXTURE_TEST_CASE(AccessoryModeSendStringQuery_SendString, AccessoryModeSendStringQueryUnitTest) -{ - common::DataBuffer buffer; - IUSBEndpoint::Promise::Pointer usbEndpointPromise; - EXPECT_CALL(*usbEndpointMock_, controlTransfer(_, _, _)).WillOnce(DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); - - const std::string expectedQueryString = "aasdkTest"; - EXPECT_CALL(usbWrapperMock_, fillControlSetup(NotNull(), LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_SEND_STRING, 0, static_cast(AccessoryModeSendStringType::MANUFACTURER), expectedQueryString.size() + 1)); - - AccessoryModeSendStringQuery::Pointer query(std::make_shared(ioService_, usbWrapperMock_, usbEndpointMock_, AccessoryModeSendStringType::MANUFACTURER, expectedQueryString)); - - query->start(std::move(promise_)); - ioService_.run(); - ioService_.reset(); - - BOOST_TEST(buffer.size == expectedQueryString.size() + 1 + 8); - const std::string actualQueryString(buffer.data + 8, buffer.data + buffer.size - 1); - BOOST_TEST(actualQueryString == expectedQueryString); - - usbEndpointPromise->resolve(buffer.size); - - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onResolve(usbEndpoint_)); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(AccessoryModeSendStringQuery_TransferError, AccessoryModeSendStringQueryUnitTest) -{ - common::DataBuffer buffer; - IUSBEndpoint::Promise::Pointer usbEndpointPromise; - EXPECT_CALL(*usbEndpointMock_, controlTransfer(_, _, _)).WillOnce(DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); - - const std::string expectedQueryString = "aasdkTest"; - EXPECT_CALL(usbWrapperMock_, fillControlSetup(NotNull(), LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_SEND_STRING, 0, static_cast(AccessoryModeSendStringType::MANUFACTURER), expectedQueryString.size() + 1)); - - AccessoryModeSendStringQuery::Pointer query(std::make_shared(ioService_, usbWrapperMock_, usbEndpointMock_, AccessoryModeSendStringType::MANUFACTURER, expectedQueryString)); - - query->start(std::move(promise_)); - ioService_.run(); - ioService_.reset(); +namespace aasdk { + namespace usb { + namespace ut { + + using ::testing::_; + using ::testing::SaveArg; + using ::testing::NotNull; + + class AccessoryModeSendStringQueryUnitTest { + protected: + AccessoryModeSendStringQueryUnitTest() + : usbEndpointMock_(std::make_shared()), + usbEndpoint_(usbEndpointMock_.get(), [](auto *) {}), + promise_(IAccessoryModeQuery::Promise::defer(ioService_)) { + promise_->then( + std::bind(&AccessoryModeQueryPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), + std::bind(&AccessoryModeQueryPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); + } + + boost::asio::io_service ioService_; + USBWrapperMock usbWrapperMock_; + std::shared_ptr usbEndpointMock_; + IUSBEndpoint::Pointer usbEndpoint_; + AccessoryModeQueryPromiseHandlerMock promiseHandlerMock_; + IAccessoryModeQuery::Promise::Pointer promise_; + + static constexpr uint32_t USB_TYPE_VENDOR = 0x40; + static constexpr uint32_t ACC_REQ_SEND_STRING = 52; + }; + + BOOST_FIXTURE_TEST_CASE(AccessoryModeSendStringQuery_SendString, AccessoryModeSendStringQueryUnitTest) + { + common::DataBuffer buffer; + IUSBEndpoint::Promise::Pointer usbEndpointPromise; + EXPECT_CALL(*usbEndpointMock_, controlTransfer(_, _, _)).WillOnce( + DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); + + const std::string expectedQueryString = "aasdkTest"; + EXPECT_CALL(usbWrapperMock_, + fillControlSetup(NotNull(), LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_SEND_STRING, 0, + static_cast(AccessoryModeSendStringType::MANUFACTURER), + expectedQueryString.size() + 1)); + + AccessoryModeSendStringQuery::Pointer query( + std::make_shared(ioService_, usbWrapperMock_, usbEndpointMock_, + AccessoryModeSendStringType::MANUFACTURER, + expectedQueryString)); + + query->start(std::move(promise_)); + ioService_.run(); + ioService_.reset(); + + BOOST_TEST(buffer.size == expectedQueryString.size() + 1 + 8); + const std::string actualQueryString(buffer.data + 8, buffer.data + buffer.size - 1); + BOOST_TEST(actualQueryString == expectedQueryString); + + usbEndpointPromise->resolve(buffer.size); + + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onResolve(usbEndpoint_)); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(AccessoryModeSendStringQuery_TransferError, AccessoryModeSendStringQueryUnitTest) + { + common::DataBuffer buffer; + IUSBEndpoint::Promise::Pointer usbEndpointPromise; + EXPECT_CALL(*usbEndpointMock_, controlTransfer(_, _, _)).WillOnce( + DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); + + const std::string expectedQueryString = "aasdkTest"; + EXPECT_CALL(usbWrapperMock_, + fillControlSetup(NotNull(), LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_SEND_STRING, 0, + static_cast(AccessoryModeSendStringType::MANUFACTURER), + expectedQueryString.size() + 1)); + + AccessoryModeSendStringQuery::Pointer query( + std::make_shared(ioService_, usbWrapperMock_, usbEndpointMock_, + AccessoryModeSendStringType::MANUFACTURER, + expectedQueryString)); + + query->start(std::move(promise_)); + ioService_.run(); + ioService_.reset(); + + const error::Error transferError(error::ErrorCode::USB_TRANSFER, LIBUSB_TRANSFER_ERROR); + usbEndpointPromise->reject(transferError); + + EXPECT_CALL(promiseHandlerMock_, onReject(transferError)); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(AccessoryModeSendStringQuery_RejectWhenInProgress, AccessoryModeSendStringQueryUnitTest) + { + common::DataBuffer buffer; + IUSBEndpoint::Promise::Pointer usbEndpointPromise; + EXPECT_CALL(*usbEndpointMock_, controlTransfer(_, _, _)).WillOnce( + DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); + + const std::string expectedQueryString = "aasdkTest"; + EXPECT_CALL(usbWrapperMock_, + fillControlSetup(NotNull(), LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_SEND_STRING, 0, + static_cast(AccessoryModeSendStringType::MANUFACTURER), + expectedQueryString.size() + 1)); + + AccessoryModeSendStringQuery::Pointer query( + std::make_shared(ioService_, usbWrapperMock_, usbEndpointMock_, + AccessoryModeSendStringType::MANUFACTURER, + expectedQueryString)); + + query->start(std::move(promise_)); + ioService_.run(); + ioService_.reset(); + + AccessoryModeQueryPromiseHandlerMock secondPromiseHandlerMock; + auto secondPromise = IAccessoryModeQuery::Promise::defer(ioService_); + secondPromise->then(std::bind(&AccessoryModeQueryPromiseHandlerMock::onResolve, &secondPromiseHandlerMock, + std::placeholders::_1), + std::bind(&AccessoryModeQueryPromiseHandlerMock::onReject, &secondPromiseHandlerMock, + std::placeholders::_1)); + + EXPECT_CALL(secondPromiseHandlerMock, onReject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS))); + EXPECT_CALL(secondPromiseHandlerMock, onResolve(_)).Times(0); + query->start(std::move(secondPromise)); + + ioService_.run(); + } - const error::Error transferError(error::ErrorCode::USB_TRANSFER, LIBUSB_TRANSFER_ERROR); - usbEndpointPromise->reject(transferError); - - EXPECT_CALL(promiseHandlerMock_, onReject(transferError)); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(AccessoryModeSendStringQuery_RejectWhenInProgress, AccessoryModeSendStringQueryUnitTest) -{ - common::DataBuffer buffer; - IUSBEndpoint::Promise::Pointer usbEndpointPromise; - EXPECT_CALL(*usbEndpointMock_, controlTransfer(_, _, _)).WillOnce(DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); - - const std::string expectedQueryString = "aasdkTest"; - EXPECT_CALL(usbWrapperMock_, fillControlSetup(NotNull(), LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_SEND_STRING, 0, static_cast(AccessoryModeSendStringType::MANUFACTURER), expectedQueryString.size() + 1)); - - AccessoryModeSendStringQuery::Pointer query(std::make_shared(ioService_, usbWrapperMock_, usbEndpointMock_, AccessoryModeSendStringType::MANUFACTURER, expectedQueryString)); - - query->start(std::move(promise_)); - ioService_.run(); - ioService_.reset(); - - AccessoryModeQueryPromiseHandlerMock secondPromiseHandlerMock; - auto secondPromise = IAccessoryModeQuery::Promise::defer(ioService_); - secondPromise->then(std::bind(&AccessoryModeQueryPromiseHandlerMock::onResolve, &secondPromiseHandlerMock, std::placeholders::_1), - std::bind(&AccessoryModeQueryPromiseHandlerMock::onReject, &secondPromiseHandlerMock, std::placeholders::_1)); - - EXPECT_CALL(secondPromiseHandlerMock, onReject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS))); - EXPECT_CALL(secondPromiseHandlerMock, onResolve(_)).Times(0); - query->start(std::move(secondPromise)); - - ioService_.run(); -} - -} -} + } + } } diff --git a/src/USB/AccessoryModeStartQuery.cpp b/src/USB/AccessoryModeStartQuery.cpp index 75cd32fb..7cb86804 100644 --- a/src/USB/AccessoryModeStartQuery.cpp +++ b/src/USB/AccessoryModeStartQuery.cpp @@ -1,63 +1,56 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include #include -namespace aasdk -{ -namespace usb -{ - -AccessoryModeStartQuery::AccessoryModeStartQuery(boost::asio::io_service& ioService, IUSBWrapper& usbWrapper, IUSBEndpoint::Pointer usbEndpoint) - : AccessoryModeQuery(ioService, std::move(usbEndpoint)) -{ - data_.resize(8); - usbWrapper.fillControlSetup(&data_[0], LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_START, 0, 0, 0); -} - -void AccessoryModeStartQuery::start(Promise::Pointer promise) -{ - strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable { - if(promise_ != nullptr) - { - promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); +namespace aasdk { + namespace usb { + + AccessoryModeStartQuery::AccessoryModeStartQuery(boost::asio::io_service &ioService, IUSBWrapper &usbWrapper, + IUSBEndpoint::Pointer usbEndpoint) + : AccessoryModeQuery(ioService, std::move(usbEndpoint)) { + data_.resize(8); + usbWrapper.fillControlSetup(&data_[0], LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_START, 0, 0, 0); + } + + void AccessoryModeStartQuery::start(Promise::Pointer promise) { + strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable { + if (promise_ != nullptr) { + promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); + } else { + promise_ = std::move(promise); + + auto usbEndpointPromise = IUSBEndpoint::Promise::defer(strand_); + usbEndpointPromise->then([this, self = this->shared_from_this()](size_t bytesTransferred) mutable { + promise_->resolve(usbEndpoint_); + promise_.reset(); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + promise_->reject(e); + promise_.reset(); + }); + + usbEndpoint_->controlTransfer(common::DataBuffer(data_), cTransferTimeoutMs, std::move(usbEndpointPromise)); } - else - { - promise_ = std::move(promise); - - auto usbEndpointPromise = IUSBEndpoint::Promise::defer(strand_); - usbEndpointPromise->then([this, self = this->shared_from_this()](size_t bytesTransferred) mutable { - promise_->resolve(usbEndpoint_); - promise_.reset(); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - promise_->reject(e); - promise_.reset(); - }); - - usbEndpoint_->controlTransfer(common::DataBuffer(data_), cTransferTimeoutMs, std::move(usbEndpointPromise)); - } - }); -} + }); + } -} + } } diff --git a/src/USB/AccessoryModeStartQuery.ut.cpp b/src/USB/AccessoryModeStartQuery.ut.cpp index 87183aed..ef066563 100644 --- a/src/USB/AccessoryModeStartQuery.ut.cpp +++ b/src/USB/AccessoryModeStartQuery.ut.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -23,102 +22,109 @@ #include -namespace aasdk -{ -namespace usb -{ -namespace ut -{ - -using ::testing::_; -using ::testing::SaveArg; -using ::testing::NotNull; - -class AccessoryModeStartQueryUnitTest -{ -protected: - AccessoryModeStartQueryUnitTest() - : usbEndpointMock_(std::make_shared()) - , usbEndpoint_(usbEndpointMock_.get(), [](auto*) {}) - , promise_(IAccessoryModeQuery::Promise::defer(ioService_)) - { - promise_->then(std::bind(&AccessoryModeQueryPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), - std::bind(&AccessoryModeQueryPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); - } - - boost::asio::io_service ioService_; - USBWrapperMock usbWrapperMock_; - std::shared_ptr usbEndpointMock_; - IUSBEndpoint::Pointer usbEndpoint_; - AccessoryModeQueryPromiseHandlerMock promiseHandlerMock_; - IAccessoryModeQuery::Promise::Pointer promise_; - - static constexpr uint32_t USB_TYPE_VENDOR = 0x40; - static constexpr uint32_t ACC_REQ_START = 53; -}; - -BOOST_FIXTURE_TEST_CASE(AccessoryModeStartQuery_Start, AccessoryModeStartQueryUnitTest) -{ - common::DataBuffer buffer; - IUSBEndpoint::Promise::Pointer usbEndpointPromise; - EXPECT_CALL(*usbEndpointMock_, controlTransfer(_, _, _)).WillOnce(DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); - EXPECT_CALL(usbWrapperMock_, fillControlSetup(NotNull(), LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_START, 0, 0, 0)); - - AccessoryModeStartQuery::Pointer query(std::make_shared(ioService_, usbWrapperMock_, usbEndpointMock_)); - query->start(std::move(promise_)); - ioService_.run(); - ioService_.reset(); - - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onResolve(usbEndpoint_)); - - usbEndpointPromise->resolve(buffer.size); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(AccessoryModeStartQuery_TransferError, AccessoryModeStartQueryUnitTest) -{ - common::DataBuffer buffer; - IUSBEndpoint::Promise::Pointer usbEndpointPromise; - EXPECT_CALL(*usbEndpointMock_, controlTransfer(_, _, _)).WillOnce(DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); - EXPECT_CALL(usbWrapperMock_, fillControlSetup(NotNull(), LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_START, 0, 0, 0)); +namespace aasdk { + namespace usb { + namespace ut { + + using ::testing::_; + using ::testing::SaveArg; + using ::testing::NotNull; + + class AccessoryModeStartQueryUnitTest { + protected: + AccessoryModeStartQueryUnitTest() + : usbEndpointMock_(std::make_shared()), + usbEndpoint_(usbEndpointMock_.get(), [](auto *) {}), + promise_(IAccessoryModeQuery::Promise::defer(ioService_)) { + promise_->then( + std::bind(&AccessoryModeQueryPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), + std::bind(&AccessoryModeQueryPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); + } + + boost::asio::io_service ioService_; + USBWrapperMock usbWrapperMock_; + std::shared_ptr usbEndpointMock_; + IUSBEndpoint::Pointer usbEndpoint_; + AccessoryModeQueryPromiseHandlerMock promiseHandlerMock_; + IAccessoryModeQuery::Promise::Pointer promise_; + + static constexpr uint32_t USB_TYPE_VENDOR = 0x40; + static constexpr uint32_t ACC_REQ_START = 53; + }; + + BOOST_FIXTURE_TEST_CASE(AccessoryModeStartQuery_Start, AccessoryModeStartQueryUnitTest) + { + common::DataBuffer buffer; + IUSBEndpoint::Promise::Pointer usbEndpointPromise; + EXPECT_CALL(*usbEndpointMock_, controlTransfer(_, _, _)).WillOnce( + DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); + EXPECT_CALL(usbWrapperMock_, + fillControlSetup(NotNull(), LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_START, 0, 0, 0)); + + AccessoryModeStartQuery::Pointer query( + std::make_shared(ioService_, usbWrapperMock_, usbEndpointMock_)); + query->start(std::move(promise_)); + ioService_.run(); + ioService_.reset(); + + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onResolve(usbEndpoint_)); + + usbEndpointPromise->resolve(buffer.size); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(AccessoryModeStartQuery_TransferError, AccessoryModeStartQueryUnitTest) + { + common::DataBuffer buffer; + IUSBEndpoint::Promise::Pointer usbEndpointPromise; + EXPECT_CALL(*usbEndpointMock_, controlTransfer(_, _, _)).WillOnce( + DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); + EXPECT_CALL(usbWrapperMock_, + fillControlSetup(NotNull(), LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_START, 0, 0, 0)); + + AccessoryModeStartQuery::Pointer query( + std::make_shared(ioService_, usbWrapperMock_, usbEndpointMock_)); + query->start(std::move(promise_)); + ioService_.run(); + ioService_.reset(); + + const error::Error transferError(error::ErrorCode::USB_TRANSFER, LIBUSB_TRANSFER_ERROR); + EXPECT_CALL(promiseHandlerMock_, onReject(transferError)); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + + usbEndpointPromise->reject(transferError); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(AccessoryModeStartQuery_RejectWhenInProgress, AccessoryModeStartQueryUnitTest) + { + common::DataBuffer buffer; + IUSBEndpoint::Promise::Pointer usbEndpointPromise; + EXPECT_CALL(*usbEndpointMock_, controlTransfer(_, _, _)).WillOnce( + DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); + EXPECT_CALL(usbWrapperMock_, + fillControlSetup(NotNull(), LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_START, 0, 0, 0)); + + AccessoryModeStartQuery::Pointer query( + std::make_shared(ioService_, usbWrapperMock_, usbEndpointMock_)); + query->start(std::move(promise_)); + ioService_.run(); + ioService_.reset(); + + AccessoryModeQueryPromiseHandlerMock secondPromiseHandlerMock; + auto secondPromise = IAccessoryModeQuery::Promise::defer(ioService_); + secondPromise->then(std::bind(&AccessoryModeQueryPromiseHandlerMock::onResolve, &secondPromiseHandlerMock, + std::placeholders::_1), + std::bind(&AccessoryModeQueryPromiseHandlerMock::onReject, &secondPromiseHandlerMock, + std::placeholders::_1)); + + EXPECT_CALL(secondPromiseHandlerMock, onReject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS))); + EXPECT_CALL(secondPromiseHandlerMock, onResolve(_)).Times(0); + query->start(std::move(secondPromise)); + ioService_.run(); + } - AccessoryModeStartQuery::Pointer query(std::make_shared(ioService_, usbWrapperMock_, usbEndpointMock_)); - query->start(std::move(promise_)); - ioService_.run(); - ioService_.reset(); - - const error::Error transferError(error::ErrorCode::USB_TRANSFER, LIBUSB_TRANSFER_ERROR); - EXPECT_CALL(promiseHandlerMock_, onReject(transferError)); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - - usbEndpointPromise->reject(transferError); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(AccessoryModeStartQuery_RejectWhenInProgress, AccessoryModeStartQueryUnitTest) -{ - common::DataBuffer buffer; - IUSBEndpoint::Promise::Pointer usbEndpointPromise; - EXPECT_CALL(*usbEndpointMock_, controlTransfer(_, _, _)).WillOnce(DoAll(SaveArg<0>(&buffer), SaveArg<2>(&usbEndpointPromise))); - EXPECT_CALL(usbWrapperMock_, fillControlSetup(NotNull(), LIBUSB_ENDPOINT_OUT | USB_TYPE_VENDOR, ACC_REQ_START, 0, 0, 0)); - - AccessoryModeStartQuery::Pointer query(std::make_shared(ioService_, usbWrapperMock_, usbEndpointMock_)); - query->start(std::move(promise_)); - ioService_.run(); - ioService_.reset(); - - AccessoryModeQueryPromiseHandlerMock secondPromiseHandlerMock; - auto secondPromise = IAccessoryModeQuery::Promise::defer(ioService_); - secondPromise->then(std::bind(&AccessoryModeQueryPromiseHandlerMock::onResolve, &secondPromiseHandlerMock, std::placeholders::_1), - std::bind(&AccessoryModeQueryPromiseHandlerMock::onReject, &secondPromiseHandlerMock, std::placeholders::_1)); - - EXPECT_CALL(secondPromiseHandlerMock, onReject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS))); - EXPECT_CALL(secondPromiseHandlerMock, onResolve(_)).Times(0); - query->start(std::move(secondPromise)); - ioService_.run(); -} - -} -} + } + } } diff --git a/src/USB/ConnectedAccessoriesEnumerator.cpp b/src/USB/ConnectedAccessoriesEnumerator.cpp index 062c79bb..2a441a6a 100644 --- a/src/USB/ConnectedAccessoriesEnumerator.cpp +++ b/src/USB/ConnectedAccessoriesEnumerator.cpp @@ -1,136 +1,110 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -ConnectedAccessoriesEnumerator::ConnectedAccessoriesEnumerator(IUSBWrapper& usbWrapper, boost::asio::io_service& ioService, IAccessoryModeQueryChainFactory& queryChainFactory) - : usbWrapper_(usbWrapper) - , strand_(ioService) - , queryChainFactory_(queryChainFactory) -{ + ConnectedAccessoriesEnumerator::ConnectedAccessoriesEnumerator(IUSBWrapper &usbWrapper, + boost::asio::io_service &ioService, + IAccessoryModeQueryChainFactory &queryChainFactory) + : usbWrapper_(usbWrapper), strand_(ioService), queryChainFactory_(queryChainFactory) { -} + } -void ConnectedAccessoriesEnumerator::enumerate(Promise::Pointer promise) -{ - strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable { - if(promise_ != nullptr) - { - promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); + void ConnectedAccessoriesEnumerator::enumerate(Promise::Pointer promise) { + strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable { + if (promise_ != nullptr) { + promise->reject(error::Error(error::ErrorCode::OPERATION_IN_PROGRESS)); + } else { + promise_ = std::move(promise); + + auto result = usbWrapper_.getDeviceList(deviceListHandle_); + + if (result < 0) { + promise_->reject(error::Error(error::ErrorCode::USB_LIST_DEVICES)); + } else if (deviceListHandle_->empty()) { + promise_->resolve(false); + } else { + actualDeviceIter_ = deviceListHandle_->begin(); + this->queryNextDevice(); + } } - else - { - promise_ = std::move(promise); - - auto result = usbWrapper_.getDeviceList(deviceListHandle_); - - if(result < 0) - { - promise_->reject(error::Error(error::ErrorCode::USB_LIST_DEVICES)); - } - else if(deviceListHandle_->empty()) - { - promise_->resolve(false); - } - else - { - actualDeviceIter_ = deviceListHandle_->begin(); - this->queryNextDevice(); - } - } - }); -} + }); + } -void ConnectedAccessoriesEnumerator::cancel() -{ - strand_.dispatch([this, self = this->shared_from_this()]() mutable { - if(queryChain_ != nullptr) - { - queryChain_->cancel(); + void ConnectedAccessoriesEnumerator::cancel() { + strand_.dispatch([this, self = this->shared_from_this()]() mutable { + if (queryChain_ != nullptr) { + queryChain_->cancel(); } - }); -} + }); + } -void ConnectedAccessoriesEnumerator::queryNextDevice() -{ - auto deviceHandle = this->getNextDeviceHandle(); + void ConnectedAccessoriesEnumerator::queryNextDevice() { + auto deviceHandle = this->getNextDeviceHandle(); - if(deviceHandle != nullptr) - { + if (deviceHandle != nullptr) { queryChain_ = queryChainFactory_.create(); auto queryChainPromise = IAccessoryModeQueryChain::Promise::defer(strand_); queryChainPromise->then([this, self = this->shared_from_this()](DeviceHandle) mutable { - promise_->resolve(true); - this->reset(); - }, - [this, self = this->shared_from_this()](const error::Error& e) mutable { - if(e != error::ErrorCode::OPERATION_ABORTED) - { - this->queryNextDevice(); - } - else - { - promise_->reject(e); - this->reset(); - } - }); + promise_->resolve(true); + this->reset(); + }, + [this, self = this->shared_from_this()](const error::Error &e) mutable { + if (e != error::ErrorCode::OPERATION_ABORTED) { + this->queryNextDevice(); + } else { + promise_->reject(e); + this->reset(); + } + }); queryChain_->start(std::move(deviceHandle), std::move(queryChainPromise)); - } - else if(actualDeviceIter_ == deviceListHandle_->end()) - { + } else if (actualDeviceIter_ == deviceListHandle_->end()) { promise_->resolve(false); this->reset(); + } } -} -DeviceHandle ConnectedAccessoriesEnumerator::getNextDeviceHandle() -{ - DeviceHandle handle; + DeviceHandle ConnectedAccessoriesEnumerator::getNextDeviceHandle() { + DeviceHandle handle; - while(actualDeviceIter_ != deviceListHandle_->end()) - { + while (actualDeviceIter_ != deviceListHandle_->end()) { auto openResult = usbWrapper_.open(*actualDeviceIter_, handle); ++actualDeviceIter_; - if(openResult == 0) - { - break; + if (openResult == 0) { + break; } - } + } - return handle; -} + return handle; + } -void ConnectedAccessoriesEnumerator::reset() -{ - queryChain_.reset(); - deviceListHandle_.reset(); - actualDeviceIter_ = DeviceList::iterator(); - promise_.reset(); -} + void ConnectedAccessoriesEnumerator::reset() { + queryChain_.reset(); + deviceListHandle_.reset(); + actualDeviceIter_ = DeviceList::iterator(); + promise_.reset(); + } -} + } } diff --git a/src/USB/ConnectedAccessoriesEnumerator.ut.cpp b/src/USB/ConnectedAccessoriesEnumerator.ut.cpp index ea203546..59eccf72 100644 --- a/src/USB/ConnectedAccessoriesEnumerator.ut.cpp +++ b/src/USB/ConnectedAccessoriesEnumerator.ut.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -24,212 +23,219 @@ #include -namespace aasdk -{ -namespace usb -{ -namespace ut -{ - -using ::testing::_; -using ::testing::SetArgReferee; -using ::testing::Return; -using ::testing::SaveArg; - -class ConnectedAccessoriesEnumeratorUnitTest -{ -protected: - ConnectedAccessoriesEnumeratorUnitTest() - : queryChain_(&queryChainMock_, [](auto*) {}) - , deviceListHandle_(&deviceList_, [](auto*) {}) - , device_(reinterpret_cast(-1)) - , deviceHandle_(reinterpret_cast(&dummyDeviceHandle_), [](auto*) {}) - , promise_(IConnectedAccessoriesEnumerator::Promise::defer(ioService_)) - { - promise_->then(std::bind(&ConnectedAccessoriesEnumeratorPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), - std::bind(&ConnectedAccessoriesEnumeratorPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); - } +namespace aasdk { + namespace usb { + namespace ut { + + using ::testing::_; + using ::testing::SetArgReferee; + using ::testing::Return; + using ::testing::SaveArg; + + class ConnectedAccessoriesEnumeratorUnitTest { + protected: + ConnectedAccessoriesEnumeratorUnitTest() + : queryChain_(&queryChainMock_, [](auto *) {}), deviceListHandle_(&deviceList_, [](auto *) {}), + device_(reinterpret_cast(-1)), + deviceHandle_(reinterpret_cast(&dummyDeviceHandle_), [](auto *) {}), + promise_(IConnectedAccessoriesEnumerator::Promise::defer(ioService_)) { + promise_->then(std::bind(&ConnectedAccessoriesEnumeratorPromiseHandlerMock::onResolve, &promiseHandlerMock_, + std::placeholders::_1), + std::bind(&ConnectedAccessoriesEnumeratorPromiseHandlerMock::onReject, &promiseHandlerMock_, + std::placeholders::_1)); + } + + boost::asio::io_service ioService_; + USBWrapperMock usbWrapperMock_; + AccessoryModeQueryChainFactoryMock queryChainFactoryMock_; + AccessoryModeQueryChainMock queryChainMock_; + IAccessoryModeQueryChain::Pointer queryChain_; + DeviceList deviceList_; + DeviceListHandle deviceListHandle_; + libusb_device *device_; + USBWrapperMock::DummyDeviceHandle dummyDeviceHandle_; + DeviceHandle deviceHandle_; + ConnectedAccessoriesEnumeratorPromiseHandlerMock promiseHandlerMock_; + IConnectedAccessoriesEnumerator::Promise::Pointer promise_; + }; + + BOOST_FIXTURE_TEST_CASE(ConnectedAccessoriesEnumerator_FirstDeviceIsAOAPCapables, + ConnectedAccessoriesEnumeratorUnitTest) + { + deviceList_.push_back(reinterpret_cast(1)); + EXPECT_CALL(queryChainFactoryMock_, create()).WillOnce(Return(queryChain_)); + auto connectedAccessoriesEnumerator( + std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); + + EXPECT_CALL(usbWrapperMock_, getDeviceList(_)).WillOnce(DoAll(SetArgReferee<0>(deviceListHandle_), Return(0))); + connectedAccessoriesEnumerator->enumerate(std::move(promise_)); + + EXPECT_CALL(usbWrapperMock_, open(*deviceList_.begin(), _)).WillOnce( + DoAll(SetArgReferee<1>(deviceHandle_), Return(0))); - boost::asio::io_service ioService_; - USBWrapperMock usbWrapperMock_; - AccessoryModeQueryChainFactoryMock queryChainFactoryMock_; - AccessoryModeQueryChainMock queryChainMock_; - IAccessoryModeQueryChain::Pointer queryChain_; - DeviceList deviceList_; - DeviceListHandle deviceListHandle_; - libusb_device* device_; - USBWrapperMock::DummyDeviceHandle dummyDeviceHandle_; - DeviceHandle deviceHandle_; - ConnectedAccessoriesEnumeratorPromiseHandlerMock promiseHandlerMock_; - IConnectedAccessoriesEnumerator::Promise::Pointer promise_; -}; - -BOOST_FIXTURE_TEST_CASE(ConnectedAccessoriesEnumerator_FirstDeviceIsAOAPCapables, ConnectedAccessoriesEnumeratorUnitTest) -{ - deviceList_.push_back(reinterpret_cast(1)); - EXPECT_CALL(queryChainFactoryMock_, create()).WillOnce(Return(queryChain_)); - auto connectedAccessoriesEnumerator(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); - - EXPECT_CALL(usbWrapperMock_, getDeviceList(_)).WillOnce(DoAll(SetArgReferee<0>(deviceListHandle_), Return(0))); - connectedAccessoriesEnumerator->enumerate(std::move(promise_)); - - EXPECT_CALL(usbWrapperMock_, open(*deviceList_.begin(), _)).WillOnce(DoAll(SetArgReferee<1>(deviceHandle_), Return(0))); - - IAccessoryModeQueryChain::Promise::Pointer queryChainPromise; - EXPECT_CALL(queryChainMock_, start(deviceHandle_, _)).WillOnce(SaveArg<1>(&queryChainPromise)); - ioService_.run(); - ioService_.reset(); - - EXPECT_CALL(promiseHandlerMock_, onResolve(true)); - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - queryChainPromise->resolve(deviceHandle_); - ioService_.run(); -} + IAccessoryModeQueryChain::Promise::Pointer queryChainPromise; + EXPECT_CALL(queryChainMock_, start(deviceHandle_, _)).WillOnce(SaveArg<1>(&queryChainPromise)); + ioService_.run(); + ioService_.reset(); -BOOST_FIXTURE_TEST_CASE(ConnectedAccessoriesEnumerator_SecondDeviceIsAOAPCapable, ConnectedAccessoriesEnumeratorUnitTest) -{ - deviceList_.push_back(reinterpret_cast(1)); - deviceList_.push_back(reinterpret_cast(2)); - auto connectedAccessoriesEnumerator(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); - - EXPECT_CALL(queryChainFactoryMock_, create()).Times(deviceList_.size()).WillRepeatedly(Return(queryChain_)); - EXPECT_CALL(usbWrapperMock_, getDeviceList(_)).WillOnce(DoAll(SetArgReferee<0>(deviceListHandle_), Return(0))); - connectedAccessoriesEnumerator->enumerate(std::move(promise_)); - - EXPECT_CALL(usbWrapperMock_, open(*deviceList_.begin(), _)).WillOnce(DoAll(SetArgReferee<1>(deviceHandle_), Return(0))); - IAccessoryModeQueryChain::Promise::Pointer queryChainPromise; - EXPECT_CALL(queryChainMock_, start(deviceHandle_, _)).WillRepeatedly(SaveArg<1>(&queryChainPromise)); - ioService_.run(); - ioService_.reset(); - - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - - // open second device - USBWrapperMock::DummyDeviceHandle dummyDeviceHandle2; - DeviceHandle deviceHandle2(reinterpret_cast(&dummyDeviceHandle2), [](auto*) {}); - EXPECT_CALL(usbWrapperMock_, open(*(++deviceList_.begin()), _)).WillOnce(DoAll(SetArgReferee<1>(deviceHandle2), Return(0))); - - IAccessoryModeQueryChain::Promise::Pointer queryChainPromise2; - EXPECT_CALL(queryChainMock_, start(deviceHandle2, _)).WillRepeatedly(SaveArg<1>(&queryChainPromise2)); - - queryChainPromise->reject(error::Error(error::ErrorCode::USB_AOAP_PROTOCOL_VERSION)); - ioService_.run(); - ioService_.reset(); - - EXPECT_CALL(promiseHandlerMock_, onResolve(true)); - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - queryChainPromise2->resolve(deviceHandle2); - ioService_.run(); -} + EXPECT_CALL(promiseHandlerMock_, onResolve(true)); + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + queryChainPromise->resolve(deviceHandle_); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(ConnectedAccessoriesEnumerator_SecondDeviceIsAOAPCapable, + ConnectedAccessoriesEnumeratorUnitTest) + { + deviceList_.push_back(reinterpret_cast(1)); + deviceList_.push_back(reinterpret_cast(2)); + auto connectedAccessoriesEnumerator( + std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); + + EXPECT_CALL(queryChainFactoryMock_, create()).Times(deviceList_.size()).WillRepeatedly(Return(queryChain_)); + EXPECT_CALL(usbWrapperMock_, getDeviceList(_)).WillOnce(DoAll(SetArgReferee<0>(deviceListHandle_), Return(0))); + connectedAccessoriesEnumerator->enumerate(std::move(promise_)); + + EXPECT_CALL(usbWrapperMock_, open(*deviceList_.begin(), _)).WillOnce( + DoAll(SetArgReferee<1>(deviceHandle_), Return(0))); + IAccessoryModeQueryChain::Promise::Pointer queryChainPromise; + EXPECT_CALL(queryChainMock_, start(deviceHandle_, _)).WillRepeatedly(SaveArg<1>(&queryChainPromise)); + ioService_.run(); + ioService_.reset(); -BOOST_FIXTURE_TEST_CASE(ConnectedAccessoriesEnumerator_NoAOAPCapableDevice, ConnectedAccessoriesEnumeratorUnitTest) -{ - for(size_t i = 1; i < 1000; ++i) - { - deviceList_.push_back(reinterpret_cast(i)); - } + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(usbWrapperMock_, getDeviceList(_)).WillOnce(DoAll(SetArgReferee<0>(deviceListHandle_), Return(0))); - EXPECT_CALL(queryChainFactoryMock_, create()).Times(deviceList_.size()).WillRepeatedly(Return(queryChain_)); + // open second device + USBWrapperMock::DummyDeviceHandle dummyDeviceHandle2; + DeviceHandle deviceHandle2(reinterpret_cast(&dummyDeviceHandle2), [](auto *) {}); + EXPECT_CALL(usbWrapperMock_, open(*(++deviceList_.begin()), _)).WillOnce( + DoAll(SetArgReferee<1>(deviceHandle2), Return(0))); - auto connectedAccessoriesEnumerator(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); - connectedAccessoriesEnumerator->enumerate(std::move(promise_)); + IAccessoryModeQueryChain::Promise::Pointer queryChainPromise2; + EXPECT_CALL(queryChainMock_, start(deviceHandle2, _)).WillRepeatedly(SaveArg<1>(&queryChainPromise2)); - EXPECT_CALL(promiseHandlerMock_, onResolve(false)); - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + queryChainPromise->reject(error::Error(error::ErrorCode::USB_AOAP_PROTOCOL_VERSION)); + ioService_.run(); + ioService_.reset(); - for(const auto& device : deviceList_) - { - USBWrapperMock::DummyDeviceHandle dummyDeviceHandle; - DeviceHandle deviceHandle(reinterpret_cast(&dummyDeviceHandle), [](auto*) {}); - EXPECT_CALL(usbWrapperMock_, open(device, _)).WillOnce(DoAll(SetArgReferee<1>(deviceHandle), Return(0))); + EXPECT_CALL(promiseHandlerMock_, onResolve(true)); + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + queryChainPromise2->resolve(deviceHandle2); + ioService_.run(); + } - IAccessoryModeQueryChain::Promise::Pointer queryChainPromise; - EXPECT_CALL(queryChainMock_, start(deviceHandle, _)).WillRepeatedly(SaveArg<1>(&queryChainPromise)); + BOOST_FIXTURE_TEST_CASE(ConnectedAccessoriesEnumerator_NoAOAPCapableDevice, + ConnectedAccessoriesEnumeratorUnitTest) + { + for (size_t i = 1; i < 1000; ++i) { + deviceList_.push_back(reinterpret_cast(i)); + } - ioService_.run(); - ioService_.reset(); + EXPECT_CALL(usbWrapperMock_, getDeviceList(_)).WillOnce(DoAll(SetArgReferee<0>(deviceListHandle_), Return(0))); + EXPECT_CALL(queryChainFactoryMock_, create()).Times(deviceList_.size()).WillRepeatedly(Return(queryChain_)); - queryChainPromise->reject(error::Error(error::ErrorCode::USB_AOAP_PROTOCOL_VERSION)); - } + auto connectedAccessoriesEnumerator( + std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); + connectedAccessoriesEnumerator->enumerate(std::move(promise_)); - ioService_.run(); -} + EXPECT_CALL(promiseHandlerMock_, onResolve(false)); + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); -BOOST_FIXTURE_TEST_CASE(ConnectedAccessoriesEnumerator_GetDeviceListFailed, ConnectedAccessoriesEnumeratorUnitTest) -{ - EXPECT_CALL(usbWrapperMock_, getDeviceList(_)).WillOnce(DoAll(SetArgReferee<0>(deviceListHandle_), Return(-1))); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::USB_LIST_DEVICES))); + for (const auto &device: deviceList_) { + USBWrapperMock::DummyDeviceHandle dummyDeviceHandle; + DeviceHandle deviceHandle(reinterpret_cast(&dummyDeviceHandle), [](auto *) {}); + EXPECT_CALL(usbWrapperMock_, open(device, _)).WillOnce(DoAll(SetArgReferee<1>(deviceHandle), Return(0))); - auto connectedAccessoriesEnumerator(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); - connectedAccessoriesEnumerator->enumerate(std::move(promise_)); + IAccessoryModeQueryChain::Promise::Pointer queryChainPromise; + EXPECT_CALL(queryChainMock_, start(deviceHandle, _)).WillRepeatedly(SaveArg<1>(&queryChainPromise)); - ioService_.run(); -} + ioService_.run(); + ioService_.reset(); -BOOST_FIXTURE_TEST_CASE(ConnectedAccessoriesEnumerator_EmptyDevicesList, ConnectedAccessoriesEnumeratorUnitTest) -{ - EXPECT_CALL(usbWrapperMock_, getDeviceList(_)).WillOnce(DoAll(SetArgReferee<0>(deviceListHandle_), Return(0))); - EXPECT_CALL(promiseHandlerMock_, onResolve(false)); - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + queryChainPromise->reject(error::Error(error::ErrorCode::USB_AOAP_PROTOCOL_VERSION)); + } - auto connectedAccessoriesEnumerator(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); - connectedAccessoriesEnumerator->enumerate(std::move(promise_)); + ioService_.run(); + } - ioService_.run(); -} + BOOST_FIXTURE_TEST_CASE(ConnectedAccessoriesEnumerator_GetDeviceListFailed, + ConnectedAccessoriesEnumeratorUnitTest) + { + EXPECT_CALL(usbWrapperMock_, getDeviceList(_)).WillOnce(DoAll(SetArgReferee<0>(deviceListHandle_), Return(-1))); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::USB_LIST_DEVICES))); -BOOST_FIXTURE_TEST_CASE(ConnectedAccessoriesEnumerator_OpenDeviceFailed, ConnectedAccessoriesEnumeratorUnitTest) -{ - for(size_t i = 1; i < 1000; ++i) - { - deviceList_.push_back(reinterpret_cast(i)); - } + auto connectedAccessoriesEnumerator( + std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); + connectedAccessoriesEnumerator->enumerate(std::move(promise_)); - EXPECT_CALL(usbWrapperMock_, getDeviceList(_)).WillOnce(DoAll(SetArgReferee<0>(deviceListHandle_), Return(0))); + ioService_.run(); + } - auto connectedAccessoriesEnumerator(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); - connectedAccessoriesEnumerator->enumerate(std::move(promise_)); + BOOST_FIXTURE_TEST_CASE(ConnectedAccessoriesEnumerator_EmptyDevicesList, ConnectedAccessoriesEnumeratorUnitTest) + { + EXPECT_CALL(usbWrapperMock_, getDeviceList(_)).WillOnce(DoAll(SetArgReferee<0>(deviceListHandle_), Return(0))); + EXPECT_CALL(promiseHandlerMock_, onResolve(false)); + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onResolve(false)); - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + auto connectedAccessoriesEnumerator( + std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); + connectedAccessoriesEnumerator->enumerate(std::move(promise_)); - for(const auto& device : deviceList_) - { - EXPECT_CALL(usbWrapperMock_, open(device, _)).WillOnce(DoAll(SetArgReferee<1>(nullptr), Return(0xFFF))); - } + ioService_.run(); + } - ioService_.run(); -} + BOOST_FIXTURE_TEST_CASE(ConnectedAccessoriesEnumerator_OpenDeviceFailed, ConnectedAccessoriesEnumeratorUnitTest) + { + for (size_t i = 1; i < 1000; ++i) { + deviceList_.push_back(reinterpret_cast(i)); + } -BOOST_FIXTURE_TEST_CASE(ConnectedAccessoriesEnumerator_CancelEnumeration, ConnectedAccessoriesEnumeratorUnitTest) -{ - deviceList_.push_back(reinterpret_cast(1)); - EXPECT_CALL(queryChainFactoryMock_, create()).WillOnce(Return(queryChain_)); - auto connectedAccessoriesEnumerator(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); + EXPECT_CALL(usbWrapperMock_, getDeviceList(_)).WillOnce(DoAll(SetArgReferee<0>(deviceListHandle_), Return(0))); - EXPECT_CALL(usbWrapperMock_, getDeviceList(_)).WillOnce(DoAll(SetArgReferee<0>(deviceListHandle_), Return(0))); - connectedAccessoriesEnumerator->enumerate(std::move(promise_)); + auto connectedAccessoriesEnumerator( + std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); + connectedAccessoriesEnumerator->enumerate(std::move(promise_)); - EXPECT_CALL(usbWrapperMock_, open(*deviceList_.begin(), _)).WillOnce(DoAll(SetArgReferee<1>(deviceHandle_), Return(0))); + EXPECT_CALL(promiseHandlerMock_, onResolve(false)); + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - IAccessoryModeQueryChain::Promise::Pointer queryChainPromise; - EXPECT_CALL(queryChainMock_, start(deviceHandle_, _)).WillOnce(SaveArg<1>(&queryChainPromise)); - ioService_.run(); - ioService_.reset(); + for (const auto &device: deviceList_) { + EXPECT_CALL(usbWrapperMock_, open(device, _)).WillOnce(DoAll(SetArgReferee<1>(nullptr), Return(0xFFF))); + } - EXPECT_CALL(queryChainMock_, cancel()); - connectedAccessoriesEnumerator->cancel(); + ioService_.run(); + } - error::Error e(error::ErrorCode::OPERATION_ABORTED); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(e)); - queryChainPromise->reject(e); - ioService_.run(); -} + BOOST_FIXTURE_TEST_CASE(ConnectedAccessoriesEnumerator_CancelEnumeration, ConnectedAccessoriesEnumeratorUnitTest) + { + deviceList_.push_back(reinterpret_cast(1)); + EXPECT_CALL(queryChainFactoryMock_, create()).WillOnce(Return(queryChain_)); + auto connectedAccessoriesEnumerator( + std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); -} -} + EXPECT_CALL(usbWrapperMock_, getDeviceList(_)).WillOnce(DoAll(SetArgReferee<0>(deviceListHandle_), Return(0))); + connectedAccessoriesEnumerator->enumerate(std::move(promise_)); + + EXPECT_CALL(usbWrapperMock_, open(*deviceList_.begin(), _)).WillOnce( + DoAll(SetArgReferee<1>(deviceHandle_), Return(0))); + + IAccessoryModeQueryChain::Promise::Pointer queryChainPromise; + EXPECT_CALL(queryChainMock_, start(deviceHandle_, _)).WillOnce(SaveArg<1>(&queryChainPromise)); + ioService_.run(); + ioService_.reset(); + + EXPECT_CALL(queryChainMock_, cancel()); + connectedAccessoriesEnumerator->cancel(); + + error::Error e(error::ErrorCode::OPERATION_ABORTED); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(e)); + queryChainPromise->reject(e); + ioService_.run(); + } + + } + } } diff --git a/src/USB/USBEndpoint.cpp b/src/USB/USBEndpoint.cpp index f4e5bf91..86bedc4e 100644 --- a/src/USB/USBEndpoint.cpp +++ b/src/USB/USBEndpoint.cpp @@ -1,176 +1,150 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include #include +#include +namespace aasdk { + namespace usb { -namespace aasdk -{ -namespace usb -{ - -USBEndpoint::USBEndpoint(IUSBWrapper& usbWrapper, boost::asio::io_service& ioService, DeviceHandle handle, uint8_t endpointAddress) - : usbWrapper_(usbWrapper) - , strand_(ioService) - , handle_(std::move(handle)) - , endpointAddress_(endpointAddress) -{ -} + USBEndpoint::USBEndpoint(IUSBWrapper &usbWrapper, boost::asio::io_service &ioService, DeviceHandle handle, + uint8_t endpointAddress) + : usbWrapper_(usbWrapper), strand_(ioService), handle_(std::move(handle)), endpointAddress_(endpointAddress) { + } -void USBEndpoint::controlTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) -{ - if(endpointAddress_ != 0) - { + void USBEndpoint::controlTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) { + if (endpointAddress_ != 0) { promise->reject(error::Error(error::ErrorCode::USB_INVALID_TRANSFER_METHOD)); - } - else - { - auto* transfer = usbWrapper_.allocTransfer(0); - if(transfer == nullptr) - { - promise->reject(error::Error(error::ErrorCode::USB_TRANSFER_ALLOCATION)); - } - else - { - usbWrapper_.fillControlTransfer(transfer, handle_, buffer.data, reinterpret_cast(&USBEndpoint::transferHandler), this, timeout); - this->transfer(transfer, std::move(promise)); + } else { + auto *transfer = usbWrapper_.allocTransfer(0); + if (transfer == nullptr) { + promise->reject(error::Error(error::ErrorCode::USB_TRANSFER_ALLOCATION)); + } else { + usbWrapper_.fillControlTransfer(transfer, handle_, buffer.data, + reinterpret_cast(&USBEndpoint::transferHandler), this, + timeout); + this->transfer(transfer, std::move(promise)); } + } } -} -void USBEndpoint::interruptTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) -{ - if(endpointAddress_ == 0) - { + void USBEndpoint::interruptTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) { + if (endpointAddress_ == 0) { promise->reject(error::Error(error::ErrorCode::USB_INVALID_TRANSFER_METHOD)); - } - else - { - auto* transfer = usbWrapper_.allocTransfer(0); - if(transfer == nullptr) - { - promise->reject(error::Error(error::ErrorCode::USB_TRANSFER_ALLOCATION)); - } - else - { - usbWrapper_.fillInterruptTransfer(transfer, handle_, endpointAddress_, buffer.data, buffer.size, reinterpret_cast(&USBEndpoint::transferHandler), this, timeout); - this->transfer(transfer, std::move(promise)); + } else { + auto *transfer = usbWrapper_.allocTransfer(0); + if (transfer == nullptr) { + promise->reject(error::Error(error::ErrorCode::USB_TRANSFER_ALLOCATION)); + } else { + usbWrapper_.fillInterruptTransfer(transfer, handle_, endpointAddress_, buffer.data, buffer.size, + reinterpret_cast(&USBEndpoint::transferHandler), + this, timeout); + this->transfer(transfer, std::move(promise)); } + } } -} -void USBEndpoint::bulkTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) -{ - if(endpointAddress_ == 0) - { + void USBEndpoint::bulkTransfer(common::DataBuffer buffer, uint32_t timeout, Promise::Pointer promise) { + if (endpointAddress_ == 0) { promise->reject(error::Error(error::ErrorCode::USB_INVALID_TRANSFER_METHOD)); - } - else - { - auto* transfer = usbWrapper_.allocTransfer(0); - if(transfer == nullptr) - { - promise->reject(error::Error(error::ErrorCode::USB_TRANSFER_ALLOCATION)); - } - else - { - usbWrapper_.fillBulkTransfer(transfer, handle_, endpointAddress_, buffer.data, buffer.size, reinterpret_cast(&USBEndpoint::transferHandler), this, timeout); - this->transfer(transfer, std::move(promise)); + } else { + auto *transfer = usbWrapper_.allocTransfer(0); + if (transfer == nullptr) { + AASDK_LOG(debug) << "[USBEndpoint] Rejecting Promise " << endpointAddress_ << " size " << buffer.size; + promise->reject(error::Error(error::ErrorCode::USB_TRANSFER_ALLOCATION)); + } else { + AASDK_LOG(debug) << "[USBEndpoint] Fill Bulk Transfer " << endpointAddress_ << " size " << buffer.size; + usbWrapper_.fillBulkTransfer(transfer, handle_, endpointAddress_, buffer.data, buffer.size, + reinterpret_cast(&USBEndpoint::transferHandler), this, + timeout); + this->transfer(transfer, std::move(promise)); } + } } -} -void USBEndpoint::transfer(libusb_transfer *transfer, Promise::Pointer promise) -{ - strand_.dispatch([this, self = this->shared_from_this(), transfer, promise = std::move(promise)]() mutable { + void USBEndpoint::transfer(libusb_transfer *transfer, Promise::Pointer promise) { + strand_.dispatch([this, self = this->shared_from_this(), transfer, promise = std::move(promise)]() mutable { auto submitResult = usbWrapper_.submitTransfer(transfer); - if(submitResult == 0) - { - // guarantee that endpoint will live until all transfers are finished - if(self_ == nullptr) - { - self_ = std::move(self); - } - - transfers_.insert(std::make_pair(transfer, std::move(promise))); + if (submitResult == libusb_error::LIBUSB_SUCCESS) { + // guarantee that endpoint will live until all transfers are finished + if (self_ == nullptr) { + self_ = std::move(self); + } + + transfers_.insert(std::make_pair(transfer, std::move(promise))); + } else { + AASDK_LOG(debug) << "[USBEndpoint] USB Failure " << submitResult; + promise->reject(error::Error(error::ErrorCode::USB_TRANSFER, submitResult)); + usbWrapper_.freeTransfer(transfer); } - else - { - promise->reject(error::Error(error::ErrorCode::USB_TRANSFER, submitResult)); - usbWrapper_.freeTransfer(transfer); - } - }); -} + }); + } -uint8_t USBEndpoint::getAddress() -{ - return endpointAddress_; -} + uint8_t USBEndpoint::getAddress() { + return endpointAddress_; + } -void USBEndpoint::cancelTransfers() -{ - strand_.dispatch([this, self = this->shared_from_this()]() mutable { - for(const auto& transfer : transfers_) - { - usbWrapper_.cancelTransfer(transfer.first); + void USBEndpoint::cancelTransfers() { + strand_.dispatch([this, self = this->shared_from_this()]() mutable { + for (const auto &transfer: transfers_) { + usbWrapper_.cancelTransfer(transfer.first); } - }); -} + }); + } -DeviceHandle USBEndpoint::getDeviceHandle() const -{ - return handle_; -} + DeviceHandle USBEndpoint::getDeviceHandle() const { + return handle_; + } -void USBEndpoint::transferHandler(libusb_transfer *transfer) -{ - auto self = reinterpret_cast(transfer->user_data)->shared_from_this(); + void USBEndpoint::transferHandler(libusb_transfer *transfer) { + AASDK_LOG(debug) << "[USBEndpoint] transferHandler()"; + auto self = reinterpret_cast(transfer->user_data)->shared_from_this(); - self->strand_.dispatch([self, transfer]() mutable { - if(self->transfers_.count(transfer) == 0) - { - return; + self->strand_.dispatch([self, transfer]() mutable { + if (self->transfers_.count(transfer) == 0) { + AASDK_LOG(debug) << "[USBEndpoint] No more transfers."; + return; } auto promise(std::move(self->transfers_.at(transfer))); - if(transfer->status == LIBUSB_TRANSFER_COMPLETED) - { - promise->resolve(transfer->actual_length); - } - else - { - auto error = transfer->status == LIBUSB_TRANSFER_CANCELLED ? error::Error(error::ErrorCode::OPERATION_ABORTED) : error::Error(error::ErrorCode::USB_TRANSFER, transfer->status); - promise->reject(error); + if (transfer->status == LIBUSB_TRANSFER_COMPLETED) { + AASDK_LOG(debug) << "[Transport] Transfer Complete."; + promise->resolve(transfer->actual_length); + } else { + AASDK_LOG(debug) << "[Transport] Transfer Cancelled."; + auto error = transfer->status == + LIBUSB_TRANSFER_CANCELLED ? error::Error(error::ErrorCode::OPERATION_ABORTED) + : error::Error(error::ErrorCode::USB_TRANSFER, + transfer->status); + promise->reject(error); } self->usbWrapper_.freeTransfer(transfer); self->transfers_.erase(transfer); - if(self->transfers_.empty()) - { - self->self_.reset(); + if (self->transfers_.empty()) { + self->self_.reset(); } - }); -} + }); + } -} + } } diff --git a/src/USB/USBEndpoint.ut.cpp b/src/USB/USBEndpoint.ut.cpp index b030a2cd..0c06196d 100644 --- a/src/USB/USBEndpoint.ut.cpp +++ b/src/USB/USBEndpoint.ut.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -24,269 +23,274 @@ #include -namespace aasdk -{ -namespace usb -{ -namespace ut -{ - -using ::testing::_; -using ::testing::Return; -using ::testing::SaveArg; - -class USBEndpointUnitTest -{ -protected: - USBEndpointUnitTest() - : deviceHandle_(reinterpret_cast(&dummyDeviceHandle_), [](auto*) {}) - , promise_(IUSBEndpoint::Promise::defer(ioService_)) - { - promise_->then(std::bind(&USBEndpointPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), - std::bind(&USBEndpointPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); - } - - USBWrapperMock usbWrapperMock_; - boost::asio::io_service ioService_; - USBWrapperMock::DummyDeviceHandle dummyDeviceHandle_; - DeviceHandle deviceHandle_; - USBEndpointPromiseHandlerMock promiseHandlerMock_; - IUSBEndpoint::Promise::Pointer promise_; -}; - -BOOST_FIXTURE_TEST_CASE(USBEndpoint_ControlTransferForNonControlEndpoint, USBEndpointUnitTest) -{ - common::Data data(10, 0); - USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_, 0x01)); - - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::USB_INVALID_TRANSFER_METHOD))); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - usbEndpoint->controlTransfer(common::DataBuffer(data), 0, std::move(promise_)); - - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(USBEndpoint_BulkTransferForControlEndpoint, USBEndpointUnitTest) -{ - common::Data data(10, 0); - USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_)); - - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::USB_INVALID_TRANSFER_METHOD))); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - usbEndpoint->bulkTransfer(common::DataBuffer(data), 0, std::move(promise_)); - - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(USBEndpoint_InterruptTransferForControlEndpoint, USBEndpointUnitTest) -{ - common::Data data(10, 0); - USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_)); - - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::USB_INVALID_TRANSFER_METHOD))); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - usbEndpoint->interruptTransfer(common::DataBuffer(data), 0, std::move(promise_)); - - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(USBEndpoint_ControlTransferAllocationFailed, USBEndpointUnitTest) -{ - common::Data data(10, 0); - USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_)); - - EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillOnce(Return(nullptr)); - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::USB_TRANSFER_ALLOCATION))); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - usbEndpoint->controlTransfer(common::DataBuffer(data), 0, std::move(promise_)); +namespace aasdk { + namespace usb { + namespace ut { + + using ::testing::_; + using ::testing::Return; + using ::testing::SaveArg; + + class USBEndpointUnitTest { + protected: + USBEndpointUnitTest() + : deviceHandle_(reinterpret_cast(&dummyDeviceHandle_), [](auto *) {}), + promise_(IUSBEndpoint::Promise::defer(ioService_)) { + promise_->then( + std::bind(&USBEndpointPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), + std::bind(&USBEndpointPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); + } + + USBWrapperMock usbWrapperMock_; + boost::asio::io_service ioService_; + USBWrapperMock::DummyDeviceHandle dummyDeviceHandle_; + DeviceHandle deviceHandle_; + USBEndpointPromiseHandlerMock promiseHandlerMock_; + IUSBEndpoint::Promise::Pointer promise_; + }; + + BOOST_FIXTURE_TEST_CASE(USBEndpoint_ControlTransferForNonControlEndpoint, USBEndpointUnitTest) + { + common::Data data(10, 0); + USBEndpoint::Pointer usbEndpoint( + std::make_shared(usbWrapperMock_, ioService_, deviceHandle_, 0x01)); + + EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::USB_INVALID_TRANSFER_METHOD))); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + usbEndpoint->controlTransfer(common::DataBuffer(data), 0, std::move(promise_)); - ioService_.run(); -} + ioService_.run(); + } -BOOST_FIXTURE_TEST_CASE(USBEndpoint_BulkTransferAllocationFailed, USBEndpointUnitTest) -{ - common::Data data(10, 0); - USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_, 0x01)); + BOOST_FIXTURE_TEST_CASE(USBEndpoint_BulkTransferForControlEndpoint, USBEndpointUnitTest) + { + common::Data data(10, 0); + USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_)); - EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillOnce(Return(nullptr)); - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::USB_TRANSFER_ALLOCATION))); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - usbEndpoint->bulkTransfer(common::DataBuffer(data), 0, std::move(promise_)); + EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::USB_INVALID_TRANSFER_METHOD))); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + usbEndpoint->bulkTransfer(common::DataBuffer(data), 0, std::move(promise_)); - ioService_.run(); -} + ioService_.run(); + } -BOOST_FIXTURE_TEST_CASE(USBEndpoint_InterruptTransferAllocationFailed, USBEndpointUnitTest) -{ - common::Data data(10, 0); - USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_, 0x01)); + BOOST_FIXTURE_TEST_CASE(USBEndpoint_InterruptTransferForControlEndpoint, USBEndpointUnitTest) + { + common::Data data(10, 0); + USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_)); - EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillOnce(Return(nullptr)); - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::USB_TRANSFER_ALLOCATION))); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - usbEndpoint->interruptTransfer(common::DataBuffer(data), 0, std::move(promise_)); + EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::USB_INVALID_TRANSFER_METHOD))); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + usbEndpoint->interruptTransfer(common::DataBuffer(data), 0, std::move(promise_)); - ioService_.run(); -} + ioService_.run(); + } -BOOST_FIXTURE_TEST_CASE(USBEndpoint_BulkTransfer, USBEndpointUnitTest) -{ - const uint8_t endpointAddress = 0x55; - USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_, endpointAddress)); + BOOST_FIXTURE_TEST_CASE(USBEndpoint_ControlTransferAllocationFailed, USBEndpointUnitTest) + { + common::Data data(10, 0); + USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_)); - libusb_transfer transfer; - EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillOnce(Return(&transfer)); + EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillOnce(Return(nullptr)); + EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::USB_TRANSFER_ALLOCATION))); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + usbEndpoint->controlTransfer(common::DataBuffer(data), 0, std::move(promise_)); - libusb_transfer_cb_fn transferCallback; - common::Data data(1000, 0); - common::DataBuffer buffer(data); - EXPECT_CALL(usbWrapperMock_, fillBulkTransfer(&transfer, _, endpointAddress, buffer.data, buffer.size, _, _, _)) - .WillOnce(DoAll(SaveArg<5>(&transferCallback), SaveArg<6>(&transfer.user_data))); - EXPECT_CALL(usbWrapperMock_, submitTransfer(&transfer)); + ioService_.run(); + } - usbEndpoint->bulkTransfer(common::DataBuffer(data), 0, std::move(promise_)); - ioService_.run(); - ioService_.reset(); + BOOST_FIXTURE_TEST_CASE(USBEndpoint_BulkTransferAllocationFailed, USBEndpointUnitTest) + { + common::Data data(10, 0); + USBEndpoint::Pointer usbEndpoint( + std::make_shared(usbWrapperMock_, ioService_, deviceHandle_, 0x01)); - transfer.actual_length = buffer.size; - transfer.status = LIBUSB_TRANSFER_COMPLETED; - transferCallback(&transfer); + EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillOnce(Return(nullptr)); + EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::USB_TRANSFER_ALLOCATION))); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + usbEndpoint->bulkTransfer(common::DataBuffer(data), 0, std::move(promise_)); - EXPECT_CALL(usbWrapperMock_, freeTransfer(&transfer)); - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onResolve(buffer.size)); - ioService_.run(); -} + ioService_.run(); + } -BOOST_FIXTURE_TEST_CASE(USBEndpoint_MultipleBulkTransfers, USBEndpointUnitTest) -{ - const uint8_t endpointAddress = 0x55; - USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_, endpointAddress)); + BOOST_FIXTURE_TEST_CASE(USBEndpoint_InterruptTransferAllocationFailed, USBEndpointUnitTest) + { + common::Data data(10, 0); + USBEndpoint::Pointer usbEndpoint( + std::make_shared(usbWrapperMock_, ioService_, deviceHandle_, 0x01)); - libusb_transfer transfer; - EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillRepeatedly(Return(&transfer)); + EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillOnce(Return(nullptr)); + EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::USB_TRANSFER_ALLOCATION))); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + usbEndpoint->interruptTransfer(common::DataBuffer(data), 0, std::move(promise_)); - const size_t attemptsCount = 1000; + ioService_.run(); + } - libusb_transfer_cb_fn transferCallback; + BOOST_FIXTURE_TEST_CASE(USBEndpoint_BulkTransfer, USBEndpointUnitTest) + { + const uint8_t endpointAddress = 0x55; + USBEndpoint::Pointer usbEndpoint( + std::make_shared(usbWrapperMock_, ioService_, deviceHandle_, endpointAddress)); - EXPECT_CALL(usbWrapperMock_, submitTransfer(&transfer)).Times(attemptsCount); - EXPECT_CALL(usbWrapperMock_, freeTransfer(&transfer)).Times(attemptsCount); - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + libusb_transfer transfer; + EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillOnce(Return(&transfer)); - for(size_t i = 0; i < attemptsCount; ++i) - { - common::Data data(10000 + attemptsCount, 0); + libusb_transfer_cb_fn transferCallback; + common::Data data(1000, 0); common::DataBuffer buffer(data); EXPECT_CALL(usbWrapperMock_, fillBulkTransfer(&transfer, _, endpointAddress, buffer.data, buffer.size, _, _, _)) - .WillOnce(DoAll(SaveArg<5>(&transferCallback), SaveArg<6>(&transfer.user_data))); - EXPECT_CALL(promiseHandlerMock_, onResolve(buffer.size)).Times(1); - - transfer.actual_length = 0; - transfer.status = LIBUSB_TRANSFER_ERROR; - - auto promise = IUSBEndpoint::Promise::defer(ioService_); - promise->then(std::bind(&USBEndpointPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), - std::bind(&USBEndpointPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); + .WillOnce(DoAll(SaveArg<5>(&transferCallback), SaveArg<6>(&transfer.user_data))); + EXPECT_CALL(usbWrapperMock_, submitTransfer(&transfer)); - usbEndpoint->bulkTransfer(common::DataBuffer(data), 0, std::move(promise)); + usbEndpoint->bulkTransfer(common::DataBuffer(data), 0, std::move(promise_)); ioService_.run(); ioService_.reset(); transfer.actual_length = buffer.size; transfer.status = LIBUSB_TRANSFER_COMPLETED; transferCallback(&transfer); - ioService_.run(); - ioService_.reset(); - } -} - -BOOST_FIXTURE_TEST_CASE(USBEndpoint_ControlTransfer, USBEndpointUnitTest) -{ - USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_)); - - libusb_transfer transfer; - EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillOnce(Return(&transfer)); - libusb_transfer_cb_fn transferCallback; - common::Data data(100, 0); - common::DataBuffer buffer(data); - EXPECT_CALL(usbWrapperMock_, fillControlTransfer(&transfer, _, buffer.data, _, _, _)) + EXPECT_CALL(usbWrapperMock_, freeTransfer(&transfer)); + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onResolve(buffer.size)); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(USBEndpoint_MultipleBulkTransfers, USBEndpointUnitTest) + { + const uint8_t endpointAddress = 0x55; + USBEndpoint::Pointer usbEndpoint( + std::make_shared(usbWrapperMock_, ioService_, deviceHandle_, endpointAddress)); + + libusb_transfer transfer; + EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillRepeatedly(Return(&transfer)); + + const size_t attemptsCount = 1000; + + libusb_transfer_cb_fn transferCallback; + + EXPECT_CALL(usbWrapperMock_, submitTransfer(&transfer)).Times(attemptsCount); + EXPECT_CALL(usbWrapperMock_, freeTransfer(&transfer)).Times(attemptsCount); + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + + for (size_t i = 0; i < attemptsCount; ++i) { + common::Data data(10000 + attemptsCount, 0); + common::DataBuffer buffer(data); + EXPECT_CALL(usbWrapperMock_, + fillBulkTransfer(&transfer, _, endpointAddress, buffer.data, buffer.size, _, _, _)) + .WillOnce(DoAll(SaveArg<5>(&transferCallback), SaveArg<6>(&transfer.user_data))); + EXPECT_CALL(promiseHandlerMock_, onResolve(buffer.size)).Times(1); + + transfer.actual_length = 0; + transfer.status = LIBUSB_TRANSFER_ERROR; + + auto promise = IUSBEndpoint::Promise::defer(ioService_); + promise->then( + std::bind(&USBEndpointPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), + std::bind(&USBEndpointPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); + + usbEndpoint->bulkTransfer(common::DataBuffer(data), 0, std::move(promise)); + ioService_.run(); + ioService_.reset(); + + transfer.actual_length = buffer.size; + transfer.status = LIBUSB_TRANSFER_COMPLETED; + transferCallback(&transfer); + ioService_.run(); + ioService_.reset(); + } + } + + BOOST_FIXTURE_TEST_CASE(USBEndpoint_ControlTransfer, USBEndpointUnitTest) + { + USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_)); + + libusb_transfer transfer; + EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillOnce(Return(&transfer)); + + libusb_transfer_cb_fn transferCallback; + common::Data data(100, 0); + common::DataBuffer buffer(data); + EXPECT_CALL(usbWrapperMock_, fillControlTransfer(&transfer, _, buffer.data, _, _, _)) .WillOnce(DoAll(SaveArg<3>(&transferCallback), SaveArg<4>(&transfer.user_data))); - EXPECT_CALL(usbWrapperMock_, submitTransfer(&transfer)); + EXPECT_CALL(usbWrapperMock_, submitTransfer(&transfer)); - usbEndpoint->controlTransfer(common::DataBuffer(data), 0, std::move(promise_)); - ioService_.run(); - ioService_.reset(); + usbEndpoint->controlTransfer(common::DataBuffer(data), 0, std::move(promise_)); + ioService_.run(); + ioService_.reset(); - transfer.actual_length = buffer.size; - transfer.status = LIBUSB_TRANSFER_COMPLETED; - transferCallback(&transfer); + transfer.actual_length = buffer.size; + transfer.status = LIBUSB_TRANSFER_COMPLETED; + transferCallback(&transfer); - EXPECT_CALL(usbWrapperMock_, freeTransfer(&transfer)); - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onResolve(buffer.size)); - ioService_.run(); -} + EXPECT_CALL(usbWrapperMock_, freeTransfer(&transfer)); + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onResolve(buffer.size)); + ioService_.run(); + } -BOOST_FIXTURE_TEST_CASE(USBEndpoint_InterruptTransfer, USBEndpointUnitTest) -{ - const uint8_t endpointAddress = 0x35; - USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_, endpointAddress)); + BOOST_FIXTURE_TEST_CASE(USBEndpoint_InterruptTransfer, USBEndpointUnitTest) + { + const uint8_t endpointAddress = 0x35; + USBEndpoint::Pointer usbEndpoint( + std::make_shared(usbWrapperMock_, ioService_, deviceHandle_, endpointAddress)); - libusb_transfer transfer; - EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillOnce(Return(&transfer)); + libusb_transfer transfer; + EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillOnce(Return(&transfer)); - libusb_transfer_cb_fn transferCallback; - common::Data data(150, 0); - common::DataBuffer buffer(data); - EXPECT_CALL(usbWrapperMock_, fillInterruptTransfer(&transfer, _, endpointAddress, buffer.data, buffer.size, _, _, _)) + libusb_transfer_cb_fn transferCallback; + common::Data data(150, 0); + common::DataBuffer buffer(data); + EXPECT_CALL(usbWrapperMock_, + fillInterruptTransfer(&transfer, _, endpointAddress, buffer.data, buffer.size, _, _, _)) .WillOnce(DoAll(SaveArg<5>(&transferCallback), SaveArg<6>(&transfer.user_data))); - EXPECT_CALL(usbWrapperMock_, submitTransfer(&transfer)); + EXPECT_CALL(usbWrapperMock_, submitTransfer(&transfer)); - usbEndpoint->interruptTransfer(common::DataBuffer(data), 0, std::move(promise_)); - ioService_.run(); - ioService_.reset(); + usbEndpoint->interruptTransfer(common::DataBuffer(data), 0, std::move(promise_)); + ioService_.run(); + ioService_.reset(); - transfer.actual_length = buffer.size; - transfer.status = LIBUSB_TRANSFER_COMPLETED; - transferCallback(&transfer); + transfer.actual_length = buffer.size; + transfer.status = LIBUSB_TRANSFER_COMPLETED; + transferCallback(&transfer); - EXPECT_CALL(usbWrapperMock_, freeTransfer(&transfer)); - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onResolve(buffer.size)); - ioService_.run(); -} + EXPECT_CALL(usbWrapperMock_, freeTransfer(&transfer)); + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onResolve(buffer.size)); + ioService_.run(); + } -BOOST_FIXTURE_TEST_CASE(USBEndpoint_BulkTransferFailed, USBEndpointUnitTest) -{ - const uint8_t endpointAddress = 0x55; - USBEndpoint::Pointer usbEndpoint(std::make_shared(usbWrapperMock_, ioService_, deviceHandle_, endpointAddress)); + BOOST_FIXTURE_TEST_CASE(USBEndpoint_BulkTransferFailed, USBEndpointUnitTest) + { + const uint8_t endpointAddress = 0x55; + USBEndpoint::Pointer usbEndpoint( + std::make_shared(usbWrapperMock_, ioService_, deviceHandle_, endpointAddress)); - libusb_transfer transfer; - EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillOnce(Return(&transfer)); + libusb_transfer transfer; + EXPECT_CALL(usbWrapperMock_, allocTransfer(0)).WillOnce(Return(&transfer)); - libusb_transfer_cb_fn transferCallback; - common::Data data(10, 0); - common::DataBuffer buffer(data); - EXPECT_CALL(usbWrapperMock_, fillBulkTransfer(&transfer, _, endpointAddress, buffer.data, buffer.size, _, _, _)) + libusb_transfer_cb_fn transferCallback; + common::Data data(10, 0); + common::DataBuffer buffer(data); + EXPECT_CALL(usbWrapperMock_, fillBulkTransfer(&transfer, _, endpointAddress, buffer.data, buffer.size, _, _, _)) .WillOnce(DoAll(SaveArg<5>(&transferCallback), SaveArg<6>(&transfer.user_data))); - EXPECT_CALL(usbWrapperMock_, submitTransfer(&transfer)); + EXPECT_CALL(usbWrapperMock_, submitTransfer(&transfer)); - usbEndpoint->bulkTransfer(common::DataBuffer(data), 0, std::move(promise_)); - ioService_.run(); - ioService_.reset(); + usbEndpoint->bulkTransfer(common::DataBuffer(data), 0, std::move(promise_)); + ioService_.run(); + ioService_.reset(); - transfer.actual_length = buffer.size; - transfer.status = LIBUSB_TRANSFER_CANCELLED; - transferCallback(&transfer); + transfer.actual_length = buffer.size; + transfer.status = LIBUSB_TRANSFER_CANCELLED; + transferCallback(&transfer); - EXPECT_CALL(usbWrapperMock_, freeTransfer(&transfer)); - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::OPERATION_ABORTED))).Times(1); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - ioService_.run(); -} + EXPECT_CALL(usbWrapperMock_, freeTransfer(&transfer)); + EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::OPERATION_ABORTED))).Times(1); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + ioService_.run(); + } -} -} + } + } } diff --git a/src/USB/USBHub.cpp b/src/USB/USBHub.cpp index e3b187d4..71c68a21 100644 --- a/src/USB/USBHub.cpp +++ b/src/USB/USBHub.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -23,102 +22,88 @@ #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -USBHub::USBHub(IUSBWrapper& usbWrapper, boost::asio::io_service& ioService, IAccessoryModeQueryChainFactory& queryChainFactory) - : usbWrapper_(usbWrapper) - , strand_(ioService) - , queryChainFactory_(queryChainFactory) -{ -} + USBHub::USBHub(IUSBWrapper &usbWrapper, boost::asio::io_service &ioService, + IAccessoryModeQueryChainFactory &queryChainFactory) + : usbWrapper_(usbWrapper), strand_(ioService), queryChainFactory_(queryChainFactory) { + } -void USBHub::start(Promise::Pointer promise) -{ - strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() { - if(hotplugPromise_ != nullptr) - { - hotplugPromise_->reject(error::Error(error::ErrorCode::OPERATION_ABORTED)); - hotplugPromise_.reset(); + void USBHub::start(Promise::Pointer promise) { + strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() { + if (hotplugPromise_ != nullptr) { + hotplugPromise_->reject(error::Error(error::ErrorCode::OPERATION_ABORTED)); + hotplugPromise_.reset(); } hotplugPromise_ = std::move(promise); - if(self_ == nullptr) - { - self_ = this->shared_from_this(); - hotplugHandle_ = usbWrapper_.hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, LIBUSB_HOTPLUG_ENUMERATE, LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, - LIBUSB_HOTPLUG_MATCH_ANY, reinterpret_cast(&USBHub::hotplugEventsHandler), reinterpret_cast(this)); + if (self_ == nullptr) { + self_ = this->shared_from_this(); + hotplugHandle_ = usbWrapper_.hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, + LIBUSB_HOTPLUG_ENUMERATE, LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, + reinterpret_cast(&USBHub::hotplugEventsHandler), + reinterpret_cast(this)); } - }); -} + }); + } -void USBHub::cancel() -{ - strand_.dispatch([this, self = this->shared_from_this()]() mutable { - if(hotplugPromise_ != nullptr) - { - hotplugPromise_->reject(error::Error(error::ErrorCode::OPERATION_ABORTED)); - hotplugPromise_.reset(); + void USBHub::cancel() { + strand_.dispatch([this, self = this->shared_from_this()]() mutable { + if (hotplugPromise_ != nullptr) { + hotplugPromise_->reject(error::Error(error::ErrorCode::OPERATION_ABORTED)); + hotplugPromise_.reset(); } - std::for_each(queryChainQueue_.begin(), queryChainQueue_.end(), std::bind(&IAccessoryModeQueryChain::cancel, std::placeholders::_1)); + std::for_each(queryChainQueue_.begin(), queryChainQueue_.end(), + std::bind(&IAccessoryModeQueryChain::cancel, std::placeholders::_1)); - if(self_ != nullptr) - { - hotplugHandle_.reset(); - self_.reset(); + if (self_ != nullptr) { + hotplugHandle_.reset(); + self_.reset(); } - }); -} + }); + } -int USBHub::hotplugEventsHandler(libusb_context* usbContext, libusb_device* device, libusb_hotplug_event event, void* userData) -{ - if(event == LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED) - { - auto self = reinterpret_cast(userData)->shared_from_this(); + int USBHub::hotplugEventsHandler(libusb_context *usbContext, libusb_device *device, libusb_hotplug_event event, + void *userData) { + if (event == LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED) { + auto self = reinterpret_cast(userData)->shared_from_this(); self->strand_.dispatch(std::bind(&USBHub::handleDevice, self, device)); + } + + return 0; } - - return 0; -} -bool USBHub::isAOAPDevice(const libusb_device_descriptor& deviceDescriptor) const -{ - return deviceDescriptor.idVendor == cGoogleVendorId && - (deviceDescriptor.idProduct == cAOAPId || deviceDescriptor.idProduct == cAOAPWithAdbId); -} + bool USBHub::isAOAPDevice(const libusb_device_descriptor &deviceDescriptor) const { + return deviceDescriptor.idVendor == cGoogleVendorId && + (deviceDescriptor.idProduct == cAOAPId || deviceDescriptor.idProduct == cAOAPWithAdbId); + } -void USBHub::handleDevice(libusb_device* device) -{ - if(hotplugPromise_ == nullptr) - { + void USBHub::handleDevice(libusb_device *device) { + if (hotplugPromise_ == nullptr) { return; - } + } - libusb_device_descriptor deviceDescriptor; - if(usbWrapper_.getDeviceDescriptor(device, deviceDescriptor) != 0) - { + libusb_device_descriptor deviceDescriptor; + if (usbWrapper_.getDeviceDescriptor(device, deviceDescriptor) != 0) { return; - } + } - DeviceHandle handle; - auto openResult = usbWrapper_.open(device, handle); + DeviceHandle handle; + auto openResult = usbWrapper_.open(device, handle); - if(openResult != 0) - { + if (openResult != 0) { return; - } + } - if(this->isAOAPDevice(deviceDescriptor)) - { + if (this->isAOAPDevice(deviceDescriptor)) { hotplugPromise_->resolve(std::move(handle)); hotplugPromise_.reset(); - } - else - { + } else { ////////// Workaround for VMware std::this_thread::sleep_for(std::chrono::milliseconds(1000)); ////////// @@ -128,15 +113,16 @@ void USBHub::handleDevice(libusb_device* device) auto queueElementIter = std::prev(queryChainQueue_.end()); auto queryChainPromise = IAccessoryModeQueryChain::Promise::defer(strand_); queryChainPromise->then([this, self = this->shared_from_this(), queueElementIter](DeviceHandle handle) mutable { - queryChainQueue_.erase(queueElementIter); - }, - [this, self = this->shared_from_this(), queueElementIter](const error::Error& e) mutable { - queryChainQueue_.erase(queueElementIter); - }); + queryChainQueue_.erase(queueElementIter); + }, + [this, self = this->shared_from_this(), queueElementIter]( + const error::Error &e) mutable { + queryChainQueue_.erase(queueElementIter); + }); queryChainQueue_.back()->start(std::move(handle), std::move(queryChainPromise)); + } } -} -} + } } diff --git a/src/USB/USBHub.ut.cpp b/src/USB/USBHub.ut.cpp index 15ada932..ec29a3fd 100644 --- a/src/USB/USBHub.ut.cpp +++ b/src/USB/USBHub.ut.cpp @@ -1,20 +1,19 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include #include @@ -24,219 +23,224 @@ #include -namespace aasdk -{ -namespace usb -{ -namespace ut -{ - -using ::testing::_; -using ::testing::Return; -using ::testing::SaveArg; -using ::testing::SetArgReferee; - -class USBHubUnitTest -{ -protected: - USBHubUnitTest() - : queryChain_(&queryChainMock_, [](auto*) {}) - , device_(reinterpret_cast(-1)) - , deviceHandle_(reinterpret_cast(&dummyDeviceHandle_), [](auto*) {}) - , promise_(IUSBHub::Promise::defer(ioService_)) - , rawHotplugCallbacHandle_(-1) - , hotplugCallbackHandle_(&rawHotplugCallbacHandle_, [](auto*) {}) - { - promise_->then(std::bind(&USBHubPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), - std::bind(&USBHubPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); - } - - boost::asio::io_service ioService_; - USBWrapperMock usbWrapperMock_; - AccessoryModeQueryChainFactoryMock queryChainFactoryMock_; - AccessoryModeQueryChainMock queryChainMock_; - IAccessoryModeQueryChain::Pointer queryChain_; - libusb_device* device_; - USBWrapperMock::DummyDeviceHandle dummyDeviceHandle_; - DeviceHandle deviceHandle_; - USBHubPromiseHandlerMock promiseHandlerMock_; - IUSBHub::Promise::Pointer promise_; - libusb_hotplug_callback_handle rawHotplugCallbacHandle_; - HotplugCallbackHandle hotplugCallbackHandle_; - libusb_hotplug_callback_fn hotplugCallback_; - - static constexpr uint16_t cGoogleVendorId = 0x18D1; - static constexpr uint16_t cAOAPId = 0x2D00; - static constexpr uint16_t cAOAPWithAdbId = 0x2D01; -}; - -BOOST_FIXTURE_TEST_CASE(USBHub_QueryDevice, USBHubUnitTest) -{ - void* userData = nullptr; - EXPECT_CALL(usbWrapperMock_, hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, LIBUSB_HOTPLUG_NO_FLAGS, - LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, - LIBUSB_HOTPLUG_MATCH_ANY, _, _)) +namespace aasdk { + namespace usb { + namespace ut { + + using ::testing::_; + using ::testing::Return; + using ::testing::SaveArg; + using ::testing::SetArgReferee; + + class USBHubUnitTest { + protected: + USBHubUnitTest() + : queryChain_(&queryChainMock_, [](auto *) {}), device_(reinterpret_cast(-1)), + deviceHandle_(reinterpret_cast(&dummyDeviceHandle_), [](auto *) {}), + promise_(IUSBHub::Promise::defer(ioService_)), rawHotplugCallbacHandle_(-1), + hotplugCallbackHandle_(&rawHotplugCallbacHandle_, [](auto *) {}) { + promise_->then(std::bind(&USBHubPromiseHandlerMock::onResolve, &promiseHandlerMock_, std::placeholders::_1), + std::bind(&USBHubPromiseHandlerMock::onReject, &promiseHandlerMock_, std::placeholders::_1)); + } + + boost::asio::io_service ioService_; + USBWrapperMock usbWrapperMock_; + AccessoryModeQueryChainFactoryMock queryChainFactoryMock_; + AccessoryModeQueryChainMock queryChainMock_; + IAccessoryModeQueryChain::Pointer queryChain_; + libusb_device *device_; + USBWrapperMock::DummyDeviceHandle dummyDeviceHandle_; + DeviceHandle deviceHandle_; + USBHubPromiseHandlerMock promiseHandlerMock_; + IUSBHub::Promise::Pointer promise_; + libusb_hotplug_callback_handle rawHotplugCallbacHandle_; + HotplugCallbackHandle hotplugCallbackHandle_; + libusb_hotplug_callback_fn hotplugCallback_; + + static constexpr uint16_t cGoogleVendorId = 0x18D1; + static constexpr uint16_t cAOAPId = 0x2D00; + static constexpr uint16_t cAOAPWithAdbId = 0x2D01; + }; + + BOOST_FIXTURE_TEST_CASE(USBHub_QueryDevice, USBHubUnitTest) + { + void *userData = nullptr; + EXPECT_CALL(usbWrapperMock_, + hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, LIBUSB_HOTPLUG_NO_FLAGS, + LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, _, _)) .WillOnce(DoAll(SaveArg<5>(&hotplugCallback_), SaveArg<6>(&userData), Return(hotplugCallbackHandle_))); - USBHub::Pointer usbHub(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); - usbHub->start(std::move(promise_)); - - ioService_.run(); - ioService_.reset(); - - libusb_device_descriptor connectedDeviceDescriptor = {0}; - connectedDeviceDescriptor.idVendor = 123; - connectedDeviceDescriptor.idProduct = 456; - - EXPECT_CALL(usbWrapperMock_, getDeviceDescriptor(device_, _)).WillOnce(DoAll(SetArgReferee<1>(connectedDeviceDescriptor), Return(0))); - EXPECT_CALL(usbWrapperMock_, open(device_, _)).WillOnce(DoAll(SetArgReferee<1>(deviceHandle_), Return(0))); - EXPECT_CALL(queryChainFactoryMock_, create()).WillOnce(Return(queryChain_)); - - IAccessoryModeQueryChain::Promise::Pointer queryChainPromise; - EXPECT_CALL(queryChainMock_, start(deviceHandle_, _)).WillOnce(SaveArg<1>(&queryChainPromise)); - - hotplugCallback_(nullptr, device_, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, userData); - ioService_.run(); - ioService_.reset(); - - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::OPERATION_ABORTED))); - queryChainPromise->resolve(deviceHandle_); - usbHub->cancel(); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(USBHub_AOAPDeviceConnected, USBHubUnitTest) -{ - void* userData = nullptr; - EXPECT_CALL(usbWrapperMock_, hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, LIBUSB_HOTPLUG_NO_FLAGS, - LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, - LIBUSB_HOTPLUG_MATCH_ANY, _, _)) + USBHub::Pointer usbHub(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); + usbHub->start(std::move(promise_)); + + ioService_.run(); + ioService_.reset(); + + libusb_device_descriptor connectedDeviceDescriptor = {0}; + connectedDeviceDescriptor.idVendor = 123; + connectedDeviceDescriptor.idProduct = 456; + + EXPECT_CALL(usbWrapperMock_, getDeviceDescriptor(device_, _)).WillOnce( + DoAll(SetArgReferee<1>(connectedDeviceDescriptor), Return(0))); + EXPECT_CALL(usbWrapperMock_, open(device_, _)).WillOnce(DoAll(SetArgReferee<1>(deviceHandle_), Return(0))); + EXPECT_CALL(queryChainFactoryMock_, create()).WillOnce(Return(queryChain_)); + + IAccessoryModeQueryChain::Promise::Pointer queryChainPromise; + EXPECT_CALL(queryChainMock_, start(deviceHandle_, _)).WillOnce(SaveArg<1>(&queryChainPromise)); + + hotplugCallback_(nullptr, device_, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, userData); + ioService_.run(); + ioService_.reset(); + + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::OPERATION_ABORTED))); + queryChainPromise->resolve(deviceHandle_); + usbHub->cancel(); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(USBHub_AOAPDeviceConnected, USBHubUnitTest) + { + void *userData = nullptr; + EXPECT_CALL(usbWrapperMock_, + hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, LIBUSB_HOTPLUG_NO_FLAGS, + LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, _, _)) .WillOnce(DoAll(SaveArg<5>(&hotplugCallback_), SaveArg<6>(&userData), Return(hotplugCallbackHandle_))); - USBHub::Pointer usbHub(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); - usbHub->start(std::move(promise_)); - - ioService_.run(); - ioService_.reset(); - - libusb_device_descriptor connectedDeviceDescriptor = {0}; - connectedDeviceDescriptor.idVendor = cGoogleVendorId; - connectedDeviceDescriptor.idProduct = cAOAPWithAdbId; - - EXPECT_CALL(usbWrapperMock_, getDeviceDescriptor(device_, _)).WillOnce(DoAll(SetArgReferee<1>(connectedDeviceDescriptor), Return(0))); - EXPECT_CALL(usbWrapperMock_, open(device_, _)).WillOnce(DoAll(SetArgReferee<1>(deviceHandle_), Return(0))); - EXPECT_CALL(promiseHandlerMock_, onResolve(deviceHandle_)); - EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); - - hotplugCallback_(nullptr, device_, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, userData); - ioService_.run(); - ioService_.reset(); - - usbHub->cancel(); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(USBHub_GetDeviceDescriptorFailed, USBHubUnitTest) -{ - void* userData = nullptr; - EXPECT_CALL(usbWrapperMock_, hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, LIBUSB_HOTPLUG_NO_FLAGS, - LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, - LIBUSB_HOTPLUG_MATCH_ANY, _, _)) + USBHub::Pointer usbHub(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); + usbHub->start(std::move(promise_)); + + ioService_.run(); + ioService_.reset(); + + libusb_device_descriptor connectedDeviceDescriptor = {0}; + connectedDeviceDescriptor.idVendor = cGoogleVendorId; + connectedDeviceDescriptor.idProduct = cAOAPWithAdbId; + + EXPECT_CALL(usbWrapperMock_, getDeviceDescriptor(device_, _)).WillOnce( + DoAll(SetArgReferee<1>(connectedDeviceDescriptor), Return(0))); + EXPECT_CALL(usbWrapperMock_, open(device_, _)).WillOnce(DoAll(SetArgReferee<1>(deviceHandle_), Return(0))); + EXPECT_CALL(promiseHandlerMock_, onResolve(deviceHandle_)); + EXPECT_CALL(promiseHandlerMock_, onReject(_)).Times(0); + + hotplugCallback_(nullptr, device_, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, userData); + ioService_.run(); + ioService_.reset(); + + usbHub->cancel(); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(USBHub_GetDeviceDescriptorFailed, USBHubUnitTest) + { + void *userData = nullptr; + EXPECT_CALL(usbWrapperMock_, + hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, LIBUSB_HOTPLUG_NO_FLAGS, + LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, _, _)) .WillOnce(DoAll(SaveArg<5>(&hotplugCallback_), SaveArg<6>(&userData), Return(hotplugCallbackHandle_))); - USBHub::Pointer usbHub(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); - usbHub->start(std::move(promise_)); - - ioService_.run(); - ioService_.reset(); - - libusb_device_descriptor connectedDeviceDescriptor = {0}; - EXPECT_CALL(usbWrapperMock_, getDeviceDescriptor(device_, _)).WillOnce(DoAll(SetArgReferee<1>(connectedDeviceDescriptor), Return(1))); - - hotplugCallback_(nullptr, device_, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, userData); - ioService_.run(); - ioService_.reset(); - - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::OPERATION_ABORTED))); - usbHub->cancel(); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(USBHub_OpenDeviceFailed, USBHubUnitTest) -{ - void* userData = nullptr; - EXPECT_CALL(usbWrapperMock_, hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, LIBUSB_HOTPLUG_NO_FLAGS, - LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, - LIBUSB_HOTPLUG_MATCH_ANY, _, _)) + USBHub::Pointer usbHub(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); + usbHub->start(std::move(promise_)); + + ioService_.run(); + ioService_.reset(); + + libusb_device_descriptor connectedDeviceDescriptor = {0}; + EXPECT_CALL(usbWrapperMock_, getDeviceDescriptor(device_, _)).WillOnce( + DoAll(SetArgReferee<1>(connectedDeviceDescriptor), Return(1))); + + hotplugCallback_(nullptr, device_, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, userData); + ioService_.run(); + ioService_.reset(); + + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::OPERATION_ABORTED))); + usbHub->cancel(); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(USBHub_OpenDeviceFailed, USBHubUnitTest) + { + void *userData = nullptr; + EXPECT_CALL(usbWrapperMock_, + hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, LIBUSB_HOTPLUG_NO_FLAGS, + LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, _, _)) .WillOnce(DoAll(SaveArg<5>(&hotplugCallback_), SaveArg<6>(&userData), Return(hotplugCallbackHandle_))); - USBHub::Pointer usbHub(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); - usbHub->start(std::move(promise_)); - - ioService_.run(); - ioService_.reset(); - - libusb_device_descriptor connectedDeviceDescriptor = {0}; - EXPECT_CALL(usbWrapperMock_, getDeviceDescriptor(device_, _)).WillOnce(DoAll(SetArgReferee<1>(connectedDeviceDescriptor), Return(0))); - EXPECT_CALL(usbWrapperMock_, open(device_, _)).WillOnce(DoAll(SetArgReferee<1>(deviceHandle_), Return(1))); - - hotplugCallback_(nullptr, device_, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, userData); - ioService_.run(); - ioService_.reset(); - - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::OPERATION_ABORTED))); - usbHub->cancel(); - ioService_.run(); -} - -BOOST_FIXTURE_TEST_CASE(USBHub_CancelAllQueryChains, USBHubUnitTest) -{ - void* userData = nullptr; - EXPECT_CALL(usbWrapperMock_, hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, LIBUSB_HOTPLUG_NO_FLAGS, - LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, - LIBUSB_HOTPLUG_MATCH_ANY, _, _)) + USBHub::Pointer usbHub(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); + usbHub->start(std::move(promise_)); + + ioService_.run(); + ioService_.reset(); + + libusb_device_descriptor connectedDeviceDescriptor = {0}; + EXPECT_CALL(usbWrapperMock_, getDeviceDescriptor(device_, _)).WillOnce( + DoAll(SetArgReferee<1>(connectedDeviceDescriptor), Return(0))); + EXPECT_CALL(usbWrapperMock_, open(device_, _)).WillOnce(DoAll(SetArgReferee<1>(deviceHandle_), Return(1))); + + hotplugCallback_(nullptr, device_, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, userData); + ioService_.run(); + ioService_.reset(); + + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::OPERATION_ABORTED))); + usbHub->cancel(); + ioService_.run(); + } + + BOOST_FIXTURE_TEST_CASE(USBHub_CancelAllQueryChains, USBHubUnitTest) + { + void *userData = nullptr; + EXPECT_CALL(usbWrapperMock_, + hotplugRegisterCallback(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, LIBUSB_HOTPLUG_NO_FLAGS, + LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, _, _)) .WillOnce(DoAll(SaveArg<5>(&hotplugCallback_), SaveArg<6>(&userData), Return(hotplugCallbackHandle_))); - USBHub::Pointer usbHub(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); - usbHub->start(std::move(promise_)); + USBHub::Pointer usbHub(std::make_shared(usbWrapperMock_, ioService_, queryChainFactoryMock_)); + usbHub->start(std::move(promise_)); - ioService_.run(); - ioService_.reset(); + ioService_.run(); + ioService_.reset(); - libusb_device_descriptor connectedDeviceDescriptor = {0}; - connectedDeviceDescriptor.idVendor = 123; - connectedDeviceDescriptor.idProduct = 456; + libusb_device_descriptor connectedDeviceDescriptor = {0}; + connectedDeviceDescriptor.idVendor = 123; + connectedDeviceDescriptor.idProduct = 456; - EXPECT_CALL(usbWrapperMock_, getDeviceDescriptor(device_, _)).Times(2).WillRepeatedly(DoAll(SetArgReferee<1>(connectedDeviceDescriptor), Return(0))); - EXPECT_CALL(usbWrapperMock_, open(device_, _)).Times(2).WillRepeatedly(DoAll(SetArgReferee<1>(deviceHandle_), Return(0))); - EXPECT_CALL(queryChainFactoryMock_, create()).Times(2).WillRepeatedly(Return(queryChain_)); + EXPECT_CALL(usbWrapperMock_, getDeviceDescriptor(device_, _)).Times(2).WillRepeatedly( + DoAll(SetArgReferee<1>(connectedDeviceDescriptor), Return(0))); + EXPECT_CALL(usbWrapperMock_, open(device_, _)).Times(2).WillRepeatedly( + DoAll(SetArgReferee<1>(deviceHandle_), Return(0))); + EXPECT_CALL(queryChainFactoryMock_, create()).Times(2).WillRepeatedly(Return(queryChain_)); - IAccessoryModeQueryChain::Promise::Pointer queryChainPromise[2]; - EXPECT_CALL(queryChainMock_, start(deviceHandle_, _)).WillOnce(SaveArg<1>(&queryChainPromise[0])).WillOnce(SaveArg<1>(&queryChainPromise[1])); + IAccessoryModeQueryChain::Promise::Pointer queryChainPromise[2]; + EXPECT_CALL(queryChainMock_, start(deviceHandle_, _)).WillOnce(SaveArg<1>(&queryChainPromise[0])).WillOnce( + SaveArg<1>(&queryChainPromise[1])); - hotplugCallback_(nullptr, device_, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, userData); - ioService_.run(); - ioService_.reset(); + hotplugCallback_(nullptr, device_, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, userData); + ioService_.run(); + ioService_.reset(); - hotplugCallback_(nullptr, device_, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, userData); - ioService_.run(); - ioService_.reset(); + hotplugCallback_(nullptr, device_, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, userData); + ioService_.run(); + ioService_.reset(); - EXPECT_CALL(queryChainMock_, cancel()).Times(2); - EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); - EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::OPERATION_ABORTED))); - usbHub->cancel(); - ioService_.run(); - ioService_.reset(); + EXPECT_CALL(queryChainMock_, cancel()).Times(2); + EXPECT_CALL(promiseHandlerMock_, onResolve(_)).Times(0); + EXPECT_CALL(promiseHandlerMock_, onReject(error::Error(error::ErrorCode::OPERATION_ABORTED))); + usbHub->cancel(); + ioService_.run(); + ioService_.reset(); - queryChainPromise[0]->reject(error::Error(error::ErrorCode::OPERATION_ABORTED)); - queryChainPromise[1]->reject(error::Error(error::ErrorCode::OPERATION_ABORTED)); - ioService_.run(); -} + queryChainPromise[0]->reject(error::Error(error::ErrorCode::OPERATION_ABORTED)); + queryChainPromise[1]->reject(error::Error(error::ErrorCode::OPERATION_ABORTED)); + ioService_.run(); + } -} -} + } + } } diff --git a/src/USB/USBWrapper.cpp b/src/USB/USBWrapper.cpp index 4a0ccd8a..4695722e 100644 --- a/src/USB/USBWrapper.cpp +++ b/src/USB/USBWrapper.cpp @@ -1,171 +1,153 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ +// 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) +// +// 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 . #include -namespace aasdk -{ -namespace usb -{ +namespace aasdk { + namespace usb { -USBWrapper::USBWrapper(libusb_context* usbContext) - : usbContext_(usbContext) -{ + USBWrapper::USBWrapper(libusb_context *usbContext) + : usbContext_(usbContext) { -} + } -int USBWrapper::releaseInterface(const DeviceHandle& dev_handle, int interface_number) -{ - return libusb_release_interface(dev_handle.get(), interface_number); -} + int USBWrapper::releaseInterface(const DeviceHandle &dev_handle, int interface_number) { + return libusb_release_interface(dev_handle.get(), interface_number); + } -libusb_device* USBWrapper::getDevice(const DeviceHandle& dev_handle) -{ - return libusb_get_device(dev_handle.get()); -} + libusb_device *USBWrapper::getDevice(const DeviceHandle &dev_handle) { + return libusb_get_device(dev_handle.get()); + } -int USBWrapper::claimInterface(const DeviceHandle& dev_handle, int interface_number) -{ - return libusb_claim_interface(dev_handle.get(), interface_number); -} + int USBWrapper::claimInterface(const DeviceHandle &dev_handle, int interface_number) { + return libusb_claim_interface(dev_handle.get(), interface_number); + } -DeviceHandle USBWrapper::openDeviceWithVidPid(uint16_t vendor_id, uint16_t product_id) -{ - auto raw_handle = libusb_open_device_with_vid_pid(usbContext_, vendor_id, product_id); - return raw_handle != nullptr ? DeviceHandle(raw_handle, &libusb_close) : DeviceHandle(); -} + DeviceHandle USBWrapper::openDeviceWithVidPid(uint16_t vendor_id, uint16_t product_id) { + auto raw_handle = libusb_open_device_with_vid_pid(usbContext_, vendor_id, product_id); + return raw_handle != nullptr ? DeviceHandle(raw_handle, &libusb_close) : DeviceHandle(); + } -int USBWrapper::getConfigDescriptor(libusb_device *dev, uint8_t config_index, ConfigDescriptorHandle& config_descriptor_handle) -{ - libusb_config_descriptor* raw_handle = nullptr; - auto result = libusb_get_config_descriptor(dev, config_index, &raw_handle); + int USBWrapper::getConfigDescriptor(libusb_device *dev, uint8_t config_index, + ConfigDescriptorHandle &config_descriptor_handle) { + libusb_config_descriptor *raw_handle = nullptr; + auto result = libusb_get_config_descriptor(dev, config_index, &raw_handle); - config_descriptor_handle = (result == 0 && raw_handle != nullptr) ? ConfigDescriptorHandle(raw_handle, &libusb_free_config_descriptor) : ConfigDescriptorHandle(); - return result; -} + config_descriptor_handle = (result == 0 && raw_handle != nullptr) ? ConfigDescriptorHandle(raw_handle, + &libusb_free_config_descriptor) + : ConfigDescriptorHandle(); + return result; + } -void USBWrapper::fillBulkTransfer(libusb_transfer *transfer, - const DeviceHandle& dev_handle, unsigned char endpoint, - unsigned char *buffer, int length, libusb_transfer_cb_fn callback, - void *user_data, unsigned int timeout) -{ - libusb_fill_bulk_transfer(transfer, dev_handle.get(), endpoint, buffer, length, callback, user_data, timeout); -} + void USBWrapper::fillBulkTransfer(libusb_transfer *transfer, + const DeviceHandle &dev_handle, unsigned char endpoint, + unsigned char *buffer, int length, libusb_transfer_cb_fn callback, + void *user_data, unsigned int timeout) { + libusb_fill_bulk_transfer(transfer, dev_handle.get(), endpoint, buffer, length, callback, user_data, timeout); + } -void USBWrapper::fillInterruptTransfer(libusb_transfer *transfer, - const DeviceHandle& dev_handle, unsigned char endpoint, - unsigned char *buffer, int length, libusb_transfer_cb_fn callback, - void *user_data, unsigned int timeout) -{ - libusb_fill_interrupt_transfer(transfer, dev_handle.get(), endpoint, buffer, length, callback, user_data, timeout); -} + void USBWrapper::fillInterruptTransfer(libusb_transfer *transfer, + const DeviceHandle &dev_handle, unsigned char endpoint, + unsigned char *buffer, int length, libusb_transfer_cb_fn callback, + void *user_data, unsigned int timeout) { + libusb_fill_interrupt_transfer(transfer, dev_handle.get(), endpoint, buffer, length, callback, user_data, + timeout); + } -void USBWrapper::fillControlTransfer( - libusb_transfer *transfer, const DeviceHandle& dev_handle, - unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data, - unsigned int timeout) -{ - libusb_fill_control_transfer(transfer, dev_handle.get(), buffer, callback, user_data, timeout); -} + void USBWrapper::fillControlTransfer( + libusb_transfer *transfer, const DeviceHandle &dev_handle, + unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data, + unsigned int timeout) { + libusb_fill_control_transfer(transfer, dev_handle.get(), buffer, callback, user_data, timeout); + } -int USBWrapper::submitTransfer(libusb_transfer *transfer) -{ - return libusb_submit_transfer(transfer); -} + int USBWrapper::submitTransfer(libusb_transfer *transfer) { + return libusb_submit_transfer(transfer); + } -int USBWrapper::cancelTransfer(libusb_transfer *transfer) -{ - return libusb_cancel_transfer(transfer); -} + int USBWrapper::cancelTransfer(libusb_transfer *transfer) { + return libusb_cancel_transfer(transfer); + } -void USBWrapper::freeTransfer(libusb_transfer *transfer) -{ - libusb_free_transfer(transfer); -} + void USBWrapper::freeTransfer(libusb_transfer *transfer) { + libusb_free_transfer(transfer); + } -ssize_t USBWrapper::getDeviceList(DeviceListHandle& handle) -{ - libusb_device** raw_handle; - auto result = libusb_get_device_list(usbContext_, &raw_handle); + ssize_t USBWrapper::getDeviceList(DeviceListHandle &handle) { + libusb_device **raw_handle; + auto result = libusb_get_device_list(usbContext_, &raw_handle); - if(result >= 0) - { + if (result >= 0) { handle = DeviceListHandle(new DeviceList(raw_handle, raw_handle + result), - [raw_handle](auto in_device_list) - { - if(!in_device_list->empty()) - { - libusb_free_device_list(raw_handle, 1); - } - - in_device_list->clear(); - delete in_device_list; - }); - } - else - { + [raw_handle](auto in_device_list) { + if (!in_device_list->empty()) { + libusb_free_device_list(raw_handle, 1); + } + + in_device_list->clear(); + delete in_device_list; + }); + } else { handle = DeviceListHandle(); - } - - return result; -} + } -int USBWrapper::open(libusb_device *dev, DeviceHandle& dev_handle) -{ - libusb_device_handle* raw_handle; - auto result = libusb_open(dev, &raw_handle); + return result; + } - dev_handle = (result == 0 && raw_handle != nullptr) ? DeviceHandle(raw_handle, &libusb_close) : DeviceHandle(); - return result; -} + int USBWrapper::open(libusb_device *dev, DeviceHandle &dev_handle) { + libusb_device_handle *raw_handle; + auto result = libusb_open(dev, &raw_handle); -void USBWrapper::fillControlSetup(unsigned char *buffer, - uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, - uint16_t wLength) -{ - libusb_fill_control_setup(buffer, bmRequestType, bRequest, wValue, wIndex, wLength); -} + dev_handle = (result == 0 && raw_handle != nullptr) ? DeviceHandle(raw_handle, &libusb_close) : DeviceHandle(); + return result; + } -int USBWrapper::getDeviceDescriptor(libusb_device *dev, libusb_device_descriptor &desc) -{ - return libusb_get_device_descriptor(dev, &desc); -} + void USBWrapper::fillControlSetup(unsigned char *buffer, + uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, + uint16_t wLength) { + libusb_fill_control_setup(buffer, bmRequestType, bRequest, wValue, wIndex, wLength); + } -void USBWrapper::handleEvents() -{ - libusb_handle_events(usbContext_); -} + int USBWrapper::getDeviceDescriptor(libusb_device *dev, libusb_device_descriptor &desc) { + return libusb_get_device_descriptor(dev, &desc); + } -HotplugCallbackHandle USBWrapper::hotplugRegisterCallback(libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int product_id, int dev_class, - libusb_hotplug_callback_fn cb_fn, void *user_data) -{ - libusb_hotplug_callback_handle raw_handle; - libusb_hotplug_register_callback (usbContext_, events, flags, vendor_id, product_id, dev_class, cb_fn, user_data, &raw_handle); + void USBWrapper::handleEvents() { + libusb_handle_events(usbContext_); + } - HotplugCallbackHandle handle(&raw_handle, [this](auto raw_handle) { libusb_hotplug_deregister_callback(usbContext_, *raw_handle); }); - return handle; -} + HotplugCallbackHandle + USBWrapper::hotplugRegisterCallback(libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, + int product_id, int dev_class, + libusb_hotplug_callback_fn cb_fn, void *user_data) { + libusb_hotplug_callback_handle raw_handle; + libusb_hotplug_register_callback(usbContext_, events, flags, vendor_id, product_id, dev_class, cb_fn, user_data, + &raw_handle); + + HotplugCallbackHandle handle(&raw_handle, [this](auto raw_handle) { + libusb_hotplug_deregister_callback(usbContext_, *raw_handle); + }); + return handle; + } -libusb_transfer* USBWrapper::allocTransfer(int iso_packets) -{ - return libusb_alloc_transfer(iso_packets); -} + libusb_transfer *USBWrapper::allocTransfer(int iso_packets) { + return libusb_alloc_transfer(iso_packets); + } -} + } } diff --git a/unit_test/Messenger/UT/Cryptor.mock.hpp b/unit_test/Messenger/UT/Cryptor.mock.hpp index 30baca60..57f24ca4 100644 --- a/unit_test/Messenger/UT/Cryptor.mock.hpp +++ b/unit_test/Messenger/UT/Cryptor.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/Messenger/UT/MessageInStream.mock.hpp b/unit_test/Messenger/UT/MessageInStream.mock.hpp index ee7932c8..aca70dbb 100644 --- a/unit_test/Messenger/UT/MessageInStream.mock.hpp +++ b/unit_test/Messenger/UT/MessageInStream.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/Messenger/UT/MessageOutStream.mock.hpp b/unit_test/Messenger/UT/MessageOutStream.mock.hpp index 6f9e0489..cbc739f4 100644 --- a/unit_test/Messenger/UT/MessageOutStream.mock.hpp +++ b/unit_test/Messenger/UT/MessageOutStream.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/Messenger/UT/ReceivePromiseHandler.mock.hpp b/unit_test/Messenger/UT/ReceivePromiseHandler.mock.hpp index 8719e2b7..2f52ca57 100644 --- a/unit_test/Messenger/UT/ReceivePromiseHandler.mock.hpp +++ b/unit_test/Messenger/UT/ReceivePromiseHandler.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/Messenger/UT/SendPromiseHandler.mock.hpp b/unit_test/Messenger/UT/SendPromiseHandler.mock.hpp index 942b2678..dcb19c94 100644 --- a/unit_test/Messenger/UT/SendPromiseHandler.mock.hpp +++ b/unit_test/Messenger/UT/SendPromiseHandler.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/TCP/UT/TCPEndpoint.mock.hpp b/unit_test/TCP/UT/TCPEndpoint.mock.hpp index 27e7339b..96b78258 100644 --- a/unit_test/TCP/UT/TCPEndpoint.mock.hpp +++ b/unit_test/TCP/UT/TCPEndpoint.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/TCP/UT/TCPEndpointPromiseHandler.mock.hpp b/unit_test/TCP/UT/TCPEndpointPromiseHandler.mock.hpp index 4cb3ad45..32457cb3 100644 --- a/unit_test/TCP/UT/TCPEndpointPromiseHandler.mock.hpp +++ b/unit_test/TCP/UT/TCPEndpointPromiseHandler.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/TCP/UT/TCPWrapper.mock.hpp b/unit_test/TCP/UT/TCPWrapper.mock.hpp index f5238699..a785ea23 100644 --- a/unit_test/TCP/UT/TCPWrapper.mock.hpp +++ b/unit_test/TCP/UT/TCPWrapper.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/Transport/UT/Transport.mock.hpp b/unit_test/Transport/UT/Transport.mock.hpp index 4b1ae802..5eb828bc 100644 --- a/unit_test/Transport/UT/Transport.mock.hpp +++ b/unit_test/Transport/UT/Transport.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/Transport/UT/TransportReceivePromiseHandler.mock.hpp b/unit_test/Transport/UT/TransportReceivePromiseHandler.mock.hpp index 6a902a67..9a58a8d4 100644 --- a/unit_test/Transport/UT/TransportReceivePromiseHandler.mock.hpp +++ b/unit_test/Transport/UT/TransportReceivePromiseHandler.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/Transport/UT/TransportSendPromiseHandler.mock.hpp b/unit_test/Transport/UT/TransportSendPromiseHandler.mock.hpp index c9f7de16..65c484c1 100644 --- a/unit_test/Transport/UT/TransportSendPromiseHandler.mock.hpp +++ b/unit_test/Transport/UT/TransportSendPromiseHandler.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/USB/UT/AOAPDevice.mock.hpp b/unit_test/USB/UT/AOAPDevice.mock.hpp index 4bd47b1c..dd3347b2 100644 --- a/unit_test/USB/UT/AOAPDevice.mock.hpp +++ b/unit_test/USB/UT/AOAPDevice.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/USB/UT/AccessoryModeQuery.mock.hpp b/unit_test/USB/UT/AccessoryModeQuery.mock.hpp index 3442f82b..dbcdfc58 100644 --- a/unit_test/USB/UT/AccessoryModeQuery.mock.hpp +++ b/unit_test/USB/UT/AccessoryModeQuery.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/USB/UT/AccessoryModeQueryChain.mock.hpp b/unit_test/USB/UT/AccessoryModeQueryChain.mock.hpp index bfa37a7f..adf92ad6 100644 --- a/unit_test/USB/UT/AccessoryModeQueryChain.mock.hpp +++ b/unit_test/USB/UT/AccessoryModeQueryChain.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/USB/UT/AccessoryModeQueryChainFactory.mock.hpp b/unit_test/USB/UT/AccessoryModeQueryChainFactory.mock.hpp index 9e179274..75f00d4b 100644 --- a/unit_test/USB/UT/AccessoryModeQueryChainFactory.mock.hpp +++ b/unit_test/USB/UT/AccessoryModeQueryChainFactory.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/USB/UT/AccessoryModeQueryChainPromiseHandler.mock.hpp b/unit_test/USB/UT/AccessoryModeQueryChainPromiseHandler.mock.hpp index f9784342..b9e25711 100644 --- a/unit_test/USB/UT/AccessoryModeQueryChainPromiseHandler.mock.hpp +++ b/unit_test/USB/UT/AccessoryModeQueryChainPromiseHandler.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/USB/UT/AccessoryModeQueryFactory.mock.hpp b/unit_test/USB/UT/AccessoryModeQueryFactory.mock.hpp index 9c523043..c6e654fb 100644 --- a/unit_test/USB/UT/AccessoryModeQueryFactory.mock.hpp +++ b/unit_test/USB/UT/AccessoryModeQueryFactory.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/USB/UT/AccessoryModeQueryPromiseHandler.mock.hpp b/unit_test/USB/UT/AccessoryModeQueryPromiseHandler.mock.hpp index 5d46e081..ee1acf0a 100644 --- a/unit_test/USB/UT/AccessoryModeQueryPromiseHandler.mock.hpp +++ b/unit_test/USB/UT/AccessoryModeQueryPromiseHandler.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/USB/UT/ConnectedAccessoriesEnumeratorPromiseHandler.mock.hpp b/unit_test/USB/UT/ConnectedAccessoriesEnumeratorPromiseHandler.mock.hpp index d8b0233e..911af528 100644 --- a/unit_test/USB/UT/ConnectedAccessoriesEnumeratorPromiseHandler.mock.hpp +++ b/unit_test/USB/UT/ConnectedAccessoriesEnumeratorPromiseHandler.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/USB/UT/USBEndpoint.mock.hpp b/unit_test/USB/UT/USBEndpoint.mock.hpp index 7e7d8973..88ac2f31 100644 --- a/unit_test/USB/UT/USBEndpoint.mock.hpp +++ b/unit_test/USB/UT/USBEndpoint.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/USB/UT/USBEndpointPromiseHandler.mock.hpp b/unit_test/USB/UT/USBEndpointPromiseHandler.mock.hpp index 67b9518b..a9ade1d7 100644 --- a/unit_test/USB/UT/USBEndpointPromiseHandler.mock.hpp +++ b/unit_test/USB/UT/USBEndpointPromiseHandler.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/USB/UT/USBHub.mock.hpp b/unit_test/USB/UT/USBHub.mock.hpp index 40da9dea..ede36b14 100644 --- a/unit_test/USB/UT/USBHub.mock.hpp +++ b/unit_test/USB/UT/USBHub.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/USB/UT/USBHubPromiseHandler.mock.hpp b/unit_test/USB/UT/USBHubPromiseHandler.mock.hpp index 67417aef..e67638db 100644 --- a/unit_test/USB/UT/USBHubPromiseHandler.mock.hpp +++ b/unit_test/USB/UT/USBHubPromiseHandler.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include diff --git a/unit_test/USB/UT/USBWrapper.mock.hpp b/unit_test/USB/UT/USBWrapper.mock.hpp index 7c3d52cc..2219d40c 100644 --- a/unit_test/USB/UT/USBWrapper.mock.hpp +++ b/unit_test/USB/UT/USBWrapper.mock.hpp @@ -1,21 +1,3 @@ -/* -* This file is part of aasdk library project. -* Copyright (C) 2018 f1x.studio (Michal Szwaj) -* -* 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 . -*/ - #pragma once #include