Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update telnet_cli.h to take into account DISABLE_CLI_TELNET #30

Merged
merged 1 commit into from
Mar 7, 2025

Conversation

antongorodezkiy
Copy link
Contributor

Description

Added telnet functions placeholders for cases when DISABLE_CLI_TELNET=1

Related Issues

Tests

@antongorodezkiy
Copy link
Contributor Author

antongorodezkiy commented Mar 7, 2025

Hello @hpsaturn, thank you for your package 👍

I used hpsaturn/ESP32 Wifi CLI@^0.3.3 for a while in my pet project and on some stage of developing the RAM overflowed.
Started to debug here and there, looked into PlatformIO Inspect tool and found that the <ESP32WifiCLI.hpp/telnet_cli.h> takes 24Kb though I don't actually use any telnet functions and don't plan to.

Screenshot from 2025-03-07 02-15-39

I looked through the library code and found DISABLE_CLI_TELNET constant. Pretty straightforward - so I turned it off in the platformio.ini:

...
build_flags =
	...
	-D SHELLMINATOR_BUFF_LEN=128
	-D SHELLMINATOR_BUFF_DIM=128
	-D COMMANDER_MAX_COMMAND_SIZE=128
	-D WCLI_MAX_CMDS=14
    -D DISABLE_CLI_TELNET=1
...

And after that the project stopped to compile because it expected for those functions:

~/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/ttgo-lora32-v1/lib18e/libESP32 Wifi CLI.a(ESP32WifiCLI.cpp.o):(.literal._Z9_nmcli_upPcP6Stream+0x4): undefined reference to `ESP32WifiCLI::isTelnetEnable()'
~/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/ttgo-lora32-v1/lib18e/libESP32 Wifi CLI.a(ESP32WifiCLI.cpp.o):(.literal._Z9_nmcli_upPcP6Stream+0x8): undefined reference to `ESP32WifiCLI::isTelnetRunning()'
~/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/ttgo-lora32-v1/lib18e/libESP32 Wifi CLI.a(ESP32WifiCLI.cpp.o):(.literal._Z9_nmcli_upPcP6Stream+0xc): undefined reference to `ESP32WifiCLI::enableTelnet()'
~/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/ttgo-lora32-v1/lib18e/libESP32 Wifi CLI.a(ESP32WifiCLI.cpp.o): in function `_nmcli_up(char*, Stream*)':
~/programming/embedded/SmartPosition/Monitor/.pio/libdeps/ttgo-lora32-v1/ESP32 Wifi CLI/src/ESP32WifiCLI.cpp:372: undefined reference to `ESP32WifiCLI::isTelnetEnable()'
~/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: ~/programming/embedded/SmartPosition/Monitor/.pio/libdeps/ttgo-lora32-v1/ESP32 Wifi CLI/src/ESP32WifiCLI.cpp:372: undefined reference to `ESP32WifiCLI::isTelnetRunning()'
~/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: ~/programming/embedded/SmartPosition/Monitor/.pio/libdeps/ttgo-lora32-v1/ESP32 Wifi CLI/src/ESP32WifiCLI.cpp:372: undefined reference to `ESP32WifiCLI::enableTelnet()'

The ugly workaround I used is to include the following file in my main.cpp:

#include <ESP32WifiCLI.hpp>

#ifdef DISABLE_CLI_TELNET
void ESP32WifiCLI::enableTelnet() {
}

void ESP32WifiCLI::disableTelnet() {
}

bool ESP32WifiCLI::isTelnetEnable() {
    return false;
}

bool ESP32WifiCLI::isTelnetRunning() {
    return false;
}
#endif

Th project compiled and the memory issue is gone so far.

@hpsaturn
Copy link
Owner

hpsaturn commented Mar 7, 2025

Thanks for your contribution. It's true, the Telnet feature consume more memory. Thanks to notice the missing prototypes for this case.

@hpsaturn hpsaturn merged commit f89c600 into hpsaturn:devel Mar 7, 2025
@hpsaturn hpsaturn mentioned this pull request Mar 7, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants