diff --git a/src/sysview/PeerListWnd.h b/src/sysview/PeerListWnd.h index cf626e01..cb1ab657 100644 --- a/src/sysview/PeerListWnd.h +++ b/src/sysview/PeerListWnd.h @@ -155,36 +155,46 @@ public: } } - json::object peerConfig = peerObj["config"].get(); - std::string identity = peerConfig["identity"].getDefault(""); - std::string software = peerConfig["software"].getDefault(""); - - json::object channel = peerConfig["channel"].get(); - uint32_t chNo = (uint32_t)channel["channelNo"].getDefault(1); - uint8_t chId = channel["channelId"].getDefault(0U); - - g_peerIdentityNameMap[peerId] = std::string(identity); + std::string identity = "* UNK *"; + std::string software = "**INVALID**"; + uint32_t chNo = 0U; + uint8_t chId = 0U; std::ostringstream txOss; std::ostringstream rxOss; - if (chNo > 0U) { - IdenTable idenEntry = g_idenTable->find(chId); - if (idenEntry.baseFrequency() == 0U) { - ::LogError(LOG_HOST, "Channel Id %u has an invalid base frequency.", chId); - } - if (idenEntry.txOffsetMhz() == 0U) { - ::LogError(LOG_HOST, "Channel Id %u has an invalid Tx offset.", chId); - } + if (peerObj["config"].is()) { + json::object peerConfig = peerObj["config"].get(); + identity = peerConfig["identity"].getDefault("* UNK *"); + software = peerConfig["software"].getDefault("**INVALID**"); + + if (peerConfig["channel"].is()) { + json::object channel = peerConfig["channel"].get(); + uint32_t chNo = (uint32_t)channel["channelNo"].getDefault(1); + uint8_t chId = channel["channelId"].getDefault(0U); - uint32_t calcSpace = (uint32_t)(idenEntry.chSpaceKhz() / 0.125); - float calcTxOffset = idenEntry.txOffsetMhz() * 1000000.0; + g_peerIdentityNameMap[peerId] = std::string(identity); - uint32_t rxFrequency = (uint32_t)((idenEntry.baseFrequency() + ((calcSpace * 125) * chNo)) + (int32_t)calcTxOffset); - uint32_t txFrequency = (uint32_t)((idenEntry.baseFrequency() + ((calcSpace * 125) * chNo))); + if (chNo > 0U) { + IdenTable idenEntry = g_idenTable->find(chId); + if (idenEntry.baseFrequency() == 0U) { + ::LogError(LOG_HOST, "Channel Id %u has an invalid base frequency.", chId); + } - txOss << std::fixed << std::setprecision(5) << (double)(txFrequency / 1000000.0); - rxOss << std::fixed << std::setprecision(5) << (double)(rxFrequency / 1000000.0); + if (idenEntry.txOffsetMhz() == 0U) { + ::LogError(LOG_HOST, "Channel Id %u has an invalid Tx offset.", chId); + } + + uint32_t calcSpace = (uint32_t)(idenEntry.chSpaceKhz() / 0.125); + float calcTxOffset = idenEntry.txOffsetMhz() * 1000000.0; + + uint32_t rxFrequency = (uint32_t)((idenEntry.baseFrequency() + ((calcSpace * 125) * chNo)) + (int32_t)calcTxOffset); + uint32_t txFrequency = (uint32_t)((idenEntry.baseFrequency() + ((calcSpace * 125) * chNo))); + + txOss << std::fixed << std::setprecision(5) << (double)(txFrequency / 1000000.0); + rxOss << std::fixed << std::setprecision(5) << (double)(rxFrequency / 1000000.0); + } + } } // pad peer IDs properly @@ -278,7 +288,7 @@ private: m_listView.addColumn("CC Peer ID", 10); m_listView.addColumn("VC Count", 8); m_listView.addColumn("Connected", 5); - m_listView.addColumn("State", 15); + m_listView.addColumn("State", 18); m_listView.addColumn("Pings Received", 8); m_listView.addColumn("Ch. ID", 8); m_listView.addColumn("Ch. No", 8);