Patching YSF2NXDN matching G4KLX code

This commit is contained in:
root 2020-06-06 19:52:21 +01:00
parent b4f762dca1
commit 0570756044
3 changed files with 35 additions and 37 deletions

View File

@ -138,7 +138,6 @@ bool CConf::read()
// Remove quotes from the value
size_t len = ::strlen(value);
char *t;
unsigned char tokencnt = 0;
if (len > 1U && *value == '"' && value[len - 1U] == '"') {
value[len - 1U] = '\0';
value++;
@ -181,7 +180,7 @@ bool CConf::read()
else if (::strcmp(key, "WiresXMakeUpper") == 0)
m_wiresXMakeUpper = ::atoi(value) == 1;
else if (::strcmp(key, "RadioID") == 0)
::memcpy(m_ysfRadioID, value, 5);
m_ysfRadioID = value;
else if (::strcmp(key, "FICHCallsign") == 0)
m_fichCallSign = ::atoi(value);
else if (::strcmp(key, "FICHCallMode") == 0)
@ -198,22 +197,13 @@ bool CConf::read()
m_fichSQLType = ::atoi(value);
else if (::strcmp(key, "FICHSQLCode") == 0)
m_fichSQLCode = ::atoi(value);
else if (::strcmp(key, "DT1") == 0){
tokencnt = 0;
while((t = strtok_r(value, ",", &value)) != NULL){
if(tokencnt < 10){
m_ysfDT1[tokencnt++] = atoi(t);
}
}
}
else if (::strcmp(key, "DT2") == 0){
tokencnt = 0;
while((t = strtok_r(value, ",", &value)) != NULL){
if(tokencnt < 10){
m_ysfDT2[tokencnt++] = atoi(t);
}
}
}
else if (::strcmp(key, "DT1") == 0){
while ((t = strtok_r(value, ",", &value)) != NULL)
m_ysfDT1.push_back(::atoi(t));
} else if (::strcmp(key, "DT2") == 0){
while ((t = strtok_r(value, ",", &value)) != NULL)
m_ysfDT2.push_back(::atoi(t));
}
else if (::strcmp(key, "Daemon") == 0)
m_daemon = ::atoi(value) == 1;
} else if (section == SECTION_NXDN_NETWORK) {
@ -380,17 +370,17 @@ unsigned char CConf::getFICHSQLCode() const
return m_fichSQLCode;
}
unsigned char* CConf::getYsfDT1()
std::vector<unsigned char> CConf::getYsfDT1()
{
return m_ysfDT1;
}
unsigned char* CConf::getYsfDT2()
std::vector<unsigned char> CConf::getYsfDT2()
{
return m_ysfDT2;
}
char* CConf::getYsfRadioID()
std::string CConf::getYsfRadioID()
{
return m_ysfRadioID;
}

View File

@ -56,9 +56,9 @@ public:
unsigned char getFICHDataType() const;
unsigned char getFICHSQLType() const;
unsigned char getFICHSQLCode() const;
unsigned char* getYsfDT1();
unsigned char* getYsfDT2();
char* getYsfRadioID();
std::vector<unsigned char> getYsfDT1();
std::vector<unsigned char> getYsfDT2();
std::string getYsfRadioID();
bool getDaemon() const;
// The NXDN Network section
@ -109,9 +109,9 @@ private:
unsigned char m_fichDataType;
unsigned char m_fichSQLType;
unsigned char m_fichSQLCode;
unsigned char m_ysfDT1[10U];
unsigned char m_ysfDT2[10U];
char m_ysfRadioID[5];
std::vector<unsigned char> m_ysfDT1;
std::vector<unsigned char> m_ysfDT2;
std::string m_ysfRadioID;
bool m_daemon;
unsigned int m_rxFrequency;

View File

@ -620,7 +620,7 @@ int CYSF2NXDN::run()
unsigned char csd1[20U], csd2[20U];
memset(csd1, '*', YSF_CALLSIGN_LENGTH/2);
memcpy(csd1 + YSF_CALLSIGN_LENGTH/2, m_conf.getYsfRadioID(), YSF_CALLSIGN_LENGTH/2);
memcpy(csd1 + YSF_CALLSIGN_LENGTH/2, m_conf.getYsfRadioID().c_str(), YSF_CALLSIGN_LENGTH/2);
memcpy(csd1 + YSF_CALLSIGN_LENGTH, m_netSrc.c_str(), YSF_CALLSIGN_LENGTH);
memset(csd2, ' ', YSF_CALLSIGN_LENGTH + YSF_CALLSIGN_LENGTH);
@ -660,7 +660,7 @@ int CYSF2NXDN::run()
unsigned char csd1[20U], csd2[20U];
memset(csd1, '*', YSF_CALLSIGN_LENGTH/2);
memcpy(csd1 + YSF_CALLSIGN_LENGTH/2, m_conf.getYsfRadioID(), YSF_CALLSIGN_LENGTH/2);
memcpy(csd1 + YSF_CALLSIGN_LENGTH/2, m_conf.getYsfRadioID().c_str(), YSF_CALLSIGN_LENGTH/2);
memcpy(csd1 + YSF_CALLSIGN_LENGTH, m_netSrc.c_str(), YSF_CALLSIGN_LENGTH);
memset(csd2, ' ', YSF_CALLSIGN_LENGTH + YSF_CALLSIGN_LENGTH);
@ -687,25 +687,33 @@ int CYSF2NXDN::run()
switch (fn) {
case 0:
memset(dch, '*', YSF_CALLSIGN_LENGTH/2);
memcpy(dch + YSF_CALLSIGN_LENGTH/2, m_conf.getYsfRadioID(), YSF_CALLSIGN_LENGTH/2);
memcpy(dch + YSF_CALLSIGN_LENGTH/2, m_conf.getYsfRadioID().c_str(), YSF_CALLSIGN_LENGTH/2);
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, dch);
break;
case 1:
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, (const unsigned char*)m_netSrc.c_str());
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, (unsigned char*)m_netSrc.c_str());
break;
case 2:
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, (const unsigned char*)m_netDst.c_str());
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, (unsigned char*)m_netDst.c_str());
break;
case 5:
memset(dch, ' ', YSF_CALLSIGN_LENGTH/2);
memcpy(dch + YSF_CALLSIGN_LENGTH/2, m_conf.getYsfRadioID(), YSF_CALLSIGN_LENGTH/2);
memcpy(dch + YSF_CALLSIGN_LENGTH/2, m_conf.getYsfRadioID().c_str(), YSF_CALLSIGN_LENGTH/2);
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, dch); // Rem3/4
break;
case 6:
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, m_conf.getYsfDT1());
case 6: {
unsigned char dt1[10U] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U};
for (unsigned int i = 0U; i < m_conf.getYsfDT1().size() && i < 10U; i++)
dt1[i] = m_conf.getYsfDT1()[i];
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, dt1);
}
break;
case 7:
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, m_conf.getYsfDT2());
case 7: {
unsigned char dt2[10U] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U};
for (unsigned int i = 0U; i < m_conf.getYsfDT2().size() && i < 10U; i++)
dt2[i] = m_conf.getYsfDT2()[i];
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, dt2);
}
break;
default:
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, (const unsigned char*)" ");