Index: CloudConnect/CloudConnectController.cpp =================================================================== diff -u -rfe8875710ffd0f7ecc8df54bb5dee1be3d28212b -ra3de17abef83da8edaa4ca90b9f5091ff98cfc1e --- CloudConnect/CloudConnectController.cpp (.../CloudConnectController.cpp) (revision fe8875710ffd0f7ecc8df54bb5dee1be3d28212b) +++ CloudConnect/CloudConnectController.cpp (.../CloudConnectController.cpp) (revision a3de17abef83da8edaa4ca90b9f5091ff98cfc1e) @@ -106,8 +106,6 @@ return false; } - _appServerSocketPath = config.value("App/SocketName", "/tmp/cloudconnect.sock").toString(); - config.beginGroup(QStringLiteral("Cloud")); MqttClient::Config mqttConfig; mqttConfig.endpoint = config.value(QStringLiteral("ServerAddress"), QStringLiteral("localhost")).toString(); @@ -164,27 +162,6 @@ } /*! - * \brief CloudConnectController::listenForApp - * \details Creates the app socket server, then starts listening. - * \return true if the server bound successfully, false otherwise. - * \note Must run on the controller thread, after initThread(). - * QLocalServer ties its socket engine to the thread that calls - * listen(), and accepted client sockets are parented to that engine. - */ -bool CloudConnectController::listenForApp() -{ - // use Q_ASSERT only during object creation or thread move - Q_ASSERT_X(QThread::currentThread() == thread(), __func__, - "listenForApp() must run on the controller thread"); - - if (_appServer == nullptr) { - _appServer = QSharedPointer::create(this); - } - - return _appServer->listen(_appServerSocketPath); -} - -/*! * \brief CloudConnectController::connectToCloud * \details Starts connecting to the cloud server with the configuration loaded in loadConfig. * \return true if the attempt was started, or false if MQTT is disabled. @@ -212,12 +189,12 @@ { QStringLiteral("SendDelta"), CanAction::SendDelta }, { QStringLiteral("Drop"), CanAction::Drop }, }; - static const QHash topicMap = { - { QStringLiteral("HighPriority"), CloudConnectFrame::Topic::HighPriority }, - { QStringLiteral("NormalPriority"), CloudConnectFrame::Topic::NormalPriority }, - { QStringLiteral("DeviceLogFile"), CloudConnectFrame::Topic::DeviceLogFile }, - { QStringLiteral("TreatmentLogFile"), CloudConnectFrame::Topic::TreatmentLogFile }, - { QStringLiteral("CloudSyncLogFile"), CloudConnectFrame::Topic::CloudSyncLogFile }, + static const QHash topicMap = { + { QStringLiteral("HighPriority"), MqttTopic::HighPriority }, + { QStringLiteral("NormalPriority"), MqttTopic::NormalPriority }, + { QStringLiteral("DeviceLogFile"), MqttTopic::DeviceLogFile }, + { QStringLiteral("TreatmentLogFile"), MqttTopic::TreatmentLogFile }, + { QStringLiteral("CloudSyncLogFile"), MqttTopic::CloudSyncLogFile }, }; if (!QFile::exists(canRoutingPath)) { @@ -253,7 +230,7 @@ // TODO: uncomment the following line after testing // canRouting.action = actionMap.value(actionStr, CanAction::Drop); canRouting.action = actionMap.value(actionStr, CanAction::SendAlways); // TODO: remove after testing - canRouting.topic = topicMap.value(topicStr, CloudConnectFrame::Topic::NormalPriority); + canRouting.topic = topicMap.value(topicStr, MqttTopic::NormalPriority); if (actionStr.length() > 0 && !actionMap.contains(actionStr)) { qCWarning(logCanRouting).noquote() << QString("unknown message action \"%1\" for msgId=0x%2, defaulting to Drop") @@ -278,14 +255,14 @@ * \param topic - message class from the CAN message routing INI * \return Topic of the form {prefix}/{deviceId}/{suffix}. */ -QString CloudConnectController::mqttTopic(CloudConnectFrame::Topic topic) const +QString CloudConnectController::mqttTopic(MqttTopic topic) const { - static const QMap suffixes = { - { CloudConnectFrame::Topic::HighPriority, QStringLiteral("high") }, - { CloudConnectFrame::Topic::NormalPriority, QStringLiteral("normal") }, - { CloudConnectFrame::Topic::DeviceLogFile, QStringLiteral("log") }, - { CloudConnectFrame::Topic::TreatmentLogFile, QStringLiteral("tx_log") }, - { CloudConnectFrame::Topic::CloudSyncLogFile, QStringLiteral("cs_log") }, + static const QMap suffixes = { + { MqttTopic::HighPriority, QStringLiteral("high") }, + { MqttTopic::NormalPriority, QStringLiteral("normal") }, + { MqttTopic::DeviceLogFile, QStringLiteral("log") }, + { MqttTopic::TreatmentLogFile, QStringLiteral("tx_log") }, + { MqttTopic::CloudSyncLogFile, QStringLiteral("cs_log") }, }; // TODO: uncomment the following line after testing @@ -425,7 +402,7 @@ _msgAckAvgTime = 0; _msgRecvAvgTime = 0; // END: Mesg Stats - (void)_mqttClient.subscribe(mqttTopic(CloudConnectFrame::Topic::NormalPriority)); + (void)_mqttClient.subscribe(mqttTopic(MqttTopic::NormalPriority)); break; default: break; Index: CloudConnect/CloudConnectController.h =================================================================== diff -u -rfe8875710ffd0f7ecc8df54bb5dee1be3d28212b -ra3de17abef83da8edaa4ca90b9f5091ff98cfc1e --- CloudConnect/CloudConnectController.h (.../CloudConnectController.h) (revision fe8875710ffd0f7ecc8df54bb5dee1be3d28212b) +++ CloudConnect/CloudConnectController.h (.../CloudConnectController.h) (revision a3de17abef83da8edaa4ca90b9f5091ff98cfc1e) @@ -23,8 +23,6 @@ #include "CanInterface.h" #include "CanMessage.h" -#include "CloudConnectFrame.h" -#include "CloudConnectServer.h" #include "MessageDispatcher.h" #include "MqttClient.h" @@ -53,7 +51,6 @@ bool loadConfig(const QString &configPath); void initThread(QThread &thread); bool startCan(); - bool listenForApp(); bool connectToCloud(); private: @@ -66,23 +63,29 @@ SendDelta, }; + enum class MqttTopic : quint16 { + HighPriority = 0x0001, + NormalPriority = 0x0002, + DeviceLogFile = 0x0003, + TreatmentLogFile = 0x0004, + CloudSyncLogFile = 0x0005, + }; + /*! * \brief CAN message routing entry loaded from CAN handling INI. */ struct CanRouting { CanAction action = CanAction::Drop; - CloudConnectFrame::Topic topic = CloudConnectFrame::Topic::NormalPriority; + MqttTopic topic = MqttTopic::NormalPriority; }; bool loadCanRouting(const QString &canRoutingPath); - QString mqttTopic(CloudConnectFrame::Topic topic) const; + QString mqttTopic(MqttTopic topic) const; Can::CanInterface _canInterface; Can::MessageDispatcher _dispatcher; QMap> _canCache; QHash _canRouting; - QString _appServerSocketPath; - QSharedPointer _appServer; MqttClient _mqttClient; QString _topicPrefix; // TODO: define in INI? QString _deviceId; // TODO: this needs to be sent from Leahi app or retrieved from somewhere Index: CloudConnect/config/CloudConnect.ini =================================================================== diff -u -rfe8875710ffd0f7ecc8df54bb5dee1be3d28212b -ra3de17abef83da8edaa4ca90b9f5091ff98cfc1e --- CloudConnect/config/CloudConnect.ini (.../CloudConnect.ini) (revision fe8875710ffd0f7ecc8df54bb5dee1be3d28212b) +++ CloudConnect/config/CloudConnect.ini (.../CloudConnect.ini) (revision a3de17abef83da8edaa4ca90b9f5091ff98cfc1e) @@ -1,9 +1,6 @@ [General] CanRoutingConfig=config/LeahiCanRouting.ini -[App] -SocketName=/tmp/cloudconnect.sock - [Cloud] ; ServerAddress=127.0.0.1 ServerAddress=a30gn2ua3sx6wx-ats.iot.us-east-1.amazonaws.com Index: CloudConnect/main.cpp =================================================================== diff -u -raaebfee335c74b0250864a6dce0555f866adadea -ra3de17abef83da8edaa4ca90b9f5091ff98cfc1e --- CloudConnect/main.cpp (.../main.cpp) (revision aaebfee335c74b0250864a6dce0555f866adadea) +++ CloudConnect/main.cpp (.../main.cpp) (revision a3de17abef83da8edaa4ca90b9f5091ff98cfc1e) @@ -73,11 +73,6 @@ // thread that calls listen(), and accepted sockets are parented under it. QObject::connect(&controllerThread, &QThread::started, &ccController, [&ccController, &app]() { - if (!ccController.listenForApp()) { - qCritical() << "Failed to bind the app socket; shutting down"; - QMetaObject::invokeMethod(&app, [&app]() { app.exit(1); }, Qt::QueuedConnection); - return; - } // QTcpSocket belongs to the thread that constructs it. // Broker connect is async, so false = config failure, not unreachable. if (!ccController.connectToCloud()) { Index: lib/Comms/CMakeLists.txt =================================================================== diff -u -r51e99f2578e0901d9da91a4cb60d1b8858cfe971 -ra3de17abef83da8edaa4ca90b9f5091ff98cfc1e --- lib/Comms/CMakeLists.txt (.../CMakeLists.txt) (revision 51e99f2578e0901d9da91a4cb60d1b8858cfe971) +++ lib/Comms/CMakeLists.txt (.../CMakeLists.txt) (revision a3de17abef83da8edaa4ca90b9f5091ff98cfc1e) @@ -11,9 +11,6 @@ set(INCLUDES include/CanInterface.h include/CanMessage.h - include/CloudConnectClient.h - include/CloudConnectFrame.h - include/CloudConnectServer.h include/crc.h include/format.h include/FrameInterface.h @@ -26,9 +23,6 @@ set(SRCS src/CanInterface.cpp - src/CloudConnectClient.cpp - src/CloudConnectFrame.cpp - src/CloudConnectServer.cpp src/crc.cpp src/format.cpp src/FrameInterface.cpp Index: lib/Comms/Comms.pro =================================================================== diff -u -re9aa2c82ccb8cb5662f05ed878d2f7b5ef9f4a65 -ra3de17abef83da8edaa4ca90b9f5091ff98cfc1e --- lib/Comms/Comms.pro (.../Comms.pro) (revision e9aa2c82ccb8cb5662f05ed878d2f7b5ef9f4a65) +++ lib/Comms/Comms.pro (.../Comms.pro) (revision a3de17abef83da8edaa4ca90b9f5091ff98cfc1e) @@ -14,9 +14,6 @@ HEADERS = \ include/CanInterface.h \ include/CanMessage.h \ - include/CloudConnectClient.h \ - include/CloudConnectFrame.h \ - include/CloudConnectServer.h \ include/crc.h \ include/format.h \ include/FrameInterface.h \ @@ -28,9 +25,6 @@ SOURCES = \ src/CanInterface.cpp \ - src/CloudConnectClient.cpp \ - src/CloudConnectFrame.cpp \ - src/CloudConnectServer.cpp \ src/crc.cpp \ src/format.cpp \ src/FrameInterface.cpp \ Fisheye: Tag a3de17abef83da8edaa4ca90b9f5091ff98cfc1e refers to a dead (removed) revision in file `lib/Comms/include/CloudConnectClient.h'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a3de17abef83da8edaa4ca90b9f5091ff98cfc1e refers to a dead (removed) revision in file `lib/Comms/include/CloudConnectFrame.h'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a3de17abef83da8edaa4ca90b9f5091ff98cfc1e refers to a dead (removed) revision in file `lib/Comms/include/CloudConnectServer.h'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a3de17abef83da8edaa4ca90b9f5091ff98cfc1e refers to a dead (removed) revision in file `lib/Comms/src/CloudConnectClient.cpp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a3de17abef83da8edaa4ca90b9f5091ff98cfc1e refers to a dead (removed) revision in file `lib/Comms/src/CloudConnectFrame.cpp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a3de17abef83da8edaa4ca90b9f5091ff98cfc1e refers to a dead (removed) revision in file `lib/Comms/src/CloudConnectServer.cpp'. Fisheye: No comparison available. Pass `N' to diff?