So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By A001
#93904 Hi
I found ESP two weeks ago.
One (first) question: AP_STA mode means one interface with two IP address ?
I saw if I start UDP server is it also seen by clients from AP and STA.
Thanks.
User avatar
By Inq720
#93908
A001 wrote:Hi
I found ESP two weeks ago.
One (first) question: AP_STA mode means one interface with two IP address ?
I saw if I start UDP server is it also seen by clients from AP and STA.
Thanks.


Welcome to the new hobby.

I'll describe it as I understand it and maybe it'll answer your question. If not, try again.
  • There is SoftAP mode where the ESP acts like a router and you can connect devices (up to 8) directly to it. It has DHCP and you can define what addresses the ESP will hand out to your devices.
  • There is Station mode where you can tell the ESP to hook up to your home router. That way your other devices on your LAN can connect up to the ESP via your router. They and the ESP will use IP addresses handed out by your router's DHCP.
  • You can do both at the same time also.
Once connected, you can use TCP, HTTP and/or UDP through either path.

Does that help or make things worse? :D
User avatar
By A001
#93920 Ok.
It's possible to detect which way a packet came to the my ESP8266 UDP server? From AP or STA ?
I want to redirect these packages.
If they came from the AP to UDP server they must be sent to a client.
And vice versa.
Thanks.
User avatar
By Inq720
#93957
A001 wrote:Ok.
It's possible to detect which way a packet came to the my ESP8266 UDP server? From AP or STA ?
I want to redirect these packages.
If they came from the AP to UDP server they must be sent to a client.
And vice versa.
Thanks.


Depends on a couple of things.
UDP messages contain a UDP header and an IP header. The IP header includes Source IP Address and Destination IP Address. This is true for all machines.
udp.png


TCP and directed UDP packet's Destination IP Address coming into your ESP8266 will have the ESP8266's address of the SoftAP or StationAP that they arrive. Unfortunately, if the senders were using broadcasts the destination is 255.255.255.255.

But... you can solve this in different ways. Maybe you know what the source IP addresses ranges... that will be coming in one versus the other. OR you can setup the Listening Ports to be different and know which one they came in on by their Ports.

Now as far as how to dig out those header details, that depends on what library you're using. The lowest level uses lwIP and so do several of the other libraries, but they'll probably have different ways at digging out those details. Kind of a dumpster diving exercise in the code base.

Good Luck.
You do not have the required permissions to view the files attached to this post.