Design questions
Design questions
Postby stickben » Wed Jul 22, 2015 3:27 am
- is the espcomm rx callback called from interrupt?
- can you save off the connection pointer in the rx callback and use it later?
- are the user tasks pre-emptive?
- can you start more than one TX at a time (for other connections) or should you always wait for the sent callback?
Is there any design documentation? It would be really nice to have some flow charts and data flow diagrams to show how data moves through the system.
Thanks!
Ben
Re: Design questions
Postby ESP_Faye » Fri Jul 24, 2015 5:05 pm
Here is an example of TCP connection http://bbs.espressif.com/viewtopic.php?f=21&t=232
- is the espcomm rx callback called from interrupt?
-> RX will trigger an 802.11 interrupt, 802.11 will post a message to lwip, espconn rx callback is in lwip.
- can you save off the connection pointer in the rx callback and use it later?
-> Please don't do that, because the pointer may be released in lwip (espconn disconnect callback & espconn reconnect callback)
- are the user tasks pre-emptive?
-> Without RTOS user tasks are not pre-emptive, with RTOS user tasks are pre-emptive.
- can you start more than one TX at a time (for other connections) or should you always wait for the sent callback?
-> To the same espconn connection, you need to wait for the sent callback or write finish callback.
Thanks for your interest in Espressif Systems and ESP8266 !
Re: Design questions
Postby stickben » Tue Jul 28, 2015 9:38 am
For example:
I am writing a server, the server wants to occasionally send data to the client without the client sending to the server.
1-Server is listening
2-TCP client connects
3-I get the connect callback
4-Server waits 5 minutes.
5-Server needs to send data to the connected client
How do I send data to the connected client? The connect callback is over and the client has not sent data so I dont have a current espconn. Is there a way to look up the connection to get the espconn*?
Right now I am saving the espconn * from the connect callback and it seems to work, but I dont see any way to get the espconn * without the connect callback or data sent callback.
Re: Design questions
Postby kolban » Tue Jul 28, 2015 9:58 am
How you manage one or more espconn references is up to you.
Neil
Re: Design questions
Postby stickben » Wed Jul 29, 2015 12:53 am
Re: Design questions
Postby tve » Wed Jul 29, 2015 7:35 am
Re: Design questions
Postby ming » Sun Aug 02, 2015 10:15 am
The only tricky thing is that when you receive a disconnect or recon callback the espconn argument will have the reverse field properly set to point to your struct, but your struct's forward pointer to the espconn will be incorrect at that point (which doesn't matter much 'cause you can't do anything to the connection anymore anyway).
This is really correct and unfortunately I have learned it in a hard way.
The struct espconn pointer comes along with the disconnect or reconnect callback is indeed the espconn of the TCP server that you has created to "listen" for incoming TCP connection (called tcpServerEspconn hereafter), rather than the espconn of the "accepted" TCP connection (called acceptEspconn hereafter). But when the time to dismantle the accepted TCP connection comes, several parameters, including the reverse pointer, are copied from the acceptEspconn to tcpServerEspconn before destroying the acceptEspconn internally and calling the disconnect/reconnect callbacks.
So it is safe to keep acceptEspconn and use it to send/receive/etc until disconnect/reconnect callback is made. In those callbacks, the acceptEspconn pointer is no longer valid, and the most convenient way to find your data structure (where a reference of acceptEspconn is kept) is to use the reverse pointer, which you must set (very likely in the connect callback) when you first made a reference of acceptEspconn.
Who is online
Users browsing this forum: No registered users and 29 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.