mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-18 13:02:21 +02:00
esp_modem: Add ConsoleCommand destructor
Commands are registered in Constructor. But there is now of deregistering it This is needed for correct console re-construction, for example with USB modem replugging.
This commit is contained in:
@ -18,6 +18,16 @@ ConsoleCommand::ConsoleCommand(const char *command, const char *help, const std:
|
|||||||
RegisterCommand(command, help, args);
|
RegisterCommand(command, help, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConsoleCommand::~ConsoleCommand()
|
||||||
|
{
|
||||||
|
// Find this command in static list of commands and remove it
|
||||||
|
auto cmd = std::find(console_commands.begin(), console_commands.end(), this);
|
||||||
|
if (cmd != console_commands.end()) {
|
||||||
|
console_commands.erase(cmd);
|
||||||
|
last_command--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConsoleCommand::RegisterCommand(const char *command, const char *help, const std::vector<CommandArgs> &args)
|
void ConsoleCommand::RegisterCommand(const char *command, const char *help, const std::vector<CommandArgs> &args)
|
||||||
{
|
{
|
||||||
assert(last_command <= MAX_REPEAT_NR);
|
assert(last_command <= MAX_REPEAT_NR);
|
||||||
|
@ -92,6 +92,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
explicit ConsoleCommand(const char *command, const char *help, const std::vector<CommandArgs> &args, std::function<bool(ConsoleCommand *)> f);
|
explicit ConsoleCommand(const char *command, const char *help, const std::vector<CommandArgs> &args, std::function<bool(ConsoleCommand *)> f);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Destructor of ConsoleCommand
|
||||||
|
*/
|
||||||
|
~ConsoleCommand();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Utility getters of various params from the argument list
|
* @brief Utility getters of various params from the argument list
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user