diff --git a/plugins/channel/lora/lorabits.h b/plugins/channel/lora/lorabits.h index 347996099..046d6a0ce 100644 --- a/plugins/channel/lora/lorabits.h +++ b/plugins/channel/lora/lorabits.h @@ -4,15 +4,16 @@ */ // Needs adjusting for different sizes -void LoRaDemod::interleave(short* inout) +void LoRaDemod::interleave(char* inout) { int i, index = 6; - short in[index * 2]; + char in[index * 2]; for (i = 0; i < index; i++) in[i] = inout[i]; + // top bits are swapped ? for (i = 0; i < index; i++) { - inout[i] = (1 & in[0 + i]) | (2 & in[1 + i]) | (4 & in[2 + i]) - | (8 & in[3 + i]) | (16 & in[4 + i]) | (32 & in[5 + i]); + inout[i] = (32 & in[1 + i]) | (16 & in[0 + i]) | (8 & in[2 + i]) + | (4 & in[3 + i]) | (2 & in[4 + i]) | (1 & in[5 + i]); in[i + index] = in[i]; } } diff --git a/plugins/channel/lora/lorademod.cpp b/plugins/channel/lora/lorademod.cpp index 243d8e51e..194b940b5 100644 --- a/plugins/channel/lora/lorademod.cpp +++ b/plugins/channel/lora/lorademod.cpp @@ -74,16 +74,20 @@ void LoRaDemod::configure(MessageQueue* messageQueue, Real Bandwidth) void LoRaDemod::dumpRaw() { short bin, j, max; - max = m_time / 4 - 1; - if (max > 32) - max = 32; + max = m_time / 4 - 3; + if (max > 36) + max = 36; char text[256]; for ( j=0; j < max; j++) { - bin = (history[j * 4 + 4] + m_tune) & (LORA_SFFT_LEN - 1); - text[j] = 32 + (toGray(bin) >> 1); + bin = (history[j * 4 + 12] + m_tune ) & (LORA_SFFT_LEN - 1); + text[j] = toGray(bin >> 1); } + for ( j=0; j < max; j+=6) + interleave(&text[j]); + for ( j=0; j < max; j++) + text[j] += 32; text[j] = 0; - printf(">%s..(%d)\n", text, m_time / 4); + printf(">%s..(%d)\n", text, m_time / 4 - 2); } short LoRaDemod::synch(short bin) diff --git a/plugins/channel/lora/lorademod.h b/plugins/channel/lora/lorademod.h index 13845aa82..3675a850d 100644 --- a/plugins/channel/lora/lorademod.h +++ b/plugins/channel/lora/lorademod.h @@ -44,7 +44,7 @@ public: private: int detect(Complex sample, Complex angle); - void interleave(short* inout); + void interleave(char* inout); void dumpRaw(void); short synch (short bin); short toGray(short bin);