diff --git a/plugins/channel/lora/lorabits.h b/plugins/channel/lora/lorabits.h index 9698a5618..0ef527279 100644 --- a/plugins/channel/lora/lorabits.h +++ b/plugins/channel/lora/lorabits.h @@ -3,12 +3,15 @@ Chosen mode "spreading 8, low rate" has 6 bits per symbol, so use 4:6 FEC More spreading needs higher frequency resolution and longer time on air, increasing drift errors. - Want higher bandwidth when using more spreading, which needs more CPU. + Want higher bandwidth when using more spreading, which needs more CPU and a better FFT. - Six bit Hamming can only correct drift errors. Want 7 or 8 bit FEC for QRM + Six bit Hamming can only correct drift errors. Need 7 or 8 bit FEC for QRM + Easier to use 5:4 FEC with Reed-Soloman messages. + + Implicit Mode: explicit starts with a 4:8 block and has different whitening */ -// Needs adjusting for different sizes +// Six bits per symbol, six chars per block void LoRaDemod::interleave6(char* inout, int size) { int i, j; @@ -46,11 +49,11 @@ void LoRaDemod::hamming6(char* c, int size) i++; c[i] = ((c[i] & 1)<<2) | ((c[i] & 2)<<2) | ((c[i] & 4)>>1) | ((c[i] & 8)>>3); i++; - c[i] = ((c[i] & 32)>>2) | ((c[i] & 2)<<1) | ((c[i] & 4)>>1) | ((c[i] & 8)>>3); + c[i] = ((c[i] &32)>>2) | ((c[i] & 2)<<1) | ((c[i] & 4)>>1) | ((c[i] & 8)>>3); i++; c[i] = ((c[i] & 1)<<3) | ((c[i] & 2)<<1) | ((c[i] & 4)>>1) | ((c[i] & 8)>>3); i++; - c[i] = ((c[i] & 1)<<3) | ((c[i] & 2)<<1) | ((c[i] & 4)>>1) | ((c[i] & 16)>>4); + c[i] = ((c[i] & 1)<<3) | ((c[i] & 2)<<1) | ((c[i] & 4)>>1) | ((c[i] &16)>>4); i++; c[i] = ((c[i] & 1)<<3) | ((c[i] & 2)<<1) | ((c[i] & 4)>>2) | ((c[i] & 8)>>2); } @@ -61,7 +64,12 @@ void LoRaDemod::hamming6(char* c, int size) void LoRaDemod::prng6(char* inout, int size) { const char otp[] = { - "5^ZSm0=cOGMgUB=bNcb<@a^T;_f=6DEB]2ImPIKg:j]RlYT4YZ<`9hZ\\PPb;@8X8i]Zmc_6B52\\8oUPHIcBOc>dY?d9[n5Lg]b]R8hR<0`T008h9c9QJm[c?a:lQEGa;nU=b_UbTW3=W5Aa<9i;F;ondS[LBA;[4S9]kkh]Vc2j>kX" + //explicit mode + "cOGGg7CM2=b5a?<`i;T2of5jDAB=2DoQ9ko?h_RLQR4@Z\\`9jY\\PX89lHX8h_R]c_^@OB<0`W08ik?Mg>dQZf3kn5Je5R=R4h[dY?d9[n5Lg]b]R8hR<0`T008h9c9QJm[c?a:lQEGa;nU=b_WfUV2?V4@c=8h9B9njlQZDC@9Z 100) - max = 100; // about 2 symbols to each char + if (max > 140) + max = 140; // about 2 symbols to each char for ( j=0; j < max; j++) { - bin = (history[j * 4 + 12] + m_tune ) & (LORA_SFFT_LEN - 1); + bin = (history[(j + 1) * 4] + m_tune ) & (LORA_SFFT_LEN - 1); text[j] = toGray(bin >> 1); } - prng6(text, max); - interleave6(text, max); - hamming6(text, max); + // First block is always 8 symbols + interleave6(text, 6); + interleave6(&text[8], max); + hamming6(text, 6); + hamming6(&text[8], max); for ( j=0; j < max / 2; j++) { - text[j] = (text[j * 2 + 2] << 4) | (0xf & text[j * 2 + 1]); + text[j] = (text[j * 2 + 1] << 4) | (0xf & text[j * 2 + 0]); if ((text[j] < 32 )||( text[j] > 126)) text[j] = 0x5f; } + text[3] = text[2]; + text[2] = text[1]; + text[1] = text[0]; text[j] = 0; - printf("%s\n", text); + printf("%s\n", &text[1]); } short LoRaDemod::synch(short bin)