diff --git a/plugins/channelrx/demodchirpchat/chirpchatdemoddecoderft.cpp b/plugins/channelrx/demodchirpchat/chirpchatdemoddecoderft.cpp index dbfcbc285..3d1a31154 100644 --- a/plugins/channelrx/demodchirpchat/chirpchatdemoddecoderft.cpp +++ b/plugins/channelrx/demodchirpchat/chirpchatdemoddecoderft.cpp @@ -54,10 +54,7 @@ void ChirpChatDemodDecoderFT::decodeSymbols( return; } - // float *lls = new float[mags.size()*nbSymbolBits]; // bits log likelihoods (>0 for 0, <0 for 1) - // std::fill(lls, lls+mags.size()*nbSymbolBits, 0.0); FT8::FT8Params params; - // FT8::FT8::soft_decode_mags(params, mags, nbSymbolBits, lls); int r174[174]; std::string comments; payloadParityStatus = (int) ChirpChatDemodSettings::ParityOK; @@ -170,7 +167,21 @@ int ChirpChatDemodDecoderFT::decodeWithShift( float *lls = new float[mags.size()*nbSymbolBits]; // bits log likelihoods (>0 for 0, <0 for 1) std::fill(lls, lls+mags.size()*nbSymbolBits, 0.0); FT8::FT8::soft_decode_mags(params, mags, nbSymbolBits, lls); - return FT8::FT8::decode(lls, r174, params, 0, comments); + deinterleave174(lls); + int ret = FT8::FT8::decode(lls, r174, params, 0, comments); + delete[] lls; + return ret; +} + +void ChirpChatDemodDecoderFT::deinterleave174(float ll174[]) +{ + // 174 = 2*3*29 + float t174[174]; + std::copy(ll174, ll174+174, t174); + + for (int i = 0; i < 174; i++) { + ll174[i] = t174[(i%6)*29 + (i%29)]; + } } #endif // HAS_FT8 diff --git a/plugins/channelrx/demodchirpchat/chirpchatdemoddecoderft.h b/plugins/channelrx/demodchirpchat/chirpchatdemoddecoderft.h index f921cf815..d54140cdb 100644 --- a/plugins/channelrx/demodchirpchat/chirpchatdemoddecoderft.h +++ b/plugins/channelrx/demodchirpchat/chirpchatdemoddecoderft.h @@ -57,6 +57,7 @@ private: std::string& comments, int shift = 0 ); + static void deinterleave174(float ll174[]); }; diff --git a/plugins/channelrx/demodchirpchat/chirpchatdemodgui.ui b/plugins/channelrx/demodchirpchat/chirpchatdemodgui.ui index b127dc8c4..8ba668482 100644 --- a/plugins/channelrx/demodchirpchat/chirpchatdemodgui.ui +++ b/plugins/channelrx/demodchirpchat/chirpchatdemodgui.ui @@ -953,16 +953,6 @@ - - - - Header CRC status - - - HC - - - @@ -973,6 +963,16 @@ + + + + Header CRC status + + + HC + + + diff --git a/plugins/channelrx/demodchirpchat/readme.md b/plugins/channelrx/demodchirpchat/readme.md index 854ed46dd..cf9df60c8 100644 --- a/plugins/channelrx/demodchirpchat/readme.md +++ b/plugins/channelrx/demodchirpchat/readme.md @@ -11,7 +11,7 @@ LoRa is a property of Semtech and the details of the protocol are not made publi - To get an idea of what is LoRa: [here](https://www.link-labs.com/blog/what-is-lora) - A detailed inspection of LoRa modulation and protocol: [here](https://static1.squarespace.com/static/54cecce7e4b054df1848b5f9/t/57489e6e07eaa0105215dc6c/1464376943218/Reversing-Lora-Knight.pdf) -⚠ Only spread factors of 11 and 12 are working in LoRa mode thus with the distance enhancement active (DE=2) +⚠ Only spread factors of 11 and 12 are working in LoRa mode with the distance enhancement active (DE=2) Transmissions from the RN2483 module (SF=11 and SF=12 with DE=2) could be successfully received. It has not been tested with Semtech SX127x hardware. This LoRa decoder is designed for experimentation. For production grade applications it is recommended to use dedicated hardware instead. @@ -110,7 +110,9 @@ This is the Spread Factor parameter of the ChirpChat signal. This is the log2 of The LoRa standard specifies 0 (no DE) or 2 (DE active). The ChirpChat DE range is extended to all values between 0 and 4 bits. -This is the log2 of the number of FFT bins used for one symbol. Extending the number of FFT bins per symbol decreases the probability to detect the wrong symbol as an adjacent bin. It can also overcome frequency drift on long messages. +The LoRa standard also specifies that the LowDataRateOptimizatio flag (thus DE=2 vs DE=0 here) should be set when the symbol time defined as BW / 2^SF exceeds 16 ms (See section 4.1.1.6 of the SX127x datasheet). In practice this happens for SF=11 and SF=12 and large enough bandwidths (you can do the maths). + +Here this value is the log2 of the number of FFT bins used for one symbol. Extending the number of FFT bins per symbol decreases the probability to detect the wrong symbol as an adjacent bin. It can also overcome frequency or samlping time drift on long messages particularly for small bandwidths. In practice it is difficult to make correct decodes if only one FFT bin is used to code one symbol (DE=0) therefore it is recommended to use a DE factor of 2 or more. With medium SNR DE=1 can still achieve good results. diff --git a/plugins/channeltx/modchirpchat/chirpchatmodencoderft.cpp b/plugins/channeltx/modchirpchat/chirpchatmodencoderft.cpp index b36511add..0d0d09769 100644 --- a/plugins/channeltx/modchirpchat/chirpchatmodencoderft.cpp +++ b/plugins/channeltx/modchirpchat/chirpchatmodencoderft.cpp @@ -74,6 +74,8 @@ void ChirpChatModEncoderFT::encodeMsg( int iBit; int symbol = 0; + interleave174(a174); + for (int i = 0; i < allBits; i++) { iBit = nbSymbolBits - (i % nbSymbolBits) - 1; // MSB first @@ -230,4 +232,15 @@ void ChirpChatModEncoderFT::encodeMsgFinish(const QString& myCall, const QString FT8::FT8::encode(a174, a77); } +void ChirpChatModEncoderFT::interleave174(int a174[]) +{ + // 174 = 2*3*29 + int t174[174]; + std::copy(a174, a174+174, t174); + + for (int i = 0; i < 174; i++) { + a174[i] = t174[(i%6)*29 + (i%29)]; + } +} + #endif // HAS_FT8 diff --git a/plugins/channeltx/modchirpchat/chirpchatmodencoderft.h b/plugins/channeltx/modchirpchat/chirpchatmodencoderft.h index b8370bfd0..3167ddb0d 100644 --- a/plugins/channeltx/modchirpchat/chirpchatmodencoderft.h +++ b/plugins/channeltx/modchirpchat/chirpchatmodencoderft.h @@ -43,6 +43,7 @@ private: static void encodeMsgReply(const QString& myCall, const QString& urCall, const QString& myLocator, int a174[]); static void encodeMsgReport(const QString& myCall, const QString& urCall, const QString& myReport, int reply, int a174[]); static void encodeMsgFinish(const QString& myCall, const QString& urCall, const QString& shorthand, int a174[]); + static void interleave174(int a174[]); }; #endif // PLUGINS_CHANNELTX_MODCHIRPCHAT_CHIRPCHATMODENCODEFT_H_ diff --git a/plugins/channeltx/modchirpchat/readme.md b/plugins/channeltx/modchirpchat/readme.md index 085b40d54..39eca052f 100644 --- a/plugins/channeltx/modchirpchat/readme.md +++ b/plugins/channeltx/modchirpchat/readme.md @@ -74,13 +74,15 @@ The ChirpChat signal is oversampled by four therefore it needs a baseband of at

5: Spread Factor

-This is the Spread Factor parameter of the ChirpChat signal. This is the log2 of the possible frequency shifts used over the bandwidth (3). The number of symbols is 2SF-DE where SF is the spread factor and DE the Distance Enhancement factor (8). To +This is the Spread Factor parameter of the ChirpChat signal. This is the log2 of the possible frequency shifts used over the bandwidth (3). The number of symbols is 2SF-DE where SF is the spread factor and DE the Distance Enhancement factor (6).

6: Distance Enhancement factor

The LoRa standard specifies 0 (no DE) or 2 (DE active). The ChirpChat range is extended to all values between 0 and 4 bits. -This is the log2 of the number of frequency shifts separating two consecutive shifts that represent a symbol. On the receiving side this decreases the probability to detect the wrong symbol as an adjacent FFT bin. It can also overcome frequency drift on long messages. +The LoRa standard also specifies that the LowDataRateOptimization flag (thus DE=2 vs DE=0 here) should be set when the symbol time defined as BW / 2^SF exceeds 16 ms (See section 4.1.1.6 of the SX127x datasheet). In practice this happens for SF=11 and SF=12 and large enough bandwidths (you can do the maths). + +Here this value is the log2 of the number of frequency shifts separating two consecutive shifts that represent a symbol. On the receiving side this decreases the probability to detect the wrong symbol as an adjacent FFT bin. It can also overcome frequency or sampling time drift on long messages particularly for small bandwidths. In practice it is difficult on the Rx side to make correct decodes if only one FFT bin is used to code one symbol (DE=0). It is therefore recommended to use a factor of 1 or more.