Change M17_orig to link and change callsign handling

This will swap the first extended callsign with the source callsign
if there is extended callsign data.
This allows to always store the true source in the M17_src variable

See #188
This commit is contained in:
marco 2023-10-03 16:15:40 +02:00 committed by Silvano Seva
parent 04d6d01a5c
commit 20b0c375aa
6 changed files with 38 additions and 17 deletions

View File

@ -126,6 +126,7 @@ private:
bool startTx; ///< Flag for TX management.
bool locked; ///< Demodulator locked on data stream.
bool dataValid; ///< Demodulated data is valid
bool extendedCall; ///< Extended callsign data received
bool invertTxPhase; ///< TX signal phase inversion setting.
bool invertRxPhase; ///< RX signal phase inversion setting.
pathId rxAudioPath; ///< Audio path ID for RX

View File

@ -64,7 +64,7 @@ typedef struct
bool lsfOk; /** M17 LSF is valid */
char M17_dst[10]; /** M17 LSF destination */
char M17_src[10]; /** M17 LSF source */
char M17_orig[10]; /** M17 LSF traffic originator */
char M17_link[10]; /** M17 LSF traffic originator */
char M17_refl[10]; /** M17 LSF reflector module */
}
rtxStatus_t;

View File

@ -39,8 +39,8 @@ using namespace std;
using namespace M17;
OpMode_M17::OpMode_M17() : startRx(false), startTx(false), locked(false),
dataValid(false), invertTxPhase(false),
invertRxPhase(false)
dataValid(false), extendedCall(false),
invertTxPhase(false), invertRxPhase(false)
{
}
@ -55,10 +55,11 @@ void OpMode_M17::enable()
codec_init();
modulator.init();
demodulator.init();
locked = false;
dataValid = false;
startRx = true;
startTx = false;
locked = false;
dataValid = false;
extendedCall = false;
startRx = true;
startTx = false;
}
void OpMode_M17::disable()
@ -221,8 +222,6 @@ void OpMode_M17::rxState(rtxStatus_t *const status)
// Retrieve stream source and destination data
std::string dst = lsf.getDestination();
std::string src = lsf.getSource();
strncpy(status->M17_src, src.c_str(), 10);
strncpy(status->M17_dst, dst.c_str(), 10);
// Retrieve extended callsign data
streamType_t streamType = lsf.getType();
@ -230,14 +229,34 @@ void OpMode_M17::rxState(rtxStatus_t *const status)
if((streamType.fields.encType == M17_ENCRYPTION_NONE) &&
(streamType.fields.encSubType == M17_META_EXTD_CALLSIGN))
{
extendedCall = true;
meta_t& meta = lsf.metadata();
std::string exCall1 = decode_callsign(meta.extended_call_sign.call1);
std::string exCall2 = decode_callsign(meta.extended_call_sign.call2);
strncpy(status->M17_orig, exCall1.c_str(), 10);
//
// The source callsign only contains the last link when
// receiving extended callsign data: in order to always store
// the true source of a transmission, we need to store the first
// extended callsign in M17_src.
//
strncpy(status->M17_src, exCall1.c_str(), 10);
strncpy(status->M17_refl, exCall2.c_str(), 10);
extendedCall = true;
}
// Set source and destination fields.
// If we have received an extended callsign the src will be the RF link address
// The M17_src will already be stored from the extended callsign
strncpy(status->M17_dst, dst.c_str(), 10);
if(extendedCall)
strncpy(status->M17_link, src.c_str(), 10);
else
strncpy(status->M17_src, src.c_str(), 10);
// Check CAN on RX, if enabled.
// If check is disabled, force match to true.
bool canMatch = (streamType.fields.CAN == status->can)
@ -268,7 +287,8 @@ void OpMode_M17::rxState(rtxStatus_t *const status)
{
status->lsfOk = false;
dataValid = false;
status->M17_orig[0] = '\0';
extendedCall = false;
status->M17_link[0] = '\0';
status->M17_refl[0] = '\0';
}
}

View File

@ -62,7 +62,7 @@ void rtx_init(pthread_mutex_t *m)
rtxStatus.lsfOk = false;
rtxStatus.M17_src[0] = '\0';
rtxStatus.M17_dst[0] = '\0';
rtxStatus.M17_orig[0] = '\0';
rtxStatus.M17_link[0] = '\0';
rtxStatus.M17_refl[0] = '\0';
currMode = &noMode;

View File

@ -143,14 +143,14 @@ void _ui_drawModeInfo(ui_state_t* ui_state)
gfx_print(layout.line1_pos, layout.line2_font, TEXT_ALIGN_CENTER,
color_white, "%s", rtxStatus.M17_src);
// Stream originator (if present)
if(rtxStatus.M17_orig[0] != '\0')
// RF link (if present)
if(rtxStatus.M17_link[0] != '\0')
{
gfx_drawSymbol(layout.line4_pos, layout.line3_symbol_size, TEXT_ALIGN_LEFT,
color_white, SYMBOL_ACCESS_POINT);
gfx_print(layout.line4_pos, layout.line2_font, TEXT_ALIGN_CENTER,
color_white, "%s", rtxStatus.M17_orig);
color_white, "%s", rtxStatus.M17_link);
}
// Reflector (if present)

View File

@ -112,12 +112,12 @@ void _ui_drawModeInfo(ui_state_t* ui_state)
gfx_print(layout.line1_pos, layout.line2_font, TEXT_ALIGN_CENTER,
color_white, "%s", rtxStatus.M17_src);
if(rtxStatus.M17_orig[0] != '\0')
if(rtxStatus.M17_link[0] != '\0')
{
gfx_drawSymbol(layout.line4_pos, layout.line3_symbol_font, TEXT_ALIGN_LEFT,
color_white, SYMBOL_ACCESS_POINT);
gfx_print(layout.line4_pos, layout.line2_font, TEXT_ALIGN_CENTER,
color_white, "%s", rtxStatus.M17_orig);
color_white, "%s", rtxStatus.M17_link);
}
if(rtxStatus.M17_refl[0] != '\0')