kopia lustrzana https://github.com/OpenRTX/OpenRTX
M17: added callsign-based squelch for incoming transmissions
rodzic
5ec0587c48
commit
2653ee01aa
|
@ -121,6 +121,19 @@ private:
|
||||||
*/
|
*/
|
||||||
void txState(rtxStatus_t *const status);
|
void txState(rtxStatus_t *const status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare two callsigns in plain text form.
|
||||||
|
* The comparison does not take into account the country prefixes (strips
|
||||||
|
* the '/' and whatever is in front from all callsigns). It does take into
|
||||||
|
* account the dash and whatever is after it. In case the incoming callsign
|
||||||
|
* is "ALL" the function returns true.
|
||||||
|
*
|
||||||
|
* \param localCs plain text callsign from the user
|
||||||
|
* \param incomingCs plain text destination callsign
|
||||||
|
* \return true if local an incoming callsigns match.
|
||||||
|
*/
|
||||||
|
bool compareCallsigns(const std::string& localCs, const std::string& incomingCs);
|
||||||
|
|
||||||
|
|
||||||
bool startRx; ///< Flag for RX management.
|
bool startRx; ///< Flag for RX management.
|
||||||
bool startTx; ///< Flag for TX management.
|
bool startTx; ///< Flag for TX management.
|
||||||
|
|
|
@ -268,8 +268,13 @@ void OpMode_M17::rxState(rtxStatus_t *const status)
|
||||||
bool canMatch = (streamType.fields.CAN == status->can)
|
bool canMatch = (streamType.fields.CAN == status->can)
|
||||||
|| (status->canRxEn == false);
|
|| (status->canRxEn == false);
|
||||||
|
|
||||||
|
// Check if the destination callsign of the incoming transmission
|
||||||
|
// matches with ours
|
||||||
|
bool callMatch = compareCallsigns(std::string(status->source_address), dst);
|
||||||
|
|
||||||
// Extract audio data
|
// Extract audio data
|
||||||
if((type == M17FrameType::STREAM) && (pthSts == PATH_OPEN) && (canMatch == true))
|
if((type == M17FrameType::STREAM) && (pthSts == PATH_OPEN) &&
|
||||||
|
(canMatch == true) && (callMatch == true))
|
||||||
{
|
{
|
||||||
M17StreamFrame sf = decoder.getStreamFrame();
|
M17StreamFrame sf = decoder.getStreamFrame();
|
||||||
codec_pushFrame(sf.payload().data(), false);
|
codec_pushFrame(sf.payload().data(), false);
|
||||||
|
@ -359,3 +364,26 @@ void OpMode_M17::txState(rtxStatus_t *const status)
|
||||||
modulator.stop();
|
modulator.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OpMode_M17::compareCallsigns(const std::string& localCs,
|
||||||
|
const std::string& incomingCs)
|
||||||
|
{
|
||||||
|
if(incomingCs == "ALL")
|
||||||
|
return true;
|
||||||
|
|
||||||
|
std::string truncatedLocal(localCs);
|
||||||
|
std::string truncatedIncoming(incomingCs);
|
||||||
|
|
||||||
|
int slashPos = localCs.find_first_of('/');
|
||||||
|
if(slashPos <= 2)
|
||||||
|
truncatedLocal = localCs.substr(slashPos + 1);
|
||||||
|
|
||||||
|
slashPos = incomingCs.find_first_of('/');
|
||||||
|
if(slashPos <= 2)
|
||||||
|
truncatedIncoming = incomingCs.substr(slashPos + 1);
|
||||||
|
|
||||||
|
if(truncatedLocal == truncatedIncoming)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue