add support to report host status JSON blob to FNE for storage in InfluxDB;

3.6-maint
Bryan Biedenkapp 2 years ago
parent 5a3e031247
commit 2c560dc3ce

@ -69,6 +69,8 @@ network:
allowActivityTransfer: true allowActivityTransfer: true
# Flag indicating whether or not the host diagnostic log will be sent to the network. # Flag indicating whether or not the host diagnostic log will be sent to the network.
allowDiagnosticTransfer: true allowDiagnosticTransfer: true
# Flag indicating whether or not the host status will be sent to the network.
allowStatusTransfer: true
# Flag indicating whether or not verbose debug logging is enabled. # Flag indicating whether or not verbose debug logging is enabled.
debug: false debug: false

@ -129,7 +129,6 @@ bool BaseNetwork::writeGrantReq(const uint8_t mode, const uint32_t srcId, const
/// Writes the local activity log to the network. /// Writes the local activity log to the network.
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
/// <param name="useAlternatePort"></param>
/// <returns></returns> /// <returns></returns>
bool BaseNetwork::writeActLog(const char* message) bool BaseNetwork::writeActLog(const char* message)
{ {
@ -154,7 +153,6 @@ bool BaseNetwork::writeActLog(const char* message)
/// Writes the local diagnostics log to the network. /// Writes the local diagnostics log to the network.
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
/// <param name="useAlternatePort"></param>
/// <returns></returns> /// <returns></returns>
bool BaseNetwork::writeDiagLog(const char* message) bool BaseNetwork::writeDiagLog(const char* message)
{ {
@ -175,6 +173,34 @@ bool BaseNetwork::writeDiagLog(const char* message)
0U, 0U, false, m_useAlternatePortForDiagnostics); 0U, 0U, false, m_useAlternatePortForDiagnostics);
} }
/// <summary>
/// Writes the local status to the network.
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
bool BaseNetwork::writePeerStatus(json::object obj)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
return false;
if (!m_allowActivityTransfer)
return false;
if (!m_useAlternatePortForDiagnostics)
return false; // this is intentional -- peer status is a noisy message and it shouldn't be done
// when the FNE is configured for main port transfers
json::value v = json::value(obj);
std::string json = std::string(v.serialize());
char buffer[DATA_PACKET_LENGTH];
uint32_t len = ::strlen(json.c_str());
::strcpy(buffer + 11U, json.c_str());
return writeMaster({ NET_FUNC_TRANSFER, NET_TRANSFER_SUBFUNC_STATUS }, (uint8_t*)buffer, (uint32_t)len + 12U,
0U, 0U, false, m_useAlternatePortForDiagnostics);
}
/// <summary> /// <summary>
/// Writes a group affiliation to the network. /// Writes a group affiliation to the network.
/// </summary> /// </summary>

@ -23,6 +23,7 @@
#include "common/p25/Audio.h" #include "common/p25/Audio.h"
#include "common/nxdn/lc/RTCH.h" #include "common/nxdn/lc/RTCH.h"
#include "common/network/FrameQueue.h" #include "common/network/FrameQueue.h"
#include "common/network/json/json.h"
#include "common/network/udp/Socket.h" #include "common/network/udp/Socket.h"
#include "common/RingBuffer.h" #include "common/RingBuffer.h"
#include "common/Utils.h" #include "common/Utils.h"
@ -53,6 +54,7 @@
#define TAG_TRANSFER "TRNS" #define TAG_TRANSFER "TRNS"
#define TAG_TRANSFER_ACT_LOG "TRNSLOG" #define TAG_TRANSFER_ACT_LOG "TRNSLOG"
#define TAG_TRANSFER_DIAG_LOG "TRNSDIAG" #define TAG_TRANSFER_DIAG_LOG "TRNSDIAG"
#define TAG_TRANSFER_STATUS "TRNSSTS"
#define TAG_ANNOUNCE "ANNC" #define TAG_ANNOUNCE "ANNC"
@ -103,6 +105,7 @@ namespace network
const uint8_t NET_FUNC_TRANSFER = 0x90U; // Network Transfer Function const uint8_t NET_FUNC_TRANSFER = 0x90U; // Network Transfer Function
const uint8_t NET_TRANSFER_SUBFUNC_ACTIVITY = 0x01U; // Activity Log Transfer const uint8_t NET_TRANSFER_SUBFUNC_ACTIVITY = 0x01U; // Activity Log Transfer
const uint8_t NET_TRANSFER_SUBFUNC_DIAG = 0x02U; // Diagnostic Log Transfer const uint8_t NET_TRANSFER_SUBFUNC_DIAG = 0x02U; // Diagnostic Log Transfer
const uint8_t NET_TRANSFER_SUBFUNC_STATUS = 0x03U; // Status Transfer
const uint8_t NET_FUNC_ANNOUNCE = 0x91U; // Network Announce Function const uint8_t NET_FUNC_ANNOUNCE = 0x91U; // Network Announce Function
const uint8_t NET_ANNC_SUBFUNC_GRP_AFFIL = 0x00U; // Announce Group Affiliation const uint8_t NET_ANNC_SUBFUNC_GRP_AFFIL = 0x00U; // Announce Group Affiliation
@ -178,6 +181,9 @@ namespace network
/// <summary>Writes the local diagnostic logs to the network.</summary> /// <summary>Writes the local diagnostic logs to the network.</summary>
virtual bool writeDiagLog(const char* message); virtual bool writeDiagLog(const char* message);
/// <summary>Writes the local status to the network.</summary>
virtual bool writePeerStatus(json::object obj);
/// <summary>Writes a group affiliation to the network.</summary> /// <summary>Writes a group affiliation to the network.</summary>
virtual bool announceGroupAffiliation(uint32_t srcId, uint32_t dstId); virtual bool announceGroupAffiliation(uint32_t srcId, uint32_t dstId);
/// <summary>Writes a unit registration to the network.</summary> /// <summary>Writes a unit registration to the network.</summary>

@ -280,6 +280,36 @@ void* DiagNetwork::threadedNetworkRx(void* arg)
} }
} }
} }
else if (req->fneHeader.getSubFunction() == NET_TRANSFER_SUBFUNC_STATUS) { // Peer Status Transfer
// report peer status to InfluxDB
if (network->m_enableInfluxDB) {
if (peerId > 0 && (network->m_peers.find(peerId) != network->m_peers.end())) {
FNEPeerConnection* connection = network->m_peers[peerId];
if (connection != nullptr) {
std::string ip = udp::Socket::address(req->address);
// validate peer (simple validation really)
if (connection->connected() && connection->address() == ip) {
uint8_t rawPayload[req->length - 11U];
::memset(rawPayload, 0x00U, req->length - 11U);
::memcpy(rawPayload, req->buffer + 11U, req->length - 11U);
std::string payload(rawPayload, rawPayload + (req->length - 11U));
influxdb::QueryBuilder()
.meas("peer_status")
.tag("peerId", std::to_string(peerId))
.field("identity", connection->identity())
.field("status", payload)
.timestamp(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch()).count())
.request(network->m_influxServer);
}
else {
network->writePeerNAK(peerId, TAG_TRANSFER_STATUS, NET_CONN_NAK_FNE_UNAUTHORIZED);
}
}
}
}
}
else { else {
network->writePeerNAK(peerId, TAG_TRANSFER, NET_CONN_NAK_ILLEGAL_PACKET); network->writePeerNAK(peerId, TAG_TRANSFER, NET_CONN_NAK_ILLEGAL_PACKET);
Utils::dump("unknown transfer opcode from the peer", req->buffer, req->length); Utils::dump("unknown transfer opcode from the peer", req->buffer, req->length);

@ -1036,6 +1036,9 @@ void* FNENetwork::threadedNetworkRx(void* arg)
} }
} }
} }
else if (req->fneHeader.getSubFunction() == NET_TRANSFER_SUBFUNC_STATUS) { // Peer Status Transfer
// main traffic port status transfers aren't supported for performance reasons
}
else { else {
network->writePeerNAK(peerId, TAG_TRANSFER, NET_CONN_NAK_ILLEGAL_PACKET); network->writePeerNAK(peerId, TAG_TRANSFER, NET_CONN_NAK_ILLEGAL_PACKET);
Utils::dump("unknown transfer opcode from the peer", req->buffer, req->length); Utils::dump("unknown transfer opcode from the peer", req->buffer, req->length);

@ -693,10 +693,13 @@ bool Host::createNetwork()
bool slot2 = networkConf["slot2"].as<bool>(true); bool slot2 = networkConf["slot2"].as<bool>(true);
bool allowActivityTransfer = networkConf["allowActivityTransfer"].as<bool>(false); bool allowActivityTransfer = networkConf["allowActivityTransfer"].as<bool>(false);
bool allowDiagnosticTransfer = networkConf["allowDiagnosticTransfer"].as<bool>(false); bool allowDiagnosticTransfer = networkConf["allowDiagnosticTransfer"].as<bool>(false);
bool allowStatusTransfer = networkConf["allowStatusTransfer"].as<bool>(true);
bool updateLookup = networkConf["updateLookups"].as<bool>(false); bool updateLookup = networkConf["updateLookups"].as<bool>(false);
bool saveLookup = networkConf["saveLookups"].as<bool>(false); bool saveLookup = networkConf["saveLookups"].as<bool>(false);
bool debug = networkConf["debug"].as<bool>(false); bool debug = networkConf["debug"].as<bool>(false);
m_allowStatusTransfer = allowStatusTransfer;
bool encrypted = networkConf["encrypted"].as<bool>(false); bool encrypted = networkConf["encrypted"].as<bool>(false);
std::string key = networkConf["presharedKey"].as<std::string>(); std::string key = networkConf["presharedKey"].as<std::string>();
uint8_t presharedKey[AES_WRAPPED_PCKT_KEY_LEN]; uint8_t presharedKey[AES_WRAPPED_PCKT_KEY_LEN];
@ -778,6 +781,7 @@ bool Host::createNetwork()
LogInfo(" Slot 2: %s", slot2 ? "enabled" : "disabled"); LogInfo(" Slot 2: %s", slot2 ? "enabled" : "disabled");
LogInfo(" Allow Activity Log Transfer: %s", allowActivityTransfer ? "yes" : "no"); LogInfo(" Allow Activity Log Transfer: %s", allowActivityTransfer ? "yes" : "no");
LogInfo(" Allow Diagnostic Log Transfer: %s", allowDiagnosticTransfer ? "yes" : "no"); LogInfo(" Allow Diagnostic Log Transfer: %s", allowDiagnosticTransfer ? "yes" : "no");
LogInfo(" Allow Status Transfer: %s", m_allowStatusTransfer ? "yes" : "no");
LogInfo(" Update Lookups: %s", updateLookup ? "yes" : "no"); LogInfo(" Update Lookups: %s", updateLookup ? "yes" : "no");
LogInfo(" Save Network Lookups: %s", saveLookup ? "yes" : "no"); LogInfo(" Save Network Lookups: %s", saveLookup ? "yes" : "no");

@ -75,6 +75,7 @@ Host::Host(const std::string& confFile) :
m_netModeHang(3U), m_netModeHang(3U),
m_lastDstId(0U), m_lastDstId(0U),
m_lastSrcId(0U), m_lastSrcId(0U),
m_allowStatusTransfer(true),
m_identity(), m_identity(),
m_cwCallsign(), m_cwCallsign(),
m_cwIdTime(0U), m_cwIdTime(0U),
@ -1035,13 +1036,14 @@ int Host::run()
if (g_killed) if (g_killed)
return; return;
Timer networkPeerStatusNotify(1000U, 5U);
networkPeerStatusNotify.start();
StopWatch stopWatch; StopWatch stopWatch;
stopWatch.start(); stopWatch.start();
LogDebug(LOG_HOST, "started adj. site and affiliation processor"); LogDebug(LOG_HOST, "started adj. site and affiliation processor");
while (!g_killed) { while (!g_killed) {
m_nxdnTxWatchdogTimer.start();
uint32_t ms = stopWatch.elapsed(); uint32_t ms = stopWatch.elapsed();
stopWatch.start(); stopWatch.start();
m_adjSiteLoopMS = ms; m_adjSiteLoopMS = ms;
@ -1053,6 +1055,15 @@ int Host::run()
if (nxdn != nullptr) if (nxdn != nullptr)
nxdn->clockSiteData(ms); nxdn->clockSiteData(ms);
if (m_allowStatusTransfer) {
networkPeerStatusNotify.clock(ms);
if (networkPeerStatusNotify.isRunning() && networkPeerStatusNotify.hasExpired()) {
networkPeerStatusNotify.start();
json::object statusObj = getStatus();
m_network->writePeerStatus(statusObj);
}
}
if (m_state != STATE_IDLE) if (m_state != STATE_IDLE)
Thread::sleep(m_activeTickDelay); Thread::sleep(m_activeTickDelay);
if (m_state == STATE_IDLE) if (m_state == STATE_IDLE)
@ -1683,6 +1694,141 @@ int Host::run()
// Private Class Members // Private Class Members
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/// <summary>
/// Helper to generate the status of the host in JSON format.
/// </summary>
json::object Host::getStatus()
{
json::object response = json::object();
yaml::Node systemConf = m_conf["system"];
yaml::Node networkConf = m_conf["network"];
{
response["state"].set<uint8_t>(m_state);
response["isTxCW"].set<bool>(m_isTxCW);
response["fixedMode"].set<bool>(m_fixedMode);
response["dmrTSCCEnable"].set<bool>(m_dmrTSCCData);
response["dmrCC"].set<bool>(m_dmrCtrlChannel);
response["p25CtrlEnable"].set<bool>(m_p25CCData);
response["p25CC"].set<bool>(m_p25CtrlChannel);
response["nxdnCtrlEnable"].set<bool>(m_nxdnCCData);
response["nxdnCC"].set<bool>(m_nxdnCtrlChannel);
yaml::Node p25Protocol = m_conf["protocols"]["p25"];
yaml::Node nxdnProtocol = m_conf["protocols"]["nxdn"];
response["tx"].set<bool>(m_modem->m_tx);
response["channelId"].set<uint8_t>(m_channelId);
response["channelNo"].set<uint32_t>(m_channelNo);
response["lastDstId"].set<uint32_t>(m_lastDstId);
response["lastSrcId"].set<uint32_t>(m_lastSrcId);
uint32_t peerId = networkConf["id"].as<uint32_t>();
response["peerId"].set<uint32_t>(peerId);
}
yaml::Node modemConfig = m_conf["system"]["modem"];
{
json::object modemInfo = json::object();
std::string portType = modemConfig["protocol"]["type"].as<std::string>();
modemInfo["portType"].set<std::string>(portType);
yaml::Node uartConfig = modemConfig["protocol"]["uart"];
std::string modemPort = uartConfig["port"].as<std::string>();
modemInfo["modemPort"].set<std::string>(modemPort);
uint32_t portSpeed = uartConfig["speed"].as<uint32_t>(115200U);
modemInfo["portSpeed"].set<uint32_t>(portSpeed);
if (!m_modem->isHotspot()) {
modemInfo["pttInvert"].set<bool>(m_modem->m_pttInvert);
modemInfo["rxInvert"].set<bool>(m_modem->m_rxInvert);
modemInfo["txInvert"].set<bool>(m_modem->m_txInvert);
modemInfo["dcBlocker"].set<bool>(m_modem->m_dcBlocker);
}
modemInfo["rxLevel"].set<float>(m_modem->m_rxLevel);
modemInfo["cwTxLevel"].set<float>(m_modem->m_cwIdTXLevel);
modemInfo["dmrTxLevel"].set<float>(m_modem->m_dmrTXLevel);
modemInfo["p25TxLevel"].set<float>(m_modem->m_p25TXLevel);
modemInfo["nxdnTxLevel"].set<float>(m_modem->m_nxdnTXLevel);
modemInfo["rxDCOffset"].set<int>(m_modem->m_rxDCOffset);
modemInfo["txDCOffset"].set<int>(m_modem->m_txDCOffset);
if (!m_modem->isHotspot()) {
modemInfo["dmrSymLevel3Adj"].set<int>(m_modem->m_dmrSymLevel3Adj);
modemInfo["dmrSymLevel1Adj"].set<int>(m_modem->m_dmrSymLevel1Adj);
modemInfo["p25SymLevel3Adj"].set<int>(m_modem->m_p25SymLevel3Adj);
modemInfo["p25SymLevel1Adj"].set<int>(m_modem->m_p25SymLevel1Adj);
// are we on a protocol version 3 firmware?
if (m_modem->getVersion() >= 3U) {
modemInfo["nxdnSymLevel3Adj"].set<int>(m_modem->m_nxdnSymLevel3Adj);
modemInfo["nxdnSymLevel1Adj"].set<int>(m_modem->m_nxdnSymLevel1Adj);
}
}
if (m_modem->isHotspot()) {
modemInfo["dmrDiscBW"].set<int8_t>(m_modem->m_dmrDiscBWAdj);
modemInfo["dmrPostBW"].set<int8_t>(m_modem->m_dmrPostBWAdj);
modemInfo["p25DiscBW"].set<int8_t>(m_modem->m_p25DiscBWAdj);
modemInfo["p25PostBW"].set<int8_t>(m_modem->m_p25PostBWAdj);
// are we on a protocol version 3 firmware?
if (m_modem->getVersion() >= 3U) {
modemInfo["nxdnDiscBW"].set<int8_t>(m_modem->m_nxdnDiscBWAdj);
modemInfo["nxdnPostBW"].set<int8_t>(m_modem->m_nxdnPostBWAdj);
modemInfo["afcEnabled"].set<bool>(m_modem->m_afcEnable);
modemInfo["afcKI"].set<uint8_t>(m_modem->m_afcKI);
modemInfo["afcKP"].set<uint8_t>(m_modem->m_afcKP);
modemInfo["afcRange"].set<uint8_t>(m_modem->m_afcRange);
}
switch (m_modem->m_adfGainMode) {
case ADF_GAIN_AUTO_LIN:
modemInfo["gainMode"].set<std::string>("ADF7021 Gain Mode: Auto High Linearity");
break;
case ADF_GAIN_LOW:
modemInfo["gainMode"].set<std::string>("ADF7021 Gain Mode: Low");
break;
case ADF_GAIN_HIGH:
modemInfo["gainMode"].set<std::string>("ADF7021 Gain Mode: High");
break;
case ADF_GAIN_AUTO:
default:
modemInfo["gainMode"].set<std::string>("ADF7021 Gain Mode: Auto");
break;
}
}
modemInfo["fdmaPreambles"].set<uint8_t>(m_modem->m_fdmaPreamble);
modemInfo["dmrRxDelay"].set<uint8_t>(m_modem->m_dmrRxDelay);
modemInfo["p25CorrCount"].set<uint8_t>(m_modem->m_p25CorrCount);
modemInfo["rxFrequency"].set<uint32_t>(m_modem->m_rxFrequency);
modemInfo["txFrequency"].set<uint32_t>(m_modem->m_txFrequency);
modemInfo["rxTuning"].set<int>(m_modem->m_rxTuning);
modemInfo["txTuning"].set<int>(m_modem->m_txTuning);
uint32_t rxFreqEffective = m_modem->m_rxFrequency + m_modem->m_rxTuning;
modemInfo["rxFrequencyEffective"].set<uint32_t>(rxFreqEffective);
uint32_t txFreqEffective = m_modem->m_txFrequency + m_modem->m_txTuning;
modemInfo["txFrequencyEffective"].set<uint32_t>(txFreqEffective);
uint8_t protoVer = m_modem->getVersion();
modemInfo["protoVer"].set<uint8_t>(protoVer);
response["modem"].set<json::object>(modemInfo);
}
return response;
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

@ -22,6 +22,7 @@
#include "common/lookups/IdenTableLookup.h" #include "common/lookups/IdenTableLookup.h"
#include "common/lookups/RadioIdLookup.h" #include "common/lookups/RadioIdLookup.h"
#include "common/lookups/TalkgroupRulesLookup.h" #include "common/lookups/TalkgroupRulesLookup.h"
#include "common/network/json/json.h"
#include "common/yaml/Yaml.h" #include "common/yaml/Yaml.h"
#include "dmr/Control.h" #include "dmr/Control.h"
#include "p25/Control.h" #include "p25/Control.h"
@ -91,6 +92,8 @@ private:
uint32_t m_lastDstId; uint32_t m_lastDstId;
uint32_t m_lastSrcId; uint32_t m_lastSrcId;
bool m_allowStatusTransfer;
std::string m_identity; std::string m_identity;
std::string m_cwCallsign; std::string m_cwCallsign;
uint32_t m_cwIdTime; uint32_t m_cwIdTime;
@ -171,6 +174,9 @@ private:
uint16_t m_restPort; uint16_t m_restPort;
RESTAPI *m_RESTAPI; RESTAPI *m_RESTAPI;
/// <summary>Helper to generate the status of the host in JSON format.</summary>
json::object getStatus();
/// <summary>Modem port open callback.</summary> /// <summary>Modem port open callback.</summary>
bool rmtPortModemOpen(modem::Modem* modem); bool rmtPortModemOpen(modem::Modem* modem);
/// <summary>Modem port close callback.</summary> /// <summary>Modem port close callback.</summary>

@ -54,6 +54,7 @@
// Class Prototypes // Class Prototypes
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
class HOST_SW_API Host;
class HOST_SW_API HostCal; class HOST_SW_API HostCal;
class HOST_SW_API RESTAPI; class HOST_SW_API RESTAPI;
@ -365,6 +366,7 @@ namespace modem
uint8_t getVersion() const; uint8_t getVersion() const;
private: private:
friend class ::Host;
friend class ::HostCal; friend class ::HostCal;
friend class ::RESTAPI; friend class ::RESTAPI;

@ -509,138 +509,16 @@ void RESTAPI::restAPI_GetStatus(const HTTPPayload& request, HTTPPayload& reply,
return; return;
} }
json::object response = json::object(); json::object response = m_host->getStatus();
setResponseDefaultStatus(response); setResponseDefaultStatus(response);
yaml::Node systemConf = m_host->m_conf["system"];
yaml::Node networkConf = m_host->m_conf["network"];
{ {
response["state"].set<uint8_t>(m_host->m_state);
bool dmrEnabled = m_dmr != nullptr; bool dmrEnabled = m_dmr != nullptr;
response["dmrEnabled"].set<bool>(dmrEnabled); response["dmrEnabled"].set<bool>(dmrEnabled);
bool p25Enabled = m_p25 != nullptr; bool p25Enabled = m_p25 != nullptr;
response["p25Enabled"].set<bool>(p25Enabled); response["p25Enabled"].set<bool>(p25Enabled);
bool nxdnEnabled = m_nxdn != nullptr; bool nxdnEnabled = m_nxdn != nullptr;
response["nxdnEnabled"].set<bool>(nxdnEnabled); response["nxdnEnabled"].set<bool>(nxdnEnabled);
response["isTxCW"].set<bool>(m_host->m_isTxCW);
response["fixedMode"].set<bool>(m_host->m_fixedMode);
response["dmrTSCCEnable"].set<bool>(m_host->m_dmrTSCCData);
response["dmrCC"].set<bool>(m_host->m_dmrCtrlChannel);
response["p25CtrlEnable"].set<bool>(m_host->m_p25CCData);
response["p25CC"].set<bool>(m_host->m_p25CtrlChannel);
response["nxdnCtrlEnable"].set<bool>(m_host->m_nxdnCCData);
response["nxdnCC"].set<bool>(m_host->m_nxdnCtrlChannel);
yaml::Node p25Protocol = m_host->m_conf["protocols"]["p25"];
yaml::Node nxdnProtocol = m_host->m_conf["protocols"]["nxdn"];
response["tx"].set<bool>(m_host->m_modem->m_tx);
response["channelId"].set<uint8_t>(m_host->m_channelId);
response["channelNo"].set<uint32_t>(m_host->m_channelNo);
response["lastDstId"].set<uint32_t>(m_host->m_lastDstId);
response["lastSrcId"].set<uint32_t>(m_host->m_lastSrcId);
uint32_t peerId = networkConf["id"].as<uint32_t>();
response["peerId"].set<uint32_t>(peerId);
}
yaml::Node modemConfig = m_host->m_conf["system"]["modem"];
{
json::object modemInfo = json::object();
std::string portType = modemConfig["protocol"]["type"].as<std::string>();
modemInfo["portType"].set<std::string>(portType);
yaml::Node uartConfig = modemConfig["protocol"]["uart"];
std::string modemPort = uartConfig["port"].as<std::string>();
modemInfo["modemPort"].set<std::string>(modemPort);
uint32_t portSpeed = uartConfig["speed"].as<uint32_t>(115200U);
modemInfo["portSpeed"].set<uint32_t>(portSpeed);
if (!m_host->m_modem->isHotspot()) {
modemInfo["pttInvert"].set<bool>(m_host->m_modem->m_pttInvert);
modemInfo["rxInvert"].set<bool>(m_host->m_modem->m_rxInvert);
modemInfo["txInvert"].set<bool>(m_host->m_modem->m_txInvert);
modemInfo["dcBlocker"].set<bool>(m_host->m_modem->m_dcBlocker);
}
modemInfo["rxLevel"].set<float>(m_host->m_modem->m_rxLevel);
modemInfo["cwTxLevel"].set<float>(m_host->m_modem->m_cwIdTXLevel);
modemInfo["dmrTxLevel"].set<float>(m_host->m_modem->m_dmrTXLevel);
modemInfo["p25TxLevel"].set<float>(m_host->m_modem->m_p25TXLevel);
modemInfo["nxdnTxLevel"].set<float>(m_host->m_modem->m_nxdnTXLevel);
modemInfo["rxDCOffset"].set<int>(m_host->m_modem->m_rxDCOffset);
modemInfo["txDCOffset"].set<int>(m_host->m_modem->m_txDCOffset);
if (!m_host->m_modem->isHotspot()) {
modemInfo["dmrSymLevel3Adj"].set<int>(m_host->m_modem->m_dmrSymLevel3Adj);
modemInfo["dmrSymLevel1Adj"].set<int>(m_host->m_modem->m_dmrSymLevel1Adj);
modemInfo["p25SymLevel3Adj"].set<int>(m_host->m_modem->m_p25SymLevel3Adj);
modemInfo["p25SymLevel1Adj"].set<int>(m_host->m_modem->m_p25SymLevel1Adj);
// are we on a protocol version 3 firmware?
if (m_host->m_modem->getVersion() >= 3U) {
modemInfo["nxdnSymLevel3Adj"].set<int>(m_host->m_modem->m_nxdnSymLevel3Adj);
modemInfo["nxdnSymLevel1Adj"].set<int>(m_host->m_modem->m_nxdnSymLevel1Adj);
}
}
if (m_host->m_modem->isHotspot()) {
modemInfo["dmrDiscBW"].set<int8_t>(m_host->m_modem->m_dmrDiscBWAdj);
modemInfo["dmrPostBW"].set<int8_t>(m_host->m_modem->m_dmrPostBWAdj);
modemInfo["p25DiscBW"].set<int8_t>(m_host->m_modem->m_p25DiscBWAdj);
modemInfo["p25PostBW"].set<int8_t>(m_host->m_modem->m_p25PostBWAdj);
// are we on a protocol version 3 firmware?
if (m_host->m_modem->getVersion() >= 3U) {
modemInfo["nxdnDiscBW"].set<int8_t>(m_host->m_modem->m_nxdnDiscBWAdj);
modemInfo["nxdnPostBW"].set<int8_t>(m_host->m_modem->m_nxdnPostBWAdj);
modemInfo["afcEnabled"].set<bool>(m_host->m_modem->m_afcEnable);
modemInfo["afcKI"].set<uint8_t>(m_host->m_modem->m_afcKI);
modemInfo["afcKP"].set<uint8_t>(m_host->m_modem->m_afcKP);
modemInfo["afcRange"].set<uint8_t>(m_host->m_modem->m_afcRange);
}
switch (m_host->m_modem->m_adfGainMode) {
case ADF_GAIN_AUTO_LIN:
modemInfo["gainMode"].set<std::string>("ADF7021 Gain Mode: Auto High Linearity");
break;
case ADF_GAIN_LOW:
modemInfo["gainMode"].set<std::string>("ADF7021 Gain Mode: Low");
break;
case ADF_GAIN_HIGH:
modemInfo["gainMode"].set<std::string>("ADF7021 Gain Mode: High");
break;
case ADF_GAIN_AUTO:
default:
modemInfo["gainMode"].set<std::string>("ADF7021 Gain Mode: Auto");
break;
}
}
modemInfo["fdmaPreambles"].set<uint8_t>(m_host->m_modem->m_fdmaPreamble);
modemInfo["dmrRxDelay"].set<uint8_t>(m_host->m_modem->m_dmrRxDelay);
modemInfo["p25CorrCount"].set<uint8_t>(m_host->m_modem->m_p25CorrCount);
modemInfo["rxFrequency"].set<uint32_t>(m_host->m_modem->m_rxFrequency);
modemInfo["txFrequency"].set<uint32_t>(m_host->m_modem->m_txFrequency);
modemInfo["rxTuning"].set<int>(m_host->m_modem->m_rxTuning);
modemInfo["txTuning"].set<int>(m_host->m_modem->m_txTuning);
uint32_t rxFreqEffective = m_host->m_modem->m_rxFrequency + m_host->m_modem->m_rxTuning;
modemInfo["rxFrequencyEffective"].set<uint32_t>(rxFreqEffective);
uint32_t txFreqEffective = m_host->m_modem->m_txFrequency + m_host->m_modem->m_txTuning;
modemInfo["txFrequencyEffective"].set<uint32_t>(txFreqEffective);
uint8_t protoVer = m_host->m_modem->getVersion();
modemInfo["protoVer"].set<uint8_t>(protoVer);
response["modem"].set<json::object>(modemInfo);
} }
reply.payload(response); reply.payload(response);

Loading…
Cancel
Save

Powered by TurnKey Linux.