Index: lib/Comms/src/AgentInterface.cpp =================================================================== diff -u -rf8c0a0b1c19dc386b2f88484d53db022270690a7 -r088513e6ea7bad08b4fb7862127c726eabad18fd --- lib/Comms/src/AgentInterface.cpp (.../AgentInterface.cpp) (revision f8c0a0b1c19dc386b2f88484d53db022270690a7) +++ lib/Comms/src/AgentInterface.cpp (.../AgentInterface.cpp) (revision 088513e6ea7bad08b4fb7862127c726eabad18fd) @@ -21,8 +21,8 @@ /*! * \brief AgentInterface::AgentInterface - * \details Constructor. Wires all socket and timer signal/slot connections. - * \param parent Optional QObject parent. + * \details Constructor + * \param parent - optional QObject parent */ AgentInterface::AgentInterface(QObject *parent) : QObject(parent) { @@ -37,11 +37,11 @@ /*! * \brief AgentInterface::init - * \details Stores the socket path and reconnect interval, then initiates the first - * connection attempt. Guards against double-initialisation. - * \param socketPath Path to the Unix domain socket. - * \param reconnectIntervalMs Interval in milliseconds between reconnect attempts. - * \return true on success, false if already initialised. + * \details Stores the socket path and reconnect interval and initiates the + * first connection attempt. Guards against double-initialisation. + * \param socketPath - path to the Unix domain socket + * \param reconnectIntervalMs - milliseconds between reconnect attempts + * \return true on success, false if already initialised */ bool AgentInterface::init(const QString &socketPath, int reconnectIntervalMs) { @@ -58,12 +58,12 @@ /*! * \brief AgentInterface::init - * \details Calls init() then moves this object onto \p thread. Must be called - * from the main thread. - * \param socketPath Path to the Unix domain socket. - * \param reconnectIntervalMs Interval in milliseconds between reconnect attempts. - * \param thread The thread to move this object onto. - * \return true on success, false if already initialised. + * \details Calls init() then moves this object onto vThread. + * Must be called from the main thread. + * \param socketPath - path to the Unix domain socket + * \param reconnectIntervalMs - milliseconds between reconnect attempts + * \param thread - the thread to move this object onto + * \return true on success, false if already initialised */ bool AgentInterface::init(const QString &socketPath, int reconnectIntervalMs, QThread &thread) { @@ -76,18 +76,23 @@ /*! * \brief AgentInterface::send - * \details Builds a wire-ready AgentMessage frame and writes it to the socket. - * \param msgId Message identifier for Agent MQTT routing. - * \param sequence Caller-managed sequence number. - * \param payload Message payload. Pass an empty QByteArray for zero-length frames. - * \return true if the frame was written to the socket, false if not connected. + * \details Builds an AgentMessage frame and writes it to the socket. + * \param msgId - message identifier for Agent MQTT routing + * \param sequence - caller-managed sequence number + * \param payload - message payload; pass empty for zero-length frames + * \return true if written to the socket, false if not connected */ bool AgentInterface::send(AgentMessage::MsgId msgId, quint16 sequence, const QByteArray &payload) { if (_socket.state() != QLocalSocket::ConnectedState) { return false; } const QByteArray frame = AgentMessage::build(msgId, sequence, payload); + QString output; + for (auto i = 0; i < frame.size(); i++) { + output += QStringLiteral(" 0x") + QString("%1").arg(uint8_t(frame.at(i)), 2, 16, QChar('0')).toUpper(); + } + qDebug().noquote() << QString("frame =%1").arg(output); _socket.write(frame); _socket.flush(); return true; @@ -107,9 +112,9 @@ /*! * \brief AgentInterface::initThread - * \details Names the thread, connects aboutToQuit to quit(), moves this object - * onto the thread, and starts it. Must be called from the main thread. - * \param thread The thread to move this object onto. + * \details Moves this object onto vThread and starts it. + * Must be called from the main thread. + * \param thread - the thread to move this object onto */ void AgentInterface::initThread(QThread &thread) { @@ -123,8 +128,7 @@ /*! * \brief AgentInterface::quitThread - * \details Moves this object back to the main thread so it can be safely - * destroyed by its owner. + * \details Moves this object back to the main thread. */ void AgentInterface::quitThread() { @@ -160,7 +164,7 @@ /*! * \brief AgentInterface::onError * \details Logs the socket error and starts the reconnect timer if not already running. - * \param error The socket error code. + * \param error - the socket error code */ void AgentInterface::onError(QLocalSocket::LocalSocketError error) { @@ -172,8 +176,8 @@ /*! * \brief AgentInterface::onReadyRead - * \details Appends incoming bytes to the receive buffer and drains it through - * the AgentMessage parser. Emits didMessageReceive() for each complete frame. + * \details Drains incoming bytes through the AgentMessage parser and emits + * didMessageReceive() for each complete frame. */ void AgentInterface::onReadyRead() {