Finished implementing wspr coding process
This commit is contained in:
parent
9655ca5ee0
commit
4100c7fce0
Binary file not shown.
|
@ -3,6 +3,8 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
static const uint8_t WSPR_LENGTH = 162;
|
||||||
|
|
||||||
uint8_t wspr_call_char(char c) {
|
uint8_t wspr_call_char(char c) {
|
||||||
c = toupper(c);
|
c = toupper(c);
|
||||||
if(c >= '0' && c <= '9') {
|
if(c >= '0' && c <= '9') {
|
||||||
|
@ -41,18 +43,18 @@ uint8_t wspr_power(uint8_t power) {
|
||||||
uint64_t wspr_message(char *call, char *loc, uint8_t power) {
|
uint64_t wspr_message(char *call, char *loc, uint8_t power) {
|
||||||
uint32_t m, n;
|
uint32_t m, n;
|
||||||
|
|
||||||
n = wspr_loc_char(call[0]);
|
n = wspr_call_char(call[0]);
|
||||||
n = n * 36 + wspr_loc_char(call[1]);
|
n = n * 36 + wspr_call_char(call[1]);
|
||||||
n = n * 10 + wspr_loc_char(call[2]);
|
n = n * 10 + wspr_call_char(call[2]);
|
||||||
n = n * 27 + wspr_loc_char(call[3]) - 10;
|
n = n * 27 + wspr_call_char(call[3]) - 10;
|
||||||
n = n * 27 + wspr_loc_char(call[4]) - 10;
|
n = n * 27 + wspr_call_char(call[4]) - 10;
|
||||||
n = n * 27 + wspr_loc_char(call[5]) - 10;
|
n = n * 27 + wspr_call_char(call[5]) - 10;
|
||||||
|
|
||||||
m = 179 - 10 * wspr_loc_char(loc[0]) - wspr_loc_char(loc[2]);
|
m = 179 - 10 * wspr_loc_char(loc[0]) - wspr_loc_char(loc[2]);
|
||||||
m = m * 180 + 10 * wspr_loc_char(loc[1]) + wspr_loc_char(loc[3]);
|
m = m * 180 + 10 * wspr_loc_char(loc[1]) + wspr_loc_char(loc[3]);
|
||||||
m = m * 128 + wspr_power(power) + 64;
|
m = m * 128 + wspr_power(power) + 64;
|
||||||
|
|
||||||
return n << 21 | m;
|
return ((uint64_t) n) << 22 | m;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t WSPR_FEC_TAPS1 = 0xF2D05351;
|
const uint32_t WSPR_FEC_TAPS1 = 0xF2D05351;
|
||||||
|
@ -68,13 +70,13 @@ uint8_t wspr_parity32(uint32_t x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void wspr_fec(uint64_t msg, uint8_t *output) {
|
void wspr_fec(uint64_t msg, uint8_t *output) {
|
||||||
memset(output, 0, 162);
|
memset(output, 0, WSPR_LENGTH);
|
||||||
|
|
||||||
uint32_t reg = 0;
|
uint32_t reg = 0;
|
||||||
for(uint8_t i = 0; i < 81; i++) {
|
for(uint8_t i = 0; i < 81; i++) {
|
||||||
uint8_t bit = 0;
|
uint8_t bit = 0;
|
||||||
if(i < 50) {
|
if(i < 50) {
|
||||||
bit = (msg & (1 << (50 - i))) != 0;
|
bit = (msg >> (50 - i - 1)) & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
reg = (reg << 1) | bit;
|
reg = (reg << 1) | bit;
|
||||||
|
@ -104,9 +106,9 @@ uint8_t wspr_reverse_bits(uint8_t bits) {
|
||||||
void wspr_interleave(uint8_t *input, uint8_t *output) {
|
void wspr_interleave(uint8_t *input, uint8_t *output) {
|
||||||
uint8_t p = 0;
|
uint8_t p = 0;
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
while(p < 162) {
|
while(p < WSPR_LENGTH) {
|
||||||
uint8_t rev_i = wspr_reverse_bits(i);
|
uint8_t rev_i = wspr_reverse_bits(i);
|
||||||
if(rev_i < 162) {
|
if(rev_i < WSPR_LENGTH) {
|
||||||
output[rev_i] = input[p];
|
output[rev_i] = input[p];
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
@ -122,23 +124,65 @@ const uint8_t WSPR_SYNC[162] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void wspr_add_sync(uint8_t *symbols) {
|
void wspr_add_sync(uint8_t *symbols) {
|
||||||
for(uint8_t i = 0; i < 161; i++) {
|
for(uint8_t i = 0; i < WSPR_LENGTH; i++) {
|
||||||
symbols[i] = WSPR_SYNC[i] + 2 * symbols[i];
|
symbols[i] = WSPR_SYNC[i] + 2 * symbols[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char const *argv[]) {
|
uint64_t validation_msg = 1086526031934565;
|
||||||
|
|
||||||
|
uint8_t validation_bits[162] = {
|
||||||
|
1,1,1,0,1,1,1,1,1,0,0,0,1,1,1,0,0,1,0,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,1,1,0,0,0,
|
||||||
|
1,1,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,1,1,1,0,1,0,1,0,1,1,0,1,0,1,0,1,
|
||||||
|
0,0,0,1,0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,0,1,1,0,1,0,1,0,0,0,1,1,0,0,1,1,1,1,
|
||||||
|
0,1,1,0,1,1,0,1,0,1,0,1,0,1,0,1,1,0,0,0,1,1,0,1,0,0,1,1,1,1
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t validation[162] = {
|
||||||
|
3, 3, 0, 0, 2, 0, 0, 0, 1, 0, 2, 0, 1, 3, 1, 2, 2, 2, 1, 0, 0, 3, 2, 3, 1, 3, 3, 2, 2, 0,
|
||||||
|
2, 0, 0, 0, 3, 2, 0, 1, 2, 3, 2, 2, 0, 0, 2, 2, 3, 2, 1, 1, 0, 2, 3, 3, 2, 1, 0, 2, 2, 1,
|
||||||
|
3, 2, 1, 2, 2, 2, 0, 3, 3, 0, 3, 0, 3, 0, 1, 2, 1, 0, 2, 1, 2, 0, 3, 2, 1, 3, 2, 0, 0, 3,
|
||||||
|
3, 2, 3, 0, 3, 2, 2, 0, 3, 0, 2, 0, 2, 0, 1, 0, 2, 3, 0, 2, 1, 1, 1, 2, 3, 3, 0, 2, 3, 1,
|
||||||
|
2, 1, 2, 2, 2, 1, 3, 3, 2, 0, 0, 0, 0, 1, 0, 3, 2, 0, 1, 3, 2, 2, 2, 2, 2, 0, 2, 3, 3, 2,
|
||||||
|
3, 2, 3, 3, 2, 0, 0, 3, 1, 2, 2, 2
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, char const *argv[]) {
|
||||||
|
uint8_t test[162];
|
||||||
|
uint8_t test1[162];
|
||||||
|
uint64_t msg = wspr_message(" K1ABC", "FN42", 37);
|
||||||
|
|
||||||
|
|
||||||
|
if(msg == validation_msg) {
|
||||||
|
printf("%lu✓\n", msg);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("%lu✗\n", msg);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t test[161];
|
|
||||||
uint8_t test1[161];
|
|
||||||
uint64_t msg = wspr_message("DL1SSK", "JN39WE", 27);
|
|
||||||
|
|
||||||
wspr_fec(msg, test);
|
wspr_fec(msg, test);
|
||||||
|
|
||||||
|
for(uint8_t i = 0; i < WSPR_LENGTH; i++) {
|
||||||
|
if(test[i] == validation_bits[i]) {
|
||||||
|
printf("%d✓", test[i]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("%d✗", test[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n\n");
|
||||||
|
|
||||||
wspr_interleave(test, test1);
|
wspr_interleave(test, test1);
|
||||||
wspr_add_sync(test1);
|
wspr_add_sync(test1);
|
||||||
|
|
||||||
for(uint8_t i = 0; i < 161; i++) {
|
for(uint8_t i = 0; i < WSPR_LENGTH; i++) {
|
||||||
printf("%d,", test1[i]);
|
if(test1[i] == validation[i]) {
|
||||||
|
printf("%d✓", test1[i]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("%d✗", test1[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue