diff --git a/plugins/channelrx/demodchirpchat/chirpchatdemodgui.cpp b/plugins/channelrx/demodchirpchat/chirpchatdemodgui.cpp
index 36bb245ba..c242dbdd0 100644
--- a/plugins/channelrx/demodchirpchat/chirpchatdemodgui.cpp
+++ b/plugins/channelrx/demodchirpchat/chirpchatdemodgui.cpp
@@ -239,7 +239,7 @@ void ChirpChatDemodGUI::on_clear_clicked(bool checked)
{
(void) checked;
ui->messageText->clear();
- ui->hexText->clear();
+ ui->messageText->clear();
}
void ChirpChatDemodGUI::on_eomSquelch_valueChanged(int value)
@@ -410,8 +410,7 @@ ChirpChatDemodGUI::ChirpChatDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUI
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
ui->messageText->setReadOnly(true);
- ui->syncWord->setReadOnly(true);
- ui->hexText->setReadOnly(true);
+ ui->messageText->setReadOnly(true);
m_channelMarker.setMovable(true);
m_channelMarker.setVisible(true);
@@ -602,7 +601,6 @@ void ChirpChatDemodGUI::showLoRaMessage(const Message& message)
QByteArray bytes = msg.getBytes();
QString syncWordStr((tr("%1").arg(msg.getSyncWord(), 2, 16, QChar('0'))));
- ui->syncWord->setText(tr("%1").arg(syncWordStr));
ui->sText->setText(tr("%1").arg(msg.getSingalDb(), 0, 'f', 1));
ui->snrText->setText(tr("%1").arg(msg.getSingalDb() - msg.getNoiseDb(), 0, 'f', 1));
unsigned int packetLength;
@@ -650,7 +648,8 @@ void ChirpChatDemodGUI::showLoRaMessage(const Message& message)
.arg(getParityStr(msg.getPayloadParityStatus()))
.arg(msg.getPayloadCRCStatus() ? "ok" : "err");
- displayBytes(loRaHeader, bytes);
+ displayStatus(loRaHeader);
+ displayBytes(bytes);
QByteArray bytesCopy(bytes);
bytesCopy.truncate(packetLength);
@@ -658,7 +657,7 @@ void ChirpChatDemodGUI::showLoRaMessage(const Message& message)
QString str = QString(bytesCopy.toStdString().c_str());
QString textHeader(tr("%1 (%2)").arg(dateStr).arg(syncWordStr));
- displayText(textHeader, str);
+ displayText(str);
displayLoRaStatus(msg.getHeaderParityStatus(), msg.getHeaderCRCStatus(), msg.getPayloadParityStatus(), msg.getPayloadCRCStatus());
}
@@ -672,10 +671,6 @@ void ChirpChatDemodGUI::showTextMessage(const Message& message)
QDateTime dt = QDateTime::currentDateTime();
QString dateStr = dt.toString("HH:mm:ss");
- QString syncWordStr((tr("%1").arg(msg.getSyncWord(), 2, 16, QChar('0'))));
- QString textHeader(tr("%1 (%2)").arg(dateStr).arg(syncWordStr));
- displayText(textHeader, msg.getString());
- ui->syncWord->setText(syncWordStr);
ui->sText->setText(tr("%1").arg(msg.getSingalDb(), 0, 'f', 1));
ui->snrText->setText(tr("%1").arg(msg.getSingalDb() - msg.getNoiseDb(), 0, 'f', 1));
@@ -683,30 +678,31 @@ void ChirpChatDemodGUI::showTextMessage(const Message& message)
.arg(dateStr)
.arg(msg.getSingalDb(), 0, 'f', 1)
.arg(msg.getSingalDb() - msg.getNoiseDb(), 0, 'f', 1);
+
displayStatus(status);
+ displayText(msg.getString());
}
-void ChirpChatDemodGUI::displayText(const QString& header, const QString& text)
+void ChirpChatDemodGUI::displayText(const QString& text)
{
QTextCursor cursor = ui->messageText->textCursor();
cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
if (!ui->messageText->document()->isEmpty()) {
cursor.insertText("\n");
}
- cursor.insertText(tr("%1 %2").arg(header).arg(text));
+ cursor.insertText(tr("TXT|%1").arg(text));
ui->messageText->verticalScrollBar()->setValue(ui->messageText->verticalScrollBar()->maximum());
}
-void ChirpChatDemodGUI::displayBytes(const QString& header, const QByteArray& bytes)
+void ChirpChatDemodGUI::displayBytes(const QByteArray& bytes)
{
- QTextCursor cursor = ui->hexText->textCursor();
+ QTextCursor cursor = ui->messageText->textCursor();
cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
- if (!ui->hexText->document()->isEmpty()) {
+ if (!ui->messageText->document()->isEmpty()) {
cursor.insertText("\n");
}
- cursor.insertText(tr(">%1\n").arg(header));
QByteArray::const_iterator it = bytes.begin();
unsigned int i = 0;
@@ -729,20 +725,20 @@ void ChirpChatDemodGUI::displayBytes(const QString& header, const QByteArray& by
}
}
- ui->hexText->verticalScrollBar()->setValue(ui->hexText->verticalScrollBar()->maximum());
+ ui->messageText->verticalScrollBar()->setValue(ui->messageText->verticalScrollBar()->maximum());
}
void ChirpChatDemodGUI::displayStatus(const QString& status)
{
- QTextCursor cursor = ui->hexText->textCursor();
+ QTextCursor cursor = ui->messageText->textCursor();
cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
- if (!ui->hexText->document()->isEmpty()) {
+ if (!ui->messageText->document()->isEmpty()) {
cursor.insertText("\n");
}
cursor.insertText(tr(">%1").arg(status));
- ui->hexText->verticalScrollBar()->setValue(ui->hexText->verticalScrollBar()->maximum());
+ ui->messageText->verticalScrollBar()->setValue(ui->messageText->verticalScrollBar()->maximum());
}
QString ChirpChatDemodGUI::getParityStr(int parityStatus)
diff --git a/plugins/channelrx/demodchirpchat/chirpchatdemodgui.h b/plugins/channelrx/demodchirpchat/chirpchatdemodgui.h
index dac83c6ad..bd349f308 100644
--- a/plugins/channelrx/demodchirpchat/chirpchatdemodgui.h
+++ b/plugins/channelrx/demodchirpchat/chirpchatdemodgui.h
@@ -112,8 +112,8 @@ private:
void setBandwidths();
void showLoRaMessage(const Message& message);
void showTextMessage(const Message& message); //!< For TTY and ASCII
- void displayText(const QString& header, const QString& text);
- void displayBytes(const QString& header, const QByteArray& bytes);
+ void displayText(const QString& text);
+ void displayBytes(const QByteArray& bytes);
void displayStatus(const QString& status);
void displayLoRaStatus(int headerParityStatus, bool headerCRCStatus, int payloadParityStatus, bool payloadCRCStatus);
QString getParityStr(int parityStatus);
diff --git a/plugins/channelrx/demodchirpchat/chirpchatdemodgui.ui b/plugins/channelrx/demodchirpchat/chirpchatdemodgui.ui
index 6309d0ec1..93341611c 100644
--- a/plugins/channelrx/demodchirpchat/chirpchatdemodgui.ui
+++ b/plugins/channelrx/demodchirpchat/chirpchatdemodgui.ui
@@ -6,7 +6,7 @@
0
0
- 552
+ 532
680
@@ -562,28 +562,20 @@
Msg
-
-
-
- 2
- 145
- 32
- 16
-
-
-
- Hex
-
-
30
60
490
- 80
+ 161
+
+
+ Liberation Mono
+
+
@@ -784,28 +776,6 @@
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- 492
- 10
- 25
- 20
-
-
-
- Qt::ClickFocus
-
-
- Sync word (1 byte hex)
-
-
- HH
-
-
- 00
-
-
@@ -902,22 +872,6 @@
FEC
-
-
-
- 30
- 145
- 490
- 75
-
-
-
-
- Liberation Mono
- 9
-
-
-
@@ -969,19 +923,6 @@
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- 456
- 10
- 30
- 19
-
-
-
- Sync
-
-
diff --git a/plugins/channelrx/demodchirpchat/chirpchatdemodsettings.cpp b/plugins/channelrx/demodchirpchat/chirpchatdemodsettings.cpp
index 61f0ba013..14fbe2a76 100644
--- a/plugins/channelrx/demodchirpchat/chirpchatdemodsettings.cpp
+++ b/plugins/channelrx/demodchirpchat/chirpchatdemodsettings.cpp
@@ -202,3 +202,19 @@ bool ChirpChatDemodSettings::deserialize(const QByteArray& data)
return false;
}
}
+
+unsigned int ChirpChatDemodSettings::getNbSFDFourths() const
+{
+ switch (m_codingScheme)
+ {
+ case CodingLoRa:
+ return 9;
+ default:
+ return 8;
+ }
+}
+
+bool ChirpChatDemodSettings::hasSyncWord() const
+{
+ return m_codingScheme == CodingLoRa;
+}
\ No newline at end of file
diff --git a/plugins/channelrx/demodchirpchat/chirpchatdemodsettings.h b/plugins/channelrx/demodchirpchat/chirpchatdemodsettings.h
index 1b685cae4..3373a2e6b 100644
--- a/plugins/channelrx/demodchirpchat/chirpchatdemodsettings.h
+++ b/plugins/channelrx/demodchirpchat/chirpchatdemodsettings.h
@@ -72,6 +72,8 @@ struct ChirpChatDemodSettings
void resetToDefaults();
void setChannelMarker(Serializable *channelMarker) { m_channelMarker = channelMarker; }
void setSpectrumGUI(Serializable *spectrumGUI) { m_spectrumGUI = spectrumGUI; }
+ unsigned int getNbSFDFourths() const; //!< Get the number of SFD period fourths (depends on coding scheme)
+ bool hasSyncWord() const; //!< Only LoRa has a syncword (for the moment)
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
};
diff --git a/plugins/channelrx/demodchirpchat/chirpchatdemodsink.cpp b/plugins/channelrx/demodchirpchat/chirpchatdemodsink.cpp
index 8c99c70a1..a154ea086 100644
--- a/plugins/channelrx/demodchirpchat/chirpchatdemodsink.cpp
+++ b/plugins/channelrx/demodchirpchat/chirpchatdemodsink.cpp
@@ -82,9 +82,12 @@ void ChirpChatDemodSink::initSF(unsigned int sf, unsigned int deBits)
m_nbSymbols = 1 << sf;
m_nbSymbolsEff = 1 << (sf - deBits);
+ m_deLength = 1 << deBits;
m_fftLength = m_nbSymbols;
- m_fft->configure(m_fftInterpolation*m_fftLength, false);
- m_fftSFD->configure(m_fftInterpolation*m_fftLength, false);
+ m_interpolatedFFTLength = m_fftInterpolation*m_fftLength;
+ m_preambleTolerance = (m_deLength*m_fftInterpolation)/2;
+ m_fft->configure(m_interpolatedFFTLength, false);
+ m_fftSFD->configure(m_interpolatedFFTLength, false);
m_state = ChirpChatStateReset;
m_sfdSkip = m_fftLength / 4;
m_fftWindow.create(FFTWindow::Function::Kaiser, m_fftLength);
@@ -146,7 +149,7 @@ void ChirpChatDemodSink::processSample(const Complex& ci)
if (m_fftCounter == m_fftLength)
{
m_fftWindow.apply(m_fft->in());
- std::fill(m_fft->in()+m_fftLength, m_fft->in()+m_fftInterpolation*m_fftLength, Complex{0.0, 0.0});
+ std::fill(m_fft->in()+m_fftLength, m_fft->in()+m_interpolatedFFTLength, Complex{0.0, 0.0});
m_fft->transform();
m_fftCounter = 0;
double magsq, magsqTotal;
@@ -176,11 +179,20 @@ void ChirpChatDemodSink::processSample(const Complex& ci)
for (int i = 1; i < m_requiredPreambleChirps; i++)
{
- if (m_argMaxHistory[0] != m_argMaxHistory[i])
+ int delta = m_argMaxHistory[i] - m_argMaxHistory[i-1];
+ // qDebug("ChirpChatDemodSink::processSample: search: delta: %d / %d", delta, m_deLength);
+
+ if ((delta < -m_preambleTolerance) || (delta > m_preambleTolerance))
{
preambleFound = false;
break;
}
+
+ // if (m_argMaxHistory[0] != m_argMaxHistory[i])
+ // {
+ // preambleFound = false;
+ // break;
+ // }
}
if ((preambleFound) && (magsq > 1e-9))
@@ -227,11 +239,11 @@ void ChirpChatDemodSink::processSample(const Complex& ci)
if (m_fftCounter == m_fftLength)
{
m_fftWindow.apply(m_fft->in());
- std::fill(m_fft->in()+m_fftLength, m_fft->in()+m_fftInterpolation*m_fftLength, Complex{0.0, 0.0});
+ std::fill(m_fft->in()+m_fftLength, m_fft->in()+m_interpolatedFFTLength, Complex{0.0, 0.0});
m_fft->transform();
m_fftWindow.apply(m_fftSFD->in());
- std::fill(m_fftSFD->in()+m_fftLength, m_fftSFD->in()+m_fftInterpolation*m_fftLength, Complex{0.0, 0.0});
+ std::fill(m_fftSFD->in()+m_fftLength, m_fftSFD->in()+m_interpolatedFFTLength, Complex{0.0, 0.0});
m_fftSFD->transform();
m_fftCounter = 0;
@@ -265,23 +277,30 @@ void ChirpChatDemodSink::processSample(const Complex& ci)
{
m_magsqTotalAvg(magsqSFDTotal);
- if (m_chirpCount < 3) // too early
+ if (m_chirpCount < 1 + (m_settings.hasSyncWord() ? 2 : 0)) // too early
{
m_state = ChirpChatStateReset;
qDebug("ChirpChatDemodSink::processSample: SFD search: signal drop is too early");
}
else
{
- m_syncWord = round(m_preambleHistory[m_chirpCount-2] / 8.0);
- m_syncWord += 16 * round(m_preambleHistory[m_chirpCount-3] / 8.0);
- qDebug("ChirpChatDemodSink::processSample: SFD found: up: %4u|%11.6f - down: %4u|%11.6f sync: %x", imax, magsq, imaxSFD, magsqSFD, m_syncWord);
+ if (m_settings.hasSyncWord())
+ {
+ m_syncWord = round(m_preambleHistory[m_chirpCount-2] / 8.0);
+ m_syncWord += 16 * round(m_preambleHistory[m_chirpCount-3] / 8.0);
+ qDebug("ChirpChatDemodSink::processSample: SFD found: up: %4u|%11.6f - down: %4u|%11.6f sync: %x", imax, magsq, imaxSFD, magsqSFD, m_syncWord);
+ }
+ else
+ {
+ qDebug("ChirpChatDemodSink::processSample: SFD found: up: %4u|%11.6f - down: %4u|%11.6f", imax, magsq, imaxSFD, magsqSFD);
+ }
int sadj = 0;
int nadj = 0;
int zadj;
int sfdSkip = m_sfdSkip;
- for (int i = 0; i < m_chirpCount-3; i++)
+ for (int i = 0; i < m_chirpCount - 1 - (m_settings.hasSyncWord() ? 2 : 0); i++)
{
sadj += m_preambleHistory[i] > m_nbSymbols/2 ? m_preambleHistory[i] - m_nbSymbols : m_preambleHistory[i];
nadj++;
@@ -315,7 +334,7 @@ void ChirpChatDemodSink::processSample(const Complex& ci)
}
}
}
- else if (m_state == ChirpChatStateSkipSFD) // Just skip SFD
+ else if (m_state == ChirpChatStateSkipSFD) // Just skip the rest of SFD
{
m_fftCounter++;
@@ -324,13 +343,12 @@ void ChirpChatDemodSink::processSample(const Complex& ci)
m_fftCounter = m_fftLength - m_sfdSkip;
m_sfdSkipCounter++;
- if (m_sfdSkipCounter == m_sfdFourths) // 1.25 SFD chips left
+ if (m_sfdSkipCounter == m_settings.getNbSFDFourths() - 4U) // SFD chips fourths less one full period
{
qDebug("ChirpChatDemodSink::processSample: SFD skipped");
m_chirp = m_chirp0;
m_fftCounter = 0;
m_chirpCount = 0;
- int correction = 0;
m_magsqMax = 0.0;
m_decodeMsg = ChirpChatDemodMsg::MsgDecodeSymbols::create();
m_decodeMsg->setSyncWord(m_syncWord);
@@ -346,7 +364,7 @@ void ChirpChatDemodSink::processSample(const Complex& ci)
if (m_fftCounter == m_fftLength)
{
m_fftWindow.apply(m_fft->in());
- std::fill(m_fft->in()+m_fftLength, m_fft->in()+m_fftInterpolation*m_fftLength, Complex{0.0, 0.0});
+ std::fill(m_fft->in()+m_fftLength, m_fft->in()+m_interpolatedFFTLength, Complex{0.0, 0.0});
m_fft->transform();
m_fftCounter = 0;
double magsq, magsqTotal;
diff --git a/plugins/channelrx/demodchirpchat/chirpchatdemodsink.h b/plugins/channelrx/demodchirpchat/chirpchatdemodsink.h
index 44a37ad62..0a1b74e14 100644
--- a/plugins/channelrx/demodchirpchat/chirpchatdemodsink.h
+++ b/plugins/channelrx/demodchirpchat/chirpchatdemodsink.h
@@ -77,7 +77,6 @@ private:
static const unsigned int m_requiredPreambleChirps = 4; //!< Number of chirps required to estimate preamble
static const unsigned int m_maxSFDSearchChirps = 8; //!< Maximum number of chirps when looking for SFD after preamble detection
- static const unsigned int m_sfdFourths = 5; //!< Number of SFD chip period fourths to skip until payload
static const unsigned int m_fftInterpolation = 2; //!< FFT interpolation factor (usually a power of 2)
FFTEngine *m_fft;
@@ -87,7 +86,7 @@ private:
Complex *m_upChirps;
Complex *m_spectrumLine;
unsigned int m_fftCounter;
- unsigned int m_argMaxHistory[m_requiredPreambleChirps];
+ int m_argMaxHistory[m_requiredPreambleChirps];
unsigned int m_argMaxHistoryCounter;
unsigned int m_preambleHistory[m_maxSFDSearchChirps];
unsigned int m_syncWord;
@@ -108,9 +107,12 @@ private:
BasebandSampleSink* m_spectrumSink;
Complex *m_spectrumBuffer;
- unsigned int m_nbSymbols;
- unsigned int m_nbSymbolsEff; //!< effective symbols considering DE bits
- unsigned int m_fftLength;
+ unsigned int m_nbSymbols; //!< Number of symbols = length of base FFT
+ unsigned int m_nbSymbolsEff; //!< effective symbols considering DE bits
+ unsigned int m_fftLength; //!< Length of base FFT
+ unsigned int m_interpolatedFFTLength; //!< Length of interpolated FFT
+ int m_deLength; //!< Number of FFT bins collated to represent one symbol
+ int m_preambleTolerance; //!< Number of FFT bins to collate when looking for preamble
void processSample(const Complex& ci);
void initSF(unsigned int sf, unsigned int deBits); //!< Init tables, FFTs, depending on spread factor
diff --git a/plugins/channeltx/modchirpchat/chirpchatmodgui.cpp b/plugins/channeltx/modchirpchat/chirpchatmodgui.cpp
index 8333dc294..7c3539857 100644
--- a/plugins/channeltx/modchirpchat/chirpchatmodgui.cpp
+++ b/plugins/channeltx/modchirpchat/chirpchatmodgui.cpp
@@ -109,7 +109,10 @@ bool ChirpChatModGUI::handleMessage(const Message& message)
{
const ChirpChatMod::MsgReportPayloadTime& rpt = (ChirpChatMod::MsgReportPayloadTime&) message;
float fourthsMs = ((1<timePayloadText->setText(tr("%1 ms").arg(QString::number(rpt.getPayloadTimeMs(), 'f', 0)));
ui->timeTotalText->setText(tr("%1 ms").arg(QString::number(rpt.getPayloadTimeMs() + controlMs, 'f', 0)));
ui->timeSymbolText->setText(tr("%1 ms").arg(QString::number(4.0*fourthsMs, 'f', 1)));
diff --git a/plugins/channeltx/modchirpchat/chirpchatmodgui.ui b/plugins/channeltx/modchirpchat/chirpchatmodgui.ui
index de5124db3..391385f18 100644
--- a/plugins/channeltx/modchirpchat/chirpchatmodgui.ui
+++ b/plugins/channeltx/modchirpchat/chirpchatmodgui.ui
@@ -6,7 +6,7 @@
0
0
- 392
+ 402
373
@@ -30,7 +30,7 @@
1
20
- 390
+ 400
125
@@ -74,7 +74,7 @@
40
50
- 251
+ 261
16
@@ -102,7 +102,7 @@
40
70
- 81
+ 101
16
@@ -131,7 +131,7 @@
- 130
+ 150
70
30
16
@@ -153,7 +153,7 @@
- 300
+ 310
50
80
16
@@ -175,7 +175,7 @@
- 180
+ 200
70
32
16
@@ -188,7 +188,7 @@
- 280
+ 370
70
10
16
@@ -210,9 +210,9 @@
- 210
+ 240
70
- 61
+ 91
16
@@ -243,7 +243,7 @@
10
10
- 371
+ 381
26
@@ -366,7 +366,7 @@
40
90
- 81
+ 101
16
@@ -408,7 +408,7 @@
- 130
+ 150
90
30
16
@@ -430,7 +430,7 @@
- 180
+ 200
90
32
16
@@ -443,9 +443,9 @@
- 220
+ 240
90
- 81
+ 91
16
@@ -474,7 +474,7 @@
- 320
+ 350
90
30
16
@@ -493,48 +493,13 @@
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- 310
- 70
- 32
- 16
-
-
-
- Sync
-
-
-
-
-
- 350
- 68
- 30
- 20
-
-
-
- Qt::ClickFocus
-
-
- Sync word (1 byte hex)
-
-
- HH
-
-
- 00
-
-
1
150
- 390
+ 400
221
@@ -807,7 +772,7 @@
40
110
- 341
+ 355
60
@@ -830,7 +795,7 @@
40
175
- 341
+ 355
20
@@ -964,7 +929,7 @@
- 290
+ 300
200
25
16
@@ -980,7 +945,7 @@
- 320
+ 330
200
60
16
@@ -1037,7 +1002,7 @@
- 290
+ 285
10
50
16
@@ -1053,7 +1018,7 @@
- 230
+ 226
10
50
16
@@ -1168,6 +1133,41 @@
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ 377
+ 8
+ 22
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Sync word (1 byte hex)
+
+
+ HH
+
+
+ 00
+
+
+
+
+
+ 342
+ 10
+ 32
+ 16
+
+
+
+ Sync
+
+
diff --git a/plugins/channeltx/modchirpchat/chirpchatmodsettings.cpp b/plugins/channeltx/modchirpchat/chirpchatmodsettings.cpp
index 5e446955b..a536577ae 100644
--- a/plugins/channeltx/modchirpchat/chirpchatmodsettings.cpp
+++ b/plugins/channeltx/modchirpchat/chirpchatmodsettings.cpp
@@ -122,6 +122,22 @@ void ChirpChatModSettings::generateMessages()
.arg(m_urCall).arg(m_myCall).arg(m_textMessage);
}
+unsigned int ChirpChatModSettings::getNbSFDFourths() const
+{
+ switch (m_codingScheme)
+ {
+ case CodingLoRa:
+ return 9;
+ default:
+ return 8;
+ }
+}
+
+bool ChirpChatModSettings::hasSyncWord() const
+{
+ return m_codingScheme == CodingLoRa;
+}
+
QByteArray ChirpChatModSettings::serialize() const
{
SimpleSerializer s(1);
diff --git a/plugins/channeltx/modchirpchat/chirpchatmodsettings.h b/plugins/channeltx/modchirpchat/chirpchatmodsettings.h
index 36fdc4581..f2eed957e 100644
--- a/plugins/channeltx/modchirpchat/chirpchatmodsettings.h
+++ b/plugins/channeltx/modchirpchat/chirpchatmodsettings.h
@@ -96,6 +96,8 @@ struct ChirpChatModSettings
void resetToDefaults();
void setDefaultTemplates();
void generateMessages();
+ unsigned int getNbSFDFourths() const; //!< Get the number of SFD period fourths (depends on coding scheme)
+ bool hasSyncWord() const; //!< Only LoRa has a syncword (for the moment)
void setChannelMarker(Serializable *channelMarker) { m_channelMarker = channelMarker; }
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
diff --git a/plugins/channeltx/modchirpchat/chirpchatmodsource.cpp b/plugins/channeltx/modchirpchat/chirpchatmodsource.cpp
index 092b67497..3cbb5bb77 100644
--- a/plugins/channeltx/modchirpchat/chirpchatmodsource.cpp
+++ b/plugins/channeltx/modchirpchat/chirpchatmodsource.cpp
@@ -233,10 +233,20 @@ void ChirpChatModSource::modulateSample()
if (m_chirpCount == m_settings.m_preambleChirps)
{
m_chirpCount = 0;
- m_chirp0 = ((m_settings.m_syncWord >> ((1-m_chirpCount)*4)) & 0xf)*8;
- m_chirp = (m_chirp0 + m_fftLength)*ChirpChatModSettings::oversampling - 1;
- m_fftCounter = 0;
- m_state = ChirpChatStateSyncWord;
+
+ if (m_settings.hasSyncWord())
+ {
+ m_chirp0 = ((m_settings.m_syncWord >> ((1-m_chirpCount)*4)) & 0xf)*8;
+ m_chirp = (m_chirp0 + m_fftLength)*ChirpChatModSettings::oversampling - 1;
+ m_state = ChirpChatStateSyncWord;
+ }
+ else
+ {
+ m_sampleCounter = 0;
+ m_chirp0 = 0;
+ m_chirp = m_fftLength*ChirpChatModSettings::oversampling - 1;
+ m_state = ChirpChatStateSFD;
+ }
}
}
}
@@ -286,7 +296,7 @@ void ChirpChatModSource::modulateSample()
m_sampleCounter = 0;
}
- if (m_chirpCount == 9)
+ if (m_chirpCount == m_settings.getNbSFDFourths())
{
m_fftCounter = 0;
m_chirpCount = 0;
diff --git a/plugins/channeltx/modchirpchat/readme.md b/plugins/channeltx/modchirpchat/readme.md
index 7e8e504c0..f80b117a1 100644
--- a/plugins/channeltx/modchirpchat/readme.md
+++ b/plugins/channeltx/modchirpchat/readme.md
@@ -82,7 +82,7 @@ In practice it is difficult on the Rx side to make correct decodes if only one F
7: Sync word
-This is the sync word (byte) to transmit entered as a 2 nibble hexadecimal number.
+This is a LoRa specific feature and is the sync word (byte) to transmit entered as a 2 nibble hexadecimal number.
8: Number of preamble chirps