implement proper payload SLCO;

pull/24/head 2023-03-24
Bryan Biedenkapp 3 years ago
parent db0800e6e6
commit a1dd5193cf

@ -153,10 +153,12 @@ void Control::setOptions(yaml::Node& conf, bool controlPermitTG, const std::vect
case 1U:
m_slot1->setTSCC(enableTSCC, dedicatedTSCC);
m_slot1->setControlPermitTG(m_controlPermitTG);
//m_slot2->setTSCCPayload(true); // this is not the correct way this should be done
break;
case 2U:
m_slot2->setTSCC(enableTSCC, dedicatedTSCC);
m_slot2->setControlPermitTG(m_controlPermitTG);
//m_slot1->setTSCCPayload(true); // this is not the correct way this should be done
break;
default:
LogError(LOG_DMR, "DMR, invalid slot, TSCC disabled, slotNo = %u", m_tsccSlotNo);

@ -222,6 +222,7 @@ namespace dmr
const uint8_t SLCO_NULL = 0x00U;
const uint8_t SLCO_ACT = 0x01U;
const uint8_t SLCO_TSCC = 0x02U;
const uint8_t SLCO_PAYLOAD = 0x03U;
// Reason Code(s)
const uint8_t TS_ACK_RSN_MSG = 0x60U; // TS - Message Accepted

@ -414,6 +414,12 @@ void Slot::clock()
}
}
// increment the TSCC counter on every slot 1 clock
m_tsccCnt++;
if (m_tsccCnt == TSCC_MAX_CNT) {
m_tsccCnt = 0U;
}
// if we have control enabled; do clocking to generate a CC data stream
if (m_enableTSCC) {
// clock all the grant timers
@ -438,12 +444,6 @@ void Slot::clock()
if (m_ccPacketInterval.isRunning() && m_ccPacketInterval.hasExpired()) {
if (m_ccRunning) {
// increment the TSCC counter on every slot 1 clock
m_tsccCnt++;
if (m_tsccCnt == TSCC_MAX_CNT) {
m_tsccCnt = 0U;
}
if (m_ccSeq == 3U) {
m_ccSeq = 0U;
}
@ -464,6 +464,10 @@ void Slot::clock()
}
}
if (m_tsccPayloadSlot) {
setShortLC_Payload(m_siteData, m_tsccCnt);
}
m_rfTimeoutTimer.clock(ms);
if (m_rfTimeoutTimer.isRunning() && m_rfTimeoutTimer.hasExpired()) {
if (!m_rfTimeout) {
@ -1072,7 +1076,6 @@ void Slot::setShortLC(uint32_t slotNo, uint32_t id, uint8_t flco, bool voice)
/// <summary>
///
/// </summary>
/// <param name="slotNo"></param>
/// <param name="siteData"></param>
/// <param name="counter"></param>
void Slot::setShortLC_TSCC(SiteData siteData, uint16_t counter)
@ -1132,3 +1135,66 @@ void Slot::setShortLC_TSCC(SiteData siteData, uint16_t counter)
m_modem->writeDMRShortLC(sLC);
}
/// <summary>
///
/// </summary>
/// <param name="siteData"></param>
/// <param name="counter"></param>
void Slot::setShortLC_Payload(SiteData siteData, uint16_t counter)
{
assert(m_modem != nullptr);
uint8_t lc[5U];
uint32_t lcValue = 0U;
lcValue = SLCO_PAYLOAD;
lcValue = (lcValue << 2) + siteData.siteModel();
switch (siteData.siteModel())
{
case SITE_MODEL_TINY:
{
lcValue = (lcValue << 9) + siteData.netId();
lcValue = (lcValue << 3) + siteData.siteId();
}
break;
case SITE_MODEL_SMALL:
{
lcValue = (lcValue << 7) + siteData.netId();
lcValue = (lcValue << 5) + siteData.siteId();
}
break;
case SITE_MODEL_LARGE:
{
lcValue = (lcValue << 5) + siteData.netId();
lcValue = (lcValue << 7) + siteData.siteId();
}
break;
case SITE_MODEL_HUGE:
{
lcValue = (lcValue << 2) + siteData.netId();
lcValue = (lcValue << 10) + siteData.siteId();
}
break;
}
lcValue = (lcValue << 1) + 0U; // Payload channel is Normal
lcValue = (lcValue << 9) + (counter & 0x1FFU);
// split value into bytes
lc[0U] = (uint8_t)((lcValue >> 24) & 0xFFU);
lc[1U] = (uint8_t)((lcValue >> 16) & 0xFFU);
lc[2U] = (uint8_t)((lcValue >> 8) & 0xFFU);
lc[3U] = (uint8_t)((lcValue >> 0) & 0xFFU);
lc[4U] = edac::CRC::crc8(lc, 4U);
//LogDebug(LOG_DMR, "setShortLC_Payload, netId = %02X, siteId = %02X", siteData.netId(), siteData.siteId());
//Utils::dump(1U, "setShortLC_Payload", lc, 5U);
uint8_t sLC[9U];
lc::ShortLC shortLC;
shortLC.encode(lc, sLC);
m_modem->writeDMRShortLC(sLC);
}

@ -105,6 +105,8 @@ namespace dmr
/// <summary>Helper to enable and configure TSCC support for this slot.</summary>
void setTSCC(bool enable, bool dedicated);
/// <summary>Sets a flag indicating whether the slot is a TSCC payload slot.</summary>
void setTSCCPayload(bool payload) { m_tsccPayloadSlot = payload; }
/// <summary>Sets a flag indicating whether the DMR control channel can send permit-tg to voice channels.</summary>
void setControlPermitTG(bool controlPermitTG) { m_controlPermitTG = controlPermitTG; }
/// <summary>Helper to set the voice error silence threshold.</summary>
@ -189,6 +191,7 @@ namespace dmr
bool m_enableTSCC;
bool m_dedicatedTSCC;
bool m_tsccPayloadSlot;
bool m_controlPermitTG;
@ -264,6 +267,8 @@ namespace dmr
static void setShortLC(uint32_t slotNo, uint32_t id, uint8_t flco = FLCO_GROUP, bool voice = true);
/// <summary>Helper to set the DMR short LC for TSCC.</summary>
static void setShortLC_TSCC(SiteData siteData, uint16_t counter);
/// <summary>Helper to set the DMR short LC for payload.</summary>
static void setShortLC_Payload(SiteData siteData, uint16_t counter);
};
} // namespace dmr

Loading…
Cancel
Save

Powered by TurnKey Linux.