feat: Add Ethernet runtime configuration CLI + fix PIN_USER_BTN_ANA compilation#2260
feat: Add Ethernet runtime configuration CLI + fix PIN_USER_BTN_ANA compilation#2260ndrpri wants to merge 11 commits intomeshcore-dev:devfrom
Conversation
|
This seems to be clauded by that known structures of code. Also it badly use some ETHClass2 library instead of standard Espressif's ESP-IDF SDK ETH.begin() That also caused claude (or other AI) to implement while TCP stuff around it again, but if native ESP SDK will be used instead, ir will work out-of-box with existing 'wifiserial' or 'wifi client' and no changes would be needed. Only maybe rename Wifi to Network as it would not be only wifi but also Ethernet or even LTE. Also this implementation support only one SPI W5500 and no else, like DM902x SPI ethernet or LAN7820 RMII If you want some inspiration, take look to my fork, where I trying make it more abstract, but for now I have it just for my one board, so it does not abuse other code yet. |
Security fixes: - IP validation: bounds checking for octets (0-255) - ETH.config() return value now checked with distinct logging - set ip 0.0.0.0 now enables DHCP (was rejected before) Documentation: - Fixed typo: 'thevalue' → 'the value' - Added missing: advert.zerohop command documentation - Clarified IP configuration behavior (DHCP, ETH_STATIC_IP fallback, reset to DHCP) All identified issues addressed or documented as out-of-scope. PR meshcore-dev#2260 ready for maintainer review.
|
@petrkr Thank you for the detailed feedback! Just to clarify a few points:
This PR stands on its own merits: it works, solves a real problem, and follows the existing codebase patterns. Looking forward to maintainer's decision! |
…ime ADMIN_PASSWORD
- Protect MomentaryButton instantiation with #ifdef PIN_USER_BTN_ANA - Use dummy pin 0 when PIN_USER_BTN_ANA is not defined - Allows compilation on boards without analog button support - Applied to both SX1262 and SX1276 variants
|
Do not use AI to generate response to me
|
- Add ip/gw/subnet/dns get/set commands with SPIFFS persistence - Implement reconfigureEthernet() method for runtime config - Fix TCP_CONSOLE_PORT conditional compilation - Update platformio.ini for consistency (USE_ETHERNET) - Document Ethernet settings and get bridge.type command - Fixes meshcore-dev#2196 meshcore-dev#2197 hardware and console dependencies
- Add PIN_USER_BTN_ANA=7 globally to platformio.ini - Remove abs() from millis() comparison (unsigned overflow) - Add auto declaration to ev variable in PIN_USER_BTN_ANA block Fixes compilation errors on ESP32-S3 with analog button support
Security fixes: - IP validation: bounds checking for octets (0-255) - ETH.config() return value now checked with distinct logging - set ip 0.0.0.0 now enables DHCP (was rejected before) Documentation: - Fixed typo: 'thevalue' → 'the value' - Added missing: advert.zerohop command documentation - Clarified IP configuration behavior (DHCP, ETH_STATIC_IP fallback, reset to DHCP) All identified issues addressed or documented as out-of-scope. PR meshcore-dev#2260 ready for maintainer review.
93e21a2 to
b3c36bd
Compare
|
To clarify: I use AI for translation to ensure clarity in English, Your architectural feedback is valid and noted. I'd prefer we focus If you'd like to discuss design improvements or share your fork as reference, |
|
One more thing: If you or anyone else can do it better, I'll be the first My contribution is meant to help the project. If it's not needed, just say so What matters is that the problem gets solved — not who solves it. |
my also, that is why there exist my fork repository So yes, it solved that problem,.. But now @liamcottle will have lot of headache about maintain that bundle of "ifdef's" there. My repo is also hard-coded to one board.. but with few difference
|
|
Since you clearly have the expertise and a better approach, If you don't have the time or inclination, we'll wait for someone else Thanks for the feedback — looking forward to your contribution! |
|
I am trying to do that.. Today I spent 12 hours with debugging how to use SDK 3.x on old hardware, because i take 21kB more memory so there is compromise about keep it old or have less message queue (256-->100) check pre requests #2265 and #2264 after those prerequests (if any) will be merged, then will be possible to use SDK 3.x.. for Companion radio (where is problem with RAM) you do not really need 3.x SDK too much as it does not need Ethernet (or if even it will have it, you can use less offline message queue as it will be mostly online). for router those static RAM are not there, so for that is not problem at all. After those will be merged, new doors will open... No workarounds with some bullshit old Arudino libraries. but usage of todays and updated libraries directly from chip maintainer/manufacturer |
|
Understood! I see you're working on SDK 3.x integration as foundation. My PR solves the immediate problem for current users with the existing codebase. When your PRs are merged and SDK 3.x foundation is ready, those improvements Looking forward to those updates. Let me know if there's anything I can |
|
One clarification: The T-ETH-Elite board uses W5500 (SPI), which requires This isn't a design choice — it's a hardware requirement of the board. When you implement SDK 3.x support for boards with native RMII Ethernet, |
Again claude is wrong. Espressif SDK natively supports SPI Ethernets for 4 years already... Again proof you are not programmer and only vibe coder,... check documentation |
Overview
Adds runtime Ethernet configuration commands via CLI, allowing dynamic IP/gateway/subnet/DNS settings with SPIFFS persistence. Also includes TCP console for remote management and fixes for analog button compilation on ESP32-S3.
What's Included
1. Ethernet Runtime Configuration
get/set ip,get/set gw,get/set subnet,get/set dnsreconfigureEthernet()methodcli_commands.mdwith full documentation2. TCP Console Enhancements
TCP_CONSOLE_PORTconditional compilation (removed unnecessaryESP32guard)ADMIN_PASSWORDset passwordcommand without reflashing3. PIN_USER_BTN_ANA Fixes
#ifdef PIN_USER_BTN_ANAguards intarget.cpp(both SX1262/SX1276)PIN_USER_BTN_ANA=7to platformio.ini build flagsabs()frommillis()comparison (fixes unsigned overflow on ESP32-S3)autodeclaration toevvariable in analog button block4. Documentation
cli_commands.mdget bridge.typecommand (was missing)Files Changed
src/helpers/CommonCLI.cpp/h— Ethernet CLI commands + helper functionssrc/MeshCore.h—reconfigureEthernet()virtual methodsrc/helpers/esp32/TEthEliteBoard.cpp— implementationexamples/simple_repeater/main.cpp— callreconfigureEthernet()after bootexamples/simple_room_server/main.cpp— sameexamples/companion_radio/ui-new/UITask.cpp— fix analog buttonvariants/lilygo_t_eth_elite_sx1262/platformio.ini— add build flagsvariants/lilygo_t_eth_elite_sx1276/platformio.ini— add build flagsdocs/cli_commands.md— documentationDependencies
Reviewed by
Testing
Usage Example
Ethernet Configuration Hierarchy
The device follows this priority order when initializing Ethernet:
1. If SPIFFS has valid static IP (!=0.0.0.0)
-D USE_ETHERNET -D TCP_CONSOLE_PORT=4242→ Device boots with IP from SPIFFS (previously saved via
set ipcommand)2. If SPIFFS has 0.0.0.0 BUT compile-time flags are set
→ Device boots with static IP from platformio.ini
3. If SPIFFS has 0.0.0.0 AND no compile-time flags
-D USE_ETHERNET -D TCP_CONSOLE_PORT=4242→ Device boots with DHCP (IP assigned by router)
Once booted, you can reconfigure at runtime via TCP console:
Settings persist to SPIFFS and survive across reboots!
Notes
USE_ETHERNETbuild flag