diff --git a/openrtx/src/rtx/OpMode_M17.cpp b/openrtx/src/rtx/OpMode_M17.cpp index 587eb764..2d4ffc9e 100644 --- a/openrtx/src/rtx/OpMode_M17.cpp +++ b/openrtx/src/rtx/OpMode_M17.cpp @@ -77,9 +77,9 @@ void OpMode_M17::update(rtxStatus_t *const status, const bool newCfg) audio_enableMic(); radio_enableTx(); - // TODO: Allow destinations different than broadcast - std::string source_address("OPNRTX"); - m17Tx.start(source_address); + std::string source_address(status->source_address); + std::string destination_address(status->destination_address); + m17Tx.start(source_address, destination_address); status->opStatus = TX; } diff --git a/openrtx/src/rtx/rtx.cpp b/openrtx/src/rtx/rtx.cpp index f1d42d39..6ecfae66 100644 --- a/openrtx/src/rtx/rtx.cpp +++ b/openrtx/src/rtx/rtx.cpp @@ -24,18 +24,18 @@ #include #include -pthread_mutex_t *cfgMutex; // Mutex for incoming config messages +pthread_mutex_t *cfgMutex; // Mutex for incoming config messages -const rtxStatus_t *newCnf; // Pointer for incoming config messages -rtxStatus_t rtxStatus; // RTX driver status +const rtxStatus_t *newCnf; // Pointer for incoming config messages +rtxStatus_t rtxStatus = { 0 }; // RTX driver status -float rssi; // Current RSSI in dBm -bool reinitFilter; // Flag for RSSI filter re-initialisation +float rssi; // Current RSSI in dBm +bool reinitFilter; // Flag for RSSI filter re-initialisation -OpMode *currMode; // Pointer to currently active opMode handler -OpMode noMode; // Empty opMode handler for opmode::NONE -OpMode_FM fmMode; // FM mode handler -OpMode_M17 m17Mode; // M17 mode handler +OpMode *currMode; // Pointer to currently active opMode handler +OpMode noMode; // Empty opMode handler for opmode::NONE +OpMode_FM fmMode; // FM mode handler +OpMode_M17 m17Mode; // M17 mode handler void rtx_init(pthread_mutex_t *m) { diff --git a/openrtx/src/state.c b/openrtx/src/state.c index d2e1d410..564edbf5 100644 --- a/openrtx/src/state.c +++ b/openrtx/src/state.c @@ -82,6 +82,9 @@ void state_init() state.emergency = false; + // Initialize M17_data + strncpy(state.m17_data.callsign, "OPNRTX", 10); + // Read settings from flash memory // NOTE: Disable reading VFO from flash until persistence is implemented //int valid = nvm_readSettings(&state.settings); diff --git a/openrtx/src/threads.c b/openrtx/src/threads.c index d926228c..ded227e4 100644 --- a/openrtx/src/threads.c +++ b/openrtx/src/threads.c @@ -103,6 +103,10 @@ void *ui_task(void *arg) rtx_cfg.txTone = ctcss_tone[state.channel.fm.txTone]; pthread_mutex_unlock(&rtx_mutex); + // Copy new M17 source and destination addresses + strncpy(rtx_cfg.source_address, state.m17_data.callsign, 10); + strncpy(rtx_cfg.destination_address, "", 10); + rtx_configure(&rtx_cfg); sync_rtx = false; } diff --git a/openrtx/src/ui/ui.c b/openrtx/src/ui/ui.c index 27645c3b..fe7ec405 100644 --- a/openrtx/src/ui/ui.c +++ b/openrtx/src/ui/ui.c @@ -1324,8 +1324,9 @@ void ui_updateFSM(event_t event, bool *sync_rtx) { _ui_textInputConfirm(ui_state.new_callsign); // Save selected callsign and disable input mode - strcpy(state.m17_data.callsign, ui_state.new_callsign); + strncpy(state.m17_data.callsign, ui_state.new_callsign, 10); ui_state.edit_mode = false; + *sync_rtx = true; } else if(msg.keys & KEY_ESC) // Discard selected callsign and disable input mode