mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-04 22:27:53 -04:00
Extract some bits.
This commit is contained in:
parent
d749284821
commit
2d55f3f347
@ -4,16 +4,25 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Needs adjusting for different sizes
|
// Needs adjusting for different sizes
|
||||||
void LoRaDemod::interleave(char* inout)
|
void LoRaDemod::interleave(char* inout, int size)
|
||||||
{
|
{
|
||||||
int i, index = 6;
|
int i, j;
|
||||||
char in[index * 2];
|
char in[6 * 2];
|
||||||
for (i = 0; i < index; i++)
|
short s;
|
||||||
in[i] = in[i + index] = inout[i];
|
|
||||||
// top bits are swapped ?
|
for (j = 0; j < size; j+=6) {
|
||||||
for (i = 0; i < index; i++) {
|
for (i = 0; i < 6; i++)
|
||||||
inout[i] = (32 & in[2 + i]) | (16 & in[1 + i]) | (8 & in[3 + i])
|
in[i] = in[i + 6] = inout[i + j];
|
||||||
|
// top bits are swapped
|
||||||
|
for (i = 0; i < 6; i++) {
|
||||||
|
s = (32 & in[2 + i]) | (16 & in[1 + i]) | (8 & in[3 + i])
|
||||||
| (4 & in[4 + i]) | (2 & in[5 + i]) | (1 & in[6 + i]);
|
| (4 & in[4 + i]) | (2 & in[5 + i]) | (1 & in[6 + i]);
|
||||||
|
// bits are also rotated
|
||||||
|
s = (s << 3) | (s >> 3);
|
||||||
|
s &= 63;
|
||||||
|
s = (s >> i) | (s << (6 - i));
|
||||||
|
inout[i + j] = s & 63;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,24 +31,32 @@ short LoRaDemod::toGray(short num)
|
|||||||
return (num >> 1) ^ num;
|
return (num >> 1) ^ num;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore FEC, try data in lsb, bigendian
|
// ignore FEC, try to extract raw bits
|
||||||
void LoRaDemod::hamming(char* inout, int size)
|
void LoRaDemod::hamming(char* c, int size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char c;
|
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
c = inout[i];
|
c[i] = ((c[i] & 1)<<3) | ((c[i] & 2)<<0) | ((c[i] & 4)>>0) | ((c[i] & 8)>>3);
|
||||||
c = ((c&1)<<3) | ((c&2)<<1) | ((c&4)>>1) | ((c&8)>>3);
|
i++;
|
||||||
inout[i] = c;
|
c[i] = ((c[i] & 1)<<2) | ((c[i] & 2)<<2) | ((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] & 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)>>2) | ((c[i] & 8)>>2);
|
||||||
}
|
}
|
||||||
inout[i] = 0;
|
c[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// example data whitening (4 bit only - needs 6 bit for FEC)
|
// example data whitening (4 bit only - needs 6 bit for FEC)
|
||||||
void LoRaDemod::prng(char* inout, int size)
|
void LoRaDemod::prng(char* inout, int size)
|
||||||
{
|
{
|
||||||
const char otp[] = {
|
const char otp[] = {
|
||||||
"EHFGKHGMGKGMGHG@FKDN@EHBMGBOLFALO@GIBIICJNMDFIDHAHJHMHBBHLHCHLH@IINCAOJFMLF@EKBDIAJKMNBEMBGMBKLMAHOHFHDB@DH@H@HAIKKDKAOKGDBAMIGIBCMLGCFODFAFNLECBLIHKHNBALJA"
|
"LBMGEJJENKKKJBN@KB@KAEDDMMDONIN@N@KFBGBCMCMCMIBJHBDHNJDJALDHE@A@DFGOBOMIM@M@BBBCBAMBMKDENDLEDKNKNBNHKJ@JADD@EAAADBOCGAGBLCDANFLGDCNGLOMOBIHHMLBHB@BHMJGJBLMLED@B"
|
||||||
};
|
};
|
||||||
int i, maxchars;
|
int i, maxchars;
|
||||||
|
|
||||||
@ -47,6 +64,6 @@ void LoRaDemod::prng(char* inout, int size)
|
|||||||
if (size < maxchars)
|
if (size < maxchars)
|
||||||
maxchars = size;
|
maxchars = size;
|
||||||
for (i = 0; i < maxchars; i++)
|
for (i = 0; i < maxchars; i++)
|
||||||
inout[i] ^= otp[i];
|
inout[i] ^= 0xf & otp[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,27 +73,27 @@ void LoRaDemod::configure(MessageQueue* messageQueue, Real Bandwidth)
|
|||||||
|
|
||||||
void LoRaDemod::dumpRaw()
|
void LoRaDemod::dumpRaw()
|
||||||
{
|
{
|
||||||
char hex[] = {"0123456789ABCDEFXXXX"};
|
|
||||||
short bin, j, max;
|
short bin, j, max;
|
||||||
max = m_time / 4 - 3;
|
|
||||||
if (max > 80)
|
|
||||||
max = 80; // 80 symbols is about 40 chars
|
|
||||||
char text[256];
|
char text[256];
|
||||||
|
|
||||||
|
max = m_time / 4 - 3;
|
||||||
|
if (max > 100)
|
||||||
|
max = 100; // about 2 symbols to each char
|
||||||
|
|
||||||
for ( j=0; j < max; j++) {
|
for ( j=0; j < max; j++) {
|
||||||
bin = (history[j * 4 + 12] + m_tune ) & (LORA_SFFT_LEN - 1);
|
bin = (history[j * 4 + 12] + m_tune ) & (LORA_SFFT_LEN - 1);
|
||||||
text[j] = toGray(bin >> 1);
|
text[j] = toGray(bin >> 1);
|
||||||
}
|
}
|
||||||
for ( j=0; j < max; j+=6)
|
interleave(text, max);
|
||||||
interleave(&text[j]);
|
|
||||||
prng(text, max);
|
prng(text, max);
|
||||||
hamming(text, max);
|
hamming(text, max);
|
||||||
for ( j=0; j < max; j++) {
|
|
||||||
text[j] = hex[ (0xf & text[j]) ];
|
for ( j=0; j < max / 2; j++) {
|
||||||
|
text[j] = (text[j * 2 + 2] << 4) | (0xf & text[j * 2 + 1]);
|
||||||
|
if ((text[j] < 32 )||( text[j] > 126))
|
||||||
|
text[j] = 0x5f;
|
||||||
}
|
}
|
||||||
// for ( j=0; j < max / 2; j++) {
|
|
||||||
// if ((text[j] < 32 )||( text[j] > 126))
|
|
||||||
// text[j] = 0x5f;
|
|
||||||
// }
|
|
||||||
text[j] = 0;
|
text[j] = 0;
|
||||||
printf("%s\n", text);
|
printf("%s\n", text);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int detect(Complex sample, Complex angle);
|
int detect(Complex sample, Complex angle);
|
||||||
void interleave(char* inout);
|
void interleave(char* inout, int size);
|
||||||
void dumpRaw(void);
|
void dumpRaw(void);
|
||||||
short synch (short bin);
|
short synch (short bin);
|
||||||
short toGray(short bin);
|
short toGray(short bin);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user