mirror of
https://github.com/ShaYmez/MMDVM_CM.git
synced 2024-12-22 17:21:12 -05:00
Merge pull request #1 from g4klx/master
Use std::vector and std::string.
This commit is contained in:
commit
687fa0b156
@ -119,7 +119,6 @@ bool CConf::read()
|
|||||||
// Remove quotes from the value
|
// Remove quotes from the value
|
||||||
size_t len = ::strlen(value);
|
size_t len = ::strlen(value);
|
||||||
char *t;
|
char *t;
|
||||||
unsigned char tokencnt = 0;
|
|
||||||
if (len > 1U && *value == '"' && value[len - 1U] == '"') {
|
if (len > 1U && *value == '"' && value[len - 1U] == '"') {
|
||||||
value[len - 1U] = '\0';
|
value[len - 1U] = '\0';
|
||||||
value++;
|
value++;
|
||||||
@ -146,7 +145,7 @@ bool CConf::read()
|
|||||||
else if (::strcmp(key, "Debug") == 0)
|
else if (::strcmp(key, "Debug") == 0)
|
||||||
m_debug = ::atoi(value) == 1;
|
m_debug = ::atoi(value) == 1;
|
||||||
else if (::strcmp(key, "RadioID") == 0)
|
else if (::strcmp(key, "RadioID") == 0)
|
||||||
::memcpy(m_ysfRadioID, value, 5);
|
m_ysfRadioID = value;
|
||||||
else if (::strcmp(key, "FICHCallsign") == 0)
|
else if (::strcmp(key, "FICHCallsign") == 0)
|
||||||
m_fichCallSign = ::atoi(value);
|
m_fichCallSign = ::atoi(value);
|
||||||
else if (::strcmp(key, "FICHCallMode") == 0)
|
else if (::strcmp(key, "FICHCallMode") == 0)
|
||||||
@ -164,20 +163,11 @@ bool CConf::read()
|
|||||||
else if (::strcmp(key, "FICHSQLCode") == 0)
|
else if (::strcmp(key, "FICHSQLCode") == 0)
|
||||||
m_fichSQLCode = ::atoi(value);
|
m_fichSQLCode = ::atoi(value);
|
||||||
else if (::strcmp(key, "DT1") == 0){
|
else if (::strcmp(key, "DT1") == 0){
|
||||||
tokencnt = 0;
|
while ((t = strtok_r(value, ",", &value)) != NULL)
|
||||||
while((t = strtok_r(value, ",", &value)) != NULL){
|
m_ysfDT1.push_back(::atoi(t));
|
||||||
if(tokencnt < 10){
|
} else if (::strcmp(key, "DT2") == 0){
|
||||||
m_ysfDT1[tokencnt++] = atoi(t);
|
while ((t = strtok_r(value, ",", &value)) != NULL)
|
||||||
}
|
m_ysfDT2.push_back(::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 (section == SECTION_DMR_NETWORK) {
|
} else if (section == SECTION_DMR_NETWORK) {
|
||||||
if (::strcmp(key, "Id") == 0)
|
if (::strcmp(key, "Id") == 0)
|
||||||
@ -300,17 +290,17 @@ unsigned char CConf::getFICHSQLCode() const
|
|||||||
return m_fichSQLCode;
|
return m_fichSQLCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* CConf::getYsfDT1()
|
std::vector<unsigned char> CConf::getYsfDT1()
|
||||||
{
|
{
|
||||||
return m_ysfDT1;
|
return m_ysfDT1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* CConf::getYsfDT2()
|
std::vector<unsigned char> CConf::getYsfDT2()
|
||||||
{
|
{
|
||||||
return m_ysfDT2;
|
return m_ysfDT2;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* CConf::getYsfRadioID()
|
std::string CConf::getYsfRadioID()
|
||||||
{
|
{
|
||||||
return m_ysfRadioID;
|
return m_ysfRadioID;
|
||||||
}
|
}
|
||||||
|
@ -46,9 +46,9 @@ public:
|
|||||||
unsigned char getFICHDataType() const;
|
unsigned char getFICHDataType() const;
|
||||||
unsigned char getFICHSQLType() const;
|
unsigned char getFICHSQLType() const;
|
||||||
unsigned char getFICHSQLCode() const;
|
unsigned char getFICHSQLCode() const;
|
||||||
unsigned char* getYsfDT1();
|
std::vector<unsigned char> getYsfDT1();
|
||||||
unsigned char* getYsfDT2();
|
std::vector<unsigned char> getYsfDT2();
|
||||||
char* getYsfRadioID();
|
std::string getYsfRadioID();
|
||||||
bool getDaemon() const;
|
bool getDaemon() const;
|
||||||
bool getDebug() const;
|
bool getDebug() const;
|
||||||
|
|
||||||
@ -89,9 +89,9 @@ private:
|
|||||||
unsigned char m_fichDataType;
|
unsigned char m_fichDataType;
|
||||||
unsigned char m_fichSQLType;
|
unsigned char m_fichSQLType;
|
||||||
unsigned char m_fichSQLCode;
|
unsigned char m_fichSQLCode;
|
||||||
unsigned char m_ysfDT1[10U];
|
std::vector<unsigned char> m_ysfDT1;
|
||||||
unsigned char m_ysfDT2[10U];
|
std::vector<unsigned char> m_ysfDT2;
|
||||||
char m_ysfRadioID[5];
|
std::string m_ysfRadioID;
|
||||||
bool m_daemon;
|
bool m_daemon;
|
||||||
bool m_debug;
|
bool m_debug;
|
||||||
|
|
||||||
|
@ -665,7 +665,7 @@ int CDMR2YSF::run()
|
|||||||
unsigned char csd1[20U], csd2[20U];
|
unsigned char csd1[20U], csd2[20U];
|
||||||
memset(csd1, '*', YSF_CALLSIGN_LENGTH);
|
memset(csd1, '*', YSF_CALLSIGN_LENGTH);
|
||||||
memset(csd1, '*', YSF_CALLSIGN_LENGTH/2);
|
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);
|
memcpy(csd1 + YSF_CALLSIGN_LENGTH, m_netSrc.c_str(), YSF_CALLSIGN_LENGTH);
|
||||||
memset(csd2, ' ', YSF_CALLSIGN_LENGTH + YSF_CALLSIGN_LENGTH);
|
memset(csd2, ' ', YSF_CALLSIGN_LENGTH + YSF_CALLSIGN_LENGTH);
|
||||||
|
|
||||||
@ -706,7 +706,7 @@ int CDMR2YSF::run()
|
|||||||
|
|
||||||
unsigned char csd1[20U], csd2[20U];
|
unsigned char csd1[20U], csd2[20U];
|
||||||
memset(csd1, '*', YSF_CALLSIGN_LENGTH/2);
|
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);
|
memcpy(csd1 + YSF_CALLSIGN_LENGTH, m_netSrc.c_str(), YSF_CALLSIGN_LENGTH);
|
||||||
memset(csd2, ' ', YSF_CALLSIGN_LENGTH + YSF_CALLSIGN_LENGTH);
|
memset(csd2, ' ', YSF_CALLSIGN_LENGTH + YSF_CALLSIGN_LENGTH);
|
||||||
|
|
||||||
@ -734,25 +734,33 @@ int CDMR2YSF::run()
|
|||||||
switch (fn) {
|
switch (fn) {
|
||||||
case 0:
|
case 0:
|
||||||
memset(dch, '*', YSF_CALLSIGN_LENGTH/2);
|
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);
|
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, dch);
|
||||||
break;
|
break;
|
||||||
case 1:
|
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;
|
break;
|
||||||
case 2:
|
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;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
memset(dch, ' ', YSF_CALLSIGN_LENGTH/2);
|
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
|
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, dch); // Rem3/4
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6: {
|
||||||
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, m_conf.getYsfDT1());
|
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;
|
break;
|
||||||
case 7:
|
case 7: {
|
||||||
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, m_conf.getYsfDT2());
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, (const unsigned char*)" ");
|
ysfPayload.writeVDMode2Data(m_ysfFrame + 35U, (const unsigned char*)" ");
|
||||||
|
Loading…
Reference in New Issue
Block a user