ESP8266 Developer Zone The Official ESP8266 Forum 2015-08-02T10:15:03+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=785 2015-08-02T10:15:03+08:00 2015-08-02T10:15:03+08:00 https://bbs.espressif.com:443/viewtopic.php?t=785&p=3002#p3002 <![CDATA[Re: Design questions]]>

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.

Statistics: Posted by ming — Sun Aug 02, 2015 10:15 am


]]>
2015-07-29T11:32:16+08:00 2015-07-29T11:32:16+08:00 https://bbs.espressif.com:443/viewtopic.php?t=785&p=2908#p2908 <![CDATA[Re: Design questions]]>
Ben

Statistics: Posted by stickben — Wed Jul 29, 2015 11:32 am


]]>
2015-07-29T07:35:14+08:00 2015-07-29T07:35:14+08:00 https://bbs.espressif.com:443/viewtopic.php?t=785&p=2904#p2904 <![CDATA[Re: Design questions]]> Statistics: Posted by tve — Wed Jul 29, 2015 7:35 am


]]>
2015-07-29T00:53:54+08:00 2015-07-29T00:53:54+08:00 https://bbs.espressif.com:443/viewtopic.php?t=785&p=2902#p2902 <![CDATA[Re: Design questions]]> Statistics: Posted by stickben — Wed Jul 29, 2015 12:53 am


]]>
2015-07-28T09:58:23+08:00 2015-07-28T09:58:23+08:00 https://bbs.espressif.com:443/viewtopic.php?t=785&p=2884#p2884 <![CDATA[Re: Design questions]]>
How you manage one or more espconn references is up to you.

Neil

Statistics: Posted by kolban — Tue Jul 28, 2015 9:58 am


]]>
2015-07-28T09:38:39+08:00 2015-07-28T09:38:39+08:00 https://bbs.espressif.com:443/viewtopic.php?t=785&p=2883#p2883 <![CDATA[Re: Design questions]]>
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.

Statistics: Posted by stickben — Tue Jul 28, 2015 9:38 am


]]>
2015-07-24T17:05:45+08:00 2015-07-24T17:05:45+08:00 https://bbs.espressif.com:443/viewtopic.php?t=785&p=2825#p2825 <![CDATA[Re: Design questions]]>
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 !

Statistics: Posted by ESP_Faye — Fri Jul 24, 2015 5:05 pm


]]>
2015-07-22T03:27:19+08:00 2015-07-22T03:27:19+08:00 https://bbs.espressif.com:443/viewtopic.php?t=785&p=2777#p2777 <![CDATA[Design questions]]>
- 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

Statistics: Posted by stickben — Wed Jul 22, 2015 3:27 am


]]>