diff --git a/openrtx/include/rtx/OpMode_M17.hpp b/openrtx/include/rtx/OpMode_M17.hpp index 1f827d25..537637c0 100644 --- a/openrtx/include/rtx/OpMode_M17.hpp +++ b/openrtx/include/rtx/OpMode_M17.hpp @@ -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 diff --git a/openrtx/include/rtx/rtx.h b/openrtx/include/rtx/rtx.h index 1bd8a943..092cd4bb 100644 --- a/openrtx/include/rtx/rtx.h +++ b/openrtx/include/rtx/rtx.h @@ -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; diff --git a/openrtx/src/rtx/OpMode_M17.cpp b/openrtx/src/rtx/OpMode_M17.cpp index 2abe6557..a695beae 100644 --- a/openrtx/src/rtx/OpMode_M17.cpp +++ b/openrtx/src/rtx/OpMode_M17.cpp @@ -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'; } } diff --git a/openrtx/src/rtx/rtx.cpp b/openrtx/src/rtx/rtx.cpp index 44001cbd..c4546c04 100644 --- a/openrtx/src/rtx/rtx.cpp +++ b/openrtx/src/rtx/rtx.cpp @@ -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; diff --git a/openrtx/src/ui/default/ui_main.c b/openrtx/src/ui/default/ui_main.c index f7ece103..9b5a1dc1 100644 --- a/openrtx/src/ui/default/ui_main.c +++ b/openrtx/src/ui/default/ui_main.c @@ -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) diff --git a/openrtx/src/ui/module17/ui_main.c b/openrtx/src/ui/module17/ui_main.c index d8d9f915..804bf375 100644 --- a/openrtx/src/ui/module17/ui_main.c +++ b/openrtx/src/ui/module17/ui_main.c @@ -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')