Clean up the FEC processing for M17.

This commit is contained in:
Jonathan Naylor
2021-07-08 23:00:53 +01:00
parent b6ff701c05
commit bf3dbdb55d
4 changed files with 24 additions and 16 deletions

View File

@@ -32,6 +32,16 @@ void CM17Utils::encodeCallsign(const std::string& callsign, unsigned char* encod
{
assert(encoded != NULL);
if (callsign == "ALL" || callsign == "ALL ") {
encoded[0U] = 0xFFU;
encoded[1U] = 0xFFU;
encoded[2U] = 0xFFU;
encoded[3U] = 0xFFU;
encoded[4U] = 0xFFU;
encoded[5U] = 0xFFU;
return;
}
unsigned int len = callsign.size();
if (len > 9U)
len = 9U;
@@ -60,6 +70,12 @@ void CM17Utils::decodeCallsign(const unsigned char* encoded, std::string& callsi
callsign.clear();
if (encoded[0U] == 0xFFU && encoded[1U] == 0xFFU && encoded[2U] == 0xFFU &&
encoded[3U] == 0xFFU && encoded[4U] == 0xFFU && encoded[5U] == 0xFFU) {
callsign = "ALL";
return;
}
uint64_t enc =
(uint64_t(encoded[0U]) << 40) +
(uint64_t(encoded[1U]) << 32) +