1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-09 09:25:07 -04:00

FT8 demod: support for types 0.5 and 5 messages

This commit is contained in:
f4exb
2023-01-28 22:45:07 +01:00
parent 5980dda8a9
commit f63f1270ba
3 changed files with 121 additions and 16 deletions
+108 -6
View File
@@ -145,11 +145,8 @@ std::string Packing::unpackcall(int x)
// unpack a 15-bit grid square &c.
// 77-bit version, from inspection of packjt77.f90.
// ir is the bit after the two 28+1-bit callee/caller.
// i3 is the message type, usually 1.
std::string Packing::unpackgrid(int ng, int ir, int i3)
std::string Packing::unpackgrid15(int ng, int ir)
{
(void) i3;
if (ng < NGBASE)
{
// maidenhead grid system:
@@ -203,6 +200,31 @@ std::string Packing::unpackgrid(int ng, int ir, int i3)
return std::string(tmp);
}
std::string Packing::unpackgrid25(int ng)
{
int x1 = ng / (18 * 10 * 10 * 25 * 25);
ng %= (18 * 10 * 10 * 25 * 25);
int x2 = ng / (10 * 10 * 25 * 25);
ng %= (10 * 10 * 25 * 25);
int x3 = ng / (10 * 25 * 25);
ng %= (10 * 25 * 25);
int x4 = ng / (25 * 25);
ng %= (25 * 25);
int x5 = ng / (25);
ng %= (25);
int x6 = ng;
char tmp[7];
tmp[0] = 'A' + x1;
tmp[1] = 'A' + x2;
tmp[2] = '0' + x3;
tmp[3] = '0' + x4;
tmp[4] = 'A' + x5;
tmp[5] = 'A' + x6;
tmp[6] = '\0';
return std::string(tmp);
}
void Packing::remember_call(std::string call)
{
hashes_mu.lock();
@@ -329,7 +351,7 @@ std::string Packing::unpack_1(int a77[], std::string& call1str, std::string& cal
call1str = trim(unpackcall(call1));
call2str = trim(unpackcall(call2));
locstr = unpackgrid(grid, ir, i3);
locstr = unpackgrid15(grid, ir);
remember_call(call1str);
remember_call(call2str);
@@ -339,6 +361,52 @@ std::string Packing::unpack_1(int a77[], std::string& call1str, std::string& cal
return call1str + (rover1 ? pr : "") + " " + call2str + (rover2 ? pr : "") + " " + locstr;
}
std::string Packing::unpack_5(int a77[], std::string& call1str, std::string& call2str, std::string& locstr)
{
int x12 = un64(a77, 0, 12);
// 12-bit hash
hashes_mu.lock();
std::string ocall;
if (hashes12.count(x12) > 0) {
ocall = hashes12[x12];
} else {
ocall = "<...12>";
}
call1str = std::string(ocall);
int x22 = un64(a77, 12, 22);
if (hashes22.count(x22) > 0) {
ocall = hashes12[x22];
} else {
ocall = "<...22>";
}
call2str = std::string(ocall);
// mext bit is alway for R
int i = 12+ 22 +1;
// r3
int rst = un64(a77, i, 3);
rst = 52 + 10 * rst;
i += 3;
int qsonb = un64(a77, i, 11);
char report[16];
sprintf(report, "%d%04d", rst, qsonb);
i += 11;
// g25
int ng = un64(a77, i, 25);
locstr = unpackgrid25(ng);
std::string msg;
msg = call1str + " " + call2str + " " + std::string(report) + " " + locstr;
call1str += " " + std::string(report);
return msg;
}
// free text
// 71 bits, 13 characters, each one of 42 choices.
// reversed.
@@ -408,6 +476,30 @@ std::string Packing::unpack_0_1(int a77[], std::string& call1str, std::string& c
return msg;
}
std::string Packing::unpack_0_5(int a77[], std::string& call1str, std::string& call2str, std::string& locstr)
{
(void) call2str;
(void) locstr;
const char *cc = "0123456789ABCDEF";
std::string msg = "123456789ABCDEF012";
// first digit is on 3 bits
int d0 = un64(a77, 0, 3);
msg[17] = cc[d0];
// 17 hexadecimal digits = 17*4 = 68 bits
boost::multiprecision::int128_t x = un128(a77, 3, 68);
for (int i = 0; i < 17; i++)
{
msg[17 - 1 - i] = cc[(int) (x % 4)];
x = x / 4;
}
call1str = msg;
return msg;
}
// ARRL RTTY Round-Up states/provinces
const char *Packing::ru_states[] = {
"AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA",
@@ -589,6 +681,12 @@ std::string Packing::unpack(int a77[], std::string& call1, std::string& call2, s
return unpack_0_3(a77, n3, call1, call2, loc);
}
if (i3 == 0 && n3 == 5)
{
// telemetry
return unpack_0_5(a77, call1, call2, loc);
}
if (i3 == 1 || i3 == 2)
{
// ordinary message or EU VHF
@@ -607,7 +705,11 @@ std::string Packing::unpack(int a77[], std::string& call1, std::string& call2, s
return unpack_4(a77, call1, call2, loc);
}
// TODO: i3 == 5 EU VHF missing
if (i3 == 5)
{
// EU VHF with 6 digits locator
return unpack_5(a77, call1, call2, loc);
}
call1 = "UNK";
sprintf(tmp, "UNK i3=%d n3=%d", i3, n3);