Skip to content

Commit

Permalink
fix issue when loading voice channel lists into local affiliation tab…
Browse files Browse the repository at this point in the history
…les; fix issue where appropriate voice channel data for remote callbacks was not correct; better hide messages from console and use logging appropriately in RESTClient;
  • Loading branch information
gatekeep committed Mar 26, 2023
1 parent 8674866 commit 08d2828
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/dmr/Slot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,8 @@ void Slot::setSiteData(const std::vector<uint32_t> voiceChNo, const std::unorder
m_affiliations->addRFCh(chNo);
}

m_affiliations->setRFChData(voiceChData);
std::unordered_map<uint32_t, ::lookups::VoiceChData> chData = std::unordered_map<uint32_t, ::lookups::VoiceChData>(voiceChData);
m_affiliations->setRFChData(chData);

lc::CSBK::setSiteData(m_siteData);
}
Expand Down
2 changes: 1 addition & 1 deletion src/lookups/AffiliationLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ VoiceChData AffiliationLookup::getRFChData(uint32_t chNo) const
data = VoiceChData();
}

return VoiceChData();
return data;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/lookups/AffiliationLookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace lookups
virtual uint32_t getGrantedSrcId(uint32_t srcId);

/// <summary>Helper to set RF channel data.</summary>
void setRFChData(const std::unordered_map<uint32_t, VoiceChData> chData) { m_rfChDataTable = chData; }
void setRFChData(const std::unordered_map<uint32_t, VoiceChData>& chData) { m_rfChDataTable = chData; }
/// <summary>Helper to get RF channel data.</summary>
VoiceChData getRFChData(uint32_t chNo) const;

Expand Down
3 changes: 2 additions & 1 deletion src/nxdn/Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ void Control::setOptions(yaml::Node& conf, bool controlPermitTG, const std::stri
m_affiliations.addRFCh(ch);
}

m_affiliations.setRFChData(voiceChData);
std::unordered_map<uint32_t, ::lookups::VoiceChData> chData = std::unordered_map<uint32_t, ::lookups::VoiceChData>(voiceChData);
m_affiliations.setRFChData(chData);

lc::RCCH::setSiteData(m_siteData);
lc::RCCH::setCallsign(cwCallsign);
Expand Down
3 changes: 2 additions & 1 deletion src/p25/Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ void Control::setOptions(yaml::Node& conf, bool controlPermitTG, const std::stri
m_affiliations.addRFCh(ch);
}

m_affiliations.setRFChData(voiceChData);
std::unordered_map<uint32_t, ::lookups::VoiceChData> chData = std::unordered_map<uint32_t, ::lookups::VoiceChData>(voiceChData);
m_affiliations.setRFChData(chData);

uint32_t ccBcstInterval = p25Protocol["control"]["interval"].as<uint32_t>(300U);
m_trunk->m_adjSiteUpdateInterval += ccBcstInterval;
Expand Down
1 change: 1 addition & 0 deletions src/p25/packet/Trunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2237,6 +2237,7 @@ bool Trunk::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_t serviceOp
// callback RCON to permit-tg on the specified voice channel
if (m_p25->m_authoritative && m_p25->m_controlPermitTG) {
::lookups::VoiceChData voiceChData = m_p25->m_affiliations.getRFChData(chNo);

if (voiceChData.isValidCh() && !voiceChData.address().empty() && voiceChData.port() > 0 &&
chNo != m_p25->m_siteData.channelNo()) {
json::object req = json::object();
Expand Down
11 changes: 10 additions & 1 deletion src/remote/RESTClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ using namespace network::rest::http;
bool RESTClient::m_responseAvailable = false;
HTTPPayload RESTClient::m_response;

bool RESTClient::m_console = false;
bool RESTClient::m_debug = false;

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -117,6 +118,7 @@ RESTClient::RESTClient(const std::string& address, uint32_t port, const std::str
assert(!address.empty());
assert(port > 0U);

m_console = true;
m_debug = debug;
}

Expand Down Expand Up @@ -234,7 +236,14 @@ int RESTClient::send(const std::string& address, uint32_t port, const std::strin
return ERRNO_API_CALL_TIMEOUT;
}

fprintf(stdout, "%s\r\n", m_response.content.c_str());
if (m_console) {
fprintf(stdout, "%s\r\n", m_response.content.c_str());
}
else {
if (m_debug) {
::LogDebug(LOG_REST, "REST Response: %s", m_response.content.c_str());
}
}

client.close();
}
Expand Down
2 changes: 2 additions & 0 deletions src/remote/RESTClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class HOST_SW_API RESTClient
uint32_t m_port;
std::string m_password;

static bool m_console;

static bool m_responseAvailable;
static HTTPPayload m_response;

Expand Down

0 comments on commit 08d2828

Please sign in to comment.