Rebuild of logging: New log mode LOGTRACE (4) gives more debug output to find bugs.
This commit is contained in:
parent
896d9d4e18
commit
7dbbd00340
|
|
@ -127,10 +127,11 @@ using namespace SvxLink;
|
|||
#define LOGWARN 1
|
||||
#define LOGINFO 2
|
||||
#define LOGDEBUG 3
|
||||
#define LOGTRACE 4
|
||||
|
||||
#define MAX_TRIES 5
|
||||
|
||||
#define TETRA_LOGIC_VERSION "30032022"
|
||||
#define TETRA_LOGIC_VERSION "19052022"
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
|
|
@ -314,14 +315,14 @@ bool TetraLogic::initialize(void)
|
|||
|
||||
if (!cfg().getValue(name(), "PORT", port))
|
||||
{
|
||||
cout << "Warning: Missing parameter " << name() << "/PORT"
|
||||
<< endl;
|
||||
log(LOGWARN, "Missing parameter " + name() + "/PORT");
|
||||
isok = false;
|
||||
}
|
||||
|
||||
if (!cfg().getValue(name(), "BAUD", baudrate))
|
||||
{
|
||||
cout << "Warning: Missing parameter " << name() << "/BAUD, guess "
|
||||
<< baudrate << endl;
|
||||
log(LOGWARN, "Missing parameter " + name()
|
||||
+ "/BAUD, guess " + to_string(baudrate));
|
||||
}
|
||||
|
||||
if (cfg().getValue(name(), "DEFAULT_APRS_ICON", value))
|
||||
|
|
@ -476,12 +477,9 @@ bool TetraLogic::initialize(void)
|
|||
m_user.last_activity = mktime(&mtime);
|
||||
m_user.sent_last_sds = mktime(&mtime);
|
||||
userdata[m_user.issi] = m_user;
|
||||
if (debug >= LOGINFO)
|
||||
{
|
||||
cout << "tsi=" << m_user.issi << ",call=" << m_user.call << ",name="
|
||||
<< m_user.name << ",location=" << m_user.location << ",comment="
|
||||
<< m_user.comment << endl;
|
||||
}
|
||||
log(LOGINFO, "Tsi=" + m_user.issi + ", call=" + m_user.call
|
||||
+ ", name=" + m_user.name + ", location=" + m_user.location
|
||||
+ ", comment=" + m_user.comment);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -588,10 +586,7 @@ bool TetraLogic::initialize(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (debug >= LOGINFO)
|
||||
{
|
||||
cout << isds << "=" << value << endl;
|
||||
}
|
||||
log(LOGINFO, isds + "=" + value);
|
||||
state_sds[isds] = value;
|
||||
}
|
||||
}
|
||||
|
|
@ -612,7 +607,7 @@ bool TetraLogic::initialize(void)
|
|||
tetra_modem_sql = dynamic_cast<SquelchTetra*>(squelch_det);
|
||||
if (tetra_modem_sql != nullptr)
|
||||
{
|
||||
cout << "Creating tetra specific Sql ok" << endl;
|
||||
log(LOGINFO, "Creating tetra specific Sql ok");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -623,8 +618,8 @@ bool TetraLogic::initialize(void)
|
|||
// init the Pei device
|
||||
if (!cfg().getValue(name(), "INIT_PEI", initstr))
|
||||
{
|
||||
cout << "Warning: Missing parameter " << name()
|
||||
<< "/INIT_PEI, using defaults" << endl;
|
||||
log(LOGWARN, "Warning: Missing parameter " + name()
|
||||
+ "/INIT_PEI, using defaults");
|
||||
}
|
||||
SvxLink::splitStr(initcmds, initstr, ";");
|
||||
m_cmds = initcmds;
|
||||
|
|
@ -640,7 +635,7 @@ bool TetraLogic::initialize(void)
|
|||
if (!dapnetclient->initialize())
|
||||
{
|
||||
cerr << "*** ERROR: initializing DAPNET client" << endl;
|
||||
return false;
|
||||
isok = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -652,7 +647,7 @@ bool TetraLogic::initialize(void)
|
|||
{
|
||||
cerr << "*** ERROR: Opening serial port " << name() << "/PORT="
|
||||
<< port << endl;
|
||||
return false;
|
||||
isok = false;
|
||||
}
|
||||
pei->setParams(baudrate, Serial::PARITY_NONE, 8, 1, Serial::FLOW_NONE);
|
||||
pei->charactersReceived.connect(
|
||||
|
|
@ -696,7 +691,8 @@ bool TetraLogic::initialize(void)
|
|||
|
||||
void TetraLogic::remoteCmdReceived(LogicBase* src_logic, const std::string& cmd)
|
||||
{
|
||||
cout << "command received:" << cmd << endl;
|
||||
log(LOGTRACE, "TetraLogic::remoteCmdReceived: "
|
||||
+ src_logic->name() + " -> " + cmd);
|
||||
} /* TetraLogic::remoteCmdReceived */
|
||||
|
||||
|
||||
|
|
@ -724,6 +720,7 @@ void TetraLogic::audioStreamStateChange(bool is_active, bool is_idle)
|
|||
|
||||
void TetraLogic::transmitterStateChange(bool is_transmitting)
|
||||
{
|
||||
|
||||
std::string cmd;
|
||||
is_tx = is_transmitting;
|
||||
|
||||
|
|
@ -731,6 +728,7 @@ void TetraLogic::transmitterStateChange(bool is_transmitting)
|
|||
{
|
||||
if (!talkgroup_up)
|
||||
{
|
||||
log(LOGTRACE, "TetraLogic::transmitterStateChange: " + gssi);
|
||||
initGroupCall(gssi);
|
||||
talkgroup_up = true;
|
||||
}
|
||||
|
|
@ -763,16 +761,21 @@ void TetraLogic::squelchOpen(bool is_open)
|
|||
// FIXME: A squelch open should not be possible to receive while
|
||||
// transmitting unless mute_rx_on_tx is false, in which case it
|
||||
// should be allowed. Commenting out the statements below.
|
||||
|
||||
std::string s = (is_open ? "true" : "false");
|
||||
log(LOGTRACE, "TetraLogic::squelchOpen: squelchopen=" + s);
|
||||
|
||||
if (tx().isTransmitting())
|
||||
{
|
||||
log(LOGTRACE, "TetraLogic::squelchOpen: tx().isTransmitting()=true");
|
||||
return;
|
||||
}
|
||||
|
||||
log(LOGTRACE, "TetraLogic::squelchOpen: tetra_modem_sql->setSql(" + s + ")");
|
||||
tetra_modem_sql->setSql(is_open);
|
||||
log(LOGTRACE, "TetraLogic::squelchOpen: rx().setSql(" + s + ")");
|
||||
rx().setSql(is_open);
|
||||
log(LOGTRACE, "TetraLogic::squelchOpen: Logic::squelchOpen(" + s + ")");
|
||||
Logic::squelchOpen(is_open);
|
||||
|
||||
} /* TetraLogic::squelchOpen */
|
||||
|
||||
|
||||
|
|
@ -899,13 +902,12 @@ void TetraLogic::onCharactersReceived(char *buf, int count)
|
|||
void TetraLogic::handlePeiAnswer(std::string m_message)
|
||||
{
|
||||
|
||||
if (debug >= LOGINFO)
|
||||
{
|
||||
cout << "From PEI:" << m_message << endl;
|
||||
}
|
||||
log(LOGINFO, "From PEI:" + m_message);
|
||||
|
||||
int response = handleMessage(m_message);
|
||||
|
||||
log(LOGTRACE, "TetraLogic::handlePeiAnswer: reponse=" + to_string(response));
|
||||
|
||||
switch (response)
|
||||
{
|
||||
case OK:
|
||||
|
|
@ -915,9 +917,9 @@ void TetraLogic::handlePeiAnswer(std::string m_message)
|
|||
|
||||
case ERROR:
|
||||
peistate = ERROR;
|
||||
if (m_message.length()>11 && debug >= LOGINFO)
|
||||
if (m_message.length()>11)
|
||||
{
|
||||
cout << getPeiError(atoi(m_message.erase(0,11).c_str())) << endl;
|
||||
log(LOGINFO, getPeiError(atoi(m_message.erase(0,11).c_str())) );
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -985,7 +987,7 @@ void TetraLogic::handlePeiAnswer(std::string m_message)
|
|||
break;
|
||||
|
||||
case CTDGR:
|
||||
cout << handleCtdgr(m_message);
|
||||
log(LOGINFO, handleCtdgr(m_message));
|
||||
break;
|
||||
|
||||
case CLVL:
|
||||
|
|
@ -993,10 +995,7 @@ void TetraLogic::handlePeiAnswer(std::string m_message)
|
|||
break;
|
||||
|
||||
case INVALID:
|
||||
if (debug >= LOGWARN)
|
||||
{
|
||||
cout << "+++ Pei answer not known, ignoring ;)" << endl;
|
||||
}
|
||||
log(LOGWARN, "+++ Pei answer not known, ignoring ;)");
|
||||
|
||||
default:
|
||||
break;
|
||||
|
|
@ -1012,6 +1011,7 @@ void TetraLogic::handlePeiAnswer(std::string m_message)
|
|||
|
||||
void TetraLogic::initGroupCall(int gc_gssi)
|
||||
{
|
||||
log(LOGTRACE, "TetraLogic::initGroupCall: " + to_string(gc_gssi));
|
||||
inTransmission = true;
|
||||
std::string cmd = "AT+CTSDC=0,0,0,1,1,0,1,1,0,0,0";
|
||||
sendPei(cmd);
|
||||
|
|
@ -1043,15 +1043,14 @@ TETRA Incoming Call Notification +CTICN
|
|||
*/
|
||||
void TetraLogic::handleCallBegin(std::string message)
|
||||
{
|
||||
log(LOGTRACE,"TetraLogic::handleCallBegin: " + message);
|
||||
|
||||
// +CTICN: 1, 0, 0, 4, 1002, 1, 1, 0, 1, 1, 0, 1000, 1
|
||||
std::string reg = "\\+CTICN: [0-9]{1,3},[0-9],[0-9],[0-9],[0-9]{1,17},[0-9],[0-9],[0-9],[0-9],[0-9],[0-9],[0-9]{1,17},[0-9]";
|
||||
|
||||
if (!rmatch(message, reg))
|
||||
{
|
||||
if (debug >= LOGWARN)
|
||||
{
|
||||
cout << "*** Wrong +CTICN response (wrong format)" << endl;
|
||||
}
|
||||
log(LOGWARN, "*** Wrong +CTICN response (wrong format)");
|
||||
return;
|
||||
}
|
||||
squelchOpen(true); // open the Squelch
|
||||
|
|
@ -1164,6 +1163,7 @@ void TetraLogic::handleCallBegin(std::string message)
|
|||
stringstream m_aprsmesg;
|
||||
m_aprsmesg << aprspath << ">" << iu->second.call << " initiated groupcall: "
|
||||
<< t_ci.o_issi << " -> " << t_ci.d_issi;
|
||||
log(LOGTRACE, "TetraLogic::handleCallBegin: " + m_aprsmesg.str());
|
||||
sendAprs(iu->second.call, m_aprsmesg.str());
|
||||
} /* TetraLogic::handleCallBegin */
|
||||
|
||||
|
|
@ -1210,11 +1210,8 @@ void TetraLogic::firstContact(Sds tsds)
|
|||
tsds.message = infosds;
|
||||
tsds.type = TEXT;
|
||||
tsds.remark = "Welcome Sds to a new user";
|
||||
if (debug >= LOGINFO)
|
||||
{
|
||||
cout << "Sending info Sds to new user " << tsds.tsi << " \""
|
||||
<< infosds << "\"" << endl;
|
||||
}
|
||||
log(LOGINFO, "Sending info Sds to new user " + tsds.tsi
|
||||
+ " \"" + infosds + "\"");
|
||||
queueSds(tsds);
|
||||
}
|
||||
} /* TetraLogic::firstContact */
|
||||
|
|
@ -1228,6 +1225,7 @@ void TetraLogic::firstContact(Sds tsds)
|
|||
*/
|
||||
void TetraLogic::handleSdsMsg(std::string sds)
|
||||
{
|
||||
log(LOGTRACE, "TetraLogic::handleSdsMsg: " + sds);
|
||||
Sds t_sds;
|
||||
stringstream ss, sstcl;
|
||||
std::string sds_txt;
|
||||
|
|
@ -1285,6 +1283,9 @@ void TetraLogic::handleSdsMsg(std::string sds)
|
|||
sdsinfo["lat"] = lipinfo.latitude;
|
||||
sdsinfo["lon"] = lipinfo.longitude;
|
||||
sdsinfo["reasonforsending"] = lipinfo.reasonforsending;
|
||||
log(LOGTRACE, "TetraLogic::handleSdsMsg: LIP_SDS: TSI=" + t_sds.tsi
|
||||
+ "lat=" + to_string(lipinfo.latitude) + ", lon="
|
||||
+ to_string(lipinfo.longitude));
|
||||
break;
|
||||
|
||||
case STATE_SDS:
|
||||
|
|
@ -1337,10 +1338,7 @@ void TetraLogic::handleSdsMsg(std::string sds)
|
|||
|
||||
case INVALID:
|
||||
ss << "unknown_sds_received";
|
||||
if (debug >= LOGWARN)
|
||||
{
|
||||
cout << "*** Unknown type of SDS" << endl;
|
||||
}
|
||||
log(LOGWARN, "*** Unknown type of SDS");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -1363,6 +1361,7 @@ void TetraLogic::handleSdsMsg(std::string sds)
|
|||
{
|
||||
string m_aprsmessage = aprspath;
|
||||
m_aprsmessage += m_aprsinfo.str();
|
||||
log(LOGTRACE, m_aprsmessage);
|
||||
sendAprs(userdata[t_sds.tsi].call, m_aprsmessage);
|
||||
}
|
||||
|
||||
|
|
@ -1415,6 +1414,7 @@ std::string TetraLogic::handleCtdgr(std::string m_message)
|
|||
ssret << "INFO: Station " << TransientComType[dmct] << " detected (ISSI="
|
||||
<< drp.issi << ", MNI=" << drp.mni << ", state=" << drp.state << ")"
|
||||
<< endl;
|
||||
log(LOGDEBUG, ssret.str());
|
||||
|
||||
dmo_rep_gw.emplace(drp.issi, drp);
|
||||
|
||||
|
|
@ -1437,6 +1437,7 @@ void TetraLogic::handleClvl(std::string m_message)
|
|||
}
|
||||
|
||||
ss << "audio_level " << getNextVal(m_message);
|
||||
log(LOGTRACE, "TetraLogic::handleClvl: " + ss.str());
|
||||
processEvent(ss.str());
|
||||
} /* TetraLogic::handleClvl */
|
||||
|
||||
|
|
@ -1469,10 +1470,7 @@ void TetraLogic::handleCmgs(std::string m_message)
|
|||
{
|
||||
if (state == SDS_SEND_FAILED)
|
||||
{
|
||||
if (debug >= LOGERROR)
|
||||
{
|
||||
cout << "*** ERROR: Sending message failed. Will send again..." << endl;
|
||||
}
|
||||
log(LOGERROR, "*** ERROR: Sending message failed. Will send again...");
|
||||
}
|
||||
else if(state == SDS_SEND_OK)
|
||||
{
|
||||
|
|
@ -1483,8 +1481,9 @@ void TetraLogic::handleCmgs(std::string m_message)
|
|||
if (it->second.id == pending_sds.id)
|
||||
{
|
||||
it->second = pending_sds;
|
||||
cout << "+++ message (" << it->second.id << ") with ref#" << id
|
||||
<< " to " << it->second.tsi << " successfully sent." << endl;
|
||||
log(LOGINFO, "+++ message (" + to_string(it->second.id)
|
||||
+ ") with ref#" + to_string(id) + " to "
|
||||
+ it->second.tsi + " successfully sent.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1528,8 +1527,10 @@ std::string TetraLogic::handleSimpleTextSds(std::string m_message)
|
|||
*/
|
||||
void TetraLogic::handleTxGrant(std::string txgrant)
|
||||
{
|
||||
log(LOGTRACE, "TetraLogic::handleTxGrant: " + txgrant);
|
||||
if (!is_tx && peistate==OK)
|
||||
{
|
||||
log(LOGTRACE, "TetraLogic::handleTxGrant: squelchOpen(true)");
|
||||
squelchOpen(true);
|
||||
}
|
||||
stringstream ss;
|
||||
|
|
@ -1579,12 +1580,7 @@ std::string TetraLogic::getTSI(std::string issi)
|
|||
void TetraLogic::handleStateSds(unsigned int isds)
|
||||
{
|
||||
stringstream ss;
|
||||
|
||||
if (debug >= LOGINFO)
|
||||
{
|
||||
cout << "+++ State Sds received: " << isds << endl;
|
||||
}
|
||||
|
||||
log(LOGINFO, "+++ State Sds received: " + to_string(isds));
|
||||
std::map<unsigned int, string>::iterator it = sds_to_command.find(isds);
|
||||
|
||||
if (it != sds_to_command.end())
|
||||
|
|
@ -1610,6 +1606,8 @@ void TetraLogic::handleStateSds(unsigned int isds)
|
|||
*/
|
||||
void TetraLogic::handleTransmissionEnd(std::string message)
|
||||
{
|
||||
log(LOGTRACE, "TetraLogic::handleTransmissionEnd: " + message);
|
||||
log(LOGTRACE, "TetraLogic::handleTransmissionEnd: squelchOpen(false)");
|
||||
squelchOpen(false); // close Squelch
|
||||
stringstream ss;
|
||||
ss << "groupcall_end";
|
||||
|
|
@ -1623,6 +1621,7 @@ void TetraLogic::handleTransmissionEnd(std::string message)
|
|||
void TetraLogic::handleCallReleased(std::string message)
|
||||
{
|
||||
// update Qso information, set time of activity
|
||||
log(LOGTRACE, "TetraLogic::handleCallReleased: " + message);
|
||||
Qso.stop = time(NULL);
|
||||
|
||||
stringstream ss;
|
||||
|
|
@ -1632,10 +1631,12 @@ void TetraLogic::handleCallReleased(std::string message)
|
|||
if (tetra_modem_sql->isOpen())
|
||||
{
|
||||
ss << "out_of_range " << getNextVal(message);
|
||||
log(LOGTRACE, "TetraLogic::handleCallReleased: " + ss.str());
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << "call_end \"" << DisconnectCause[getNextVal(message)] << "\"";
|
||||
log(LOGTRACE, "TetraLogic::handleCallReleased: " + ss.str());
|
||||
}
|
||||
processEvent(ss.str());
|
||||
squelchOpen(false); // close Squelch
|
||||
|
|
@ -1667,6 +1668,7 @@ void TetraLogic::handleCallReleased(std::string message)
|
|||
{
|
||||
m_aprsmesg += ">Transmission ended";
|
||||
}
|
||||
log(LOGTRACE, "TetraLogic::handleCallReleased: " + m_aprsmesg);
|
||||
sendAprs(userdata[Qso.tsi].call, m_aprsmesg);
|
||||
|
||||
talkgroup_up = false;
|
||||
|
|
@ -1700,10 +1702,7 @@ void TetraLogic::sendPei(std::string cmd)
|
|||
|
||||
pei->write(cmd.c_str(), cmd.length());
|
||||
|
||||
if (debug >= LOGDEBUG)
|
||||
{
|
||||
cout << " To PEI:" << cmd << endl;
|
||||
}
|
||||
log(LOGDEBUG, " To PEI:" + cmd);
|
||||
|
||||
peiComTimer.reset();
|
||||
peiComTimer.setEnable(true);
|
||||
|
|
@ -1714,6 +1713,7 @@ void TetraLogic::onComTimeout(Async::Timer *timer)
|
|||
{
|
||||
stringstream ss;
|
||||
ss << "peiCom_timeout";
|
||||
log(LOGTRACE, "TetraLogic::onComTimeout: " + ss.str());
|
||||
processEvent(ss.str());
|
||||
peistate = TIMEOUT;
|
||||
} /* TetraLogic::onComTimeout */
|
||||
|
|
@ -1744,6 +1744,7 @@ void TetraLogic::cfmSdsReceived(std::string tsi)
|
|||
t_sds.message = msg;
|
||||
t_sds.tsi = tsi;
|
||||
t_sds.direction = OUTGOING;
|
||||
log(LOGTRACE, "TetraLogic::cfmSdsReceived: " + tsi);
|
||||
queueSds(t_sds);
|
||||
} /* TetraLogic::cfmSdsReceived */
|
||||
|
||||
|
|
@ -1756,10 +1757,7 @@ void TetraLogic::cfmTxtSdsReceived(std::string message, std::string tsi)
|
|||
std::string msg("821000"); // confirm a sds received
|
||||
msg += id;
|
||||
|
||||
if (debug >= LOGINFO)
|
||||
{
|
||||
cout << "+++ sending confirmation Sds to " << tsi << endl;
|
||||
}
|
||||
log(LOGINFO, "+++ sending confirmation Sds to " + tsi);
|
||||
|
||||
Sds t_sds;
|
||||
t_sds.message = msg;
|
||||
|
|
@ -1784,8 +1782,8 @@ void TetraLogic::handleCnumf(std::string m_message)
|
|||
int t_mnc, t_mcc, t_issi;
|
||||
short m_numtype = getNextVal(m_message);
|
||||
|
||||
if (debug >= LOGINFO) cout << "<num type> is " << m_numtype << " ("
|
||||
<< NumType[m_numtype] << ")" << endl;
|
||||
log(LOGINFO, "<num type> is " + to_string(m_numtype)
|
||||
+ " (" + NumType[m_numtype] + ")");
|
||||
|
||||
if (m_numtype == 6 || m_numtype == 0)
|
||||
{
|
||||
|
|
@ -1795,32 +1793,23 @@ void TetraLogic::handleCnumf(std::string m_message)
|
|||
// check if the configured MCC fits to MCC in MS
|
||||
if (t_mcc != atoi(mcc.c_str()))
|
||||
{
|
||||
if (debug >= LOGWARN)
|
||||
{
|
||||
cout << "*** ERROR: wrong MCC in MS, will not work! "
|
||||
<< mcc << "!=" << t_mcc << endl;
|
||||
}
|
||||
log(LOGWARN, "*** ERROR: wrong MCC in MS, will not work! "
|
||||
+ mcc + "!=" + to_string(t_mcc));
|
||||
}
|
||||
|
||||
// check if the configured MNC fits to MNC in MS
|
||||
if (t_mnc != atoi(mnc.c_str()))
|
||||
{
|
||||
if (debug >= LOGWARN)
|
||||
{
|
||||
cout << "*** ERROR: wrong MNC in MS, will not work! "
|
||||
<< mnc << "!=" << t_mnc << endl;
|
||||
}
|
||||
log(LOGWARN, "*** ERROR: wrong MNC in MS, will not work! "
|
||||
+ mnc + "!=" + to_string(t_mnc));
|
||||
}
|
||||
dmcc = t_mcc;
|
||||
dmnc = t_mnc;
|
||||
|
||||
if (atoi(issi.c_str()) != t_issi)
|
||||
{
|
||||
if (debug >= LOGWARN)
|
||||
{
|
||||
cout << "*** ERROR: wrong ISSI in MS, will not work! "
|
||||
<< issi <<"!=" << t_issi << endl;
|
||||
}
|
||||
log(LOGWARN, "*** ERROR: wrong ISSI in MS, will not work! "
|
||||
+ issi + "!=" + to_string(t_issi));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1836,6 +1825,7 @@ void TetraLogic::handleCnumf(std::string m_message)
|
|||
*/
|
||||
void TetraLogic::sdsPtyReceived(const void *buf, size_t count)
|
||||
{
|
||||
|
||||
const char *buffer = reinterpret_cast<const char*>(buf);
|
||||
std::string injmessage = "";
|
||||
|
||||
|
|
@ -1843,9 +1833,10 @@ void TetraLogic::sdsPtyReceived(const void *buf, size_t count)
|
|||
{
|
||||
injmessage += *buffer++;
|
||||
}
|
||||
log(LOGTRACE, "TetraLogic::sdsPtyReceived: " + injmessage);
|
||||
string m_tsi = getNextStr(injmessage);
|
||||
string type = getNextStr(injmessage);
|
||||
|
||||
|
||||
// put the new Sds int a queue...
|
||||
Sds t_sds;
|
||||
t_sds.tsi = m_tsi;
|
||||
|
|
@ -1923,11 +1914,7 @@ void TetraLogic::sendInfoSds(std::string tsi, short reason)
|
|||
t_sds.direction = OUTGOING;
|
||||
t_sds.type = TEXT_SDS;
|
||||
|
||||
if (debug >= LOGINFO)
|
||||
{
|
||||
cout << "SEND info SDS (to " << t_iu->first << "):"
|
||||
<< ss.str() << endl;
|
||||
}
|
||||
log(LOGINFO, "SEND info SDS (to " + t_iu->first + "):" + ss.str());
|
||||
// queue SDS
|
||||
queueSds(t_sds);
|
||||
t_iu->second.sent_last_sds = time(NULL);
|
||||
|
|
@ -1994,10 +1981,7 @@ void TetraLogic::getAiMode(std::string aimode)
|
|||
if (aimode.length() > 6)
|
||||
{
|
||||
int t = atoi(aimode.erase(0,6).c_str());
|
||||
if (debug >= LOGINFO)
|
||||
{
|
||||
cout << "+++ New Tetra mode: " << AiMode[t] << endl;
|
||||
}
|
||||
log(LOGINFO, "+++ New Tetra mode: " + AiMode[t]);
|
||||
stringstream ss;
|
||||
ss << "tetra_mode " << t;
|
||||
processEvent(ss.str());
|
||||
|
|
@ -2023,8 +2007,8 @@ bool TetraLogic::rmatch(std::string tok, std::string pattern)
|
|||
// receive interlogic messages here
|
||||
void TetraLogic::onPublishStateEvent(const string &event_name, const string &msg)
|
||||
{
|
||||
//cout << "TetraLogic::onPublishStateEvent - event_name: " << event_name
|
||||
// << ", message: " << msg << endl;
|
||||
log(LOGTRACE, "TetraLogic::onPublishStateEvent - event_name: "
|
||||
+ event_name + ", message: " +msg);
|
||||
|
||||
// if it is not allowed to handle information about users then all userinfo
|
||||
// traffic will be ignored
|
||||
|
|
@ -2035,20 +2019,14 @@ void TetraLogic::onPublishStateEvent(const string &event_name, const string &msg
|
|||
bool b = reader.parse(msg, user_arr);
|
||||
if (!b)
|
||||
{
|
||||
if (debug >= LOGERROR)
|
||||
{
|
||||
cout << "*** Error: parsing StateEvent message ("
|
||||
<< reader.getFormattedErrorMessages() << ")" << endl;
|
||||
}
|
||||
log(LOGERROR, "*** Error: parsing StateEvent message ("
|
||||
+ reader.getFormattedErrorMessages() + ")" );
|
||||
return;
|
||||
}
|
||||
|
||||
if (event_name == "TetraUsers:info")
|
||||
{
|
||||
if (debug >= LOGINFO)
|
||||
{
|
||||
cout << "Download userdata from Reflector (TetraUsers:info):" << endl;
|
||||
}
|
||||
log(LOGDEBUG, "Download userdata from Reflector (TetraUsers:info):");
|
||||
for (Json::Value::ArrayIndex i = 0; i != user_arr.size(); i++)
|
||||
{
|
||||
User m_user;
|
||||
|
|
@ -2063,12 +2041,9 @@ void TetraLogic::onPublishStateEvent(const string &event_name, const string &msg
|
|||
m_user.last_activity = t_userdata.get("last_activity","").asUInt();
|
||||
|
||||
userdata[m_user.issi] = m_user;
|
||||
if (debug >= LOGINFO)
|
||||
{
|
||||
cout << "tsi:" << m_user.issi << ",call=" << m_user.call << ",name="
|
||||
<< m_user.name << ",location=" << m_user.location
|
||||
<< ", comment=" << m_user.comment << endl;
|
||||
}
|
||||
log(LOGDEBUG, "Tsi:" + m_user.issi + ", call=" + m_user.call
|
||||
+ ", name=" + m_user.name + ", location=" + m_user.location
|
||||
+ ", comment=" + m_user.comment);
|
||||
}
|
||||
}
|
||||
} /* TetraLogic::onPublishStateEvent */
|
||||
|
|
@ -2113,6 +2088,8 @@ void TetraLogic::clearOldSds(void)
|
|||
{
|
||||
if (it->second.tos != 0 && difftime(it->second.tos, time(NULL)) > 3600)
|
||||
{
|
||||
log(LOGTRACE, "TetraLogic::clearOldSds: " + it->second.tsi
|
||||
+ "->" + it->second.message);
|
||||
todelete.push_back(it->first);
|
||||
}
|
||||
}
|
||||
|
|
@ -2155,8 +2132,8 @@ bool TetraLogic::checkSds(void)
|
|||
{
|
||||
if (pending_sds.nroftries++ > MAX_TRIES)
|
||||
{
|
||||
cout << "+++ sending of Sds message failed after " << MAX_TRIES
|
||||
<< " tries, giving up." << endl;
|
||||
log(LOGERROR, "+++ sending of Sds message failed after "
|
||||
+ to_string(MAX_TRIES) + " tries, giving up.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2171,12 +2148,10 @@ bool TetraLogic::checkSds(void)
|
|||
}
|
||||
pending_sds.tos = time(NULL);
|
||||
|
||||
if (debug >= LOGINFO)
|
||||
{
|
||||
cout << "+++ sending Sds (type=" << pending_sds.type << ") to "
|
||||
<< getISSI(pending_sds.tsi) << ": \"" << pending_sds.message
|
||||
<< "\", tries: " << pending_sds.nroftries << endl;
|
||||
}
|
||||
log(LOGINFO, "+++ sending Sds (type=" + to_string(pending_sds.type)
|
||||
+ ") to "
|
||||
+ getISSI(pending_sds.tsi) + ": \"" + pending_sds.message
|
||||
+ "\", tries: " + to_string(pending_sds.nroftries));
|
||||
sendPei(t_sds);
|
||||
cmgs_received = false;
|
||||
retsds = true;
|
||||
|
|
@ -2200,11 +2175,7 @@ void TetraLogic::sendWelcomeSds(string tsi, short r4s)
|
|||
t_sds.remark = "welcome sds";
|
||||
t_sds.message = oa->second;
|
||||
|
||||
if (debug >= LOGINFO)
|
||||
{
|
||||
cout << "Send SDS:" << getISSI(t_sds.tsi) << ", " <<
|
||||
t_sds.message << endl;
|
||||
}
|
||||
log(LOGINFO, "Send SDS:" + getISSI(t_sds.tsi));
|
||||
queueSds(t_sds);
|
||||
}
|
||||
} /* TetraLogic::sendWelcomeSds */
|
||||
|
|
@ -2216,6 +2187,7 @@ void TetraLogic::sendWelcomeSds(string tsi, short r4s)
|
|||
*/
|
||||
int TetraLogic::handleCci(std::string m_message)
|
||||
{
|
||||
log(LOGTRACE, "TetraLogic::handleCci: " + m_message);
|
||||
squelchOpen(true);
|
||||
size_t f = m_message.find("+CTCC: ");
|
||||
if (f != string::npos)
|
||||
|
|
@ -2232,10 +2204,7 @@ void TetraLogic::sendAprs(string call, string aprsmessage)
|
|||
// send group info to aprs network
|
||||
if (LocationInfo::has_instance())
|
||||
{
|
||||
if (debug >= LOGINFO)
|
||||
{
|
||||
cout << " To APRS:" << aprsmessage << endl;
|
||||
}
|
||||
log(LOGINFO, " To APRS:" + aprsmessage);
|
||||
LocationInfo::instance()->update3rdState(call, aprsmessage);
|
||||
}
|
||||
} /* TetraLogic::sendAprs */
|
||||
|
|
@ -2243,11 +2212,7 @@ void TetraLogic::sendAprs(string call, string aprsmessage)
|
|||
|
||||
void TetraLogic::onDapnetMessage(string tsi, string message)
|
||||
{
|
||||
if (debug >= LOGINFO)
|
||||
{
|
||||
cout << "+++ new Dapnet message received for " << tsi
|
||||
<< ":" << message << endl;
|
||||
}
|
||||
log(LOGINFO, "+++ new Dapnet message received for " + tsi + ":" + message);
|
||||
|
||||
// put the new Sds int a queue...
|
||||
Sds t_sds;
|
||||
|
|
@ -2270,11 +2235,7 @@ bool TetraLogic::checkIfDapmessage(std::string message)
|
|||
message.erase(0,4);
|
||||
destcall = message.substr(0, message.find(":"));
|
||||
message.erase(0, message.find(":")+1);
|
||||
if (debug >= LOGDEBUG)
|
||||
{
|
||||
cout << "To DAPNET: call=" << destcall << ", message:" << message
|
||||
<< endl;
|
||||
}
|
||||
log(LOGDEBUG, "To DAPNET: call=" + destcall + ", message:" + message);
|
||||
dapnetclient->sendDapMessage(destcall, message);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2282,6 +2243,15 @@ bool TetraLogic::checkIfDapmessage(std::string message)
|
|||
return false;
|
||||
} /* TetraLogic::checkIfDapmessage */
|
||||
|
||||
|
||||
void TetraLogic::log(uint8_t logtype, std::string logmessage)
|
||||
{
|
||||
if (debug >= logtype)
|
||||
{
|
||||
cout << logmessage << endl;
|
||||
}
|
||||
} /* TetraLogic::log */
|
||||
|
||||
/*
|
||||
* This file has not been truncated
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -417,6 +417,7 @@ class TetraLogic : public Logic
|
|||
void sendAprs(std::string call, std::string aprsmessage);
|
||||
bool checkIfDapmessage(std::string message);
|
||||
std::string joinList(std::list<std::string> members);
|
||||
void log(uint8_t type, std::string logmessage);
|
||||
|
||||
}; /* class TetraLogic */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue