Fix M17 callsign management

Now a default callsign "OPNRTX" is used in M17 mode, and when the user
sets its own callsign in the settings menu, that one is correctly used
instead. Add initialization to RTX data structure.
replace/c0b900904fddaeb860cf3cc63ed15ea60263abac
Niccolò Izzo 2021-09-06 08:53:57 +02:00
rodzic e60d79241d
commit 120fd92d73
5 zmienionych plików z 21 dodań i 13 usunięć

Wyświetl plik

@ -77,9 +77,9 @@ void OpMode_M17::update(rtxStatus_t *const status, const bool newCfg)
audio_enableMic(); audio_enableMic();
radio_enableTx(); radio_enableTx();
// TODO: Allow destinations different than broadcast std::string source_address(status->source_address);
std::string source_address("OPNRTX"); std::string destination_address(status->destination_address);
m17Tx.start(source_address); m17Tx.start(source_address, destination_address);
status->opStatus = TX; status->opStatus = TX;
} }

Wyświetl plik

@ -24,18 +24,18 @@
#include <OpMode_FM.h> #include <OpMode_FM.h>
#include <OpMode_M17.h> #include <OpMode_M17.h>
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 const rtxStatus_t *newCnf; // Pointer for incoming config messages
rtxStatus_t rtxStatus; // RTX driver status rtxStatus_t rtxStatus = { 0 }; // RTX driver status
float rssi; // Current RSSI in dBm float rssi; // Current RSSI in dBm
bool reinitFilter; // Flag for RSSI filter re-initialisation bool reinitFilter; // Flag for RSSI filter re-initialisation
OpMode *currMode; // Pointer to currently active opMode handler OpMode *currMode; // Pointer to currently active opMode handler
OpMode noMode; // Empty opMode handler for opmode::NONE OpMode noMode; // Empty opMode handler for opmode::NONE
OpMode_FM fmMode; // FM mode handler OpMode_FM fmMode; // FM mode handler
OpMode_M17 m17Mode; // M17 mode handler OpMode_M17 m17Mode; // M17 mode handler
void rtx_init(pthread_mutex_t *m) void rtx_init(pthread_mutex_t *m)
{ {

Wyświetl plik

@ -82,6 +82,9 @@ void state_init()
state.emergency = false; state.emergency = false;
// Initialize M17_data
strncpy(state.m17_data.callsign, "OPNRTX", 10);
// Read settings from flash memory // Read settings from flash memory
// NOTE: Disable reading VFO from flash until persistence is implemented // NOTE: Disable reading VFO from flash until persistence is implemented
//int valid = nvm_readSettings(&state.settings); //int valid = nvm_readSettings(&state.settings);

Wyświetl plik

@ -103,6 +103,10 @@ void *ui_task(void *arg)
rtx_cfg.txTone = ctcss_tone[state.channel.fm.txTone]; rtx_cfg.txTone = ctcss_tone[state.channel.fm.txTone];
pthread_mutex_unlock(&rtx_mutex); 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); rtx_configure(&rtx_cfg);
sync_rtx = false; sync_rtx = false;
} }

Wyświetl plik

@ -1324,8 +1324,9 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
{ {
_ui_textInputConfirm(ui_state.new_callsign); _ui_textInputConfirm(ui_state.new_callsign);
// Save selected callsign and disable input mode // 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; ui_state.edit_mode = false;
*sync_rtx = true;
} }
else if(msg.keys & KEY_ESC) else if(msg.keys & KEY_ESC)
// Discard selected callsign and disable input mode // Discard selected callsign and disable input mode