|
|
|
@ -1,6 +1,6 @@
|
|
|
|
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
|
|
|
|
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
// ulxd -- The universal reflector
|
|
|
|
// urfd -- The universal reflector
|
|
|
|
// Copyright © 2021 Thomas A. Early N7TAE
|
|
|
|
// Copyright © 2021 Thomas A. Early N7TAE
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
@ -49,16 +49,19 @@ CCallsign::CCallsign(const char *sz, uint32_t dmrid)
|
|
|
|
m_uiDmrid = dmrid;
|
|
|
|
m_uiDmrid = dmrid;
|
|
|
|
|
|
|
|
|
|
|
|
// and populate
|
|
|
|
// and populate
|
|
|
|
if ( ::strlen(sz) > 0 )
|
|
|
|
auto len = strlen(sz);
|
|
|
|
|
|
|
|
if ( len > 0 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Calculate the M17 coded callsign
|
|
|
|
|
|
|
|
CSIn();
|
|
|
|
|
|
|
|
// callsign valid
|
|
|
|
// callsign valid
|
|
|
|
memcpy(m_Callsign, sz, MIN(strlen(sz), CALLSIGN_LEN-1));
|
|
|
|
memcpy(m_Callsign, sz, MIN(len, CALLSIGN_LEN-1));
|
|
|
|
if ( strlen(sz) >= CALLSIGN_LEN )
|
|
|
|
if ( len > CALLSIGN_LEN )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_Module = sz[CALLSIGN_LEN-1];
|
|
|
|
m_Module = sz[len-1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate the M17 coded callsign
|
|
|
|
|
|
|
|
CSIn();
|
|
|
|
|
|
|
|
|
|
|
|
// dmrid ok ?
|
|
|
|
// dmrid ok ?
|
|
|
|
if ( m_uiDmrid == 0 )
|
|
|
|
if ( m_uiDmrid == 0 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -145,10 +148,11 @@ void CCallsign::SetCallsign(const char *sz, bool UpdateDmrid)
|
|
|
|
// set callsign
|
|
|
|
// set callsign
|
|
|
|
memset(m_Callsign, ' ', CALLSIGN_LEN);
|
|
|
|
memset(m_Callsign, ' ', CALLSIGN_LEN);
|
|
|
|
m_Module = ' ';
|
|
|
|
m_Module = ' ';
|
|
|
|
memcpy(m_Callsign, sz, MIN(strlen(sz), CALLSIGN_LEN-1));
|
|
|
|
auto len = strlen(sz);
|
|
|
|
if ( strlen(sz) >= CALLSIGN_LEN )
|
|
|
|
memcpy(m_Callsign, sz, MIN(len, CALLSIGN_LEN-1));
|
|
|
|
|
|
|
|
if ( len > CALLSIGN_LEN )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_Module = sz[CALLSIGN_LEN-1];
|
|
|
|
m_Module = sz[len-1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// update M17 coded callsign
|
|
|
|
// update M17 coded callsign
|
|
|
|
CSIn();
|
|
|
|
CSIn();
|
|
|
|
@ -273,11 +277,8 @@ void CCallsign::GetCallsignString(char *sz) const
|
|
|
|
|
|
|
|
|
|
|
|
const std::string CCallsign::GetCS(unsigned len) const
|
|
|
|
const std::string CCallsign::GetCS(unsigned len) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (len > 8)
|
|
|
|
std::string rval(m_Callsign, CALLSIGN_LEN);
|
|
|
|
len = 8;
|
|
|
|
rval.append(1, m_Module);
|
|
|
|
std::string rval(m_Callsign);
|
|
|
|
|
|
|
|
if (len)
|
|
|
|
|
|
|
|
rval.resize(len, ' ');
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -411,7 +412,7 @@ void CCallsign::CSIn()
|
|
|
|
auto pos = m17_alphabet.find(m_Module);
|
|
|
|
auto pos = m17_alphabet.find(m_Module);
|
|
|
|
m_coded = pos;
|
|
|
|
m_coded = pos;
|
|
|
|
m_coded *= 40;
|
|
|
|
m_coded *= 40;
|
|
|
|
for( int i=CALLSIGN_LEN-2; i>=0; i-- ) {
|
|
|
|
for( int i=CALLSIGN_LEN-1; i>=0; i-- ) {
|
|
|
|
pos = m17_alphabet.find(m_Callsign[i]);
|
|
|
|
pos = m17_alphabet.find(m_Callsign[i]);
|
|
|
|
if (pos == std::string::npos) {
|
|
|
|
if (pos == std::string::npos) {
|
|
|
|
pos = 0;
|
|
|
|
pos = 0;
|
|
|
|
|