mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 23:45:49 +08:00
Revert "First attempt at detecting D-Star data frames, Kenwood and Icom."
This reverts commit 3362e29b62.
This commit is contained in:
171
DStarControl.cpp
171
DStarControl.cpp
@@ -127,7 +127,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
||||
|
||||
unsigned char type = data[0U];
|
||||
|
||||
if (type == TAG_LOST && (m_rfState == RS_RF_AUDIO || m_rfState == RS_RF_DATA)) {
|
||||
if (type == TAG_LOST && m_rfState == RS_RF_AUDIO) {
|
||||
unsigned char my1[DSTAR_LONG_CALLSIGN_LENGTH];
|
||||
unsigned char my2[DSTAR_SHORT_CALLSIGN_LENGTH];
|
||||
unsigned char your[DSTAR_LONG_CALLSIGN_LENGTH];
|
||||
@@ -316,7 +316,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
||||
}
|
||||
|
||||
return false;
|
||||
} else if (m_rfState == RS_RF_AUDIO || m_rfState == RS_RF_DATA) {
|
||||
} else if (m_rfState == RS_RF_AUDIO) {
|
||||
if (m_net)
|
||||
writeNetworkDataRF(DSTAR_END_PATTERN_BYTES, 0U, true);
|
||||
|
||||
@@ -340,13 +340,11 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
||||
|
||||
return false;
|
||||
} else if (type == TAG_DATA) {
|
||||
if (m_rfState == RS_RF_REJECTED)
|
||||
if (m_rfState == RS_RF_REJECTED) {
|
||||
return false;
|
||||
|
||||
if (m_rfState == RS_RF_INVALID)
|
||||
} else if (m_rfState == RS_RF_INVALID) {
|
||||
return false;
|
||||
|
||||
if (m_rfState == RS_RF_LISTENING) {
|
||||
} else if (m_rfState == RS_RF_LISTENING) {
|
||||
// The sync is regenerated by the modem so can do exact match
|
||||
if (::memcmp(data + 1U + DSTAR_VOICE_FRAME_LENGTH_BYTES, DSTAR_SYNC_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES) == 0) {
|
||||
m_slowData.start();
|
||||
@@ -354,41 +352,6 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Data signatures only appear at the beginning of the frame
|
||||
if (m_rfState == RS_RF_AUDIO && m_rfFrames < 21U) {
|
||||
if (CUtils::compare(data + 1U, DSTAR_KENWOOD_DATA_MODE_BYTES, DSTAR_VOICE_FRAME_LENGTH_BYTES) < 5U) {
|
||||
LogMessage("D-Star, switching to data mode (Kenwood)");
|
||||
m_rfState = RS_RF_DATA;
|
||||
} else if (CUtils::compare(data + 1U, DSTAR_ICOM_DATA_MODE_BYTES, DSTAR_VOICE_FRAME_LENGTH_BYTES) < 5U) {
|
||||
LogMessage("D-Star, switching to data mode (Icom)");
|
||||
m_rfState = RS_RF_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_rfState == RS_RF_DATA) {
|
||||
m_rfBits += 72U;
|
||||
m_rfErrs = 0U;
|
||||
m_rfFrames++;
|
||||
|
||||
// The sync is regenerated by the modem so can do exact match
|
||||
if (::memcmp(data + 1U + DSTAR_VOICE_FRAME_LENGTH_BYTES, DSTAR_SYNC_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES) == 0)
|
||||
m_rfN = 0U;
|
||||
|
||||
// Regenerate the sync and send the RSSI data to the display
|
||||
if (m_rfN == 0U) {
|
||||
CSync::addDStarSync(data + 1U);
|
||||
m_display->writeDStarRSSI(m_rssi);
|
||||
}
|
||||
|
||||
if (m_net)
|
||||
writeNetworkDataRF(data, 0U, false);
|
||||
|
||||
if (m_duplex)
|
||||
writeQueueDataRF(data);
|
||||
|
||||
m_rfN = (m_rfN + 1U) % 21U;
|
||||
} else if (m_rfState == RS_RF_AUDIO) {
|
||||
unsigned int errors = 0U;
|
||||
if (!m_rfHeader.isDataPacket()) {
|
||||
@@ -396,10 +359,6 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
|
||||
m_display->writeDStarBER(float(errors) / 0.48F);
|
||||
LogDebug("D-Star, audio sequence no. %u, errs: %u/48 (%.1f%%)", m_rfN, errors, float(errors) / 0.48F);
|
||||
m_rfErrs += errors;
|
||||
|
||||
// The sync is regenerated by the modem so can do exact match
|
||||
if (::memcmp(data + 1U + DSTAR_VOICE_FRAME_LENGTH_BYTES, DSTAR_SYNC_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES) == 0)
|
||||
m_rfN = 0U;
|
||||
}
|
||||
|
||||
m_rfBits += 48U;
|
||||
@@ -630,7 +589,7 @@ void CDStarControl::writeNetwork()
|
||||
if (!m_enabled)
|
||||
return;
|
||||
|
||||
if ((m_rfState == RS_RF_AUDIO || m_rfState == RS_RF_DATA) && m_netState == RS_NET_IDLE)
|
||||
if (m_rfState == RS_RF_AUDIO && m_netState == RS_NET_IDLE)
|
||||
return;
|
||||
|
||||
m_networkWatchdog.start();
|
||||
@@ -700,94 +659,64 @@ void CDStarControl::writeNetwork()
|
||||
m_elapsed.start();
|
||||
|
||||
} else if (type == TAG_EOT) {
|
||||
if (m_netState == RS_NET_AUDIO || m_netState == RS_NET_DATA) {
|
||||
writeQueueEOTNet();
|
||||
if (m_netState != RS_NET_AUDIO)
|
||||
return;
|
||||
|
||||
data[1U] = TAG_EOT;
|
||||
writeQueueEOTNet();
|
||||
|
||||
data[1U] = TAG_EOT;
|
||||
|
||||
#if defined(DUMP_DSTAR)
|
||||
writeFile(data + 1U, length - 1U);
|
||||
closeFile();
|
||||
writeFile(data + 1U, length - 1U);
|
||||
closeFile();
|
||||
#endif
|
||||
unsigned char my1[DSTAR_LONG_CALLSIGN_LENGTH];
|
||||
unsigned char my2[DSTAR_SHORT_CALLSIGN_LENGTH];
|
||||
unsigned char your[DSTAR_LONG_CALLSIGN_LENGTH];
|
||||
m_netHeader.getMyCall1(my1);
|
||||
m_netHeader.getMyCall2(my2);
|
||||
m_netHeader.getYourCall(your);
|
||||
unsigned char my1[DSTAR_LONG_CALLSIGN_LENGTH];
|
||||
unsigned char my2[DSTAR_SHORT_CALLSIGN_LENGTH];
|
||||
unsigned char your[DSTAR_LONG_CALLSIGN_LENGTH];
|
||||
m_netHeader.getMyCall1(my1);
|
||||
m_netHeader.getMyCall2(my2);
|
||||
m_netHeader.getYourCall(your);
|
||||
|
||||
// We've received the header and EOT haven't we?
|
||||
m_netFrames += 2U;
|
||||
LogMessage("D-Star, received network end of transmission from %8.8s/%4.4s to %8.8s, %.1f seconds, %u%% packet loss, BER: %.1f%%", my1, my2, your, float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits));
|
||||
// We've received the header and EOT haven't we?
|
||||
m_netFrames += 2U;
|
||||
LogMessage("D-Star, received network end of transmission from %8.8s/%4.4s to %8.8s, %.1f seconds, %u%% packet loss, BER: %.1f%%", my1, my2, your, float(m_netFrames) / 50.0F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits));
|
||||
|
||||
writeEndNet();
|
||||
}
|
||||
writeEndNet();
|
||||
} else if (type == TAG_DATA) {
|
||||
// Data signatures only appear at the beginning of the frame
|
||||
if (m_netState == RS_NET_AUDIO && m_netFrames < 21U) {
|
||||
if (CUtils::compare(data + 2U, DSTAR_KENWOOD_DATA_MODE_BYTES, DSTAR_VOICE_FRAME_LENGTH_BYTES) < 5U) {
|
||||
LogMessage("D-Star, switching to data mode (Kenwood)");
|
||||
m_rfState = RS_RF_DATA;
|
||||
} else if (CUtils::compare(data + 2U, DSTAR_ICOM_DATA_MODE_BYTES, DSTAR_VOICE_FRAME_LENGTH_BYTES) < 5U) {
|
||||
LogMessage("D-Star, switching to data mode (Icom)");
|
||||
m_rfState = RS_RF_DATA;
|
||||
}
|
||||
}
|
||||
if (m_netState != RS_NET_AUDIO)
|
||||
return;
|
||||
|
||||
if (m_netState == RS_NET_DATA) {
|
||||
unsigned char n = data[1U];
|
||||
unsigned char n = data[1U];
|
||||
|
||||
data[1U] = TAG_DATA;
|
||||
unsigned int errors = 0U;
|
||||
if (!m_netHeader.isDataPacket())
|
||||
errors = m_fec.regenerateDStar(data + 2U);
|
||||
|
||||
m_netBits += 72U;
|
||||
m_netErrs = 0U;
|
||||
blankDTMF(data + 2U);
|
||||
|
||||
m_netN = n;
|
||||
data[1U] = TAG_DATA;
|
||||
|
||||
// Regenerate the sync
|
||||
if (n == 0U)
|
||||
CSync::addDStarSync(data + 2U);
|
||||
// Insert silence and reject if in the past
|
||||
bool ret = insertSilence(data + 1U, n);
|
||||
if (!ret)
|
||||
return;
|
||||
|
||||
m_packetTimer.start();
|
||||
m_netFrames++;
|
||||
m_netErrs += errors;
|
||||
m_netBits += 48U;
|
||||
|
||||
m_netN = n;
|
||||
|
||||
// Regenerate the sync
|
||||
if (n == 0U)
|
||||
CSync::addDStarSync(data + 2U);
|
||||
|
||||
m_packetTimer.start();
|
||||
m_netFrames++;
|
||||
|
||||
#if defined(DUMP_DSTAR)
|
||||
writeFile(data + 1U, length - 1U);
|
||||
writeFile(data + 1U, length - 1U);
|
||||
#endif
|
||||
writeQueueDataNet(data + 1U);
|
||||
} else if (m_netState == RS_NET_AUDIO) {
|
||||
unsigned char n = data[1U];
|
||||
|
||||
unsigned int errors = 0U;
|
||||
if (!m_netHeader.isDataPacket())
|
||||
errors = m_fec.regenerateDStar(data + 2U);
|
||||
|
||||
blankDTMF(data + 2U);
|
||||
|
||||
data[1U] = TAG_DATA;
|
||||
|
||||
// Insert silence and reject if in the past
|
||||
bool ret = insertSilence(data + 1U, n);
|
||||
if (!ret)
|
||||
return;
|
||||
|
||||
m_netErrs += errors;
|
||||
m_netBits += 48U;
|
||||
|
||||
m_netN = n;
|
||||
|
||||
// Regenerate the sync
|
||||
if (n == 0U)
|
||||
CSync::addDStarSync(data + 2U);
|
||||
|
||||
m_packetTimer.start();
|
||||
m_netFrames++;
|
||||
|
||||
#if defined(DUMP_DSTAR)
|
||||
writeFile(data + 1U, length - 1U);
|
||||
#endif
|
||||
writeQueueDataNet(data + 1U);
|
||||
}
|
||||
writeQueueDataNet(data + 1U);
|
||||
} else {
|
||||
CUtils::dump("D-Star, unknown data from network", data, DSTAR_FRAME_LENGTH_BYTES + 1U);
|
||||
}
|
||||
@@ -816,7 +745,7 @@ void CDStarControl::clock()
|
||||
m_rfTimeoutTimer.clock(ms);
|
||||
m_netTimeoutTimer.clock(ms);
|
||||
|
||||
if (m_netState == RS_NET_AUDIO || m_netState == RS_NET_DATA) {
|
||||
if (m_netState == RS_NET_AUDIO) {
|
||||
m_networkWatchdog.clock(ms);
|
||||
|
||||
if (m_networkWatchdog.hasExpired()) {
|
||||
@@ -830,7 +759,7 @@ void CDStarControl::clock()
|
||||
}
|
||||
}
|
||||
|
||||
if (m_netState == RS_NET_AUDIO || m_netState == RS_NET_DATA) {
|
||||
if (m_netState == RS_NET_AUDIO) {
|
||||
m_packetTimer.clock(ms);
|
||||
|
||||
if (m_packetTimer.isRunning() && m_packetTimer.hasExpired()) {
|
||||
|
||||
Reference in New Issue
Block a user