diff --git a/dmr/Slot.cpp b/dmr/Slot.cpp
index d108562a..d7a1c1d8 100644
--- a/dmr/Slot.cpp
+++ b/dmr/Slot.cpp
@@ -212,22 +212,21 @@ bool Slot::processFrame(uint8_t *data, uint32_t len)
bool voiceSync = (data[1U] & DMR_SYNC_VOICE) == DMR_SYNC_VOICE;
if (!(dataSync || voiceSync) && m_rfState == RS_RF_LISTENING) {
- if (m_verbose) {
- uint8_t sync[DMR_SYNC_LENGTH_BYTES];
- ::memcpy(sync, data + 2U, DMR_SYNC_LENGTH_BYTES);
+ uint8_t sync[DMR_SYNC_LENGTH_BYTES];
+ ::memcpy(sync, data + 2U, DMR_SYNC_LENGTH_BYTES);
- // count data sync errors
- uint8_t dataErrs = 0U;
- for (uint8_t i = 0U; i < DMR_SYNC_LENGTH_BYTES; i++)
- dataErrs += Utils::countBits8(sync[i] ^ DMR_MS_DATA_SYNC_BYTES[i]);
+ // count data sync errors
+ uint8_t dataErrs = 0U;
+ for (uint8_t i = 0U; i < DMR_SYNC_LENGTH_BYTES; i++)
+ dataErrs += Utils::countBits8(sync[i] ^ DMR_MS_DATA_SYNC_BYTES[i]);
- // count voice sync errors
- uint8_t voiceErrs = 0U;
- for (uint8_t i = 0U; i < DMR_SYNC_LENGTH_BYTES; i++)
- voiceErrs += Utils::countBits8(sync[i] ^ DMR_MS_VOICE_SYNC_BYTES[i]);
+ // count voice sync errors
+ uint8_t voiceErrs = 0U;
+ for (uint8_t i = 0U; i < DMR_SYNC_LENGTH_BYTES; i++)
+ voiceErrs += Utils::countBits8(sync[i] ^ DMR_MS_VOICE_SYNC_BYTES[i]);
- LogDebug(LOG_RF, "DMR, sync word rejected, dataErrs = %u, voiceErrs = %u", dataErrs, voiceErrs);
- }
+ LogWarning(LOG_RF, "DMR, possible sync word rejected, dataErrs = %u, voiceErrs = %u, sync word = %02X %02X %02X %02X %02X %02X", dataErrs, voiceErrs,
+ sync[0U], sync[1U], sync[2U], sync[3U], sync[4U], sync[5U]);
}
if ((dataSync || voiceSync) && m_debug) {
diff --git a/host/Host.cpp b/host/Host.cpp
index 648e75a2..f36588bd 100644
--- a/host/Host.cpp
+++ b/host/Host.cpp
@@ -1244,7 +1244,8 @@ bool Host::createModem()
m_modem->setModeParams(m_dmrEnabled, m_p25Enabled);
m_modem->setLevels(rxLevel, cwIdTXLevel, dmrTXLevel, p25TXLevel);
m_modem->setDCOffsetParams(txDCOffset, rxDCOffset);
- m_modem->setDMRParams(m_dmrColorCode);
+ m_modem->setDMRColorCode(m_dmrColorCode);
+ m_modem->setP25NAC(m_p25NAC);
bool ret = m_modem->open();
if (!ret) {
diff --git a/host/calibrate/HostCal.cpp b/host/calibrate/HostCal.cpp
index 8cb74129..8875ce51 100644
--- a/host/calibrate/HostCal.cpp
+++ b/host/calibrate/HostCal.cpp
@@ -275,6 +275,13 @@ int HostCal::run()
writeConfig();
}
break;
+ case 'D':
+ {
+ m_debug = !m_debug;
+ LogMessage(LOG_CAL, " - Modem Debug: %s", m_debug ? "On" : "Off");
+ writeConfig();
+ }
+ break;
case 'R':
setRXLevel(1);
break;
@@ -307,7 +314,6 @@ int HostCal::run()
m_dmrRx1K = false;
m_p25Enabled = false;
m_p25Rx1K = false;
- m_debug = false;
if (m_mode == STATE_DMR_CAL) {
m_modeStr = DMR_SYM_LA_TST_STR;
@@ -330,8 +336,7 @@ int HostCal::run()
m_dmrRx1K = false;
m_p25Enabled = false;
m_p25Rx1K = false;
- m_debug = false;
-
+
if (m_mode == STATE_DMR_CAL) {
m_modeStr = DMR_SYM_LB_TST_STR;
@@ -353,7 +358,6 @@ int HostCal::run()
m_dmrRx1K = false;
m_p25Enabled = false;
m_p25Rx1K = false;
- m_debug = false;
if (m_mode == STATE_DMR_CAL) {
m_modeStr = DMR_SYM_LC_TST_STR;
@@ -376,7 +380,6 @@ int HostCal::run()
m_dmrRx1K = false;
m_p25Enabled = false;
m_p25Rx1K = false;
- m_debug = false;
if (m_mode == STATE_DMR_CAL) {
m_modeStr = DMR_SYM_LD_TST_STR;
@@ -403,7 +406,6 @@ int HostCal::run()
m_dmrRx1K = false;
m_p25Enabled = false;
m_p25Rx1K = false;
- m_debug = false;
LogMessage(LOG_CAL, " - %s", m_modeStr.c_str());
writeConfig();
@@ -418,7 +420,6 @@ int HostCal::run()
m_dmrRx1K = false;
m_p25Enabled = false;
m_p25Rx1K = false;
- m_debug = false;
LogMessage(LOG_CAL, " - %s", m_modeStr.c_str());
writeConfig();
@@ -433,7 +434,6 @@ int HostCal::run()
m_dmrRx1K = false;
m_p25Enabled = false;
m_p25Rx1K = false;
- m_debug = false;
LogMessage(LOG_CAL, " - %s", m_modeStr.c_str());
writeConfig();
@@ -448,7 +448,6 @@ int HostCal::run()
m_dmrRx1K = false;
m_p25Enabled = false;
m_p25Rx1K = false;
- m_debug = false;
LogMessage(LOG_CAL, " - %s", m_modeStr.c_str());
writeConfig();
@@ -463,7 +462,6 @@ int HostCal::run()
m_dmrRx1K = false;
m_p25Enabled = false;
m_p25Rx1K = false;
- m_debug = false;
LogMessage(LOG_CAL, " - %s", m_modeStr.c_str());
writeConfig();
@@ -478,7 +476,6 @@ int HostCal::run()
m_dmrRx1K = false;
m_p25Enabled = false;
m_p25Rx1K = false;
- m_debug = false;
LogMessage(LOG_CAL, " - %s", m_modeStr.c_str());
writeConfig();
@@ -499,7 +496,6 @@ int HostCal::run()
m_duplex = false;
m_dmrEnabled = true;
m_p25Enabled = false;
- m_debug = true;
LogMessage(LOG_CAL, " - %s", m_modeStr.c_str());
writeConfig();
@@ -520,7 +516,6 @@ int HostCal::run()
m_duplex = false;
m_dmrEnabled = false;
m_p25Enabled = true;
- m_debug = true;
LogMessage(LOG_CAL, " - %s", m_modeStr.c_str());
writeConfig();
@@ -535,7 +530,6 @@ int HostCal::run()
m_dmrRx1K = false;
m_p25Enabled = false;
m_p25Rx1K = false;
- m_debug = false;
LogMessage(LOG_CAL, " - %s", m_modeStr.c_str());
writeConfig();
@@ -571,6 +565,8 @@ int HostCal::run()
end = true;
break;
+ case 13:
+ case 10:
case -1:
break;
default:
@@ -802,8 +798,6 @@ bool HostCal::initModem()
bool ret = writeConfig();
if (!ret) {
- LogMessage(LOG_CAL, " - Modem unresponsive, retrying...");
- sleep(2500U);
ret = writeConfig();
if (!ret) {
LogError(LOG_CAL, "Modem unresponsive to configuration set after 2 attempts, calibration may fail.");
@@ -1072,6 +1066,16 @@ void HostCal::processP25BER(const uint8_t* buffer)
{
using namespace p25;
+ uint8_t sync[P25_SYNC_LENGTH_BYTES];
+ ::memcpy(sync, buffer + 1U, P25_SYNC_LENGTH_BYTES);
+
+ uint8_t syncErrs = 0U;
+ for (uint8_t i = 0U; i < P25_SYNC_LENGTH_BYTES; i++)
+ syncErrs += Utils::countBits8(sync[i] ^ P25_SYNC_BYTES[i]);
+
+ LogMessage(LOG_CAL, "P25, sync word, errs = %u, sync word = %02X %02X %02X %02X %02X %02X", syncErrs,
+ sync[0U], sync[1U], sync[2U], sync[3U], sync[4U], sync[5U]);
+
uint8_t nid[P25_NID_LENGTH_BYTES];
P25Utils::decode(buffer + 1U, nid, 48U, 114U);
uint8_t duid = nid[1U] & 0x0FU;
@@ -1090,7 +1094,7 @@ void HostCal::processP25BER(const uint8_t* buffer)
m_berUndecodableLC++;
}
else {
- LogMessage(LOG_RF, "P25_DUID_HDU (Header), dstId = %u, algo = %X, kid = %X", lc.getDstId(), lc.getAlgId(), lc.getKId());
+ LogMessage(LOG_CAL, "P25_DUID_HDU (Header), dstId = %u, algo = %X, kid = %X", lc.getDstId(), lc.getAlgId(), lc.getKId());
}
m_berBits = 0U;
@@ -1474,7 +1478,10 @@ bool HostCal::writeConfig(uint8_t modeOverride)
buffer[9U] = 1U;
buffer[10U] = m_dmrRxDelay;
- buffer[11U] = 128U;
+
+ uint32_t nac = 0xF7EU;
+ buffer[11U] = (nac >> 4) & 0xFFU;
+ buffer[12U] = (nac << 4) & 0xF0U;
buffer[13U] = (uint8_t)(m_txLevel * 2.55F + 0.5F);
buffer[15U] = (uint8_t)(m_txLevel * 2.55F + 0.5F);
diff --git a/modem/Modem.cpp b/modem/Modem.cpp
index 77632e70..377c3eea 100644
--- a/modem/Modem.cpp
+++ b/modem/Modem.cpp
@@ -74,6 +74,7 @@ Modem::Modem(const std::string& port, bool duplex, bool rxInvert, bool txInvert,
bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t packetPlayoutTime, bool disableOFlowReset, bool trace, bool debug) :
m_port(port),
m_dmrColorCode(0U),
+ m_p25NAC(0x293U),
m_duplex(duplex),
m_rxInvert(rxInvert),
m_txInvert(txInvert),
@@ -170,13 +171,24 @@ void Modem::setLevels(float rxLevel, float cwIdTXLevel, float dmrTXLevel, float
/// Sets the modem DSP DMR color code.
///
///
-void Modem::setDMRParams(uint32_t colorCode)
+void Modem::setDMRColorCode(uint32_t colorCode)
{
assert(colorCode < 16U);
m_dmrColorCode = colorCode;
}
+///
+/// Sets the modem DSP P25 NAC.
+///
+///
+void Modem::setP25NAC(uint32_t nac)
+{
+ assert(nac < 0xFFFU);
+
+ m_p25NAC = nac;
+}
+
///
/// Sets the modem DSP RF receive deviation levels.
///
@@ -1156,7 +1168,8 @@ bool Modem::writeConfig()
buffer[10U] = m_dmrRxDelay;
- buffer[11U] = 128U; // Was OscOffset
+ buffer[11U] = (m_p25NAC >> 4) & 0xFFU;
+ buffer[12U] = (m_p25NAC << 4) & 0xF0U;
buffer[13U] = (uint8_t)(m_dmrTXLevel * 2.55F + 0.5F);
buffer[15U] = (uint8_t)(m_p25TXLevel * 2.55F + 0.5F);
diff --git a/modem/Modem.h b/modem/Modem.h
index 6317a750..2f366713 100644
--- a/modem/Modem.h
+++ b/modem/Modem.h
@@ -140,6 +140,8 @@ namespace modem
RSN_INVALID_DMR_START = 14U,
RSN_INVALID_DMR_RX_DELAY = 15U,
+ RSN_INVALID_P25_NAC = 16U,
+
RSN_DMR_DISABLED = 63U,
RSN_P25_DISABLED = 64U,
};
@@ -174,7 +176,9 @@ namespace modem
/// Sets the modem DSP RF deviation levels.
virtual void setLevels(float rxLevel, float cwIdTXLevel, float dmrTXLevel, float p25TXLevel);
/// Sets the modem DSP DMR color code.
- virtual void setDMRParams(uint32_t colorCode);
+ virtual void setDMRColorCode(uint32_t colorCode);
+ /// Sets the modem DSP P25 NAC.
+ virtual void setP25NAC(uint32_t nac);
/// Sets the modem DSP RF receive deviation levels.
virtual void setRXLevel(float rxLevel);
@@ -253,6 +257,7 @@ namespace modem
std::string m_port;
uint32_t m_dmrColorCode;
+ uint32_t m_p25NAC;
bool m_duplex;
diff --git a/modem/NullModem.h b/modem/NullModem.h
index 960b187b..2185f7e0 100644
--- a/modem/NullModem.h
+++ b/modem/NullModem.h
@@ -56,7 +56,7 @@ namespace modem
/// Sets the modem DSP RF deviation levels.
virtual void setLevels(float rxLevel, float cwIdTXLevel, float dmrTXLevel, float p25TXLevel) { return; }
/// Sets the modem DSP DMR color code.
- virtual void setDMRParams(uint32_t colorCode) { return; }
+ virtual void setDMRColorCode(uint32_t colorCode) { return; }
/// Sets the modem DSP RF receive deviation levels.
virtual void setRXLevel(float rxLevel) { return; }
diff --git a/p25/DataPacket.cpp b/p25/DataPacket.cpp
index beea3ad1..3c5fa37a 100644
--- a/p25/DataPacket.cpp
+++ b/p25/DataPacket.cpp
@@ -849,7 +849,7 @@ void DataPacket::writeNet_PDU_Header()
m_netBlocksToFollow = m_netDataHeader.getBlocksToFollow();
- uint32_t bitLength = ((m_netDataHeader.getBlocksToFollow() + 1U) * P25_PDU_FEC_LENGTH_BITS) + P25_PREAMBLE_LENGTH_BITS;
+ //uint32_t bitLength = ((m_netDataHeader.getBlocksToFollow() + 1U) * P25_PDU_FEC_LENGTH_BITS) + P25_PREAMBLE_LENGTH_BITS;
m_netBitOffset = P25_PREAMBLE_LENGTH_BITS;
::memset(buffer, 0x00U, P25_PDU_FEC_LENGTH_BYTES);
diff --git a/p25/TrunkPacket.cpp b/p25/TrunkPacket.cpp
index 8c5ede4b..0b8d005f 100644
--- a/p25/TrunkPacket.cpp
+++ b/p25/TrunkPacket.cpp
@@ -1858,6 +1858,8 @@ bool TrunkPacket::writeRF_TSDU_Grant(bool grp, bool skip)
// don't transmit grants if the destination ID's don't match and the network TG hang timer is running
if (m_p25->m_rfLastDstId != 0U) {
if (m_p25->m_rfLastDstId != m_rfTSBK.getDstId() && (m_p25->m_rfTGHang.isRunning() && !m_p25->m_rfTGHang.hasExpired())) {
+ writeRF_TSDU_Deny(P25_DENY_RSN_PTT_BONK, (grp) ? TSBK_IOSP_GRP_VCH : TSBK_IOSP_UU_VCH);
+ m_p25->checkAndReject();
m_rfTSBK.setLCO(lco);
return false;
}