JS8Call-Improved master
Loading...
Searching...
No Matches
JS8.h
Go to the documentation of this file.
1
8
9#ifndef __JS8
10#define __JS8
11
12#include <QObject>
13#include <QSemaphore>
14#include <QThread>
15#include <array>
16#include <functional>
17#include <string>
18#include <variant>
19
20namespace JS8 {
21Q_NAMESPACE
22
23namespace Costas {
31enum class Type { ORIGINAL, MODIFIED };
32
34using Array = std::array<std::array<int, 7>, 3>;
35
41constexpr auto array = [] {
42 constexpr auto COSTAS =
43 std::array{std::array{std::array{4, 2, 5, 6, 1, 3, 0},
44 std::array{4, 2, 5, 6, 1, 3, 0},
45 std::array{4, 2, 5, 6, 1, 3, 0}},
46 std::array{std::array{0, 6, 2, 3, 5, 4, 1},
47 std::array{1, 5, 0, 2, 3, 6, 4},
48 std::array{2, 5, 0, 6, 4, 1, 3}}};
49
50 return [COSTAS](Type type) -> Array const & {
51 return COSTAS[static_cast<std::underlying_type_t<Type>>(type)];
52 };
53}();
54} // namespace Costas
55
63void encode(int type, Costas::Array const &costas, const char *message,
64 int *tones);
65
66namespace Event {
72};
73
75struct SyncStart {
77 int size;
78};
79
86struct SyncState {
87 enum class Type { CANDIDATE, DECODED } type;
88 int mode;
89 float frequency;
90 float dt;
91 union {
93 float decoded;
94 } sync;
95};
96
102struct Decoded {
103 int utc;
104 int snr;
105 float xdt;
106 float frequency;
107 std::string data;
108 int type;
109 float quality;
110 int mode;
111};
112
115 std::size_t decoded;
116};
117
119using Variant =
120 std::variant<DecodeStarted, SyncStart, SyncState, Decoded, DecodeFinished>;
121
123using Emitter = std::function<void(Variant const &)>;
124} // namespace Event
125
133class Worker;
134
143class Decoder : public QObject {
144 Q_OBJECT
145
146 QSemaphore m_semaphore;
147 QThread m_thread;
148 Worker *m_worker;
149
150 public:
152 Decoder(QObject *parent = nullptr);
153
154 signals:
155
158
159 public slots:
160
162 void start(QThread::Priority priority);
163
165 void quit();
166
168 void decode();
169};
170} // namespace JS8
171
172#endif
std::function< void(Variant const &)> Emitter
Definition JS8.h:123
std::array< std::array< int, 7 >, 3 > Array
Definition JS8.h:34
Type
Costas array helpers used to map symbols to tones.
Definition JS8.h:31
constexpr auto array
Return the Costas array for the requested Type.
Definition JS8.h:41
std::variant< DecodeStarted, SyncStart, SyncState, Decoded, DecodeFinished > Variant
Definition JS8.h:119
void quit()
Definition JS8.cpp:2754
void start(QThread::Priority priority)
Definition JS8.cpp:2750
Decoder(QObject *parent=nullptr)
Definition JS8.cpp:2741
void decodeEvent(Event::Variant const &)
void decode()
Definition JS8.cpp:2761
Definition JS8.cpp:2572
Definition JS8.h:114
std::size_t decoded
Number of decoded frames.
Definition JS8.h:115
Emitted when the decode process starts with the configured submodes.
Definition JS8.h:70
int submodes
Number of submodes active for decoding.
Definition JS8.h:71
Decoded frame payload emitted when a frame is successfully decoded.
Definition JS8.h:102
float xdt
Fine timing offset.
Definition JS8.h:105
float frequency
Frequency estimate in Hz.
Definition JS8.h:106
std::string data
Decoded payload string.
Definition JS8.h:107
int mode
Submode index used for decoding.
Definition JS8.h:110
int snr
Signal-to-noise ratio (dB).
Definition JS8.h:104
int utc
Raw UTC timestamp from decoder.
Definition JS8.h:103
int type
Frame type identifier.
Definition JS8.h:108
float quality
Quality metric.
Definition JS8.h:109
Indicate start of a sync window.
Definition JS8.h:75
int position
Byte/bit position of the sync candidate.
Definition JS8.h:76
int size
Size of the sync window.
Definition JS8.h:77
Sync state update emitted during candidate evaluation.
Definition JS8.h:86
float decoded
Decoded metric when Type::DECODED.
Definition JS8.h:93
float dt
Timing offset (s).
Definition JS8.h:90
int candidate
Candidate index when Type::CANDIDATE.
Definition JS8.h:92
int mode
Submode index.
Definition JS8.h:88
float frequency
Frequency estimate (Hz).
Definition JS8.h:89