Page 1 of 1
ESP32 Access Point and Station issue
Posted: Tue Apr 19, 2022 10:33 pm
by sidprice
Hello,
I am trying to get an ESP32 DevKit C Arduino sketch working that has both an AP and a Station. The AP is used to provide a private network to similar ESP32 nodes (all in STA mode). The issue I am facing is that I cannot get the ESP32 that has the AP implemented to connect to the network.
I have implemented a similar system using the AT-Command firmware and it works fine. However, I cannot get this Arduino sketch to do the same.
Is the dual mode (AP and STA) possible to work this way? I need the ESP32 with the AP to also be able to connect to the AP network and send/receive multicast packets.
Sid
Re: ESP32 Access Point and Station issue
Posted: Fri Apr 22, 2022 12:00 am
by sidprice
I would love to get a response to this question please,
Sid
Re: ESP32 Access Point and Station issue
Posted: Fri Apr 22, 2022 9:21 pm
by lbernstone
The answer is no.
The ESP32 can do this, arduino-esp32 cannot. It is compiled with the necessary options (ip forwarding and L2->L3 transfers) turned off for security reasons.
The tasmota build for platform.io by Jason2866 (
https://github.com/Jason2866/esp32-ardu ... /releases/) has these options enabled. Or, you can just use tasmota, which in turn uses that platform to build off of, and has NAT forwarding all set up out of the box.
Re: ESP32 Access Point and Station issue
Posted: Fri Apr 22, 2022 11:41 pm
by sidprice
Thank you for your help.
I am already using the jason2866 platform, I had an earlier problem and PlatformIO suggested using that. I do not understand how I can use that platform to achieve the result that I need as all the documentation links are for configuration with PlatformIO and that is done.
I would very much appreciate any help you can offer.
Re: ESP32 Access Point and Station issue
Posted: Sat Apr 23, 2022 1:05 am
by lbernstone
I don't have things setup to test, but it should be as simple as setting up your device in APSTA mode, connecting to the upstream wifi, and calling:
Code: Select all
#include "lwip/lwip_napt.h"
u32_t napt_netif_ip = 0xC0A80401; // Set to ip address of softAP netif (Default is 192.168.4.1)
ip_napt_enable(htonl(napt_netif_ip), 1);
Re: ESP32 Access Point and Station issue
Posted: Sat Apr 23, 2022 11:23 pm
by sidprice
Many thanks, that appears to enable me to send and receive multicast packets from the AP device to the network.
One issue is that after the call to "ip_napt_enable" I have to use a delay, which is not a good practice. Is there an API that could be polled to know when the device is ready?
After the delay I call WiFi.status and it returns "6" (Disconnected) and the IP address returned by WiFi.localIP is "0.0.0.0".
This is confusing because the device does send and receive multicast packets.
Any input would be much appreciated.
Re: ESP32 Access Point and Station issue
Posted: Sun Apr 24, 2022 12:01 am
by lbernstone
The code is at
https://github.com/espressif/esp-lwip/b ... ip4_napt.c
Good luck. Post what you find for the next person that comes along.