diff options
| author | hibby <d@vehibberd.com> | 2018-02-16 15:17:14 +0000 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2018-02-16 15:17:14 +0000 |
| commit | 37f727ac0746fd85504aa46c1f023c09b3eff33a (patch) | |
| tree | c8a7ce04545040a8f161ba279528730bd9a3e6ab /NetworkMessage.hpp | |
| parent | d63dd8d081a6fcd0715cd13f26df59fb831769d2 (diff) | |
New upstream version 1.8.0+repackupstream/1.8.0+repack
Diffstat (limited to 'NetworkMessage.hpp')
| -rw-r--r-- | NetworkMessage.hpp | 300 |
1 files changed, 214 insertions, 86 deletions
diff --git a/NetworkMessage.hpp b/NetworkMessage.hpp index cce1380b..e59a9a4b 100644 --- a/NetworkMessage.hpp +++ b/NetworkMessage.hpp @@ -26,7 +26,7 @@ * * for the serialization details for each type, at the time of * writing the above document is for Qt_5_0 format which is buggy - * so we use Qt_5_2 format, differences are: + * so we use Qt_5_4 format, differences are: * * QDateTime: * QDate qint64 Julian day number @@ -49,19 +49,61 @@ * strings and null strings. Empty strings have a length of zero * whereas null strings have a length field of 0xffffffff. * - * Schema Version 1: - * ----------------- + * Schema Negotiation + * ------------------ + * + * The NetworkMessage::Builder class specifies a schema number which + * may be incremented from time to time. It represents a version of + * the underlying encoding schemes used to store data items. Since the + * underlying encoding is defined by the Qt project in it's + * QDataStream stream operators, it is essential that clients and + * servers of this protocol can agree on a common scheme. The + * NetworkMessage utility classes below exchange the schema number + * actually used. The handling of the schema is backwards compatible + * to an extent, so long as clients and servers are written + * correctly. For example a server written to any particular schema + * version can communicate with a client written to a later schema. + * + * Schema Version 1:- this schema used the QDataStream::Qt_5_0 version + * which is broken. + * + * Schema Version 2:- this schema uses the QDataStream::Qt_5_2 version. + * + * Schema Version 3:- this schema uses the QDataStream::Qt_5_4 version. + * + * * * Message Direction Value Type * ------------- --------- ---------------------- ----------- - * Heartbeat Out 0 quint32 + * Heartbeat Out/In 0 quint32 * Id (unique key) utf8 - * - * The heartbeat message is sent on a periodic basis every - * NetworkMessage::pulse seconds (see below). This message is - * intended to be used by server to detect the presence of a client - * and also the unexpected disappearance of a client. The - * message_aggregator reference server does just that. + * Maximum schema number quint32 + * version utf8 + * revision utf8 + * + * The heartbeat message shall be sent on a periodic basis every + * NetworkMessage::pulse seconds (see below), the WSJT-X + * application does that using the MessageClient class. This + * message is intended to be used by servers to detect the presence + * of a client and also the unexpected disappearance of a client + * and by clients to learn the schema negotiated by the server + * after it receives the initial heartbeat message from a client. + * The message_aggregator reference server does just that using the + * MessageServer class. Upon initial startup a client must send a + * heartbeat message as soon as is practical, this message is used + * to negotiate the maximum schema number common to the client and + * server. Note that the server may not be able to support the + * client's requested maximum schema number, in which case the + * first message received from the server will specify a lower + * schema number (never a higher one as that is not allowed). If a + * server replies with a lower schema number then no higher than + * that number shall be used for all further outgoing messages from + * either clients or the server itself. + * + * Note: the "Maximum schema number" field was introduced at the + * same time as schema 3, therefore servers and clients must assume + * schema 2 is the highest schema number supported if the Heartbeat + * message does not contain the "Maximum schema number" field. * * * Status Out 1 quint32 @@ -73,21 +115,36 @@ * Tx Mode utf8 * Tx Enabled bool * Transmitting bool - * - * WSJT-X sends this status message when various internal state - * changes to allow the server to track the relevant state of each - * client without the need for polling commands. The current state - * changes that generate status messages are: - * - * Application start up, - * "Enable Tx" button status changes, - * Dial frequency changes, - * Changes to the "DX Call" field, - * Operating mode changes, - * Transmit mode changed (in dual JT9+JT65 mode), - * Changes to the "Rpt" spinner, - * After an old decodes replay sequence (see Replay below), - * When switching between Tx and Rx mode. + * Decoding bool + * Rx DF qint32 + * Tx DF qint32 + * DE call utf8 + * DE grid utf8 + * DX grid utf8 + * Tx Watchdog bool + * Sub-mode utf8 + * Fast mode bool + * + * WSJT-X sends this status message when various internal state + * changes to allow the server to track the relevant state of each + * client without the need for polling commands. The current state + * changes that generate status messages are: + * + * Application start up, + * "Enable Tx" button status changes, + * Dial frequency changes, + * Changes to the "DX Call" field, + * Operating mode, sub-mode or fast mode changes, + * Transmit mode changed (in dual JT9+JT65 mode), + * Changes to the "Rpt" spinner, + * After an old decodes replay sequence (see Replay below), + * When switching between Tx and Rx mode, + * At the start and end of decoding, + * When the Rx DF changes, + * When the Tx DF changes, + * When the DE call or grid changes (currently when settings are exited), + * When the DX call or grid changes, + * When the Tx watchdog is set or reset. * * * Decode Out 2 quint32 @@ -99,24 +156,32 @@ * Delta frequency (Hz) quint32 * Mode utf8 * Message utf8 - * - * The decode message is send when a new decode is completed, in - * this case the 'New' field is true. It is also used in response - * to a "Replay" message where each old decode in the "Band - * activity" window, that has not been erased, is sent in order - * as a one of these messages with the 'New' field set to - * false. See the "Replay" message below for details of usage. + * Low confidence bool + * Off air bool + * + * The decode message is sent when a new decode is completed, in + * this case the 'New' field is true. It is also used in response + * to a "Replay" message where each old decode in the "Band + * activity" window, that has not been erased, is sent in order + * as a one of these messages with the 'New' field set to false. + * See the "Replay" message below for details of usage. Low + * confidence decodes are flagged in protocols where the decoder + * has knows that a decode has a higher than normal probability + * of being false, they should not be reported on publicly + * accessible services without some attached warning or further + * validation. Off air decodes are those that result from playing + * back a .WAV file. * * * Clear Out 3 quint32 * Id (unique key) utf8 * - * This message is send when all prior "Decode" messages in the - * "Band activity" window have been discarded and therefore are - * no long available for actioning with a "Reply" message. It is - * sent when the user erases the "Band activity" window and when - * WSJT-X closes down normally. The server should discard all - * decode messages upon receipt of this message. + * This message is send when all prior "Decode" messages in the + * "Band activity" window have been discarded and therefore are + * no long available for actioning with a "Reply" message. It is + * sent when the user erases the "Band activity" window and when + * WSJT-X closes down normally. The server should discard all + * decode messages upon receipt of this message. * * * Reply In 4 quint32 @@ -127,26 +192,41 @@ * Delta frequency (Hz) quint32 * Mode utf8 * Message utf8 - * - * In order for a server to provide a useful cooperative service - * to WSJT-X it is possible for it to initiate a QSO by sending - * this message to a client. WSJT-X filters this message and only - * acts upon it if the message exactly describes a prior decode - * and that decode is a CQ or QRZ message. The action taken is - * exactly equivalent to the user double clicking the message in - * the "Band activity" window. The intent of this message is for - * servers to be able to provide an advanced look up of potential - * QSO partners, for example determining if they have been worked - * before or if working them may advance some objective like - * award progress. The intention is not to provide a secondary - * user interface for WSJT-X, it is expected that after QSO - * initiation the rest of the QSO is carried out manually using - * the normal WSJT-X user interface. + * Low confidence bool + * Modifiers quint8 + * + * In order for a server to provide a useful cooperative service + * to WSJT-X it is possible for it to initiate a QSO by sending + * this message to a client. WSJT-X filters this message and only + * acts upon it if the message exactly describes a prior decode + * and that decode is a CQ or QRZ message. The action taken is + * exactly equivalent to the user double clicking the message in + * the "Band activity" window. The intent of this message is for + * servers to be able to provide an advanced look up of potential + * QSO partners, for example determining if they have been worked + * before or if working them may advance some objective like + * award progress. The intention is not to provide a secondary + * user interface for WSJT-X, it is expected that after QSO + * initiation the rest of the QSO is carried out manually using + * the normal WSJT-X user interface. + * + * The Modifiers field allows the equivalent of keyboard + * modifiers to be sent "as if" those modifier keys where pressed + * while double-clicking the specified decoded message. The + * modifier values (hexadecimal) are as follows: + * + * no modifier 0x00 + * SHIFT 0x02 + * CTRL 0x04 CMD on Mac + * ALT 0x08 + * META 0x10 Windows key on MS Windows + * KEYPAD 0x20 Keypad or arrows + * Group switch 0x40 X11 only * * * QSO Logged Out 5 quint32 * Id (unique key) utf8 - * Date & Time QDateTime + * Date & Time Off QDateTime * DX call utf8 * DX grid utf8 * Dial frequency (Hz) quint64 @@ -156,41 +236,42 @@ * Tx power utf8 * Comments utf8 * Name utf8 + * Date & Time On QDateTime * - * The QSO logged message is sent to the server(s) when the - * WSJT-X user accepts the "Log QSO" dialog by clicking the "OK" - * button. + * The QSO logged message is sent to the server(s) when the + * WSJT-X user accepts the "Log QSO" dialog by clicking the "OK" + * button. * * * Close Out 6 quint32 * Id (unique key) utf8 * - * Close is sent by a client immediately prior to it shutting - * down gracefully. + * Close is sent by a client immediately prior to it shutting + * down gracefully. * * * Replay In 7 quint32 * Id (unique key) utf8 * - * When a server starts it may be useful for it to determine the - * state of preexisting clients. Sending this message to each - * client as it is discovered will cause that client (WSJT-X) to - * send a "Decode" message for each decode currently in its "Band - * activity" window. Each "Decode" message sent will have the - * "New" flag set to false so that they can be distinguished from - * new decodes. After all the old decodes have been broadcast a - * "Status" message is also broadcast. If the server wishes to - * determine the status of a newly discovered client; this - * message should be used. + * When a server starts it may be useful for it to determine the + * state of preexisting clients. Sending this message to each + * client as it is discovered will cause that client (WSJT-X) to + * send a "Decode" message for each decode currently in its "Band + * activity" window. Each "Decode" message sent will have the + * "New" flag set to false so that they can be distinguished from + * new decodes. After all the old decodes have been broadcast a + * "Status" message is also broadcast. If the server wishes to + * determine the status of a newly discovered client; this + * message should be used. * * * Halt Tx In 8 * Id (unique key) utf8 * Auto Tx Only bool * - * The server may stop a client from transmitting messages either - * immediately or at the end of the current transmission period - * using this message. + * The server may stop a client from transmitting messages either + * immediately or at the end of the current transmission period + * using this message. * * * Free Text In 9 @@ -198,15 +279,54 @@ * Text utf8 * Send bool * - * This message allows the server to set the current free text - * message content. Sending this message is equivalent to typing - * a new message (old contents are discarded) in to the WSJT-X - * free text message field or "Tx5" field (both are updated) and - * if the Send flag is set then clicking the "Now" radio button - * for the "Tx5" field if tab one is current or clicking the - * "Free msg" radio button if tab two is current. It is the - * responsibility of the sender to limit the length of the - * message text and to limit it to legal message characters. + * This message allows the server to set the current free text + * message content. Sending this message with a non-empty "Text" + * field is equivalent to typing a new message (old contents are + * discarded) in to the WSJT-X free text message field or "Tx5" + * field (both are updated) and if the "Send" flag is set then + * clicking the "Now" radio button for the "Tx5" field if tab one + * is current or clicking the "Free msg" radio button if tab two + * is current. + * + * It is the responsibility of the sender to limit the length of + * the message text and to limit it to legal message + * characters. Despite this, it may be difficult for the sender + * to determine the maximum message length without reimplementing + * the complete message encoding protocol. Because of this is may + * be better to allow any reasonable message length and to let + * the WSJT-X application encode and possibly truncate the actual + * on-air message. + * + * If the message text is empty the meaning of the message is + * refined to send the current free text unchanged when the + * "Send" flag is set or to clear the current free text when the + * "Send" flag is unset. Note that this API does not include a + * command to determine the contents of the current free text + * message. + * + * WSPRDecode Out 10 quint32 + * Id (unique key) utf8 + * New bool + * Time QTime + * snr qint32 + * Delta time (S) float (serialized as double) + * Frequency (Hz) quint64 + * Drift (Hz) qint32 + * Callsign utf8 + * Grid utf8 + * Power (dBm) qint32 + * Off air bool + * + * The decode message is sent when a new decode is completed, in + * this case the 'New' field is true. It is also used in response + * to a "Replay" message where each old decode in the "Band + * activity" window, that has not been erased, is sent in order + * as a one of these messages with the 'New' field set to + * false. See the "Replay" message below for details of + * usage. The off air field indicates that the decode was decoded + * from a played back recording. + * + * */ #include <QDataStream> @@ -232,6 +352,7 @@ namespace NetworkMessage Replay, HaltTx, FreeText, + WSPRDecode, maximum_message_type_ // ONLY add new message types // immediately before here }; @@ -239,7 +360,7 @@ namespace NetworkMessage quint32 constexpr pulse {15}; // seconds // - // NetworkMessage::Build - build a message containing serialized Qt types + // NetworkMessage::Builder - build a message containing serialized Qt types // class Builder : public QDataStream @@ -248,16 +369,23 @@ namespace NetworkMessage static quint32 constexpr magic {0xadbccbda}; // never change this // increment this if a newer Qt schema is required and add decode - // logic to InputMessageStream below + // logic to the Builder and Reader class implementations +#if QT_VERSION >= 0x050400 + static quint32 constexpr schema_number {3}; +#elif QT_VERSION >= 0x050200 static quint32 constexpr schema_number {2}; +#else + // Schema 1 (Qt_5_0) is broken +#error "Qt version 5.2 or greater required" +#endif - explicit Builder (QIODevice *, Type, QString const& id); - explicit Builder (QByteArray *, Type, QString const& id); + explicit Builder (QIODevice *, Type, QString const& id, quint32 schema); + explicit Builder (QByteArray *, Type, QString const& id, quint32 schema); Builder (Builder const&) = delete; Builder& operator = (Builder const&) = delete; private: - void common_initialization (Type type, QString const& id); + void common_initialization (Type type, QString const& id, quint32 schema); }; // |
