mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-24 01:25:41 +08:00
Refactor the JSON code and schema.
This commit is contained in:
@@ -398,7 +398,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
||||
}
|
||||
|
||||
LogMessage("D-Star, received RF header from %8.8s/%4.4s to %8.8s", my1, my2, your);
|
||||
writeJSONRF("header", my1, my2, your);
|
||||
writeJSONRF("start", my1, my2, your);
|
||||
} else if (type == TAG_EOT) {
|
||||
if (m_rfState == RS_RF_REJECTED) {
|
||||
m_rfState = RS_RF_LISTENING;
|
||||
@@ -759,11 +759,11 @@ void CDStarControl::writeNetwork()
|
||||
if (status == LS_LINKED_DEXTRA || status == LS_LINKED_DPLUS || status == LS_LINKED_DCS || status == LS_LINKED_CCS || status == LS_LINKED_LOOPBACK) {
|
||||
m_display->writeDStar((char*)my1, (char*)my2, (char*)your, "N", (char*) reflector);
|
||||
LogMessage("D-Star, received network header from %8.8s/%4.4s to %8.8s via %8.8s", my1, my2, your, reflector);
|
||||
writeJSONNet("header", my1, my2, your, reflector);
|
||||
writeJSONNet("start", my1, my2, your, reflector);
|
||||
} else {
|
||||
m_display->writeDStar((char*)my1, (char*)my2, (char*)your, "N", (char*) " ");
|
||||
LogMessage("D-Star, received network header from %8.8s/%4.4s to %8.8s", my1, my2, your);
|
||||
writeJSONNet("header", my1, my2, your);
|
||||
writeJSONNet("start", my1, my2, your);
|
||||
}
|
||||
|
||||
// Something just above here introduces a large delay forcing erroneous(?) insertion of silence packets.
|
||||
|
||||
@@ -115,10 +115,10 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
|
||||
if (type == TAG_LOST && (m_rfState == RS_RF_AUDIO || m_rfState == RS_RF_DATA_AUDIO)) {
|
||||
if (m_rssi != 0U) {
|
||||
LogMessage("M17, transmission lost from %s to %s, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", m_source.c_str(), m_dest.c_str(), float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
writeJSON("lost", m_rfState, m_source, m_dest, float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
writeJSONRF("lost", m_rfState, m_source, m_dest, float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
} else {
|
||||
LogMessage("M17, transmission lost from %s to %s, %.1f seconds, BER: %.1f%%", m_source.c_str(), m_dest.c_str(), float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
writeJSON("lost", m_rfState, m_source, m_dest, float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
writeJSONRF("lost", m_rfState, m_source, m_dest, float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
}
|
||||
writeEndRF();
|
||||
return false;
|
||||
@@ -424,10 +424,10 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
|
||||
|
||||
if (m_rssi != 0U) {
|
||||
LogMessage("M17, received RF end of transmission from %s to %s, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", m_source.c_str(), m_dest.c_str(), float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
writeJSON("end", m_rfState, m_source, m_dest, float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
writeJSONRF("end", m_rfState, m_source, m_dest, float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
} else {
|
||||
LogMessage("M17, received RF end of transmission from %s to %s, %.1f seconds, BER: %.1f%%", m_source.c_str(), m_dest.c_str(), float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
writeJSON("end", m_rfState, m_source, m_dest, float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
writeJSONRF("end", m_rfState, m_source, m_dest, float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
}
|
||||
writeEndRF();
|
||||
|
||||
@@ -535,17 +535,17 @@ void CM17Control::writeNetwork()
|
||||
case M17_DATA_TYPE_DATA:
|
||||
LogMessage("M17, received network data transmission from %s to %s", m_source.c_str(), m_dest.c_str());
|
||||
m_netState = RS_NET_DATA;
|
||||
writeJSON("header", m_netState, m_source, m_dest);
|
||||
writeJSONNet("start", m_netState, m_source, m_dest);
|
||||
break;
|
||||
case M17_DATA_TYPE_VOICE:
|
||||
LogMessage("M17, received network voice transmission from %s to %s", m_source.c_str(), m_dest.c_str());
|
||||
m_netState = RS_NET_AUDIO;
|
||||
writeJSON("header", m_netState, m_source, m_dest);
|
||||
writeJSONNet("start", m_netState, m_source, m_dest);
|
||||
break;
|
||||
case M17_DATA_TYPE_VOICE_DATA:
|
||||
LogMessage("M17, received network voice + data transmission from %s to %s", m_source.c_str(), m_dest.c_str());
|
||||
m_netState = RS_NET_DATA_AUDIO;
|
||||
writeJSON("header", m_netState, m_source, m_dest);
|
||||
writeJSONNet("start", m_netState, m_source, m_dest);
|
||||
break;
|
||||
default:
|
||||
LogMessage("M17, received network unknown transmission from %s to %s", m_source.c_str(), m_dest.c_str());
|
||||
@@ -647,7 +647,7 @@ void CM17Control::writeNetwork()
|
||||
uint16_t fn = (netData[28U] << 8) + (netData[29U] << 0);
|
||||
if ((fn & 0x8000U) == 0x8000U) {
|
||||
LogMessage("M17, received network end of transmission from %s to %s, %.1f seconds", m_source.c_str(), m_dest.c_str(), float(m_netFrames) / 25.0F);
|
||||
writeJSON("end", m_netState, m_source, m_dest, float(m_netFrames) / 25.0F);
|
||||
writeJSONNet("end", m_netState, m_source, m_dest, float(m_netFrames) / 25.0F);
|
||||
|
||||
unsigned char data[M17_FRAME_LENGTH_BYTES + 2U];
|
||||
|
||||
@@ -683,7 +683,7 @@ bool CM17Control::processRFHeader(bool lateEntry)
|
||||
if (type != M17_ENCRYPTION_TYPE_NONE) {
|
||||
LogMessage("M17, access attempt with encryption from %s to %s", m_source.c_str(), m_dest.c_str());
|
||||
m_rfState = RS_RF_REJECTED;
|
||||
writeJSON("rejected", RS_RF_AUDIO, m_source, m_dest);
|
||||
writeJSONRF("rejected", RS_RF_AUDIO, m_source, m_dest);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -693,7 +693,7 @@ bool CM17Control::processRFHeader(bool lateEntry)
|
||||
if (!ret) {
|
||||
LogMessage("M17, invalid access attempt from %s to %s", m_source.c_str(), m_dest.c_str());
|
||||
m_rfState = RS_RF_REJECTED;
|
||||
writeJSON("rejected", RS_RF_AUDIO, m_source, m_dest);
|
||||
writeJSONRF("rejected", RS_RF_AUDIO, m_source, m_dest);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -703,17 +703,17 @@ bool CM17Control::processRFHeader(bool lateEntry)
|
||||
case M17_DATA_TYPE_DATA:
|
||||
LogMessage("M17, received RF%sdata transmission from %s to %s", lateEntry ? " late entry " : " ", m_source.c_str(), m_dest.c_str());
|
||||
m_rfState = RS_RF_DATA;
|
||||
writeJSON(lateEntry ? "late_entry" : "header", m_rfState, m_source, m_dest);
|
||||
writeJSONRF(lateEntry ? "late_entry" : "start", m_rfState, m_source, m_dest);
|
||||
break;
|
||||
case M17_DATA_TYPE_VOICE:
|
||||
LogMessage("M17, received RF%svoice transmission from %s to %s", lateEntry ? " late entry " : " ", m_source.c_str(), m_dest.c_str());
|
||||
m_rfState = RS_RF_AUDIO;
|
||||
writeJSON(lateEntry ? "late_entry" : "header", m_rfState, m_source, m_dest);
|
||||
writeJSONRF(lateEntry ? "late_entry" : "start", m_rfState, m_source, m_dest);
|
||||
break;
|
||||
case M17_DATA_TYPE_VOICE_DATA:
|
||||
LogMessage("M17, received RF%svoice + data transmission from %s to %s", lateEntry ? " late entry " : " ", m_source.c_str(), m_dest.c_str());
|
||||
m_rfState = RS_RF_DATA_AUDIO;
|
||||
writeJSON(lateEntry ? "late_entry" : "header", m_rfState, m_source, m_dest);
|
||||
writeJSONRF(lateEntry ? "late_entry" : "start", m_rfState, m_source, m_dest);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
@@ -782,7 +782,7 @@ void CM17Control::clock(unsigned int ms)
|
||||
|
||||
if (m_networkWatchdog.hasExpired()) {
|
||||
LogMessage("M17, network watchdog has expired, %.1f seconds", float(m_netFrames) / 25.0F);
|
||||
writeJSON("lost", m_netState, m_source, m_dest, float(m_netFrames) / 25.0F);
|
||||
writeJSONNet("lost", m_netState, m_source, m_dest, float(m_netFrames) / 25.0F);
|
||||
writeEndNet();
|
||||
}
|
||||
}
|
||||
@@ -926,35 +926,35 @@ void CM17Control::enable(bool enabled)
|
||||
m_enabled = enabled;
|
||||
}
|
||||
|
||||
void CM17Control::writeJSON(const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest)
|
||||
void CM17Control::writeJSONRF(const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest)
|
||||
{
|
||||
assert(action != NULL);
|
||||
|
||||
nlohmann::json json;
|
||||
|
||||
writeJSON(json, action, state, source, dest);
|
||||
writeJSONRF(json, action, state, source, dest);
|
||||
|
||||
WriteJSON("M17", json);
|
||||
}
|
||||
|
||||
void CM17Control::writeJSON(const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest, float duration, float ber)
|
||||
void CM17Control::writeJSONRF(const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest, float duration, float ber)
|
||||
{
|
||||
assert(action != NULL);
|
||||
|
||||
nlohmann::json json;
|
||||
|
||||
writeJSON(json, action, state, source, dest, duration, ber);
|
||||
writeJSONRF(json, action, state, source, dest, duration, ber);
|
||||
|
||||
WriteJSON("M17", json);
|
||||
}
|
||||
|
||||
void CM17Control::writeJSON(const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI)
|
||||
void CM17Control::writeJSONRF(const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI)
|
||||
{
|
||||
assert(action != NULL);
|
||||
|
||||
nlohmann::json json;
|
||||
|
||||
writeJSON(json, action, state, source, dest, duration, ber);
|
||||
writeJSONRF(json, action, state, source, dest, duration, ber);
|
||||
|
||||
nlohmann::json rssi;
|
||||
rssi["min"] = -int(minRSSI);
|
||||
@@ -966,31 +966,31 @@ void CM17Control::writeJSON(const char* action, RPT_RF_STATE state, const std::s
|
||||
WriteJSON("M17", json);
|
||||
}
|
||||
|
||||
void CM17Control::writeJSON(const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest)
|
||||
void CM17Control::writeJSONNet(const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest)
|
||||
{
|
||||
assert(action != NULL);
|
||||
|
||||
nlohmann::json json;
|
||||
|
||||
writeJSON(json, action, state, source, dest);
|
||||
writeJSONNet(json, action, state, source, dest);
|
||||
|
||||
WriteJSON("M17", json);
|
||||
}
|
||||
|
||||
void CM17Control::writeJSON(const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest, float duration)
|
||||
void CM17Control::writeJSONNet(const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest, float duration)
|
||||
{
|
||||
assert(action != NULL);
|
||||
|
||||
nlohmann::json json;
|
||||
|
||||
writeJSON(json, action, state, source, dest);
|
||||
writeJSONNet(json, action, state, source, dest);
|
||||
|
||||
json["duration"] = duration;
|
||||
|
||||
WriteJSON("M17", json);
|
||||
}
|
||||
|
||||
void CM17Control::writeJSON(nlohmann::json& json, const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest)
|
||||
void CM17Control::writeJSONRF(nlohmann::json& json, const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest)
|
||||
{
|
||||
assert(action != NULL);
|
||||
|
||||
@@ -1018,17 +1018,17 @@ void CM17Control::writeJSON(nlohmann::json& json, const char* action, RPT_RF_STA
|
||||
}
|
||||
}
|
||||
|
||||
void CM17Control::writeJSON(nlohmann::json& json, const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest, float duration, float ber)
|
||||
void CM17Control::writeJSONRF(nlohmann::json& json, const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest, float duration, float ber)
|
||||
{
|
||||
assert(action != NULL);
|
||||
|
||||
writeJSON(json, action, state, source, dest);
|
||||
writeJSONRF(json, action, state, source, dest);
|
||||
|
||||
json["duration"] = duration;
|
||||
json["ber"] = ber;
|
||||
}
|
||||
|
||||
void CM17Control::writeJSON(nlohmann::json& json, const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest)
|
||||
void CM17Control::writeJSONNet(nlohmann::json& json, const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest)
|
||||
{
|
||||
assert(action != NULL);
|
||||
|
||||
|
||||
17
M17Control.h
17
M17Control.h
@@ -105,15 +105,16 @@ private:
|
||||
void writeEndRF();
|
||||
void writeEndNet();
|
||||
|
||||
void writeJSON(const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest);
|
||||
void writeJSON(const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest, float duration, float ber);
|
||||
void writeJSON(const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI);
|
||||
void writeJSON(const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest);
|
||||
void writeJSON(const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest, float duration);
|
||||
void writeJSONRF(const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest);
|
||||
void writeJSONRF(const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest, float duration, float ber);
|
||||
void writeJSONRF(const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI);
|
||||
|
||||
void writeJSON(nlohmann::json& json, const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest);
|
||||
void writeJSON(nlohmann::json& json, const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest, float duration, float ber);
|
||||
void writeJSON(nlohmann::json& json, const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest);
|
||||
void writeJSONNet(const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest);
|
||||
void writeJSONNet(const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest, float duration);
|
||||
|
||||
void writeJSONRF(nlohmann::json& json, const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest);
|
||||
void writeJSONRF(nlohmann::json& json, const char* action, RPT_RF_STATE state, const std::string& source, const std::string& dest, float duration, float ber);
|
||||
void writeJSONNet(nlohmann::json& json, const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest);
|
||||
|
||||
bool openFile();
|
||||
bool writeFile(const unsigned char* data);
|
||||
|
||||
@@ -300,7 +300,7 @@ bool CNXDNControl::processVoice(unsigned char usc, unsigned char option, unsigne
|
||||
std::string source = m_lookup->find(srcId);
|
||||
|
||||
LogMessage("NXDN, received RF header from %s to %s%u", source.c_str(), grp ? "TG " : "", dstId);
|
||||
writeJSONRF("header", srcId, source, grp, dstId);
|
||||
writeJSONRF("start", srcId, source, grp, dstId);
|
||||
m_display->writeNXDN(source.c_str(), grp, dstId, "R");
|
||||
}
|
||||
|
||||
@@ -616,7 +616,7 @@ bool CNXDNControl::processData(unsigned char option, unsigned char *data)
|
||||
m_display->writeNXDNRSSI(m_rssi);
|
||||
|
||||
LogMessage("NXDN, received RF data header from %s to %s%u, %u blocks", source.c_str(), grp ? "TG " : "", dstId, frames);
|
||||
writeJSONNet("header", srcId, source, grp, dstId, frames);
|
||||
writeJSONNet("start", srcId, source, grp, dstId, frames);
|
||||
|
||||
m_rfLayer3 = layer3;
|
||||
m_rfFrames = 0U;
|
||||
@@ -790,7 +790,7 @@ void CNXDNControl::writeNetwork()
|
||||
std::string source = m_lookup->find(srcId);
|
||||
m_display->writeNXDN(source.c_str(), grp, dstId, "N");
|
||||
LogMessage("NXDN, received network data header from %s to %s%u, %u blocks", source.c_str(), grp ? "TG " : "", dstId, frames);
|
||||
writeJSONNet("header", srcId, source, grp, dstId, frames);
|
||||
writeJSONNet("start", srcId, source, grp, dstId, frames);
|
||||
|
||||
m_netState = RS_NET_DATA;
|
||||
} else {
|
||||
@@ -818,7 +818,7 @@ void CNXDNControl::writeNetwork()
|
||||
std::string source = m_lookup->find(srcId);
|
||||
|
||||
LogMessage("NXDN, ended network data transmission from %s to %s%u", source.c_str(), grp ? "TG " : "", dstId);
|
||||
writeJSONNet("header", srcId, source, grp, dstId);
|
||||
writeJSONNet("start", srcId, source, grp, dstId);
|
||||
writeEndNet();
|
||||
}
|
||||
}
|
||||
@@ -862,7 +862,7 @@ void CNXDNControl::writeNetwork()
|
||||
writeEndNet();
|
||||
} else if (type == NXDN_MESSAGE_TYPE_VCALL) {
|
||||
LogMessage("NXDN, received network transmission from %s to %s%u", source.get(keyCALLSIGN).c_str(), grp ? "TG " : "", dstId);
|
||||
writeJSONNet("header", srcId, source.get(keyCALLSIGN), grp, dstId);
|
||||
writeJSONNet("start", srcId, source.get(keyCALLSIGN), grp, dstId);
|
||||
m_display->writeNXDN(source, grp, dstId, "N");
|
||||
|
||||
m_netTimeoutTimer.start();
|
||||
@@ -915,7 +915,7 @@ void CNXDNControl::writeNetwork()
|
||||
class CUserDBentry source;
|
||||
m_lookup->findWithName(srcId, &source);
|
||||
LogMessage("NXDN, received network transmission from %s to %s%u", source.get(keyCALLSIGN).c_str(), grp ? "TG " : "", dstId);
|
||||
writeJSONNet("header", srcId, source.get(keyCALLSIGN), grp, dstId);
|
||||
writeJSONNet("start", srcId, source.get(keyCALLSIGN), grp, dstId);
|
||||
m_display->writeNXDN(source, grp, dstId, "N");
|
||||
|
||||
m_netTimeoutTimer.start();
|
||||
|
||||
@@ -110,10 +110,10 @@ bool CYSFControl::writeModem(unsigned char *data, unsigned int len)
|
||||
if (type == TAG_LOST && m_rfState == RS_RF_AUDIO) {
|
||||
if (m_rssi != 0U) {
|
||||
LogMessage("YSF, transmission lost from %10.10s to %10.10s, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", m_rfSource, m_rfDest, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
writeJSON("lost", "voice_dn", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
writeJSONRF("lost", "voice_dn", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
} else {
|
||||
LogMessage("YSF, transmission lost from %10.10s to %10.10s, %.1f seconds, BER: %.1f%%", m_rfSource, m_rfDest, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
writeJSON("lost", "voice_dn", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
writeJSONRF("lost", "voice_dn", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
}
|
||||
writeEndRF();
|
||||
return false;
|
||||
@@ -236,7 +236,7 @@ bool CYSFControl::processVWData(bool valid, unsigned char *data)
|
||||
if (!ret) {
|
||||
LogMessage("YSF, invalid access attempt from %10.10s to DG-ID %u", m_rfSource, dgid);
|
||||
m_rfState = RS_RF_REJECTED;
|
||||
writeJSON("rejected", "voice_vw", m_rfSource, dgid);
|
||||
writeJSONRF("rejected", "voice_vw", m_rfSource, dgid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -262,7 +262,7 @@ bool CYSFControl::processVWData(bool valid, unsigned char *data)
|
||||
#endif
|
||||
m_display->writeFusion((char*)m_rfSource, (char*)m_rfDest, dgid, "R", " ");
|
||||
LogMessage("YSF, received RF header from %10.10s to DG-ID %u", m_rfSource, dgid);
|
||||
writeJSON("header", "voice_vw", m_rfSource, dgid);
|
||||
writeJSONRF("start", "voice_vw", m_rfSource, dgid);
|
||||
|
||||
CSync::addYSFSync(data + 2U);
|
||||
|
||||
@@ -324,10 +324,10 @@ bool CYSFControl::processVWData(bool valid, unsigned char *data)
|
||||
|
||||
if (m_rssi != 0U) {
|
||||
LogMessage("YSF, received RF end of transmission from %10.10s to DG-ID %u, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
writeJSON("end", "voice_vw", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
writeJSONRF("end", "voice_vw", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
} else {
|
||||
LogMessage("YSF, received RF end of transmission from %10.10s to DG-ID %u, %.1f seconds, BER: %.1f%%", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
writeJSON("end", "voice_vw", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
writeJSONRF("end", "voice_vw", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
}
|
||||
|
||||
writeEndRF();
|
||||
@@ -410,7 +410,7 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data)
|
||||
if (!ret) {
|
||||
LogMessage("YSF, invalid access attempt from %10.10s to DG-ID %u", m_rfSource, dgid);
|
||||
m_rfState = RS_RF_REJECTED;
|
||||
writeJSON("rejected", "voice_dn", m_rfSource, dgid);
|
||||
writeJSONRF("rejected", "voice_dn", m_rfSource, dgid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -436,7 +436,7 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data)
|
||||
#endif
|
||||
m_display->writeFusion((char*)m_rfSource, (char*)m_rfDest, dgid, "R", " ");
|
||||
LogMessage("YSF, received RF header from %10.10s to DG-ID %u", m_rfSource, dgid);
|
||||
writeJSON("header", "voice_dn", m_rfSource, dgid);
|
||||
writeJSONRF("start", "voice_dn", m_rfSource, dgid);
|
||||
|
||||
CSync::addYSFSync(data + 2U);
|
||||
|
||||
@@ -498,10 +498,10 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data)
|
||||
|
||||
if (m_rssi != 0U) {
|
||||
LogMessage("YSF, received RF end of transmission from %10.10s to DG-ID %u, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
writeJSON("end", "voice_dn", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
writeJSONRF("end", "voice_dn", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
} else {
|
||||
LogMessage("YSF, received RF end of transmission from %10.10s to DG-ID %u, %.1f seconds, BER: %.1f%%", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
writeJSON("end", "voice_dn", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
writeJSONRF("end", "voice_dn", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||
}
|
||||
|
||||
writeEndRF();
|
||||
@@ -611,7 +611,7 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data)
|
||||
if (!ret) {
|
||||
LogMessage("YSF, invalid access attempt from %10.10s to DG-ID %u", m_rfSource, dgid);
|
||||
m_rfState = RS_RF_REJECTED;
|
||||
writeJSON("rejected", "voice_dn", m_rfSource, dgid);
|
||||
writeJSONRF("rejected", "voice_dn", m_rfSource, dgid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -667,7 +667,7 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data)
|
||||
#endif
|
||||
m_display->writeFusion((char*)m_rfSource, (char*)m_rfDest, dgid, "R", " ");
|
||||
LogMessage("YSF, received RF late entry from %10.10s to DG-ID %u", m_rfSource, dgid);
|
||||
writeJSON("late_entry", "voice_dn", m_rfSource, dgid);
|
||||
writeJSONRF("late_entry", "voice_dn", m_rfSource, dgid);
|
||||
|
||||
CSync::addYSFSync(data + 2U);
|
||||
|
||||
@@ -719,7 +719,7 @@ bool CYSFControl::processFRData(bool valid, unsigned char *data)
|
||||
if (!ret) {
|
||||
LogMessage("YSF, invalid access attempt from %10.10s to DG-ID %u", m_rfSource, dgid);
|
||||
m_rfState = RS_RF_REJECTED;
|
||||
writeJSON("rejected", "data_fr", m_rfSource, dgid);
|
||||
writeJSONRF("rejected", "data_fr", m_rfSource, dgid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -742,7 +742,7 @@ bool CYSFControl::processFRData(bool valid, unsigned char *data)
|
||||
#endif
|
||||
m_display->writeFusion((char*)m_rfSource, (char*)m_rfDest, dgid, "R", " ");
|
||||
LogMessage("YSF, received RF header from %10.10s to DG-ID %u", m_rfSource, dgid);
|
||||
writeJSON("header", "data_fr", m_rfSource, dgid);
|
||||
writeJSONRF("start", "data_fr", m_rfSource, dgid);
|
||||
|
||||
CSync::addYSFSync(data + 2U);
|
||||
|
||||
@@ -803,10 +803,10 @@ bool CYSFControl::processFRData(bool valid, unsigned char *data)
|
||||
|
||||
if (m_rssi != 0U) {
|
||||
LogMessage("YSF, received RF end of transmission from %10.10s to DG-ID %u, %.1f seconds, RSSI: -%u/-%u/-%u dBm", m_rfSource, dgid, float(m_rfFrames) / 10.0F, m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
writeJSON("end", "data_fr", m_rfSource, dgid, float(m_rfFrames) / 10.0F, 0.0F, m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
writeJSONRF("end", "data_fr", m_rfSource, dgid, float(m_rfFrames) / 10.0F, 0.0F, m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
|
||||
} else {
|
||||
LogMessage("YSF, received RF end of transmission from %10.10s to DG-ID %u, %.1f seconds", m_rfSource, dgid, float(m_rfFrames) / 10.0F);
|
||||
writeJSON("end", "data_fr", m_rfSource, dgid, float(m_rfFrames) / 10.0F, 0.0F);
|
||||
writeJSONRF("end", "data_fr", m_rfSource, dgid, float(m_rfFrames) / 10.0F, 0.0F);
|
||||
}
|
||||
|
||||
writeEndRF();
|
||||
@@ -951,7 +951,7 @@ void CYSFControl::writeNetwork()
|
||||
if (::memcmp(m_netSource, " ", 10U) != 0 && ::memcmp(m_netDest, " ", 10U) != 0) {
|
||||
m_display->writeFusion((char*)m_netSource, (char*)m_netDest, dgid, "N", (char*)(data + 4U));
|
||||
LogMessage("YSF, received network data from %10.10s to DG-ID %u at %10.10s", m_netSource, dgid, data + 4U);
|
||||
writeJSON("header", "voice_dn", m_netSource, dgid, data + 4U);
|
||||
writeJSONNet("start", "voice_dn", m_netSource, dgid, data + 4U);
|
||||
}
|
||||
|
||||
m_netTimeoutTimer.start();
|
||||
@@ -1064,7 +1064,7 @@ void CYSFControl::writeNetwork()
|
||||
|
||||
if (end) {
|
||||
LogMessage("YSF, received network end of transmission from %10.10s to DG-ID %u at %10.10s, %.1f seconds, %u%% packet loss", m_netSource, dgid, data + 4U, float(m_netFrames) / 10.0F, (m_netLost * 100U) / m_netFrames);
|
||||
writeJSON("end", "voice_dn", m_netSource, dgid, data + 4U, float(m_netFrames) / 10.0F, (m_netLost * 100U) / m_netFrames);
|
||||
writeJSONNet("end", "voice_dn", m_netSource, dgid, data + 4U, float(m_netFrames) / 10.0F, (m_netLost * 100U) / m_netFrames);
|
||||
writeEndNet();
|
||||
}
|
||||
}
|
||||
@@ -1083,7 +1083,7 @@ void CYSFControl::clock(unsigned int ms)
|
||||
if (m_networkWatchdog.hasExpired()) {
|
||||
unsigned char dgid = m_lastFICH.getDGId();
|
||||
LogMessage("YSF, network watchdog has expired, %.1f seconds, %u%% packet loss", float(m_netFrames) / 10.0F, (m_netLost * 100U) / m_netFrames);
|
||||
writeJSON("lost", "voice_dn", m_netSource, dgid, float(m_netFrames) / 10.0F, (m_netLost * 100U) / m_netFrames);
|
||||
writeJSONNet("lost", "voice_dn", m_netSource, dgid, float(m_netFrames) / 10.0F, (m_netLost * 100U) / m_netFrames);
|
||||
writeEndNet();
|
||||
}
|
||||
}
|
||||
@@ -1210,7 +1210,7 @@ void CYSFControl::processNetCallsigns(const unsigned char* data, unsigned char d
|
||||
if (::memcmp(m_netSource, " ", 10U) != 0 && ::memcmp(m_netDest, " ", 10U) != 0) {
|
||||
m_display->writeFusion((char*)m_netSource, (char*)m_netDest, dgid, "N", (char*)(data + 4U));
|
||||
LogMessage("YSF, received network data from %10.10s to DG-ID %u at %10.10s", m_netSource, dgid, data + 4U);
|
||||
writeJSON("header", "voice_dn", m_netSource, dgid, data + 4U);
|
||||
writeJSONNet("start", "voice_dn", m_netSource, dgid, data + 4U);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1248,7 +1248,7 @@ void CYSFControl::enable(bool enabled)
|
||||
m_enabled = enabled;
|
||||
}
|
||||
|
||||
void CYSFControl::writeJSON(const char* action, const char* mode, const unsigned char* source, unsigned char dgid)
|
||||
void CYSFControl::writeJSONRF(const char* action, const char* mode, const unsigned char* source, unsigned char dgid)
|
||||
{
|
||||
assert(action != NULL);
|
||||
assert(mode != NULL);
|
||||
@@ -1256,12 +1256,12 @@ void CYSFControl::writeJSON(const char* action, const char* mode, const unsigned
|
||||
|
||||
nlohmann::json json;
|
||||
|
||||
writeJSON(json, action, mode, source, dgid);
|
||||
writeJSONRF(json, action, mode, source, dgid);
|
||||
|
||||
WriteJSON("YSF", json);
|
||||
}
|
||||
|
||||
void CYSFControl::writeJSON(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, float duration, float ber)
|
||||
void CYSFControl::writeJSONRF(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, float duration, float ber)
|
||||
{
|
||||
assert(action != NULL);
|
||||
assert(mode != NULL);
|
||||
@@ -1269,7 +1269,7 @@ void CYSFControl::writeJSON(const char* action, const char* mode, const unsigned
|
||||
|
||||
nlohmann::json json;
|
||||
|
||||
writeJSON(json, action, mode, source, dgid);
|
||||
writeJSONRF(json, action, mode, source, dgid);
|
||||
|
||||
json["duration"] = duration;
|
||||
json["ber"] = ber;
|
||||
@@ -1277,7 +1277,7 @@ void CYSFControl::writeJSON(const char* action, const char* mode, const unsigned
|
||||
WriteJSON("YSF", json);
|
||||
}
|
||||
|
||||
void CYSFControl::writeJSON(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI)
|
||||
void CYSFControl::writeJSONRF(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI)
|
||||
{
|
||||
assert(action != NULL);
|
||||
assert(mode != NULL);
|
||||
@@ -1285,7 +1285,7 @@ void CYSFControl::writeJSON(const char* action, const char* mode, const unsigned
|
||||
|
||||
nlohmann::json json;
|
||||
|
||||
writeJSON(json, action, mode, source, dgid);
|
||||
writeJSONRF(json, action, mode, source, dgid);
|
||||
|
||||
json["duration"] = duration;
|
||||
json["ber"] = ber;
|
||||
@@ -1300,7 +1300,7 @@ void CYSFControl::writeJSON(const char* action, const char* mode, const unsigned
|
||||
WriteJSON("YSF", json);
|
||||
}
|
||||
|
||||
void CYSFControl::writeJSON(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, const unsigned char* reflector)
|
||||
void CYSFControl::writeJSONNet(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, const unsigned char* reflector)
|
||||
{
|
||||
assert(action != NULL);
|
||||
assert(mode != NULL);
|
||||
@@ -1309,21 +1309,22 @@ void CYSFControl::writeJSON(const char* action, const char* mode, const unsigned
|
||||
|
||||
nlohmann::json json;
|
||||
|
||||
writeJSON(json, action, mode, source, dgid, reflector);
|
||||
writeJSONNet(json, action, mode, source, dgid);
|
||||
|
||||
json["reflector"] = convertBuffer(reflector);
|
||||
|
||||
WriteJSON("YSF", json);
|
||||
}
|
||||
|
||||
void CYSFControl::writeJSON(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, const unsigned char* reflector, float duration, unsigned int loss)
|
||||
void CYSFControl::writeJSONNet(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, float duration, unsigned int loss)
|
||||
{
|
||||
assert(action != NULL);
|
||||
assert(mode != NULL);
|
||||
assert(source != NULL);
|
||||
assert(reflector != NULL);
|
||||
|
||||
nlohmann::json json;
|
||||
|
||||
writeJSON(json, action, mode, source, dgid, reflector);
|
||||
writeJSONNet(json, action, mode, source, dgid);
|
||||
|
||||
json["duration"] = duration;
|
||||
json["loss"] = loss;
|
||||
@@ -1331,7 +1332,26 @@ void CYSFControl::writeJSON(const char* action, const char* mode, const unsigned
|
||||
WriteJSON("YSF", json);
|
||||
}
|
||||
|
||||
void CYSFControl::writeJSON(nlohmann::json& json, const char* action, const char* mode, const unsigned char* source, unsigned char dgid)
|
||||
void CYSFControl::writeJSONNet(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, const unsigned char* reflector, float duration, unsigned int loss)
|
||||
{
|
||||
assert(action != NULL);
|
||||
assert(mode != NULL);
|
||||
assert(source != NULL);
|
||||
assert(reflector != NULL);
|
||||
|
||||
nlohmann::json json;
|
||||
|
||||
writeJSONNet(json, action, mode, source, dgid);
|
||||
|
||||
json["reflector"] = convertBuffer(reflector);
|
||||
|
||||
json["duration"] = duration;
|
||||
json["loss"] = loss;
|
||||
|
||||
WriteJSON("YSF", json);
|
||||
}
|
||||
|
||||
void CYSFControl::writeJSONRF(nlohmann::json& json, const char* action, const char* mode, const unsigned char* source, unsigned char dgid)
|
||||
{
|
||||
assert(action != NULL);
|
||||
assert(mode != NULL);
|
||||
@@ -1347,12 +1367,11 @@ void CYSFControl::writeJSON(nlohmann::json& json, const char* action, const char
|
||||
json["dg-id"] = int(dgid);
|
||||
}
|
||||
|
||||
void CYSFControl::writeJSON(nlohmann::json& json, const char* action, const char* mode, const unsigned char* source, unsigned char dgid, const unsigned char* reflector)
|
||||
void CYSFControl::writeJSONNet(nlohmann::json& json, const char* action, const char* mode, const unsigned char* source, unsigned char dgid)
|
||||
{
|
||||
assert(action != NULL);
|
||||
assert(mode != NULL);
|
||||
assert(source != NULL);
|
||||
assert(reflector != NULL);
|
||||
|
||||
json["timestamp"] = CUtils::createTimestamp();
|
||||
|
||||
@@ -1362,8 +1381,6 @@ void CYSFControl::writeJSON(nlohmann::json& json, const char* action, const char
|
||||
json["action"] = action;
|
||||
json["mode"] = mode;
|
||||
json["dg-id"] = int(dgid);
|
||||
|
||||
json["reflector"] = convertBuffer(reflector);
|
||||
}
|
||||
|
||||
std::string CYSFControl::convertBuffer(const unsigned char* buffer) const
|
||||
|
||||
16
YSFControl.h
16
YSFControl.h
@@ -102,14 +102,16 @@ private:
|
||||
void writeEndRF();
|
||||
void writeEndNet();
|
||||
|
||||
void writeJSON(const char* action, const char* mode, const unsigned char* source, unsigned char dgid);
|
||||
void writeJSON(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, float duration, float ber);
|
||||
void writeJSON(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI);
|
||||
void writeJSON(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, const unsigned char* reflector);
|
||||
void writeJSON(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, const unsigned char* reflector, float duration, unsigned int loss);
|
||||
void writeJSONRF(const char* action, const char* mode, const unsigned char* source, unsigned char dgid);
|
||||
void writeJSONRF(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, float duration, float ber);
|
||||
void writeJSONRF(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI);
|
||||
|
||||
void writeJSON(nlohmann::json& json, const char* action, const char* mode, const unsigned char* source, unsigned char dgid);
|
||||
void writeJSON(nlohmann::json& json, const char* action, const char* mode, const unsigned char* source, unsigned char dgid, const unsigned char* reflector);
|
||||
void writeJSONNet(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, const unsigned char* reflector);
|
||||
void writeJSONNet(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, float duration, unsigned int loss);
|
||||
void writeJSONNet(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, const unsigned char* reflector, float duration, unsigned int loss);
|
||||
|
||||
void writeJSONRF(nlohmann::json& json, const char* action, const char* mode, const unsigned char* source, unsigned char dgid);
|
||||
void writeJSONNet(nlohmann::json& json, const char* action, const char* mode, const unsigned char* source, unsigned char dgid);
|
||||
|
||||
std::string convertBuffer(const unsigned char* buffer) const;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"ax25_pid": {"type": "string"},
|
||||
"pocsag_source": {"type": "string", "enum": ["local", "network"]},
|
||||
"pocsag_functional": {"type": "string", "enum": ["numeric", "alphanumeric", "alert_1", "alert_2"]},
|
||||
"action": {"type": "string", "enum": ["invalid", "rejected", "header", "late_entry", "end", "lost"]},
|
||||
"action": {"type": "string", "enum": ["invalid", "rejected", "start", "late_entry", "end", "lost"]},
|
||||
"duration": {"type": "number", "minimum": 0.0},
|
||||
"loss": {"type": "number", "minimum": 0.0},
|
||||
"ber": {"type": "number", "minimum": 0.0},
|
||||
@@ -127,7 +127,6 @@
|
||||
"source": {"$ref": "#/$defs/source"},
|
||||
"action": {"$ref": "#/$defs/action"},
|
||||
"duration": {"$ref": "#/$defs/duration"},
|
||||
"loss": {"$ref": "#/$defs/loss"},
|
||||
"ber": {"$ref": "#/$defs/ber"},
|
||||
"rssi": {
|
||||
"min": {"$ref": "#/$defs/rssi"},
|
||||
|
||||
Reference in New Issue
Block a user