user1599391
user1599391

Reputation: 27

esp8266 client and server at the same time

I need to program an esp8266 to do the following:

  1. connect to a wifi network (station mode only)
  2. start a server (udp) process to service requests
  3. start a client (udp) to send roughly every 60 seconds

I am thinking on doing these actions on the setup() function:

  1. create a timer to be triggered every 60 seconds.
  2. start the udp server.

The idea is to "interrupt" the server with the timer and using the same port used on the server to send a udp packet to a remote location. Example: server is started to listen on port 2000. Then when the interrupt is triggered, the server should "pause", then we should send a packet from port 2000 to our remote IP, then the server should "resume"

I am waiting for my board to arrive to test this setup but wanted to know if that is possible. I am assuming that the mqtt client should work similarly (it can subscribe and publish). Aside from an interrupt I can't think on another way to "stop" the server temporarily and act as a client

Has anybody tried this before?

Upvotes: 1

Views: 1303

Answers (1)

user12418439
user12418439

Reputation: 1

You should use the AT command

AT+CIPMUX=1

and

AT+CIPSTART=<link ID>,<type>,<remote IP>,<remote port>[,<TCP keep alive>]<link ID>

Upvotes: 0

Related Questions