jonask1337 / esp-idf-nat-example

ESP-IDF example project with NAT setup.
84 stars 16 forks source link

No Internet connection on ESP8266 #18

Open mtlive opened 3 years ago

mtlive commented 3 years ago

I compiled this example for ESP8266 using FREERTOS SDK which is idf style, and after successful compilation and flashing it on NodeMCU, the ESP connects to the AP and also clients can connect to the esp, but there is no internet connection on clients. i.e. clients cannot communicate with the original AP.

P.S. I needed to remove ret == ESP_ERR_NVS_NEW_VERSION_FOUND from https://github.com/jonask1337/esp-idf-nat-example/blob/master/main/main.c#L138 to get it compiled with the SDK.

Here is the console output:

I (109) boot: compile time 21:07:51
I (109) qio_mode: Enabling default flash chip QIO
I (117) boot: SPI Speed      : 40MHz
I (124) boot: SPI Mode       : QIO
I (130) boot: SPI Flash Size : 4MB
I (136) boot: Partition Table:
I (142) boot: ## Label            Usage          Type ST Offset   Length
I (153) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (165) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (177) boot:  2 factory          factory app      00 00 00010000 000f0000
I (188) boot: End of partition table
I (195) esp_image: segment 0: paddr=0x00010010 vaddr=0x40210010 size=0x4e448 (320584) map
I (296) esp_image: segment 1: paddr=0x0005e460 vaddr=0x4025e458 size=0x0e1ac ( 57772) map
I (312) esp_image: segment 2: paddr=0x0006c614 vaddr=0x3ffe8000 size=0x005f4 (  1524) load
I (313) esp_image: segment 3: paddr=0x0006cc10 vaddr=0x40100000 size=0x00080 (   128) load
I (323) esp_image: segment 4: paddr=0x0006cc98 vaddr=0x40100080 size=0x05464 ( 21604) load
I (342) boot: Loaded app from partition at offset 0x10000
I (368) system_api: Base MAC address is not set, read default base MAC address from EFUSE
I (372) system_api: Base MAC address is not set, read default base MAC address from EFUSE
phy_version: 1163.0, 665d56c, Jun 24 2020, 10:00:08, RTOS new
I (439) phy_init: phy ver: 1163_0
I (472) wifi apsta: wifi_init_apsta finished.
I (475) wifi apsta: connect to ap SSID: MyAP
I (592) wifi:state: 0 -> 2 (b0)
I (597) wifi:state: 2 -> 3 (0)
I (600) wifi:state: 3 -> 5 (10)
I (617) wifi:connected with MyAP, aid = 3, channel 11, HT20, bssid = ...
I (1375) tcpip_adapter: sta ip: 192.168.1.246, mask: 255.255.255.0, gw: 192.168.1.1
I (1379) wifi apsta: got ip:192.168.1.246
I (5011) wifi apsta: station connected
I (5120) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2

Update: I added ping code to check if the module can communicate with both sides (clients and AP), and it could ping all of them.

jonask1337 commented 3 years ago

Hi, sorry for the late response. It looks like NAT is not enabled. Otherwise, there should be a message similar to: (537) wifi apsta: NAT is enabled. This example only works with a custom lwip library and was made for the ESP32 using the ESP-IDF. I do not have experience with the ESP8266 using the FREERTOS SDK, so I do not know if I can help you with this issue. My guess is that at the moment the the custom lwip library is not used and therefore NAT does not work.

mtlive commented 3 years ago

Thank you for your response. Based on what I understand, the custom lwip library is already merged with the ESP one and the esp32 repeater project uses that one.

jonask1337 commented 3 years ago

Yes, as far as I can tell, you are right. I actually didn't know it was merged. Did you enable the NAT function via menuconfig? But it also could be possible that this example doesn't work anymore due to other changes. I will probably take a closer look at it.

mtlive commented 3 years ago

As far as I remember I did. Please kindly ignore it if you are busy, also I might not be able to test it any time soon.