114 if (p ==
nullptr)
return false;
125 return p !=
nullptr ? *p :
protocols()[1];
160 return (
float)bin * sample_rate /
frameSize();
165 return len < 4 ? 2 : (2 * (len / 5) > 4 ? 2 * (len / 5) : 4);
195 LOGE(
"ggwave: invalid protocol: %d",
protocol);
201 LOGE(
"ggwave: the sample rate %d is not supported (e.g. use 48000)",
208 LOGE(
"ggwave: the sample rate %d is too low for %s", (
int)sample_rate,
213 LOGE(
"ggwave: marker_threshold must be >= 1");
221 static const uint8_t magic[64] = {
222 0x96, 0x9f, 0xb4, 0xaf, 0x1b, 0x91, 0xde, 0xc5, 0x45, 0x75, 0xe8,
223 0x2e, 0x0f, 0x32, 0x4a, 0x5f, 0xb4, 0x56, 0x95, 0xcb, 0x7f, 0x6a,
224 0x54, 0x6a, 0x48, 0xf2, 0x0b, 0x7b, 0xcd, 0xfb, 0x93, 0x6d, 0x3c,
225 0x77, 0x5e, 0xc3, 0x33, 0x47, 0xc0, 0xf1, 0x71, 0x32, 0x33, 0x27,
226 0x35, 0x68, 0x47, 0x1f, 0x4e, 0xac, 0x23, 0x42, 0x5f, 0x00, 0x37,
227 0xa4, 0x50, 0x6d, 0x48, 0x24, 0x91, 0x7c, 0xa1, 0x4e,
229 return magic[i % 64];
234 if (mode ==
nullptr)
return nullptr;
241 static bool equals(
const char* a,
const char* b) {
243 if (tolower(*a) != tolower(*b))
return false;
Reed-Solomon code over GF(256) with the polynomial 0x11d and lengths which are defined at runtime....
Definition ReedSolomon.h:18
TinyModem: software audio modems and packets with error correction.
Definition AX25.h:11
GGWaveProtocolId
Protocol ids of ggwave: the values are identical to ggwave's ggwave_ProtocolId. The mono-tone protoco...
Definition GGWave.h:18
@ GGWAVE_DT_FAST
Definition GGWave.h:26
@ GGWAVE_AUDIBLE_FAST
Definition GGWave.h:20
@ GGWAVE_DT_FASTEST
Definition GGWave.h:27
@ GGWAVE_AUDIBLE_FASTEST
Definition GGWave.h:21
@ GGWAVE_DT_NORMAL
Definition GGWave.h:25
@ GGWAVE_ULTRASOUND_FAST
Definition GGWave.h:23
@ GGWAVE_ULTRASOUND_FASTEST
Definition GGWave.h:24
@ GGWAVE_AUDIBLE_NORMAL
Definition GGWave.h:19
@ GGWAVE_ULTRASOUND_NORMAL
Definition GGWave.h:22
RSCodec GGWaveRS
Definition GGWave.h:54
static uint8_t dssMagic(int i)
Value of the ggwave DSS sequence for the indicated payload byte.
Definition GGWave.h:220
static bool equals(const char *a, const char *b)
Definition GGWave.h:241
float symbolRate() const
Data symbols per second.
Definition GGWave.h:185
const GGWaveProtocol & protocolInfo() const
Provides the selected protocol.
Definition GGWave.h:123
static bool isMode(const char *mode)
true if the mode is a ggwave mode
Definition GGWave.h:120
int frameSize() const
Samples per frame: the tones are multiples of sample_rate / frameSize().
Definition GGWave.h:154
float bitRate() const
Payload bits per second (without markers and error correction).
Definition GGWave.h:190
static constexpr int MARKER_TONES
number of tones of a marker
Definition GGWave.h:89
static constexpr int MARKER_FRAMES
number of frames of the start and end marker
Definition GGWave.h:87
static int encodedBytes(int len)
Total number of encoded bytes of a message (length, payload, parity).
Definition GGWave.h:169
bool dss
XOR the payload with the ggwave DSS sequence (ggwave option -d).
Definition GGWave.h:98
bool isValid() const
Checks the configuration: returns false (and logs the reason) if invalid.
Definition GGWave.h:193
static const GGWaveProtocol * findMode(const char *mode)
Definition GGWave.h:233
GGWaveConfig()
Definition GGWave.h:75
static constexpr int BASE_FRAME
samples per frame (DFT size) at 48000 Hz
Definition GGWave.h:82
bool rx_one
receiver: stop after the first message
Definition GGWave.h:105
bool rx_any_speed
receiver: accept the normal, fast and fastest variant of the protocol
Definition GGWave.h:100
static constexpr int BASE_RATE
Definition GGWave.h:83
size_t messageSamples(int len) const
Number of samples of a message with len bytes.
Definition GGWave.h:178
float volume
transmit amplitude (0.0 - 1.0)
Definition GGWave.h:96
static const GGWaveProtocol * findProtocol(int id)
Provides the protocol with the indicated id (or nullptr).
Definition GGWave.h:148
float marker_threshold
Definition GGWave.h:103
static constexpr int LENGTH_BYTES
bytes of the Reed-Solomon coded length at the start of a message
Definition GGWave.h:91
GGWaveProtocolId protocol
ggwave protocol (see setMode())
Definition GGWave.h:94
static const GGWaveProtocol * protocols()
Provides the supported protocols.
Definition GGWave.h:132
uint8_t channel
receiver: input channel which is used for the decoding
Definition GGWave.h:107
static int eccBytes(int len)
Number of Reed-Solomon parity bytes for a payload of len bytes.
Definition GGWave.h:164
float binFrequency(int bin) const
Frequency of the indicated FFT bin in Hz.
Definition GGWave.h:159
bool setMode(const char *mode)
Selects the protocol by mode name: returns false if invalid.
Definition GGWave.h:112
static int protocolCount()
Number of supported protocols.
Definition GGWave.h:129
float rx_noise
receiver: (testing only) amplitude of added uniform noise
Definition GGWave.h:109
static constexpr int MAX_PAYLOAD
max payload of a message (variable length format)
Definition GGWave.h:85
int dataSymbols(int len) const
Number of data symbols of a message with len bytes.
Definition GGWave.h:172
Transmission protocol of ggwave (https://github.com/ggerganov/ggwave): the ids and parameters are ide...
Definition GGWave.h:36
const char * mode
TinyModem mode name.
Definition GGWave.h:40
int tones() const
number of simultaneous tones in a data symbol
Definition GGWave.h:49
GGWaveProtocolId id
ggwave protocol id
Definition GGWave.h:38
int frames_per_tx
number of frames per transmitted chunk (symbol)
Definition GGWave.h:44
int freq_start
FFT bin of the lowest tone.
Definition GGWave.h:42
int bytes_per_tx
number of bytes per chunk: 2 tones per byte
Definition GGWave.h:46