Simplify the end of transmission JSON for all DV modes.

This commit is contained in:
Jonathan Naylor
2023-06-09 15:46:29 +01:00
parent da147031c9
commit 8d941db7b1
13 changed files with 243 additions and 259 deletions

View File

@@ -151,10 +151,10 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
if (m_rssi != 0U) { if (m_rssi != 0U) {
LogMessage("DMR Slot %u, RF voice transmission lost from %s to %s%s, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); LogMessage("DMR Slot %u, RF voice transmission lost from %s to %s%s, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
writeJSONRF("lost", srcId, src, flco == FLCO_GROUP, dstId, float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); writeJSONRF("lost", float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
} else { } else {
LogMessage("DMR Slot %u, RF voice transmission lost from %s to %s%s, %.1f seconds, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits)); LogMessage("DMR Slot %u, RF voice transmission lost from %s to %s%s, %.1f seconds, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits));
writeJSONRF("lost", srcId, src, flco == FLCO_GROUP, dstId, float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("lost", float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits));
} }
if (m_rfTimeout) { if (m_rfTimeout) {
@@ -174,7 +174,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
FLCO flco = m_rfLC->getFLCO(); FLCO flco = m_rfLC->getFLCO();
LogMessage("DMR Slot %u, RF data transmission lost from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str()); LogMessage("DMR Slot %u, RF data transmission lost from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str());
writeJSONRF("lost", srcId, src, flco == FLCO_GROUP, dstId); writeJSONRF("lost");
writeEndRF(); writeEndRF();
return false; return false;
} }
@@ -371,10 +371,10 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
if (m_rssi != 0U) { if (m_rssi != 0U) {
LogMessage("DMR Slot %u, received RF end of voice transmission from %s to %s%s, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); LogMessage("DMR Slot %u, received RF end of voice transmission from %s to %s%s, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
writeJSONRF("end", srcId, src, flco == FLCO_GROUP, dstId, float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); writeJSONRF("end", float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
} else { } else {
LogMessage("DMR Slot %u, received RF end of voice transmission from %s to %s%s, %.1f seconds, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits)); LogMessage("DMR Slot %u, received RF end of voice transmission from %s to %s%s, %.1f seconds, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits));
writeJSONRF("end", srcId, src, flco == FLCO_GROUP, dstId, float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("end", float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits));
} }
m_display->writeDMRTA(m_slotNo, NULL, " "); m_display->writeDMRTA(m_slotNo, NULL, " ");
@@ -449,7 +449,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
if (m_rfFrames == 0U) { if (m_rfFrames == 0U) {
LogMessage("DMR Slot %u, ended RF data transmission from %s to %s%s", m_slotNo, src.c_str(), gi ? "TG " : "", dst.c_str()); LogMessage("DMR Slot %u, ended RF data transmission from %s to %s%s", m_slotNo, src.c_str(), gi ? "TG " : "", dst.c_str());
writeJSONRF("end", srcId, src, gi, dstId); writeJSONRF("end");
writeEndRF(); writeEndRF();
} }
@@ -559,11 +559,6 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
if (m_rfState != RS_RF_DATA || m_rfFrames == 0U) if (m_rfState != RS_RF_DATA || m_rfFrames == 0U)
return false; return false;
unsigned int srcId = m_rfLC->getSrcId();
unsigned int dstId = m_rfLC->getDstId();
std::string src = m_lookup->find(srcId);
FLCO flco = m_rfLC->getFLCO();
// Regenerate the rate 1/2 payload // Regenerate the rate 1/2 payload
if (dataType == DT_RATE_12_DATA) { if (dataType == DT_RATE_12_DATA) {
CBPTC19696 bptc; CBPTC19696 bptc;
@@ -600,7 +595,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
if (m_rfFrames == 0U) { if (m_rfFrames == 0U) {
LogMessage("DMR Slot %u, ended RF data transmission", m_slotNo); LogMessage("DMR Slot %u, ended RF data transmission", m_slotNo);
writeJSONRF("end", srcId, src, flco == FLCO_GROUP, dstId); writeJSONRF("end");
writeEndRF(); writeEndRF();
} }
@@ -1324,7 +1319,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
// We've received the voice header and terminator haven't we? // We've received the voice header and terminator haven't we?
m_netFrames += 2U; m_netFrames += 2U;
LogMessage("DMR Slot %u, received network end of voice transmission from %s to %s%s, %.1f seconds, %u%% packet loss, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits)); LogMessage("DMR Slot %u, received network end of voice transmission from %s to %s%s, %.1f seconds, %u%% packet loss, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str(), float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits));
writeJSONNet("end", srcId, src, flco == FLCO_GROUP, dstId, float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits)); writeJSONNet("end", float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits));
m_display->writeDMRTA(m_slotNo, NULL, " "); m_display->writeDMRTA(m_slotNo, NULL, " ");
writeEndNet(); writeEndNet();
} else if (dataType == DT_DATA_HEADER) { } else if (dataType == DT_DATA_HEADER) {
@@ -1379,7 +1374,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
if (m_netFrames == 0U) { if (m_netFrames == 0U) {
LogMessage("DMR Slot %u, ended network data transmission from %s to %s%s", m_slotNo, src.c_str(), gi ? "TG " : "", dst.c_str()); LogMessage("DMR Slot %u, ended network data transmission from %s to %s%s", m_slotNo, src.c_str(), gi ? "TG " : "", dst.c_str());
writeJSONNet("end", srcId, src, gi, dstId); writeJSONNet("end");
writeEndNet(); writeEndNet();
} }
} else if (dataType == DT_VOICE_SYNC) { } else if (dataType == DT_VOICE_SYNC) {
@@ -1805,12 +1800,8 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
writeQueueNet(data); writeQueueNet(data);
if (m_netFrames == 0U) { if (m_netFrames == 0U) {
unsigned int srcId = m_netLC->getSrcId();
unsigned int dstId = m_netLC->getDstId();
std::string src = m_lookup->find(srcId);
LogMessage("DMR Slot %u, ended network data transmission", m_slotNo); LogMessage("DMR Slot %u, ended network data transmission", m_slotNo);
writeJSONNet("end", srcId, src, m_netLC->getFLCO() == FLCO_GROUP, dstId); writeJSONNet("end");
writeEndNet(); writeEndNet();
} }
} else { } else {
@@ -1874,12 +1865,8 @@ void CDMRSlot::clock()
m_rfTimeoutTimer.clock(ms); m_rfTimeoutTimer.clock(ms);
if (m_rfTimeoutTimer.isRunning() && m_rfTimeoutTimer.hasExpired()) { if (m_rfTimeoutTimer.isRunning() && m_rfTimeoutTimer.hasExpired()) {
if (!m_rfTimeout) { if (!m_rfTimeout) {
unsigned int srcId = m_rfLC->getSrcId();
unsigned int dstId = m_rfLC->getDstId();
std::string src = m_lookup->find(srcId);
LogMessage("DMR Slot %u, RF user has timed out", m_slotNo); LogMessage("DMR Slot %u, RF user has timed out", m_slotNo);
writeJSONRF("timeout", srcId, src, m_rfLC->getFLCO() == FLCO_GROUP, dstId); writeJSONRF("timeout");
m_rfTimeout = true; m_rfTimeout = true;
} }
} }
@@ -1887,12 +1874,8 @@ void CDMRSlot::clock()
m_netTimeoutTimer.clock(ms); m_netTimeoutTimer.clock(ms);
if (m_netTimeoutTimer.isRunning() && m_netTimeoutTimer.hasExpired()) { if (m_netTimeoutTimer.isRunning() && m_netTimeoutTimer.hasExpired()) {
if (!m_netTimeout) { if (!m_netTimeout) {
unsigned int srcId = m_netLC->getSrcId();
unsigned int dstId = m_netLC->getDstId();
std::string src = m_lookup->find(srcId);
LogMessage("DMR Slot %u, network user has timed out", m_slotNo); LogMessage("DMR Slot %u, network user has timed out", m_slotNo);
writeJSONNet("timeout", srcId, src, m_netLC->getFLCO() == FLCO_GROUP, dstId); writeJSONNet("timeout");
m_netTimeout = true; m_netTimeout = true;
} }
} }
@@ -1902,25 +1885,17 @@ void CDMRSlot::clock()
if (m_networkWatchdog.hasExpired()) { if (m_networkWatchdog.hasExpired()) {
if (m_netState == RS_NET_AUDIO) { if (m_netState == RS_NET_AUDIO) {
unsigned int srcId = m_netLC->getSrcId();
unsigned int dstId = m_netLC->getDstId();
std::string src = m_lookup->find(srcId);
// We've received the voice header haven't we? // We've received the voice header haven't we?
m_netFrames += 1U; m_netFrames += 1U;
LogMessage("DMR Slot %u, network watchdog has expired, %.1f seconds, %u%% packet loss, BER: %.1f%%", m_slotNo, float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits)); LogMessage("DMR Slot %u, network watchdog has expired, %.1f seconds, %u%% packet loss, BER: %.1f%%", m_slotNo, float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits));
writeJSONNet("lost", srcId, src, m_netLC->getFLCO() == FLCO_GROUP, dstId, float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits)); writeJSONNet("lost", float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits));
writeEndNet(true); writeEndNet(true);
#if defined(DUMP_DMR) #if defined(DUMP_DMR)
closeFile(); closeFile();
#endif #endif
} else { } else {
unsigned int srcId = m_netLC->getSrcId();
unsigned int dstId = m_netLC->getDstId();
std::string src = m_lookup->find(srcId);
LogMessage("DMR Slot %u, network watchdog has expired", m_slotNo); LogMessage("DMR Slot %u, network watchdog has expired", m_slotNo);
writeJSONNet("lost", srcId, src, m_netLC->getFLCO() == FLCO_GROUP, dstId); writeJSONNet("lost");
writeEndNet(); writeEndNet();
#if defined(DUMP_DMR) #if defined(DUMP_DMR)
closeFile(); closeFile();
@@ -2314,6 +2289,17 @@ void CDMRSlot::enable(bool enabled)
m_enabled = enabled; m_enabled = enabled;
} }
void CDMRSlot::writeJSONRF(const char* action)
{
assert(action != NULL);
nlohmann::json json;
writeJSON(json, "rf", action);
WriteJSON("DMR", json);
}
void CDMRSlot::writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId) void CDMRSlot::writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId)
{ {
assert(action != NULL); assert(action != NULL);
@@ -2352,13 +2338,13 @@ void CDMRSlot::writeJSONRF(const char* action, unsigned int srcId, const std::st
WriteJSON("DMR", json); WriteJSON("DMR", json);
} }
void CDMRSlot::writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, float duration, float ber) void CDMRSlot::writeJSONRF(const char* action, float duration, float ber)
{ {
assert(action != NULL); assert(action != NULL);
nlohmann::json json; nlohmann::json json;
writeJSON(json, "rf", action, srcId, srcInfo, grp, dstId); writeJSON(json, "rf", action);
json["duration"] = duration; json["duration"] = duration;
json["ber"] = ber; json["ber"] = ber;
@@ -2366,13 +2352,13 @@ void CDMRSlot::writeJSONRF(const char* action, unsigned int srcId, const std::st
WriteJSON("DMR", json); WriteJSON("DMR", json);
} }
void CDMRSlot::writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI) void CDMRSlot::writeJSONRF(const char* action, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI)
{ {
assert(action != NULL); assert(action != NULL);
nlohmann::json json; nlohmann::json json;
writeJSON(json, "rf", action, srcId, srcInfo, grp, dstId); writeJSON(json, "rf", action);
json["duration"] = duration; json["duration"] = duration;
json["ber"] = ber; json["ber"] = ber;
@@ -2387,6 +2373,17 @@ void CDMRSlot::writeJSONRF(const char* action, unsigned int srcId, const std::st
WriteJSON("DMR", json); WriteJSON("DMR", json);
} }
void CDMRSlot::writeJSONNet(const char* action)
{
assert(action != NULL);
nlohmann::json json;
writeJSON(json, "network", action);
WriteJSON("DMR", json);
}
void CDMRSlot::writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId) void CDMRSlot::writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId)
{ {
assert(action != NULL); assert(action != NULL);
@@ -2425,13 +2422,13 @@ void CDMRSlot::writeJSONNet(const char* action, unsigned int srcId, const std::s
WriteJSON("DMR", json); WriteJSON("DMR", json);
} }
void CDMRSlot::writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, float duration, float loss, float ber) void CDMRSlot::writeJSONNet(const char* action, float duration, float loss, float ber)
{ {
assert(action != NULL); assert(action != NULL);
nlohmann::json json; nlohmann::json json;
writeJSON(json, "network", action, srcId, srcInfo, grp, dstId); writeJSON(json, "network", action);
json["duration"] = duration; json["duration"] = duration;
json["loss"] = loss; json["loss"] = loss;
@@ -2440,6 +2437,17 @@ void CDMRSlot::writeJSONNet(const char* action, unsigned int srcId, const std::s
WriteJSON("DMR", json); WriteJSON("DMR", json);
} }
void CDMRSlot::writeJSON(nlohmann::json& json, const char* source, const char* action)
{
assert(source != NULL);
assert(action != NULL);
json["timestamp"] = CUtils::createTimestamp();
json["source"] = source;
json["action"] = action;
json["slot"] = int(m_slotNo);
}
void CDMRSlot::writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId) void CDMRSlot::writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId)
{ {
assert(source != NULL); assert(source != NULL);

View File

@@ -161,17 +161,20 @@ private:
static void setShortLC(unsigned int slotNo, unsigned int id, FLCO flco = FLCO_GROUP, ACTIVITY_TYPE type = ACTIVITY_NONE); static void setShortLC(unsigned int slotNo, unsigned int id, FLCO flco = FLCO_GROUP, ACTIVITY_TYPE type = ACTIVITY_NONE);
void writeJSONRF(const char* action);
void writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId); void writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId);
void writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, unsigned int frames); void writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, unsigned int frames);
void writeJSONRF(const char* action, const char* desc, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId); void writeJSONRF(const char* action, const char* desc, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId);
void writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, float duration, float ber); void writeJSONRF(const char* action, float duration, float ber);
void writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI); void writeJSONRF(const char* action, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI);
void writeJSONNet(const char* action);
void writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId); void writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId);
void writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, unsigned int frames); void writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, unsigned int frames);
void writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, float duration, float loss, float ber); void writeJSONNet(const char* action, float duration, float loss, float ber);
void writeJSONNet(const char* action, const char* desc, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId); void writeJSONNet(const char* action, const char* desc, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId);
void writeJSON(nlohmann::json& json, const char* source, const char* action);
void writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId); void writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId);
}; };

View File

@@ -227,10 +227,10 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
if (m_rssi != 0U) { if (m_rssi != 0U) {
LogMessage("D-Star, transmission lost from %8.8s/%4.4s to %8.8s, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", my1, my2, your, float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); LogMessage("D-Star, transmission lost from %8.8s/%4.4s to %8.8s, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", my1, my2, your, float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
writeJSONRF("lost", my1, my2, your, float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); writeJSONRF("lost", float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
} else { } else {
LogMessage("D-Star, transmission lost from %8.8s/%4.4s to %8.8s, %.1f seconds, BER: %.1f%%", my1, my2, your, float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits)); LogMessage("D-Star, transmission lost from %8.8s/%4.4s to %8.8s, %.1f seconds, BER: %.1f%%", my1, my2, your, float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits));
writeJSONRF("lost", my1, my2, your, float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("lost", float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits));
} }
writeEndRF(); writeEndRF();
return false; return false;
@@ -433,10 +433,10 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
if (m_rssi != 0U) { if (m_rssi != 0U) {
LogMessage("D-Star, received RF end of transmission from %8.8s/%4.4s to %8.8s, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", my1, my2, your, float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); LogMessage("D-Star, received RF end of transmission from %8.8s/%4.4s to %8.8s, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", my1, my2, your, float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
writeJSONRF("end", my1, my2, your, float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); writeJSONRF("end", float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
} else { } else {
LogMessage("D-Star, received RF end of transmission from %8.8s/%4.4s to %8.8s, %.1f seconds, BER: %.1f%%", my1, my2, your, float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits)); LogMessage("D-Star, received RF end of transmission from %8.8s/%4.4s to %8.8s, %.1f seconds, BER: %.1f%%", my1, my2, your, float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits));
writeJSONRF("end", my1, my2, your, float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("end", float(m_rfFrames) / 50.0F, float(m_rfErrs * 100U) / float(m_rfBits));
} }
writeEndRF(); writeEndRF();
@@ -795,7 +795,7 @@ void CDStarControl::writeNetwork()
// We've received the header and EOT haven't we? // We've received the header and EOT haven't we?
m_netFrames += 2U; m_netFrames += 2U;
LogMessage("D-Star, received network end of transmission from %8.8s/%4.4s to %8.8s, %.1f seconds, %u%% packet loss", my1, my2, your, float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames); LogMessage("D-Star, received network end of transmission from %8.8s/%4.4s to %8.8s, %.1f seconds, %u%% packet loss", my1, my2, your, float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames);
writeJSONNet("end", my1, my2, your, float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames); writeJSONNet("end", float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames);
writeEndNet(); writeEndNet();
} else if (type == TAG_DATA) { } else if (type == TAG_DATA) {
@@ -877,7 +877,7 @@ void CDStarControl::clock()
m_netFrames += 1U; m_netFrames += 1U;
LogMessage("D-Star, network watchdog has expired, %.1f seconds, %u%% packet loss", float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames); LogMessage("D-Star, network watchdog has expired, %.1f seconds, %u%% packet loss", float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames);
writeJSONNet("lost", my1, my2, your, float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames); writeJSONNet("lost", float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames);
writeEndNet(); writeEndNet();
#if defined(DUMP_DSTAR) #if defined(DUMP_DSTAR)
closeFile(); closeFile();
@@ -1347,35 +1347,36 @@ void CDStarControl::writeJSONRF(const char* action, const unsigned char* my1, co
nlohmann::json json; nlohmann::json json;
writeJSONRF(json, action, my1, my2, your); json["timestamp"] = CUtils::createTimestamp();
json["source_cs"] = convertBuffer(my1, DSTAR_LONG_CALLSIGN_LENGTH);
json["source_ext"] = convertBuffer(my2, DSTAR_SHORT_CALLSIGN_LENGTH);
json["destination_cs"] = convertBuffer(your, DSTAR_LONG_CALLSIGN_LENGTH);
json["source"] = "rf";
json["action"] = action;
WriteJSON("D-Star", json); WriteJSON("D-Star", json);
} }
void CDStarControl::writeJSONRF(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, float duration, float ber) void CDStarControl::writeJSONRF(const char* action, float duration, float ber)
{ {
assert(action != NULL); assert(action != NULL);
assert(my1 != NULL);
assert(my2 != NULL);
assert(your != NULL);
nlohmann::json json; nlohmann::json json;
writeJSONRF(json, action, my1, my2, your, duration, ber); writeJSONRF(json, action, duration, ber);
WriteJSON("D-Star", json); WriteJSON("D-Star", json);
} }
void CDStarControl::writeJSONRF(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI) void CDStarControl::writeJSONRF(const char* action, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI)
{ {
assert(action != NULL); assert(action != NULL);
assert(my1 != NULL);
assert(my2 != NULL);
assert(your != NULL);
nlohmann::json json; nlohmann::json json;
writeJSONRF(json, action, my1, my2, your, duration, ber); writeJSONRF(json, action, duration, ber);
nlohmann::json rssi; nlohmann::json rssi;
rssi["min"] = -int(minRSSI); rssi["min"] = -int(minRSSI);
@@ -1396,7 +1397,14 @@ void CDStarControl::writeJSONNet(const char* action, const unsigned char* my1, c
nlohmann::json json; nlohmann::json json;
writeJSONNet(json, action, my1, my2, your); json["timestamp"] = CUtils::createTimestamp();
json["source_cs"] = convertBuffer(my1, DSTAR_LONG_CALLSIGN_LENGTH);
json["source_ext"] = convertBuffer(my2, DSTAR_SHORT_CALLSIGN_LENGTH);
json["destination_cs"] = convertBuffer(your, DSTAR_LONG_CALLSIGN_LENGTH);
json["source"] = "network";
json["action"] = action;
if (reflector != NULL) if (reflector != NULL)
json["reflector"] = convertBuffer(reflector, DSTAR_LONG_CALLSIGN_LENGTH); json["reflector"] = convertBuffer(reflector, DSTAR_LONG_CALLSIGN_LENGTH);
@@ -1404,67 +1412,33 @@ void CDStarControl::writeJSONNet(const char* action, const unsigned char* my1, c
WriteJSON("D-Star", json); WriteJSON("D-Star", json);
} }
void CDStarControl::writeJSONNet(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, float duration, float loss) void CDStarControl::writeJSONNet(const char* action, float duration, float loss)
{ {
assert(action != NULL); assert(action != NULL);
assert(my1 != NULL);
assert(my2 != NULL);
assert(your != NULL);
nlohmann::json json; nlohmann::json json;
writeJSONNet(json, action, my1, my2, your); json["timestamp"] = CUtils::createTimestamp();
json["duration"] = duration; json["duration"] = duration;
json["loss"] = loss; json["loss"] = loss;
json["source"] = "network";
json["action"] = action;
WriteJSON("D-Star", json); WriteJSON("D-Star", json);
} }
void CDStarControl::writeJSONRF(nlohmann::json& json, const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your) void CDStarControl::writeJSONRF(nlohmann::json& json, const char* action, float duration, float ber)
{ {
assert(action != NULL); assert(action != NULL);
assert(my1 != NULL);
assert(my2 != NULL);
assert(your != NULL);
json["timestamp"] = CUtils::createTimestamp(); json["timestamp"] = CUtils::createTimestamp();
json["source_cs"] = convertBuffer(my1, DSTAR_LONG_CALLSIGN_LENGTH);
json["source_ext"] = convertBuffer(my2, DSTAR_SHORT_CALLSIGN_LENGTH);
json["destination_cs"] = convertBuffer(your, DSTAR_LONG_CALLSIGN_LENGTH);
json["source"] = "rf";
json["action"] = action;
}
void CDStarControl::writeJSONRF(nlohmann::json& json, const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, float duration, float ber)
{
assert(action != NULL);
assert(my1 != NULL);
assert(my2 != NULL);
assert(your != NULL);
writeJSONRF(json, action, my1, my2, your);
json["duration"] = duration; json["duration"] = duration;
json["ber"] = ber; json["ber"] = ber;
}
void CDStarControl::writeJSONNet(nlohmann::json& json, const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your) json["source"] = "rf";
{
assert(action != NULL);
assert(my1 != NULL);
assert(my2 != NULL);
assert(your != NULL);
json["timestamp"] = CUtils::createTimestamp();
json["source_cs"] = convertBuffer(my1, DSTAR_LONG_CALLSIGN_LENGTH);
json["source_ext"] = convertBuffer(my2, DSTAR_SHORT_CALLSIGN_LENGTH);
json["destination_cs"] = convertBuffer(your, DSTAR_LONG_CALLSIGN_LENGTH);
json["source"] = "network";
json["action"] = action; json["action"] = action;
} }

View File

@@ -136,14 +136,12 @@ private:
void writeEndNet(); void writeEndNet();
void writeJSONRF(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your); void writeJSONRF(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your);
void writeJSONRF(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, float duration, float ber); void writeJSONRF(const char* action, float duration, float ber);
void writeJSONRF(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI); void writeJSONRF(const char* action, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI);
void writeJSONNet(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, const unsigned char* reflector = NULL); void writeJSONNet(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, const unsigned char* reflector = NULL);
void writeJSONNet(const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, float duration, float loss); void writeJSONNet(const char* action, float duration, float loss);
void writeJSONRF(nlohmann::json& json, const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your); void writeJSONRF(nlohmann::json& json, const char* action, float duration, float ber);
void writeJSONRF(nlohmann::json& json, const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, float duration, float ber);
void writeJSONNet(nlohmann::json& json, const char* action, const unsigned char* my1, const unsigned char* my2, const unsigned char* your);
std::string convertBuffer(const unsigned char* buffer, unsigned int length) const; std::string convertBuffer(const unsigned char* buffer, unsigned int length) const;

View File

@@ -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 (type == TAG_LOST && (m_rfState == RS_RF_AUDIO || m_rfState == RS_RF_DATA_AUDIO)) {
if (m_rssi != 0U) { 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); 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);
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); writeJSONRF("lost", float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
} else { } 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)); 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));
writeJSONRF("lost", m_rfState, m_source, m_dest, float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("lost", float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits));
} }
writeEndRF(); writeEndRF();
return false; return false;
@@ -423,10 +423,10 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
if (m_rssi != 0U) { 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); 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);
writeJSONRF("end", m_rfState, m_source, m_dest, float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("end", float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits));
} else { } 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)); 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));
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); writeJSONRF("end", float(m_rfFrames) / 25.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
} }
writeEndRF(); writeEndRF();
@@ -646,7 +646,7 @@ void CM17Control::writeNetwork()
uint16_t fn = (netData[28U] << 8) + (netData[29U] << 0); uint16_t fn = (netData[28U] << 8) + (netData[29U] << 0);
if ((fn & 0x8000U) == 0x8000U) { 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); 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);
writeJSONNet("end", m_netState, m_source, m_dest, float(m_netFrames) / 25.0F); writeJSONNet("end", float(m_netFrames) / 25.0F);
unsigned char data[M17_FRAME_LENGTH_BYTES + 2U]; unsigned char data[M17_FRAME_LENGTH_BYTES + 2U];
@@ -781,7 +781,7 @@ void CM17Control::clock(unsigned int ms)
if (m_networkWatchdog.hasExpired()) { if (m_networkWatchdog.hasExpired()) {
LogMessage("M17, network watchdog has expired, %.1f seconds", float(m_netFrames) / 25.0F); LogMessage("M17, network watchdog has expired, %.1f seconds", float(m_netFrames) / 25.0F);
writeJSONNet("lost", m_netState, m_source, m_dest, float(m_netFrames) / 25.0F); writeJSONNet("lost", float(m_netFrames) / 25.0F);
writeEndNet(); writeEndNet();
} }
} }
@@ -936,24 +936,24 @@ void CM17Control::writeJSONRF(const char* action, RPT_RF_STATE state, const std:
WriteJSON("M17", json); WriteJSON("M17", json);
} }
void CM17Control::writeJSONRF(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, float duration, float ber)
{ {
assert(action != NULL); assert(action != NULL);
nlohmann::json json; nlohmann::json json;
writeJSONRF(json, action, state, source, dest, duration, ber); writeJSONRF(json, action, duration, ber);
WriteJSON("M17", json); WriteJSON("M17", json);
} }
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) void CM17Control::writeJSONRF(const char* action, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI)
{ {
assert(action != NULL); assert(action != NULL);
nlohmann::json json; nlohmann::json json;
writeJSONRF(json, action, state, source, dest, duration, ber); writeJSONRF(json, action, duration, ber);
nlohmann::json rssi; nlohmann::json rssi;
rssi["min"] = -int(minRSSI); rssi["min"] = -int(minRSSI);
@@ -976,19 +976,29 @@ void CM17Control::writeJSONNet(const char* action, RPT_NET_STATE state, const st
WriteJSON("M17", json); WriteJSON("M17", json);
} }
void CM17Control::writeJSONNet(const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest, float duration) void CM17Control::writeJSONNet(const char* action, float duration)
{ {
assert(action != NULL); assert(action != NULL);
nlohmann::json json; nlohmann::json json;
writeJSONNet(json, action, state, source, dest); writeJSONNet(json, action);
json["duration"] = duration; json["duration"] = duration;
WriteJSON("M17", json); WriteJSON("M17", json);
} }
void CM17Control::writeJSONRF(nlohmann::json& json, const char* action)
{
assert(action != NULL);
json["timestamp"] = CUtils::createTimestamp();
json["source"] = "rf";
json["action"] = action;
}
void CM17Control::writeJSONRF(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); assert(action != NULL);
@@ -1017,16 +1027,26 @@ void CM17Control::writeJSONRF(nlohmann::json& json, const char* action, RPT_RF_S
} }
} }
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) void CM17Control::writeJSONRF(nlohmann::json& json, const char* action, float duration, float ber)
{ {
assert(action != NULL); assert(action != NULL);
writeJSONRF(json, action, state, source, dest); writeJSONRF(json, action);
json["duration"] = duration; json["duration"] = duration;
json["ber"] = ber; json["ber"] = ber;
} }
void CM17Control::writeJSONNet(nlohmann::json& json, const char* action)
{
assert(action != NULL);
json["timestamp"] = CUtils::createTimestamp();
json["source"] = "network";
json["action"] = action;
}
void CM17Control::writeJSONNet(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); assert(action != NULL);

View File

@@ -106,14 +106,16 @@ private:
void writeEndNet(); void writeEndNet();
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);
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, 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 writeJSONRF(const char* action, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI);
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);
void writeJSONNet(const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest, float duration); void writeJSONNet(const char* action, 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);
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 writeJSONRF(nlohmann::json& json, const char* action);
void writeJSONRF(nlohmann::json& json, const char* action, float duration, float ber);
void writeJSONNet(nlohmann::json& json, const char* action);
void writeJSONNet(nlohmann::json& json, const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest); void writeJSONNet(nlohmann::json& json, const char* action, RPT_NET_STATE state, const std::string& source, const std::string& dest);
bool openFile(); bool openFile();

View File

@@ -100,10 +100,10 @@ bool CNXDNControl::writeModem(unsigned char *data, unsigned int len)
if (m_rssi != 0U) { if (m_rssi != 0U) {
LogMessage("NXDN, transmission lost from %s to %s%u, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); LogMessage("NXDN, transmission lost from %s to %s%u, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
writeJSONRF("lost", srcId, source, grp, dstId, float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); writeJSONRF("lost", float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
} else { } else {
LogMessage("NXDN, transmission lost from %s to %s%u, %.1f seconds, BER: %.1f%%", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits)); LogMessage("NXDN, transmission lost from %s to %s%u, %.1f seconds, BER: %.1f%%", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits));
writeJSONRF("lost", srcId, source, grp, dstId, float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("lost", float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits));
} }
writeEndRF(); writeEndRF();
return false; return false;
@@ -275,10 +275,10 @@ bool CNXDNControl::processVoice(unsigned char usc, unsigned char option, unsigne
m_rfFrames++; m_rfFrames++;
if (m_rssi != 0U) { if (m_rssi != 0U) {
LogMessage("NXDN, received RF end of transmission from %s to %s%u, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); LogMessage("NXDN, received RF end of transmission from %s to %s%u, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
writeJSONRF("end", srcId, source, grp, dstId, float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); writeJSONRF("end", float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
} else { } else {
LogMessage("NXDN, received RF end of transmission from %s to %s%u, %.1f seconds, BER: %.1f%%", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits)); LogMessage("NXDN, received RF end of transmission from %s to %s%u, %.1f seconds, BER: %.1f%%", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits));
writeJSONRF("end", srcId, source, grp, dstId, float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("end", float(m_rfFrames) / 12.5F, float(m_rfErrs * 100U) / float(m_rfBits));
} }
writeEndRF(); writeEndRF();
} else { } else {
@@ -688,7 +688,7 @@ bool CNXDNControl::processData(unsigned char option, unsigned char *data)
std::string source = m_lookup->find(srcId); std::string source = m_lookup->find(srcId);
LogMessage("NXDN, ended RF data transmission from %s to %s%u", source.c_str(), grp ? "TG " : "", dstId); LogMessage("NXDN, ended RF data transmission from %s to %s%u", source.c_str(), grp ? "TG " : "", dstId);
writeJSONNet("end", srcId, source, grp, dstId); writeJSONNet("end");
writeEndRF(); writeEndRF();
} }
@@ -858,7 +858,7 @@ void CNXDNControl::writeNetwork()
if (type == NXDN_MESSAGE_TYPE_TX_REL) { if (type == NXDN_MESSAGE_TYPE_TX_REL) {
m_netFrames++; m_netFrames++;
LogMessage("NXDN, received network end of transmission from %s to %s%u, %.1f seconds", source.get(keyCALLSIGN).c_str(), grp ? "TG " : "", dstId, float(m_netFrames) / 12.5F); LogMessage("NXDN, received network end of transmission from %s to %s%u, %.1f seconds", source.get(keyCALLSIGN).c_str(), grp ? "TG " : "", dstId, float(m_netFrames) / 12.5F);
writeJSONNet("end", srcId, source.get(keyCALLSIGN), grp, dstId, float(m_netFrames) / 12.5F); writeJSONNet("end", float(m_netFrames) / 12.5F);
writeEndNet(); writeEndNet();
} else if (type == NXDN_MESSAGE_TYPE_VCALL) { } 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); LogMessage("NXDN, received network transmission from %s to %s%u", source.get(keyCALLSIGN).c_str(), grp ? "TG " : "", dstId);
@@ -1016,15 +1016,8 @@ void CNXDNControl::clock(unsigned int ms)
m_networkWatchdog.clock(ms); m_networkWatchdog.clock(ms);
if (m_networkWatchdog.hasExpired()) { if (m_networkWatchdog.hasExpired()) {
unsigned short srcId = m_netLayer3.getSourceUnitId();
unsigned short dstId = m_netLayer3.getDestinationGroupId();
bool grp = m_netLayer3.getIsGroup();
class CUserDBentry source;
m_lookup->findWithName(srcId, &source);
LogMessage("NXDN, network watchdog has expired, %.1f seconds", float(m_netFrames) / 12.5F); LogMessage("NXDN, network watchdog has expired, %.1f seconds", float(m_netFrames) / 12.5F);
writeJSONNet("lost", srcId, source.get(keyCALLSIGN), grp, dstId, float(m_netFrames) / 12.5F); writeJSONNet("lost", float(m_netFrames) / 12.5F);
writeEndNet(); writeEndNet();
} }
} }
@@ -1177,13 +1170,13 @@ void CNXDNControl::writeJSONRF(const char* action, unsigned short srcId, const s
WriteJSON("NXDN", json); WriteJSON("NXDN", json);
} }
void CNXDNControl::writeJSONRF(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId, float duration, float ber) void CNXDNControl::writeJSONRF(const char* action, float duration, float ber)
{ {
assert(action != NULL); assert(action != NULL);
nlohmann::json json; nlohmann::json json;
writeJSON(json, "rf", action, srcId, srcInfo, grp, dstId); writeJSON(json, "rf", action);
json["duration"] = duration; json["duration"] = duration;
json["ber"] = ber; json["ber"] = ber;
@@ -1191,13 +1184,13 @@ void CNXDNControl::writeJSONRF(const char* action, unsigned short srcId, const s
WriteJSON("NXDN", json); WriteJSON("NXDN", json);
} }
void CNXDNControl::writeJSONRF(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI) void CNXDNControl::writeJSONRF(const char* action, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI)
{ {
assert(action != NULL); assert(action != NULL);
nlohmann::json json; nlohmann::json json;
writeJSON(json, "rf", action, srcId, srcInfo, grp, dstId); writeJSON(json, "rf", action);
json["duration"] = duration; json["duration"] = duration;
json["ber"] = ber; json["ber"] = ber;
@@ -1212,6 +1205,17 @@ void CNXDNControl::writeJSONRF(const char* action, unsigned short srcId, const s
WriteJSON("NXDN", json); WriteJSON("NXDN", json);
} }
void CNXDNControl::writeJSONNet(const char* action)
{
assert(action != NULL);
nlohmann::json json;
writeJSON(json, "network", action);
WriteJSON("NXDN", json);
}
void CNXDNControl::writeJSONNet(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId) void CNXDNControl::writeJSONNet(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId)
{ {
assert(action != NULL); assert(action != NULL);
@@ -1236,19 +1240,29 @@ void CNXDNControl::writeJSONNet(const char* action, unsigned short srcId, const
WriteJSON("NXDN", json); WriteJSON("NXDN", json);
} }
void CNXDNControl::writeJSONNet(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId, float duration) void CNXDNControl::writeJSONNet(const char* action, float duration)
{ {
assert(action != NULL); assert(action != NULL);
nlohmann::json json; nlohmann::json json;
writeJSON(json, "network", action, srcId, srcInfo, grp, dstId); writeJSON(json, "network", action);
json["duration"] = duration; json["duration"] = duration;
WriteJSON("NXDN", json); WriteJSON("NXDN", json);
} }
void CNXDNControl::writeJSON(nlohmann::json& json, const char* source, const char* action)
{
assert(source != NULL);
assert(action != NULL);
json["timestamp"] = CUtils::createTimestamp();
json["source"] = source;
json["action"] = action;
}
void CNXDNControl::writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId) void CNXDNControl::writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId)
{ {
assert(source != NULL); assert(source != NULL);

View File

@@ -104,13 +104,15 @@ private:
void closeFile(); void closeFile();
void writeJSONRF(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId); void writeJSONRF(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId);
void writeJSONRF(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId, float duration, float ber); void writeJSONRF(const char* action, float duration, float ber);
void writeJSONRF(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI); void writeJSONRF(const char* action, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI);
void writeJSONNet(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId); void writeJSONNet(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId);
void writeJSONNet(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId, unsigned char frames); void writeJSONNet(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId, unsigned char frames);
void writeJSONNet(const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId, float duration); void writeJSONNet(const char* action);
void writeJSONNet(const char* action, float duration);
void writeJSON(nlohmann::json& json, const char* source, const char* action);
void writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId); void writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned short srcId, const std::string& srcInfo, bool grp, unsigned short dstId);
}; };

View File

@@ -129,10 +129,10 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
if (m_rssi != 0U) { if (m_rssi != 0U) {
LogMessage("P25, transmission lost from %s to %s%u, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); LogMessage("P25, transmission lost from %s to %s%u, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
writeJSONRF("lost", srcId, source, grp, dstId, float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); writeJSONRF("lost", float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
} else { } else {
LogMessage("P25, transmission lost from %s to %s%u, %.1f seconds, BER: %.1f%%", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits)); LogMessage("P25, transmission lost from %s to %s%u, %.1f seconds, BER: %.1f%%", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits));
writeJSONRF("lost", srcId, source, grp, dstId, float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("lost", float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits));
} }
if (m_netState == RS_NET_IDLE) if (m_netState == RS_NET_IDLE)
@@ -470,10 +470,10 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
if (m_rssi != 0U) { if (m_rssi != 0U) {
LogMessage("P25, received RF end of voice transmission from %s to %s%u, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); LogMessage("P25, received RF end of voice transmission from %s to %s%u, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
writeJSONRF("end", srcId, source, grp, dstId, float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); writeJSONRF("end", float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
} else { } else {
LogMessage("P25, received RF end of voice transmission from %s to %s%u, %.1f seconds, BER: %.1f%%", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits)); LogMessage("P25, received RF end of voice transmission from %s to %s%u, %.1f seconds, BER: %.1f%%", source.c_str(), grp ? "TG " : "", dstId, float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits));
writeJSONRF("end", srcId, source, grp, dstId, float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("end", float(m_rfFrames) / 5.56F, float(m_rfErrs * 100U) / float(m_rfBits));
} }
m_display->clearP25(); m_display->clearP25();
@@ -734,12 +734,8 @@ void CP25Control::clock(unsigned int ms)
m_networkWatchdog.clock(ms); m_networkWatchdog.clock(ms);
if (m_networkWatchdog.hasExpired()) { if (m_networkWatchdog.hasExpired()) {
unsigned int dstId = m_netData.getDstId();
unsigned int srcId = m_netData.getSrcId();
std::string source = m_lookup->find(srcId);
LogMessage("P25, network watchdog has expired, %.1f seconds, %u%% packet loss", float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames); LogMessage("P25, network watchdog has expired, %.1f seconds, %u%% packet loss", float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames);
writeJSONNet("lost", srcId, source, m_netData.getLCF() == P25_LCF_GROUP, dstId, float(m_netFrames) / 50.0F, float(m_netLost * 100U) / float(m_netFrames)); writeJSONNet("lost", float(m_netFrames) / 50.0F, float(m_netLost * 100U) / float(m_netFrames));
m_display->clearP25(); m_display->clearP25();
m_networkWatchdog.stop(); m_networkWatchdog.stop();
@@ -1141,7 +1137,7 @@ void CP25Control::createNetTerminator()
std::string source = m_lookup->find(srcId); std::string source = m_lookup->find(srcId);
LogMessage("P25, network end of transmission from %s to %s%u, %.1f seconds, %u%% packet loss", source.c_str(), m_netData.getLCF() == P25_LCF_GROUP ? "TG " : "", dstId, float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames); LogMessage("P25, network end of transmission from %s to %s%u, %.1f seconds, %u%% packet loss", source.c_str(), m_netData.getLCF() == P25_LCF_GROUP ? "TG " : "", dstId, float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames);
writeJSONNet("end", srcId, source, m_netData.getLCF() == P25_LCF_GROUP, dstId, float(m_netFrames) / 50.0F, float(m_netLost * 100U) / float(m_netFrames)); writeJSONNet("end", float(m_netFrames) / 50.0F, float(m_netLost * 100U) / float(m_netFrames));
m_display->clearP25(); m_display->clearP25();
m_netTimeout.stop(); m_netTimeout.stop();
@@ -1228,13 +1224,13 @@ void CP25Control::writeJSONRF(const char* action, unsigned int srcId, const std:
WriteJSON("P25", json); WriteJSON("P25", json);
} }
void CP25Control::writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, float duration, float ber) void CP25Control::writeJSONRF(const char* action, float duration, float ber)
{ {
assert(action != NULL); assert(action != NULL);
nlohmann::json json; nlohmann::json json;
writeJSON(json, "rf", action, srcId, srcInfo, grp, dstId); writeJSON(json, "rf", action);
json["duration"] = duration; json["duration"] = duration;
json["ber"] = ber; json["ber"] = ber;
@@ -1242,13 +1238,13 @@ void CP25Control::writeJSONRF(const char* action, unsigned int srcId, const std:
WriteJSON("P25", json); WriteJSON("P25", json);
} }
void CP25Control::writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI) void CP25Control::writeJSONRF(const char* action, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI)
{ {
assert(action != NULL); assert(action != NULL);
nlohmann::json json; nlohmann::json json;
writeJSON(json, "rf", action, srcId, srcInfo, grp, dstId); writeJSON(json, "rf", action);
json["duration"] = duration; json["duration"] = duration;
json["ber"] = ber; json["ber"] = ber;
@@ -1274,13 +1270,13 @@ void CP25Control::writeJSONNet(const char* action, unsigned int srcId, const std
WriteJSON("P25", json); WriteJSON("P25", json);
} }
void CP25Control::writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, float duration, float loss) void CP25Control::writeJSONNet(const char* action, float duration, float loss)
{ {
assert(action != NULL); assert(action != NULL);
nlohmann::json json; nlohmann::json json;
writeJSON(json, "network", action, srcId, srcInfo, grp, dstId); writeJSON(json, "network", action);
json["duration"] = duration; json["duration"] = duration;
json["loss"] = loss; json["loss"] = loss;
@@ -1288,6 +1284,16 @@ void CP25Control::writeJSONNet(const char* action, unsigned int srcId, const std
WriteJSON("P25", json); WriteJSON("P25", json);
} }
void CP25Control::writeJSON(nlohmann::json& json, const char* source, const char* action)
{
assert(source != NULL);
assert(action != NULL);
json["timestamp"] = CUtils::createTimestamp();
json["source"] = source;
json["action"] = action;
}
void CP25Control::writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId) void CP25Control::writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId)
{ {
assert(source != NULL); assert(source != NULL);

View File

@@ -122,12 +122,13 @@ private:
void closeFile(); void closeFile();
void writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId); void writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId);
void writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, float duration, float ber); void writeJSONRF(const char* action, float duration, float ber);
void writeJSONRF(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI); void writeJSONRF(const char* action, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI);
void writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId); void writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId);
void writeJSONNet(const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId, float duration, float loss); void writeJSONNet(const char* action, float duration, float loss);
void writeJSON(nlohmann::json& json, const char* source, const char* action);
void writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId); void writeJSON(nlohmann::json& json, const char* source, const char* action, unsigned int srcId, const std::string& srcInfo, bool grp, unsigned int dstId);
}; };

View File

@@ -105,15 +105,14 @@ bool CYSFControl::writeModem(unsigned char *data, unsigned int len)
return false; return false;
unsigned char type = data[0U]; unsigned char type = data[0U];
unsigned char dgid = m_lastFICH.getDGId();
if (type == TAG_LOST && m_rfState == RS_RF_AUDIO) { if (type == TAG_LOST && m_rfState == RS_RF_AUDIO) {
if (m_rssi != 0U) { 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); 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);
writeJSONRF("lost", 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", float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
} else { } 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)); 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));
writeJSONRF("lost", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("lost", float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
} }
writeEndRF(); writeEndRF();
return false; return false;
@@ -324,10 +323,10 @@ bool CYSFControl::processVWData(bool valid, unsigned char *data)
if (m_rssi != 0U) { 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); 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);
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); writeJSONRF("end", float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
} else { } 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)); 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));
writeJSONRF("end", "voice_vw", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("end", float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
} }
writeEndRF(); writeEndRF();
@@ -498,10 +497,10 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data)
if (m_rssi != 0U) { 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); 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);
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); writeJSONRF("end", float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
} else { } 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)); 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));
writeJSONRF("end", "voice_dn", m_rfSource, dgid, float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits)); writeJSONRF("end", float(m_rfFrames) / 10.0F, float(m_rfErrs * 100U) / float(m_rfBits));
} }
writeEndRF(); writeEndRF();
@@ -803,10 +802,10 @@ bool CYSFControl::processFRData(bool valid, unsigned char *data)
if (m_rssi != 0U) { 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); 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);
writeJSONRF("end", "data_fr", m_rfSource, dgid, float(m_rfFrames) / 10.0F, 0.0F, m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount); writeJSONRF("end", float(m_rfFrames) / 10.0F, 0.0F, m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
} else { } 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); LogMessage("YSF, received RF end of transmission from %10.10s to DG-ID %u, %.1f seconds", m_rfSource, dgid, float(m_rfFrames) / 10.0F);
writeJSONRF("end", "data_fr", m_rfSource, dgid, float(m_rfFrames) / 10.0F, 0.0F); writeJSONRF("end", float(m_rfFrames) / 10.0F, 0.0F);
} }
writeEndRF(); writeEndRF();
@@ -1064,7 +1063,7 @@ void CYSFControl::writeNetwork()
if (end) { 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); 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);
writeJSONNet("end", m_netSource, dgid, data + 4U, float(m_netFrames) / 10.0F, (m_netLost * 100U) / m_netFrames); writeJSONNet("end", float(m_netFrames) / 10.0F, (m_netLost * 100U) / m_netFrames);
writeEndNet(); writeEndNet();
} }
} }
@@ -1081,9 +1080,8 @@ void CYSFControl::clock(unsigned int ms)
m_networkWatchdog.clock(ms); m_networkWatchdog.clock(ms);
if (m_networkWatchdog.hasExpired()) { 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); LogMessage("YSF, network watchdog has expired, %.1f seconds, %u%% packet loss", float(m_netFrames) / 10.0F, (m_netLost * 100U) / m_netFrames);
writeJSONNet("lost", m_netSource, dgid, float(m_netFrames) / 10.0F, (m_netLost * 100U) / m_netFrames); writeJSONNet("lost", float(m_netFrames) / 10.0F, (m_netLost * 100U) / m_netFrames);
writeEndNet(); writeEndNet();
} }
} }
@@ -1263,14 +1261,13 @@ void CYSFControl::writeJSONRF(const char* action, const char* mode, const unsign
WriteJSON("YSF", json); WriteJSON("YSF", json);
} }
void CYSFControl::writeJSONRF(const char* action, const unsigned char* source, unsigned char dgid, float duration, float ber) void CYSFControl::writeJSONRF(const char* action, float duration, float ber)
{ {
assert(action != NULL); assert(action != NULL);
assert(source != NULL);
nlohmann::json json; nlohmann::json json;
writeJSONRF(json, action, source, dgid); writeJSONRF(json, action);
json["duration"] = duration; json["duration"] = duration;
json["ber"] = ber; json["ber"] = ber;
@@ -1278,56 +1275,14 @@ void CYSFControl::writeJSONRF(const char* action, const unsigned char* source, u
WriteJSON("YSF", json); WriteJSON("YSF", json);
} }
void CYSFControl::writeJSONRF(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, float duration, float ber) void CYSFControl::writeJSONRF(const char* action, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI)
{ {
assert(action != NULL); assert(action != NULL);
assert(mode != NULL);
assert(source != NULL);
nlohmann::json json; nlohmann::json json;
writeJSONRF(json, action, source, dgid); writeJSONRF(json, action);
json["mode"] = mode;
json["duration"] = duration;
json["ber"] = ber;
WriteJSON("YSF", json);
}
void CYSFControl::writeJSONRF(const char* action, const unsigned char* source, unsigned char dgid, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI)
{
assert(action != NULL);
assert(source != NULL);
nlohmann::json json;
writeJSONRF(json, action, source, dgid);
json["duration"] = duration;
json["ber"] = ber;
nlohmann::json rssi;
rssi["min"] = -int(minRSSI);
rssi["max"] = -int(maxRSSI);
rssi["ave"] = -int(aveRSSI);
json["rssi"] = rssi;
WriteJSON("YSF", json);
}
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);
assert(source != NULL);
nlohmann::json json;
writeJSONRF(json, action, source, dgid);
json["mode"] = mode;
json["duration"] = duration; json["duration"] = duration;
json["ber"] = ber; json["ber"] = ber;
@@ -1356,14 +1311,13 @@ void CYSFControl::writeJSONNet(const char* action, const unsigned char* source,
WriteJSON("YSF", json); WriteJSON("YSF", json);
} }
void CYSFControl::writeJSONNet(const char* action, const unsigned char* source, unsigned char dgid, float duration, unsigned int loss) void CYSFControl::writeJSONNet(const char* action, float duration, unsigned int loss)
{ {
assert(action != NULL); assert(action != NULL);
assert(source != NULL);
nlohmann::json json; nlohmann::json json;
writeJSONNet(json, action, source, dgid); writeJSONNet(json, action);
json["duration"] = duration; json["duration"] = duration;
json["loss"] = loss; json["loss"] = loss;
@@ -1371,22 +1325,14 @@ void CYSFControl::writeJSONNet(const char* action, const unsigned char* source,
WriteJSON("YSF", json); WriteJSON("YSF", json);
} }
void CYSFControl::writeJSONNet(const char* action, const unsigned char* source, unsigned char dgid, const unsigned char* reflector, float duration, unsigned int loss) void CYSFControl::writeJSONRF(nlohmann::json& json, const char* action)
{ {
assert(action != NULL); assert(action != NULL);
assert(source != NULL);
assert(reflector != NULL);
nlohmann::json json; json["timestamp"] = CUtils::createTimestamp();
writeJSONNet(json, action, source, dgid); json["source"] = "rf";
json["action"] = action;
json["reflector"] = convertBuffer(reflector);
json["duration"] = duration;
json["loss"] = loss;
WriteJSON("YSF", json);
} }
void CYSFControl::writeJSONRF(nlohmann::json& json, const char* action, const unsigned char* source, unsigned char dgid) void CYSFControl::writeJSONRF(nlohmann::json& json, const char* action, const unsigned char* source, unsigned char dgid)
@@ -1403,6 +1349,16 @@ void CYSFControl::writeJSONRF(nlohmann::json& json, const char* action, const un
json["dg-id"] = int(dgid); json["dg-id"] = int(dgid);
} }
void CYSFControl::writeJSONNet(nlohmann::json& json, const char* action)
{
assert(action != NULL);
json["timestamp"] = CUtils::createTimestamp();
json["source"] = "network";
json["action"] = action;
}
void CYSFControl::writeJSONNet(nlohmann::json& json, const char* action, const unsigned char* source, unsigned char dgid) void CYSFControl::writeJSONNet(nlohmann::json& json, const char* action, const unsigned char* source, unsigned char dgid)
{ {
assert(action != NULL); assert(action != NULL);

View File

@@ -103,16 +103,16 @@ private:
void writeEndNet(); void writeEndNet();
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);
void writeJSONRF(const char* action, const unsigned char* source, unsigned char dgid, float duration, float ber); void writeJSONRF(const char* action, float duration, float ber);
void writeJSONRF(const char* action, const char* mode, const unsigned char* source, unsigned char dgid, float duration, float ber); void writeJSONRF(const char* action, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI);
void writeJSONRF(const char* action, const unsigned char* source, unsigned char dgid, float duration, float ber, unsigned char minRSSI, unsigned char maxRSSI, unsigned int aveRSSI);
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 writeJSONNet(const char* action, const unsigned char* source, unsigned char dgid, const unsigned char* reflector); void writeJSONNet(const char* action, const unsigned char* source, unsigned char dgid, const unsigned char* reflector);
void writeJSONNet(const char* action, const unsigned char* source, unsigned char dgid, float duration, unsigned int loss); void writeJSONNet(const char* action, float duration, unsigned int loss);
void writeJSONNet(const char* action, const unsigned char* source, unsigned char dgid, const unsigned char* reflector, float duration, unsigned int loss);
void writeJSONRF(nlohmann::json& json, const char* action);
void writeJSONRF(nlohmann::json& json, const char* action, const unsigned char* source, unsigned char dgid); void writeJSONRF(nlohmann::json& json, const char* action, const unsigned char* source, unsigned char dgid);
void writeJSONNet(nlohmann::json& json, const char* action);
void writeJSONNet(nlohmann::json& json, const char* action, const unsigned char* source, unsigned char dgid); void writeJSONNet(nlohmann::json& json, const char* action, const unsigned char* source, unsigned char dgid);
std::string convertBuffer(const unsigned char* buffer) const; std::string convertBuffer(const unsigned char* buffer) const;

View File

@@ -56,7 +56,7 @@
"max": {"$ref": "#/$defs/rssi"}, "max": {"$ref": "#/$defs/rssi"},
"ave": {"$ref": "#/$defs/rssi"} "ave": {"$ref": "#/$defs/rssi"}
}, },
"required": ["timestamp", "source_cs", "source_ext", "destination_cs", "source", "action"] "required": ["timestamp", "source", "action"]
}, },
"DMR": { "DMR": {
@@ -79,7 +79,7 @@
"max": {"$ref": "#/$defs/rssi"}, "max": {"$ref": "#/$defs/rssi"},
"ave": {"$ref": "#/$defs/rssi"} "ave": {"$ref": "#/$defs/rssi"}
}, },
"required": ["timestamp", "source_id", "destination_id", "destination_type", "slot", "source", "action"] "required": ["timestamp", "slot", "source", "action"]
}, },
"YSF": { "YSF": {
@@ -99,7 +99,7 @@
"max": {"$ref": "#/$defs/rssi"}, "max": {"$ref": "#/$defs/rssi"},
"ave": {"$ref": "#/$defs/rssi"} "ave": {"$ref": "#/$defs/rssi"}
}, },
"required": ["timestamp", "source_cs", "dg-id", "source", "action"] "required": ["timestamp", "source", "action"]
}, },
"P25": { "P25": {
@@ -119,7 +119,7 @@
"max": {"$ref": "#/$defs/rssi"}, "max": {"$ref": "#/$defs/rssi"},
"ave": {"$ref": "#/$defs/rssi"} "ave": {"$ref": "#/$defs/rssi"}
}, },
"required": ["timestamp", "source_id", "destination_id", "destination_type", "source", "action"] "required": ["timestamp", "source", "action"]
}, },
"NXDN": { "NXDN": {
@@ -138,7 +138,7 @@
"max": {"$ref": "#/$defs/rssi"}, "max": {"$ref": "#/$defs/rssi"},
"ave": {"$ref": "#/$defs/rssi"} "ave": {"$ref": "#/$defs/rssi"}
}, },
"required": ["timestamp", "source_id", "destination_id", "destination_type", "source", "action"] "required": ["timestamp", "source", "action"]
}, },
"POCSAG": { "POCSAG": {
@@ -190,6 +190,6 @@
"max": {"$ref": "#/$defs/rssi"}, "max": {"$ref": "#/$defs/rssi"},
"ave": {"$ref": "#/$defs/rssi"} "ave": {"$ref": "#/$defs/rssi"}
}, },
"required": ["timestamp", "source_cs", "destination_cs", "source", "action", "traffic_type"] "required": ["timestamp", "source", "action"]
} }
} }