diff --git a/host/Host.cpp b/host/Host.cpp index 1b719b16..2d2680e1 100644 --- a/host/Host.cpp +++ b/host/Host.cpp @@ -1042,8 +1042,13 @@ int Host::run() setMode(HOST_STATE_QUIT); - delete dmr; - delete p25; + if (dmr != NULL) { + delete dmr; + } + + if (p25 != NULL) { + delete p25; + } return EXIT_SUCCESS; } @@ -1482,8 +1487,10 @@ void Host::setMode(uint8_t mode) m_modeTimer.stop(); if (m_mode == HOST_STATE_QUIT) { - m_modem->close(); - delete m_modem; + if (m_modem != NULL) { + m_modem->close(); + delete m_modem; + } if (m_tidLookup != NULL) { m_tidLookup->stop(); diff --git a/host/calibrate/HostCal.cpp b/host/calibrate/HostCal.cpp index 8b4bc494..c18b825f 100644 --- a/host/calibrate/HostCal.cpp +++ b/host/calibrate/HostCal.cpp @@ -1834,25 +1834,25 @@ void HostCal::printDebug(const uint8_t* buffer, uint32_t length) } else if (buffer[2U] == CMD_DEBUG2) { short val1 = (buffer[length - 2U] << 8) | buffer[length - 1U]; - LogMessage(LOG_MODEM, "M: %.*s %d", length - 5U, buffer + 3U, val1); + LogMessage(LOG_MODEM, "M: %.*s %X", length - 5U, buffer + 3U, val1); } else if (buffer[2U] == CMD_DEBUG3) { short val1 = (buffer[length - 4U] << 8) | buffer[length - 3U]; short val2 = (buffer[length - 2U] << 8) | buffer[length - 1U]; - LogMessage(LOG_MODEM, "M: %.*s %d %d", length - 7U, buffer + 3U, val1, val2); + LogMessage(LOG_MODEM, "M: %.*s %X %X", length - 7U, buffer + 3U, val1, val2); } else if (buffer[2U] == CMD_DEBUG4) { short val1 = (buffer[length - 6U] << 8) | buffer[length - 5U]; short val2 = (buffer[length - 4U] << 8) | buffer[length - 3U]; short val3 = (buffer[length - 2U] << 8) | buffer[length - 1U]; - LogMessage(LOG_MODEM, "M: %.*s %d %d %d", length - 9U, buffer + 3U, val1, val2, val3); + LogMessage(LOG_MODEM, "M: %.*s %X %X %X", length - 9U, buffer + 3U, val1, val2, val3); } else if (buffer[2U] == CMD_DEBUG5) { short val1 = (buffer[length - 8U] << 8) | buffer[length - 7U]; short val2 = (buffer[length - 6U] << 8) | buffer[length - 5U]; short val3 = (buffer[length - 4U] << 8) | buffer[length - 3U]; short val4 = (buffer[length - 2U] << 8) | buffer[length - 1U]; - LogMessage(LOG_MODEM, "M: %.*s %d %d %d %d", length - 11U, buffer + 3U, val1, val2, val3, val4); + LogMessage(LOG_MODEM, "M: %.*s %X %X %X %X", length - 11U, buffer + 3U, val1, val2, val3, val4); } } diff --git a/modem/Modem.cpp b/modem/Modem.cpp index d58d7997..79990a5f 100644 --- a/modem/Modem.cpp +++ b/modem/Modem.cpp @@ -1332,25 +1332,25 @@ void Modem::printDebug() } else if (m_buffer[2U] == CMD_DEBUG2) { short val1 = (m_buffer[m_length - 2U] << 8) | m_buffer[m_length - 1U]; - LogDebug(LOG_MODEM, "M: %.*s %d", m_length - 5U, m_buffer + 3U, val1); + LogDebug(LOG_MODEM, "M: %.*s %X", m_length - 5U, m_buffer + 3U, val1); } else if (m_buffer[2U] == CMD_DEBUG3) { short val1 = (m_buffer[m_length - 4U] << 8) | m_buffer[m_length - 3U]; short val2 = (m_buffer[m_length - 2U] << 8) | m_buffer[m_length - 1U]; - LogDebug(LOG_MODEM, "M: %.*s %d %d", m_length - 7U, m_buffer + 3U, val1, val2); + LogDebug(LOG_MODEM, "M: %.*s %X %X", m_length - 7U, m_buffer + 3U, val1, val2); } else if (m_buffer[2U] == CMD_DEBUG4) { short val1 = (m_buffer[m_length - 6U] << 8) | m_buffer[m_length - 5U]; short val2 = (m_buffer[m_length - 4U] << 8) | m_buffer[m_length - 3U]; short val3 = (m_buffer[m_length - 2U] << 8) | m_buffer[m_length - 1U]; - LogDebug(LOG_MODEM, "M: %.*s %d %d %d", m_length - 9U, m_buffer + 3U, val1, val2, val3); + LogDebug(LOG_MODEM, "M: %.*s %X %X %X", m_length - 9U, m_buffer + 3U, val1, val2, val3); } else if (m_buffer[2U] == CMD_DEBUG5) { short val1 = (m_buffer[m_length - 8U] << 8) | m_buffer[m_length - 7U]; short val2 = (m_buffer[m_length - 6U] << 8) | m_buffer[m_length - 5U]; short val3 = (m_buffer[m_length - 4U] << 8) | m_buffer[m_length - 3U]; short val4 = (m_buffer[m_length - 2U] << 8) | m_buffer[m_length - 1U]; - LogDebug(LOG_MODEM, "M: %.*s %d %d %d %d", m_length - 11U, m_buffer + 3U, val1, val2, val3, val4); + LogDebug(LOG_MODEM, "M: %.*s %X %X %X %X", m_length - 11U, m_buffer + 3U, val1, val2, val3, val4); } } diff --git a/p25/Control.cpp b/p25/Control.cpp index 18f6ccf5..7410f948 100644 --- a/p25/Control.cpp +++ b/p25/Control.cpp @@ -212,6 +212,7 @@ void Control::setOptions(yaml::Node& conf, const std::string cwCallsign, const s m_voiceOnControl = p25Protocol["voiceOnControl"].as(false); m_ackTSBKRequests = control["ackRequests"].as(true); + m_trunk->setServiceClass(m_control, m_voiceOnControl); m_voice->m_silenceThreshold = p25Protocol["silenceThreshold"].as(p25::DEFAULT_SILENCE_THRESHOLD); diff --git a/p25/TrunkPacket.cpp b/p25/TrunkPacket.cpp index e34a61c3..5698c8cc 100644 --- a/p25/TrunkPacket.cpp +++ b/p25/TrunkPacket.cpp @@ -194,6 +194,29 @@ void TrunkPacket::setSiteChCnt(uint8_t chCnt) m_netTSBK.setSiteChCnt(chCnt); } +/// +/// Sets the service class for this site. +/// +/// +/// +void TrunkPacket::setServiceClass(bool control, bool voiceOnControl) +{ + uint8_t serviceClass = P25_SVC_CLS_VOICE | P25_SVC_CLS_DATA; + if (control) { + serviceClass |= P25_SVC_CLS_REG; + } + + if (voiceOnControl) { + serviceClass |= P25_SVC_CLS_COMPOSITE; + } + + m_rfTSBK.setServiceClass(serviceClass); + m_netTSBK.setServiceClass(serviceClass); + + m_rfTDULC.setServiceClass(serviceClass); + m_netTDULC.setServiceClass(serviceClass); +} + /// /// Resets the data states for the RF interface. /// @@ -797,6 +820,9 @@ bool TrunkPacket::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, d case TSBK_OSP_U_DEREG_ACK: // ignore a network user deregistration command break; + case TSBK_OSP_LOC_REG_RSP: + // ignore a network location registration command + break; case TSBK_OSP_DENY_RSP: if (m_verbose) { LogMessage(LOG_NET, P25_TSDU_STR ", TSBK_OSP_DENY_RSP (Deny Response), AIV = %u, reason = $%02X, srcId = %u, dstId = %u", diff --git a/p25/TrunkPacket.h b/p25/TrunkPacket.h index 0345281d..bbba38be 100644 --- a/p25/TrunkPacket.h +++ b/p25/TrunkPacket.h @@ -69,6 +69,8 @@ namespace p25 void setNetActive(bool active); /// Sets the total number of channels at the site. void setSiteChCnt(uint8_t chCnt); + /// Sets the service class for this site. + void setServiceClass(bool control, bool voiceOnControl); /// Resets the data states for the RF interface. void resetRF(); diff --git a/p25/lc/TDULC.cpp b/p25/lc/TDULC.cpp index 95e13bbd..8a022c53 100644 --- a/p25/lc/TDULC.cpp +++ b/p25/lc/TDULC.cpp @@ -56,6 +56,7 @@ TDULC::TDULC() : m_mfId(P25_MFG_STANDARD), m_srcId(0U), m_dstId(0U), + m_serviceClass(P25_SVC_CLS_VOICE | P25_SVC_CLS_DATA), m_emergency(false), m_encrypted(false), m_priority(4U), @@ -370,8 +371,7 @@ void TDULC::encodeLC(uint8_t* rs) rsValue = (rsValue << 8) + m_adjSiteId; // Site ID rsValue = (rsValue << 4) + m_adjChannelId; // Channel ID rsValue = (rsValue << 12) + m_adjChannelNo; // Channel Number - rsValue = (rsValue << 8) + // System Service Class - (P25_SVC_CLS_COMPOSITE | P25_SVC_CLS_VOICE | P25_SVC_CLS_DATA | P25_SVC_CLS_REG); + rsValue = (rsValue << 8) + m_serviceClass; // System Service Class } else { LogError(LOG_P25, "invalid values for LC_ADJ_STS_BCAST, tsbkAdjSiteRFSSId = $%02X, tsbkAdjSiteId = $%02X, tsbkAdjSiteChannel = $%02X", @@ -388,8 +388,7 @@ void TDULC::encodeLC(uint8_t* rs) rsValue = (rsValue << 8) + m_siteData.siteId(); // Site ID rsValue = (rsValue << 4) + m_siteData.channelId(); // Channel ID rsValue = (rsValue << 12) + m_siteData.channelNo(); // Channel Number - rsValue = (rsValue << 8) + // System Service Class - (P25_SVC_CLS_COMPOSITE | P25_SVC_CLS_VOICE | P25_SVC_CLS_DATA | P25_SVC_CLS_REG); + rsValue = (rsValue << 8) + m_serviceClass; // System Service Class break; case LC_NET_STS_BCAST: rs[0U] |= 0x40U; // Implicit Operation @@ -398,8 +397,7 @@ void TDULC::encodeLC(uint8_t* rs) rsValue = (rsValue << 12) + m_siteData.sysId(); // System ID rsValue = (rsValue << 4) + m_siteData.channelId(); // Channel ID rsValue = (rsValue << 12) + m_siteData.channelNo(); // Channel Number - rsValue = (rsValue << 8) + // System Service Class - (P25_SVC_CLS_COMPOSITE | P25_SVC_CLS_VOICE | P25_SVC_CLS_DATA | P25_SVC_CLS_REG); + rsValue = (rsValue << 8) + m_serviceClass; // System Service Class break; default: LogError(LOG_P25, "unknown LC value, mfId = $%02X, lco = $%02X", m_mfId, m_lco); diff --git a/p25/lc/TDULC.h b/p25/lc/TDULC.h index 0ec3cd60..f01acd77 100644 --- a/p25/lc/TDULC.h +++ b/p25/lc/TDULC.h @@ -96,6 +96,9 @@ namespace p25 /// Destination ID. __PROPERTY(uint32_t, dstId, DstId); + /// Service class. + __PROPERTY(uint8_t, serviceClass, ServiceClass); + /// Voice channel number. __PROPERTY(uint32_t, grpVchNo, GrpVchNo); diff --git a/p25/lc/TSBK.cpp b/p25/lc/TSBK.cpp index 12ae981a..3775015d 100644 --- a/p25/lc/TSBK.cpp +++ b/p25/lc/TSBK.cpp @@ -58,6 +58,7 @@ TSBK::TSBK() : m_lastBlock(false), m_aivFlag(true), m_extendedAddrFlag(false), + m_serviceClass(P25_SVC_CLS_VOICE | P25_SVC_CLS_DATA), m_emergency(false), m_encrypted(false), m_priority(4U), @@ -445,12 +446,10 @@ void TSBK::encode(uint8_t * data, bool singleBlock) tsbkValue = (tsbkValue << 12) + m_sccbChannelNo; // Channel (R) Number if (m_sccbChannelId1 > 0) { - tsbkValue = (tsbkValue << 8) + // System Service Class - (P25_SVC_CLS_COMPOSITE | P25_SVC_CLS_VOICE | P25_SVC_CLS_DATA | P25_SVC_CLS_REG); + tsbkValue = (tsbkValue << 8) + m_serviceClass; // System Service Class } else { - tsbkValue = (tsbkValue << 8) + // System Service Class - (P25_SVC_CLS_INVALID); + tsbkValue = (tsbkValue << 8) + (P25_SVC_CLS_INVALID); // System Service Class } break; case TSBK_OSP_GRP_AFF_Q: @@ -513,21 +512,17 @@ void TSBK::encode(uint8_t * data, bool singleBlock) tsbkValue = (tsbkValue << 8) + m_siteData.siteId(); // Site ID tsbkValue = (tsbkValue << 16) + m_sccbChannelId1; // SCCB Channel ID 1 if (m_sccbChannelId1 > 0) { - tsbkValue = (tsbkValue << 8) + // System Service Class - (P25_SVC_CLS_COMPOSITE | P25_SVC_CLS_VOICE | P25_SVC_CLS_DATA | P25_SVC_CLS_REG); + tsbkValue = (tsbkValue << 8) + m_serviceClass; // System Service Class } else { - tsbkValue = (tsbkValue << 8) + // System Service Class - (P25_SVC_CLS_INVALID); + tsbkValue = (tsbkValue << 8) + (P25_SVC_CLS_INVALID); // System Service Class } tsbkValue = (tsbkValue << 16) + m_sccbChannelId2; // SCCB Channel ID 2 if (m_sccbChannelId2 > 0) { - tsbkValue = (tsbkValue << 8) + // System Service Class - (P25_SVC_CLS_COMPOSITE | P25_SVC_CLS_VOICE | P25_SVC_CLS_DATA | P25_SVC_CLS_REG); + tsbkValue = (tsbkValue << 8) + m_serviceClass; // System Service Class } else { - tsbkValue = (tsbkValue << 8) + // System Service Class - (P25_SVC_CLS_INVALID); + tsbkValue = (tsbkValue << 8) + (P25_SVC_CLS_INVALID); // System Service Class } break; case TSBK_OSP_RFSS_STS_BCAST: @@ -539,8 +534,7 @@ void TSBK::encode(uint8_t * data, bool singleBlock) tsbkValue = (tsbkValue << 8) + m_siteData.siteId(); // Site ID tsbkValue = (tsbkValue << 4) + m_siteData.channelId(); // Channel ID tsbkValue = (tsbkValue << 12) + m_siteData.channelNo(); // Channel Number - tsbkValue = (tsbkValue << 8) + // System Service Class - (P25_SVC_CLS_COMPOSITE | P25_SVC_CLS_VOICE | P25_SVC_CLS_DATA | P25_SVC_CLS_REG); + tsbkValue = (tsbkValue << 8) + m_serviceClass; // System Service Class break; case TSBK_OSP_NET_STS_BCAST: tsbkValue = m_siteData.lra(); // Location Registration Area @@ -548,8 +542,7 @@ void TSBK::encode(uint8_t * data, bool singleBlock) tsbkValue = (tsbkValue << 12) + m_siteData.sysId(); // System ID tsbkValue = (tsbkValue << 4) + m_siteData.channelId(); // Channel ID tsbkValue = (tsbkValue << 12) + m_siteData.channelNo(); // Channel Number - tsbkValue = (tsbkValue << 8) + // System Service Class - (P25_SVC_CLS_COMPOSITE | P25_SVC_CLS_VOICE | P25_SVC_CLS_DATA | P25_SVC_CLS_REG); + tsbkValue = (tsbkValue << 8) + m_serviceClass; // System Service Class break; case TSBK_OSP_ADJ_STS_BCAST: { @@ -565,8 +558,7 @@ void TSBK::encode(uint8_t * data, bool singleBlock) tsbkValue = (tsbkValue << 8) + m_adjSiteId; // Site ID tsbkValue = (tsbkValue << 4) + m_adjChannelId; // Channel ID tsbkValue = (tsbkValue << 12) + m_adjChannelNo; // Channel Number - tsbkValue = (tsbkValue << 8) + // System Service Class - (P25_SVC_CLS_COMPOSITE | P25_SVC_CLS_VOICE | P25_SVC_CLS_DATA | P25_SVC_CLS_REG); + tsbkValue = (tsbkValue << 8) + m_serviceClass; // System Service Class } else { LogError(LOG_P25, "invalid values for OSP_ADJ_STS_BCAST, adjRfssId = $%02X, adjSiteId = $%02X, adjChannelId = %u, adjChannelNo = $%02X", diff --git a/p25/lc/TSBK.h b/p25/lc/TSBK.h index 73dd34e7..54b748b2 100644 --- a/p25/lc/TSBK.h +++ b/p25/lc/TSBK.h @@ -113,6 +113,9 @@ namespace p25 /// Service type. __PROPERTY(uint8_t, service, Service); + /// Service class. + __PROPERTY(uint8_t, serviceClass, ServiceClass); + /// Response type. __PROPERTY(uint8_t, response, Response);