From 6fdaf564aa9f0e712117340ea1c6c75496991eb6 Mon Sep 17 00:00:00 2001 From: Chiel Prins Date: Wed, 11 Dec 2019 23:09:24 +0100 Subject: [PATCH] added wifi setup protobuf files --- aasdk_proto/WifiInfoRequestMessage.proto | 25 ++++++++++ aasdk_proto/WifiInfoResponseMessage.proto | 42 +++++++++++++++++ aasdk_proto/WifiSecurityResponseMessage.proto | 47 +++++++++++++++++++ src/Common/Data.cpp | 4 +- src/Messenger/Message.cpp | 4 +- src/Messenger/MessageInStream.cpp | 4 ++ src/Messenger/Messenger.cpp | 7 ++- 7 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 aasdk_proto/WifiInfoRequestMessage.proto create mode 100644 aasdk_proto/WifiInfoResponseMessage.proto create mode 100644 aasdk_proto/WifiSecurityResponseMessage.proto diff --git a/aasdk_proto/WifiInfoRequestMessage.proto b/aasdk_proto/WifiInfoRequestMessage.proto new file mode 100644 index 0000000..9616def --- /dev/null +++ b/aasdk_proto/WifiInfoRequestMessage.proto @@ -0,0 +1,25 @@ +/* +* This file is part of aasdk library project. +* Copyright (C) 2018 f1x.studio (Michal Szwaj) +* +* aasdk is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 3 of the License, or +* (at your option) any later version. + +* aasdk is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU 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 f1x.aasdk.proto.messages; + +message WifiInfoRequest +{ +} diff --git a/aasdk_proto/WifiInfoResponseMessage.proto b/aasdk_proto/WifiInfoResponseMessage.proto new file mode 100644 index 0000000..674d268 --- /dev/null +++ b/aasdk_proto/WifiInfoResponseMessage.proto @@ -0,0 +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 . +*/ + +syntax = "proto2"; + +package f1x.aasdk.proto.messages; + +message WifiInfoResponse { + required string ip_address = 1; + optional uint32 port = 2; + required Status status = 3; + + 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; + } +} diff --git a/aasdk_proto/WifiSecurityResponseMessage.proto b/aasdk_proto/WifiSecurityResponseMessage.proto new file mode 100644 index 0000000..f96b639 --- /dev/null +++ b/aasdk_proto/WifiSecurityResponseMessage.proto @@ -0,0 +1,47 @@ +/* +* This file is part of aasdk library project. +* Copyright (C) 2018 f1x.studio (Michal Szwaj) +* +* aasdk is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 3 of the License, or +* (at your option) any later version. + +* aasdk is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU 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 f1x.aasdk.proto.messages; + +message WifiSecurityReponse { + required string ssid = 1; //mo15384a + required string key = 2; //mo15385b + required string bssid = 3; //mo15386c + required SecurityMode security_mode = 4; + required AccessPointType access_point_type = 5; + + enum SecurityMode { + UNKNOWN_SECURITY_MODE = 0; + OPEN = 1; + WEP_64 = 2; + WEP_128 = 3; + WPA_PERSONAL = 4; + WPA2_PERSONAL = 8; + WPA_WPA2_PERSONAL = 12; + WPA_ENTERPRISE = 20; + WPA2_ENTERPRISE = 24; + WPA_WPA2_ENTERPRISE = 28; + } + + enum AccessPointType { + STATIC = 0; + DYNAMIC = 1; + } +} diff --git a/src/Common/Data.cpp b/src/Common/Data.cpp index 2227a6b..746b168 100644 --- a/src/Common/Data.cpp +++ b/src/Common/Data.cpp @@ -128,7 +128,9 @@ common::Data createData(const DataConstBuffer& buffer) std::string dump(const Data& data) { - return dump(DataConstBuffer(data)); + std::string buffer; + boost::algorithm::hex(data, back_inserter(buffer)); + return buffer; } std::string dump(const DataConstBuffer& buffer) diff --git a/src/Messenger/Message.cpp b/src/Messenger/Message.cpp index 0dd575d..59a3eb8 100644 --- a/src/Messenger/Message.cpp +++ b/src/Messenger/Message.cpp @@ -84,7 +84,9 @@ void Message::insertPayload(const common::Data& payload) void Message::insertPayload(const google::protobuf::Message& message) { - AASDK_LOG(debug) << message.DebugString(); + if (message.GetTypeName() != "f1x.aasdk.proto.messages.AVMediaAckIndication") { + AASDK_LOG(debug) << message.GetTypeName() << " - " + message.DebugString(); + } auto offset = payload_.size(); payload_.resize(payload_.size() + message.ByteSize()); diff --git a/src/Messenger/MessageInStream.cpp b/src/Messenger/MessageInStream.cpp index 72a666f..1a722fb 100644 --- a/src/Messenger/MessageInStream.cpp +++ b/src/Messenger/MessageInStream.cpp @@ -18,6 +18,7 @@ #include #include +#include namespace f1x { @@ -63,6 +64,9 @@ void MessageInStream::startReceive(ReceivePromise::Pointer promise) void MessageInStream::receiveFrameHeaderHandler(const common::DataConstBuffer& buffer) { FrameHeader frameHeader(buffer); + if (buffer.cdata[0] != 3) { + AASDK_LOG(debug) << "Message from channel " << std::to_string(buffer.cdata[0]); + } if(message_ == nullptr) { diff --git a/src/Messenger/Messenger.cpp b/src/Messenger/Messenger.cpp index 88580e1..894ad7b 100644 --- a/src/Messenger/Messenger.cpp +++ b/src/Messenger/Messenger.cpp @@ -74,6 +74,9 @@ void Messenger::enqueueSend(Message::Pointer message, SendPromise::Pointer promi void Messenger::inStreamMessageHandler(Message::Pointer message) { auto channelId = message->getChannelId(); + if (message->getChannelId() != ChannelId::VIDEO) { + //AASDK_LOG(debug) << channelIdToString(message->getChannelId()) << ": " << common::dump(message->getPayload()); + } if(channelReceivePromiseQueue_.isPending(channelId)) { @@ -94,7 +97,9 @@ void Messenger::inStreamMessageHandler(Message::Pointer message) } void Messenger::parseMessage(Message::Pointer message, ReceivePromise::Pointer promise) { - AASDK_LOG(debug) << channelIdToString(message->getChannelId()) << " " << MessageId(message->getPayload()); + if (message->getChannelId() != ChannelId::VIDEO) { + //AASDK_LOG(debug) << channelIdToString(message->getChannelId()) << " " << MessageId(message->getPayload()); + } promise->resolve(message); }