diff --git a/plugins/channel/lora/lorabits.h b/plugins/channel/lora/lorabits.h index 046d6a0ce..7c53b4fda 100644 --- a/plugins/channel/lora/lorabits.h +++ b/plugins/channel/lora/lorabits.h @@ -23,3 +23,31 @@ short LoRaDemod::toGray(short num) return (num >> 1) ^ num; } +// ignore FEC, data in lsb +void LoRaDemod::hamming(char* inout, int size) +{ + int i; + char c; + for (i = 0; i < size; i++) { + c = inout[i]; + c = ((c&1)<<3) | ((c&2)<<1) | ((c&4)>>1) | ((c&8)>>3); + inout[i] = c; + } + inout[i] = 0; +} + +// data whitening +void LoRaDemod::prng(char* inout, int size) +{ + const char otp[] = { + " " + }; + int i, maxchars; + + maxchars = sizeof( otp ); + if (size < maxchars) + maxchars = size; + for (i = 0; i < maxchars; i++) + inout[i] ^= otp[i] - 32; +} + diff --git a/plugins/channel/lora/lorademod.cpp b/plugins/channel/lora/lorademod.cpp index 194b940b5..8ffa9f3c4 100644 --- a/plugins/channel/lora/lorademod.cpp +++ b/plugins/channel/lora/lorademod.cpp @@ -75,8 +75,8 @@ void LoRaDemod::dumpRaw() { short bin, j, max; max = m_time / 4 - 3; - if (max > 36) - max = 36; + if (max > 80) + max = 80; // 80 symbols is about 40 chars char text[256]; for ( j=0; j < max; j++) { bin = (history[j * 4 + 12] + m_tune ) & (LORA_SFFT_LEN - 1); @@ -84,10 +84,12 @@ void LoRaDemod::dumpRaw() } for ( j=0; j < max; j+=6) interleave(&text[j]); + prng(text, max); // ?? + hamming(text, max); for ( j=0; j < max; j++) - text[j] += 32; + text[j] += 64; // 4 bits per symbol text[j] = 0; - printf(">%s..(%d)\n", text, m_time / 4 - 2); + printf(">%s<\n", text); } short LoRaDemod::synch(short bin) diff --git a/plugins/channel/lora/lorademod.h b/plugins/channel/lora/lorademod.h index 3675a850d..312ae66d0 100644 --- a/plugins/channel/lora/lorademod.h +++ b/plugins/channel/lora/lorademod.h @@ -48,6 +48,9 @@ private: void dumpRaw(void); short synch (short bin); short toGray(short bin); + void hamming(char* inout, int size); + void prng(char* inout, int size); + class MsgConfigureLoRaDemod : public Message { MESSAGE_CLASS_DECLARATION diff --git a/plugins/channel/lora/lorademodgui.ui b/plugins/channel/lora/lorademodgui.ui index 7f3eedebf..068f86aae 100644 --- a/plugins/channel/lora/lorademodgui.ui +++ b/plugins/channel/lora/lorademodgui.ui @@ -71,7 +71,7 @@ 0 - 1 + 2 1 @@ -109,7 +109,7 @@ - 2^8 + 6:4 2^8 Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter