correct various log messages; clean up payload channels after grant release; fix incorrect REST API being called for payload activation;

pull/24/head
Bryan Biedenkapp 3 years ago
parent f216304970
commit 68334b34bc

@ -78,6 +78,7 @@ Control::Control(bool authoritative, uint32_t colorCode, uint32_t callHang, uint
m_ridLookup(ridLookup), m_ridLookup(ridLookup),
m_tidLookup(tidLookup), m_tidLookup(tidLookup),
m_tsccSlotNo(0U), m_tsccSlotNo(0U),
m_tsccPayloadActive(false),
m_ccRunning(false), m_ccRunning(false),
m_ccHalted(false), m_ccHalted(false),
m_dumpCSBKData(dumpCSBKData), m_dumpCSBKData(dumpCSBKData),
@ -408,14 +409,16 @@ void Control::tsccActivateSlot(uint32_t slotNo, uint32_t dstId, bool group)
{ {
if (m_verbose) { if (m_verbose) {
LogMessage(LOG_DMR, "DMR Slot %u, payload activation, group = %u, dstId = %u", LogMessage(LOG_DMR, "DMR Slot %u, payload activation, group = %u, dstId = %u",
group, dstId); slotNo, group, dstId);
} }
switch (slotNo) { switch (slotNo) {
case 1U: case 1U:
m_tsccPayloadActive = true;
m_slot1->setTSCCActivated(dstId, group); m_slot1->setTSCCActivated(dstId, group);
break; break;
case 2U: case 2U:
m_tsccPayloadActive = true;
m_slot2->setTSCCActivated(dstId, group); m_slot2->setTSCCActivated(dstId, group);
break; break;
default: default:
@ -431,7 +434,7 @@ void Control::tsccActivateSlot(uint32_t slotNo, uint32_t dstId, bool group)
void Control::tsccClearActivatedSlot(uint32_t slotNo) void Control::tsccClearActivatedSlot(uint32_t slotNo)
{ {
if (m_verbose) { if (m_verbose) {
LogMessage(LOG_DMR, "DMR Slot %u, payload activation clear"); LogMessage(LOG_DMR, "DMR Slot %u, payload activation clear", slotNo);
} }
switch (slotNo) { switch (slotNo) {
@ -445,6 +448,10 @@ void Control::tsccClearActivatedSlot(uint32_t slotNo)
LogError(LOG_DMR, "DMR, invalid slot, TSCC payload activation, slotNo = %u", slotNo); LogError(LOG_DMR, "DMR, invalid slot, TSCC payload activation, slotNo = %u", slotNo);
break; break;
} }
if (m_tsccPayloadActive && m_slot1->m_tsccPayloadDstId == 0U && m_slot2->m_tsccPayloadDstId == 0U) {
m_tsccPayloadActive = false;
}
} }
/// <summary> /// <summary>

@ -142,6 +142,7 @@ namespace dmr
::lookups::TalkgroupIdLookup* m_tidLookup; ::lookups::TalkgroupIdLookup* m_tidLookup;
uint8_t m_tsccSlotNo; uint8_t m_tsccSlotNo;
bool m_tsccPayloadActive;
bool m_ccRunning; bool m_ccRunning;
bool m_ccHalted; bool m_ccHalted;

@ -171,7 +171,7 @@ namespace dmr
// Feature IDs // Feature IDs
const uint8_t FID_ETSI = 0x00U; // ETSI Standard Feature Set const uint8_t FID_ETSI = 0x00U; // ETSI Standard Feature Set
const uint8_t FID_DMRA = 0x10U; // const uint8_t FID_DMRA = 0x10U; //
const uint8_t FID_DVM = 0xFEU; // internal DMR FID used for internal signalling const uint8_t FID_DVM = 0x3FU; // internal DMR FID used for internal signalling
// LC Service Options // LC Service Options
const uint8_t LC_SVC_OPT_EMERGENCY = 0x80U; const uint8_t LC_SVC_OPT_EMERGENCY = 0x80U;

@ -33,6 +33,7 @@
#include "dmr/Sync.h" #include "dmr/Sync.h"
#include "edac/BPTC19696.h" #include "edac/BPTC19696.h"
#include "edac/CRC.h" #include "edac/CRC.h"
#include "remote/RESTClient.h"
#include "Log.h" #include "Log.h"
#include "Utils.h" #include "Utils.h"
@ -419,12 +420,6 @@ 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 we have control enabled; do clocking to generate a CC data stream
if (m_enableTSCC) { if (m_enableTSCC) {
// clock all the grant timers // clock all the grant timers
@ -448,12 +443,25 @@ void Slot::clock()
} }
if (m_ccPacketInterval.isRunning() && m_ccPacketInterval.hasExpired()) { if (m_ccPacketInterval.isRunning() && m_ccPacketInterval.hasExpired()) {
m_tsccCnt++;
if (m_tsccCnt == TSCC_MAX_CNT) {
m_tsccCnt = 0U;
}
if (m_ccRunning) { if (m_ccRunning) {
if (m_ccSeq == 3U) { if (m_ccSeq == 3U) {
m_ccSeq = 0U; m_ccSeq = 0U;
} }
setShortLC_TSCC(m_siteData, m_tsccCnt); if (m_dmr->m_tsccPayloadActive) {
if ((m_tsccCnt % 2) == 0) {
setShortLC_TSCC(m_siteData, m_tsccCnt);
}
}
else {
setShortLC_TSCC(m_siteData, m_tsccCnt);
}
writeRF_ControlData(m_tsccCnt, m_ccSeq); writeRF_ControlData(m_tsccCnt, m_ccSeq);
m_ccSeq++; m_ccSeq++;
@ -470,31 +478,22 @@ void Slot::clock()
} }
// never allow the TSCC to become payload activated // never allow the TSCC to become payload activated
if (m_tsccActivated && m_enableTSCC) { if (m_tsccActivated && m_slotNo == m_dmr->m_tsccSlotNo) {
::LogDebug(LOG_DMR, "DMR Slot %u, BUG BUG tried to payload activate the TSCC slot", m_slotNo); ::LogDebug(LOG_DMR, "DMR Slot %u, BUG BUG tried to payload activate the TSCC slot", m_slotNo);
clearTSCCActivated(); clearTSCCActivated();
} }
// activate payload channel if requested from the TSCC // activate payload channel if requested from the TSCC
if (m_tsccActivated && !m_enableTSCC) { if (m_tsccActivated) {
if (m_rfState == RS_RF_LISTENING && m_netState == RS_NET_IDLE) { if (m_rfState == RS_RF_LISTENING && m_netState == RS_NET_IDLE) {
if (m_tsccPayloadDstId > 0U) { if (m_tsccPayloadDstId > 0U) {
if (m_dmr->m_tsccSlotNo > 0U) { if ((m_tsccCnt % 2) > 0) {
// every 4 frames transmit the payload TSCC setShortLC(m_slotNo, m_tsccPayloadDstId, m_tsccPayloadGroup ? FLCO_GROUP : FLCO_PRIVATE, false);
if ((m_tsccCnt % 4) == 0) {
setShortLC_Payload(m_siteData, m_tsccCnt);
}
else {
// only transmit the payload short LC every 2 frames
if ((m_tsccCnt % 2) == 0) {
setShortLC(m_slotNo, m_tsccPayloadDstId, m_tsccPayloadGroup ? FLCO_GROUP : FLCO_PRIVATE, true);
}
}
}
else {
setShortLC(m_slotNo, m_tsccPayloadDstId, m_tsccPayloadGroup ? FLCO_GROUP : FLCO_PRIVATE, true);
} }
} }
else {
setShortLC_TSCC(m_siteData, m_tsccCnt);
}
} }
else { else {
clearTSCCActivated(); clearTSCCActivated();
@ -563,7 +562,9 @@ void Slot::clock()
} }
if (m_rfState == RS_RF_REJECTED) { if (m_rfState == RS_RF_REJECTED) {
m_queue.clear(); if (!m_enableTSCC) {
m_queue.clear();
}
m_rfFrames = 0U; m_rfFrames = 0U;
m_rfErrs = 0U; m_rfErrs = 0U;
@ -677,6 +678,29 @@ void Slot::init(Control* dmr, bool authoritative, uint32_t colorCode, SiteData s
m_ridLookup = ridLookup; m_ridLookup = ridLookup;
m_tidLookup = tidLookup; m_tidLookup = tidLookup;
m_affiliations = new dmr::lookups::DMRAffiliationLookup(verbose); m_affiliations = new dmr::lookups::DMRAffiliationLookup(verbose);
m_affiliations->setReleaseGrantCallback([=](uint32_t chNo, uint32_t dstId, uint8_t slot) {
Slot* tscc = m_dmr->getTSCCSlot();
if (tscc != nullptr) {
if (chNo == tscc->m_channelNo) {
m_dmr->tsccClearActivatedSlot(slot);
return;
}
::lookups::VoiceChData voiceChData = tscc->m_affiliations->getRFChData(chNo);
if (voiceChData.isValidCh() && !voiceChData.address().empty() && voiceChData.port() > 0) {
json::object req = json::object();
req["slot"].set<uint8_t>(slot);
bool clear = true;
req["clear"].set<bool>(clear);
RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(),
HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, tscc->m_debug);
}
else {
::LogError(LOG_DMR, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to clear payload channel, chNo = %u", tscc->m_slotNo, chNo);
}
}
});
m_hangCount = callHang * 17U; m_hangCount = callHang * 17U;

@ -44,7 +44,8 @@ using namespace dmr::lookups;
DMRAffiliationLookup::DMRAffiliationLookup(bool verbose) : ::lookups::AffiliationLookup("DMR Affiliation", verbose), DMRAffiliationLookup::DMRAffiliationLookup(bool verbose) : ::lookups::AffiliationLookup("DMR Affiliation", verbose),
m_grantChSlotTable(), m_grantChSlotTable(),
m_tsccChNo(0U), m_tsccChNo(0U),
m_tsccSlot(0U) m_tsccSlot(0U),
m_releaseGrant(nullptr)
{ {
/* stub */ /* stub */
} }
@ -156,6 +157,10 @@ bool DMRAffiliationLookup::releaseGrant(uint32_t dstId, bool releaseAll)
m_name, chNo, slot, dstId); m_name, chNo, slot, dstId);
} }
if (m_releaseGrant != nullptr) {
m_releaseGrant(chNo, dstId, slot);
}
m_grantChTable[dstId] = 0U; m_grantChTable[dstId] = 0U;
m_grantChSlotTable.erase(dstId); m_grantChSlotTable.erase(dstId);

@ -30,6 +30,7 @@
#include "lookups/AffiliationLookup.h" #include "lookups/AffiliationLookup.h"
#include <tuple> #include <tuple>
#include <functional>
namespace dmr namespace dmr
{ {
@ -65,13 +66,18 @@ namespace dmr
/// <summary>Helper to determine the first available slot for given the channel number.</summary> /// <summary>Helper to determine the first available slot for given the channel number.</summary>
uint8_t getAvailableSlotForChannel(uint32_t chNo) const; uint8_t getAvailableSlotForChannel(uint32_t chNo) const;
/// <summary>Helper to set the release grant callback.</summary>
void setReleaseGrantCallback(std::function<void(uint32_t, uint32_t, uint8_t)>&& callback) { m_releaseGrant = callback; }
protected: protected:
std::unordered_map<uint32_t, std::tuple<uint32_t, uint8_t>> m_grantChSlotTable; std::unordered_map<uint32_t, std::tuple<uint32_t, uint8_t>> m_grantChSlotTable;
uint32_t m_tsccChNo; uint32_t m_tsccChNo;
uint8_t m_tsccSlot; uint8_t m_tsccSlot;
std::function<void(uint32_t, uint32_t, uint8_t)> m_releaseGrant;
}; };
} // namespace lookups } // namespace lookups
} // namespace dmr } // namespace dmr
#endif // __DMR_AFFILIATION_LOOKUP_H__ #endif // __DMR_AFFILIATION_LOOKUP_H__

@ -851,7 +851,7 @@ bool ControlSignaling::writeRF_CSBK_Grant(uint32_t srcId, uint32_t dstId, uint8_
req["group"].set<bool>(grp); req["group"].set<bool>(grp);
RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(),
HTTP_PUT, PUT_PERMIT_TG, req, m_tscc->m_debug); HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, m_tscc->m_debug);
} }
else { else {
::LogError(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to activate payload channel, chNo = %u, slot = %u", m_tscc->m_slotNo, chNo, slot); ::LogError(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to activate payload channel, chNo = %u, slot = %u", m_tscc->m_slotNo, chNo, slot);
@ -913,7 +913,7 @@ bool ControlSignaling::writeRF_CSBK_Grant(uint32_t srcId, uint32_t dstId, uint8_
req["group"].set<bool>(grp); req["group"].set<bool>(grp);
RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(),
HTTP_PUT, PUT_PERMIT_TG, req, m_tscc->m_debug); HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, m_tscc->m_debug);
} }
else { else {
::LogError(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to activate payload channel, chNo = %u, slot = %u", m_tscc->m_slotNo, chNo, slot); ::LogError(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to activate payload channel, chNo = %u, slot = %u", m_tscc->m_slotNo, chNo, slot);
@ -1084,7 +1084,7 @@ bool ControlSignaling::writeRF_CSBK_Data_Grant(uint32_t srcId, uint32_t dstId, u
req["group"].set<bool>(grp); req["group"].set<bool>(grp);
RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(),
HTTP_PUT, PUT_PERMIT_TG, req, m_tscc->m_debug); HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, m_tscc->m_debug);
} }
else { else {
::LogError(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to activate payload channel, chNo = %u, slot = %u", m_tscc->m_slotNo, chNo, slot); ::LogError(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to activate payload channel, chNo = %u, slot = %u", m_tscc->m_slotNo, chNo, slot);
@ -1126,7 +1126,7 @@ bool ControlSignaling::writeRF_CSBK_Data_Grant(uint32_t srcId, uint32_t dstId, u
req["group"].set<bool>(grp); req["group"].set<bool>(grp);
RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(), RESTClient::send(voiceChData.address(), voiceChData.port(), voiceChData.password(),
HTTP_PUT, PUT_PERMIT_TG, req, m_tscc->m_debug); HTTP_PUT, PUT_DMR_TSCC_PAYLOAD_ACT, req, m_tscc->m_debug);
} }
else { else {
::LogError(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to activate payload channel, chNo = %u, slot = %u", m_tscc->m_slotNo, chNo, slot); ::LogError(LOG_RF, "DMR Slot %u, DT_CSBK, CSBKO_RAND (Random Access), failed to activate payload channel, chNo = %u, slot = %u", m_tscc->m_slotNo, chNo, slot);

Loading…
Cancel
Save

Powered by TurnKey Linux.