#ifndef VARICODE_H #define VARICODE_H /** * (C) 2018 Jordan Sherer - All Rights Reserved **/ #include #include #include #include #include class Varicode { public: enum FrameType{ FT8 = 0, // [000] FT8Fox = 1, // [001] FT8Call = 2, // [010] FT8CallLast = 3, // [011] <- used to indicate last frame in transmission FT8CallReservedA = 4, // [100] FT8CallReservedB = 5, // [101] FT8CallReservedC = 6, // [110] FT8CallReservedD = 7, // [111] }; //Varicode(); static QString formatSNR(int snr); static QString formatPWR(int dbm); static QString checksum16(QString const &input); static bool checksum16Valid(QString const &checksum, QString const &input); static QString checksum32(QString const &input); static bool checksum32Valid(QString const &checksum, QString const &input); static QStringList parseCallsigns(QString const &input); static QStringList parseGrids(QString const &input); static QList> huffEncode(const QMap &huff, QString const& text); static QString huffDecode(const QMap &huff, QVector const& bitvec, int pad=0); static QString huffUnescape(QString const &input); static QString huffEscape(QString const &input); static bool huffShouldEscape(QString const &input); static QVector bytesToBits(char * bitvec, int n); static QVector strToBits(QString const& bitvec); static QString bitsToStr(QVector const& bitvec); static QVector intToBits(quint64 value, int expected=0); static quint64 bitsToInt(QVector const value); static quint64 bitsToInt(QVector::ConstIterator start, int n); static QVector bitsListToBits(QList> &list); static quint8 unpack5bits(QString const& value); static QString pack5bits(quint8 packed); static quint8 unpack6bits(QString const& value); static QString pack6bits(quint8 packed); static quint16 unpack16bits(QString const& value); static QString pack16bits(quint16 packed); static quint32 unpack32bits(QString const& value); static QString pack32bits(quint32 packed); static quint64 unpack64bits(QString const& value); static QString pack64bits(quint64 packed); static quint32 packCallsignPrefixSuffix(QString const& value); static QString unpackCallsignPrefixSuffix(quint32 packed); static quint32 packCallsign(QString const& value); static QString unpackCallsign(quint32 value); static quint16 packGrid(QString const& value); static QString unpackGrid(quint16 value); static bool isCommandAllowed(const QString &cmd); static bool isCommandBuffered(const QString &cmd); static QString packCompoundMessage(const QString &baseCallsign, const QString &fix, bool isPrefix, quint16 num); static QStringList unpackCompoundMessage(const QString &text); static QString packDirectedMessage(QString const& text, QString const& callsign, QString * pCmd, int *n); static QStringList unpackDirectedMessage(QString const& text); static QString packDataMessage(QString const& text, QString *out, int *n); static QString unpackDataMessage(QString const& text); }; #endif // VARICODE_H