Page 1 of 2

ESP8266 SoftAP with UDP

PostPosted: Wed Dec 01, 2021 5:33 am
by JPM06
Hi, all,

I meet a problem using an ESP8266 in SoftAP mode.

I want to receive UDP packets on the AP size, and send other UDP packets on the station size (after some processing).

Using examples found on the net, I have written a small program, and my ESP-01 now connecs as both a station and an access point, with correct addresses.

But I dont know what to do next: in some programs I have written, I use the "readPacket" and "sendPacket" functions to receive and send UDP packets, but how can I distinguish between both networks? (f.i. send a packet on one network and not the other).

I have tried to duplicate the instanciation of UDP (WiFiUDP udp) but I get an error messages from the IDE.

Could you please help me? Thanks!

Re: ESP8266 SoftAP with UDP

PostPosted: Fri Dec 03, 2021 3:41 am
by JurajA
the two network interfaces (STA and AP) have a different IP address range. LwIP TCP/IP stack of the esp8266 arduino core will use the right interface based on the remote IP you use to send the UDP message

Re: ESP8266 SoftAP with UDP

PostPosted: Fri Dec 03, 2021 3:57 am
by JPM06
Nice, thank you!
But how can I define the address range for each interface? At this point in time I only define the 8266 own addresses on each network.

Re: ESP8266 SoftAP with UDP

PostPosted: Sat Dec 04, 2021 2:38 am
by JurajA
yes and the other devices have their IP addresses set too to be on the same network