kopia lustrzana https://github.com/mobilinkd/m17-cxx-demod
Decode destination callsign.
rodzic
42aae3dc18
commit
c3f523de11
|
@ -17,6 +17,9 @@ struct LinkSetupFrame
|
|||
using encoded_call_t = std::array<uint8_t, 6>;
|
||||
using frame_t = std::array<uint8_t, 30>;
|
||||
using nonce_t = std::string_view; // std::span would be better here.
|
||||
|
||||
static constexpr encoded_call_t BROADCAST_ADDRESS = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
static constexpr call_t BROADCAST_CALL = {'B', 'R', 'O', 'A', 'D', 'C', 'A', 'S', 'T', 0};
|
||||
|
||||
enum TxType { PACKET, STREAM };
|
||||
enum DataType { DT_RESERVED, DATA, VOICE, MIXED };
|
||||
|
@ -93,12 +96,19 @@ struct LinkSetupFrame
|
|||
{
|
||||
static const char callsign_map[] = "xABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-/.";
|
||||
|
||||
call_t result;
|
||||
|
||||
if (callsign == BROADCAST_ADDRESS)
|
||||
{
|
||||
result = BROADCAST_CALL;
|
||||
return result;
|
||||
}
|
||||
|
||||
uint64_t encoded = 0; // This only works on little endian architectures.
|
||||
auto p = reinterpret_cast<uint8_t*>(&encoded);
|
||||
std::copy(callsign.rbegin(), callsign.rend(), p);
|
||||
|
||||
// decode each base-40 digit and map them to the appriate character.
|
||||
call_t result;
|
||||
result.fill(0);
|
||||
size_t index = 0;
|
||||
while (encoded)
|
||||
|
@ -110,7 +120,6 @@ struct LinkSetupFrame
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
LinkSetupFrame()
|
||||
{}
|
||||
|
||||
|
|
|
@ -168,8 +168,9 @@ struct M17FrameDecoder
|
|||
std::cerr << "\nSRC: ";
|
||||
for (auto x : src) if (x) std::cerr << x;
|
||||
std::copy(lsf.begin(), lsf.begin() + 6, encoded_call.begin());
|
||||
auto dest = LinkSetupFrame::decode_callsign(encoded_call);
|
||||
std::cerr << ", DEST: ";
|
||||
for (auto x : encoded_call) if (x) std::cerr << std::hex << std::setw(2) << std::setfill('0') << int(x);
|
||||
for (auto x : dest) if (x) std::cerr << x;
|
||||
uint16_t type = (lsf[12] << 8) | lsf[13];
|
||||
std::cerr << ", TYPE: " << std::setw(4) << std::setfill('0') << type;
|
||||
std::cerr << ", NONCE: ";
|
||||
|
|
Ładowanie…
Reference in New Issue