/*************************************************************************** * Copyright (C) 2021 - 2025 by Federico Amedeo Izzo IU2NUO, * * Niccolò Izzo IU2KIN * * Frederik Saraci IU2NRO * * Silvano Seva IU2KWO * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, see * ***************************************************************************/ #ifndef OPMODE_H #define OPMODE_H #include #include "rtx.h" /** * This class provides a standard interface for all the operating modes. * The class is then specialised for each operating mode and its implementation * groups all the common code required to manage the given mode, like data * encoding and decoding, squelch management, ... */ class OpMode { public: /** * Constructor. */ OpMode() { } /** * Destructor. */ virtual ~OpMode() { } /** * Enable the operating mode. * * Application must ensure this function is being called when entering the * new operating mode and always before the first call of "update". */ virtual void enable() { } /** * Disable the operating mode. This function ensures that, after being * called, the radio, the audio amplifier and the microphone are in OFF state. * * Application must ensure this function is being called when exiting the * current operating mode. */ virtual void disable() { } /** * Update the internal FSM. * Application code has to call this function periodically, to ensure proper * functionality. * * @param status: pointer to the rtxStatus_t structure containing the current * RTX status. Internal FSM may change the current value of the opStatus flag. * @param newCfg: flag used inform the internal FSM that a new RTX configuration * has been applied. */ virtual void update(rtxStatus_t *const status, const bool newCfg) { (void) status; (void) newCfg; sleepFor(0u, 30u); } /** * Get the mode identifier corresponding to the OpMode class. * * @return the corresponding flag from the opmode enum. */ virtual opmode getID() { return OPMODE_NONE; } /** * Check if RX squelch is open. * * @return true if RX squelch is open. */ virtual bool rxSquelchOpen() { return false; } }; #endif /* OPMODE_H */