/*! * * Copyright (c) 2024-2026 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file CloudConnectController.h * \author (original) Stephen Quong * \date (original) 24-May-2026 * */ #pragma once #include #include #include // TODO: temporary for protobuf capture #include #include #include #include #include #include #include #include #include #include "CloudConnectFrame.h" #include "CanInterface.h" #include "CanMessage.h" #include "CloudConnectServer.h" #include "MessageDispatcher.h" #include "MqttClient.h" using namespace Can; /*! * \brief CloudConnect controller */ class CloudConnectController : public QObject { Q_OBJECT public: explicit CloudConnectController(const QString &configPath, const QString &msgHandlingPath, QObject *parent = nullptr); ~CloudConnectController(); bool startCan(); bool listenForApp(); bool connectToCloud(); void initThread(QThread &thread); private: /*! * \brief Send message handling policy for a CAN message. */ enum class MsgAction { Drop, SendAlways, SendDelta, }; /*! * \brief Message handling entry loaded from message handling INI. */ struct MsgHandling { MsgAction action = MsgAction::Drop; CloudConnectFrame::Topic topic = CloudConnectFrame::Topic::NormalPriority; }; void loadMsgHandling(const QString &msgHandlingPath); QString mqttTopic(CloudConnectFrame::Topic topic) const; void captureProtobuf(const QByteArray &payload); // TODO: temporary for protobuf capture QSettings _settings; Can::CanInterface _canInterface; Can::MessageDispatcher _dispatcher; QMap> _msgCache; QHash _msgHandling; 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 bool _mqttEnabled = false; // TODO: temporary for protobuf capture std::unique_ptr _captureSerFile; std::unique_ptr _captureJsonFile; private Q_SLOTS: void onFrameReceive(const QCanBusFrame frame); void onMessageReceive(const Can::Message &msg); };