paclema / esp32_lwip_nat_example

4 stars 2 forks source link

Manual recompile not necessary? #6

Closed gsicilia82 closed 1 year ago

gsicilia82 commented 1 year ago

Hi, after failing few times by manually recompile Arduino-SDK with enabled LWIP-NAT, I have asked ChatGPT.

It told me to use this platformio.ini:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
lib_deps = 
    esp32wifi
build_flags = 
    -DLWIP_FEATURES=1
    -DLWIP_IPV4_NAT=1

ChatGPTs C++ code was bullshit, but replacing it with your example file: IT WORKS! Using these build flags, your example script works out of the box. I don't really understand, why it works without issues by using standard arduino sdk.

Do you know why?

gsicilia82 commented 1 year ago

Hmm, ok it works also without any build flags.... Maybe, LWIP NAT is uncluded in standard arduino SDK?

paclema commented 1 year ago

Hi @gsicilia82, thank you for your comments! At the time that I made this example, the lwip nat layer was not totally available by default yet into the esp-idf compiled core that arduino-esp32 is based on.

If it works for you, it might be then included now then :)

I will check that out further and I will let you know, but I am happy that you made it works out of the box.

paclema commented 1 year ago

Hi @gsicilia82 I have been testing this repo example using your platofmio.ini but for me the ip_napt_enable() function is not available using the standard arduino-esp32 framework.

Could you share what are the exact program that you had run that works for you, please?

gsicilia82 commented 1 year ago

To be sure that my arduino framework still coresponds to original distribution, how can I "reset" my data and start by null?

Attached, you will find my platformio.ini. Maybe, the tasmota distribution has napt/lwip already included? I always use tasmota distro cause of esp32 solo1 framework.

[platformio]
default_envs = esp32debug
build_cache_dir = /home/giuseppe/.buildcache
extra_configs = platformio_override.ini

[env]
lib_compat_mode = strict

[common]
lib_deps = 
build_flags = 
    -D DEBUG

[env:esp32]
platform = https://github.com/tasmota/platform-espressif32/releases/download/v.2.0.5/platform-espressif32-v.2.0.5.zip
platform_packages = 
framework = arduino
board = esp32dev
check_tool = cppcheck
lib_deps = ${common.lib_deps}
monitor_speed = 115200
upload_speed = 1500000
lib_ldf_mode = deep
monitor_filters = 
    esp32_exception_decoder
    time
build_unflags = 
build_flags = ${common.build_flags}

[env:esp32debug]
platform = https://github.com/tasmota/platform-espressif32/releases/download/v.2.0.5/platform-espressif32-v.2.0.5.zip
platform_packages = 
framework = arduino
board = esp32dev
check_tool = cppcheck
lib_deps = ${common.lib_deps}
monitor_speed = 115200
monitor_port = /dev/ttyUSB1
debug_tool = esp-prog
debug_init_break = tbreak setup
upload_port = /dev/ttyUSB1
lib_ldf_mode = deep
monitor_filters = 
    esp32_exception_decoder
    time
build_unflags = 
build_type = debug
build_flags = ${common.build_flags}
#upload_protocol = esp-prog
#debug_port = /dev/ttyUSB0
paclema commented 1 year ago

Thanks for your answer @gsicilia82! I am afraid that this is the case. Tasmota platform has its own arduino-esp32 version where they have compiled esp-idf adding the NAPT features by default (not enabled in the espressif official arduino-esp32 framework) in the same way that I explain in the readme of this repo. So in your case you are not using the official arduino-esp32 framework distributed from espressif but the Tasmota version, which already include LWIP-NAPT capabilities.

You can also check more details about this on this issue: https://github.com/espressif/arduino-esp32/issues/6421

Using platformio, the arduino-esp32 framework will be downloaded under the folder .platormio/packages/framework-arduinoespressif32 inside your user home folder. You can remove manually that folder if you want to make platformio download it again the next time that you compile your program.

gsicilia82 commented 1 year ago

Thanks for your effort to clarify this topic. In this case, I am pretty sure that your test with original framework and not working lwip napt coresponds to real/original behaviour. With solo1 project, I started to use tasmota distribution and I continued this way cause of stable results. I never thought about other side effects.

paclema commented 1 year ago

Thank you for your feedback too! I guess we must wait until this feature is included in espressif´s framework with this PR: https://github.com/espressif/esp32-arduino-lib-builder/pull/69, but in your case, it makes sense to use tasmota´s ;)

I close this issue since I guess this has been clarified.