diff --git a/plugins/channelrx/demodlora/lorademodsink.h b/plugins/channelrx/demodlora/lorademodsink.h
index 1d2a0b27f..616b0873f 100644
--- a/plugins/channelrx/demodlora/lorademodsink.h
+++ b/plugins/channelrx/demodlora/lorademodsink.h
@@ -63,7 +63,7 @@ private:
int m_chirp;
int m_chirp0;
- static const unsigned int m_requiredPreambleChirps = 3; //!< Number of chirps required to estimate preamble
+ 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 = 1; //!< FFT interpolation factor (usually a power of 2)
diff --git a/plugins/channeltx/modlora/loramodgui.ui b/plugins/channeltx/modlora/loramodgui.ui
index 87189431b..79208b448 100644
--- a/plugins/channeltx/modlora/loramodgui.ui
+++ b/plugins/channeltx/modlora/loramodgui.ui
@@ -223,7 +223,7 @@
0
- 2
+ 4
1
diff --git a/plugins/channeltx/modlora/loramodsettings.cpp b/plugins/channeltx/modlora/loramodsettings.cpp
index c817929b4..324da1eef 100644
--- a/plugins/channeltx/modlora/loramodsettings.cpp
+++ b/plugins/channeltx/modlora/loramodsettings.cpp
@@ -24,8 +24,8 @@
#include "settings/serializable.h"
#include "loramodsettings.h"
-const int LoRaModSettings::bandwidths[] = {7813, 10417, 15625, 20833, 31250, 41667, 62500, 125000, 250000, 500000};
-const int LoRaModSettings::nbBandwidths = 10;
+const int LoRaModSettings::bandwidths[] = {2500, 7813, 10417, 15625, 20833, 31250, 41667, 62500, 125000, 250000, 500000};
+const int LoRaModSettings::nbBandwidths = 11;
const int LoRaModSettings::oversampling = 4;
LoRaModSettings::LoRaModSettings() :
diff --git a/plugins/channeltx/modlora/loramodsource.cpp b/plugins/channeltx/modlora/loramodsource.cpp
index 5a925ef6a..7cc387282 100644
--- a/plugins/channeltx/modlora/loramodsource.cpp
+++ b/plugins/channeltx/modlora/loramodsource.cpp
@@ -35,6 +35,7 @@ LoRaModSource::LoRaModSource() :
m_magsq = 0.0;
initSF(m_settings.m_spreadFactor);
+ initTest(m_settings.m_spreadFactor, m_settings.m_deBits);
reset();
applySettings(m_settings, true);
applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true);
@@ -61,13 +62,6 @@ void LoRaModSource::initSF(unsigned int sf)
m_quarterSamples = (m_fftLength/4)*LoRaModSettings::oversampling;
m_downChirps = new Complex[2*m_fftLength*LoRaModSettings::oversampling]; // Each table is 2 chirps long to allow use from arbitrary offsets.
m_upChirps = new Complex[2*m_fftLength*LoRaModSettings::oversampling];
- m_symbols.clear();
-
- for (unsigned int symbol = m_fftLength/4; symbol < m_fftLength; symbol += m_fftLength/4)
- {
- m_symbols.push_back(symbol);
- m_symbols.push_back(symbol+1);
- }
float halfAngle = M_PI/LoRaModSettings::oversampling;
float phase = -halfAngle;
@@ -89,11 +83,32 @@ void LoRaModSource::initSF(unsigned int sf)
m_phaseIncrements = new double[2*m_fftLength*LoRaModSettings::oversampling];
phase = -halfAngle;
- for (int i = 0; i < 2*m_fftLength*LoRaModSettings::oversampling; i++)
+ for (int i = 0; i < m_fftLength*LoRaModSettings::oversampling; i++)
{
m_phaseIncrements[i] = phase;
phase += (2*halfAngle) / (m_fftLength*LoRaModSettings::oversampling);
- phase = phase > halfAngle ? -halfAngle : phase;
+ }
+
+ std::copy(
+ m_phaseIncrements,
+ m_phaseIncrements+m_fftLength*LoRaModSettings::oversampling,
+ m_phaseIncrements+m_fftLength*LoRaModSettings::oversampling
+ );
+}
+
+void LoRaModSource::initTest(unsigned int sf, unsigned int deBits)
+{
+ unsigned int fftLength = 1<