ESP8266 Developer Zone The Official ESP8266 Forum 2016-09-14T22:59:27+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=2771 2016-09-14T22:59:27+08:00 2016-09-14T22:59:27+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2771&p=9831#p9831 <![CDATA[Re: When and how to use espconn_set_keepalive?]]>
Could you explain why i have to use all three of those keepalive functions? It also doesn't help to check every 30s if the connection is still established because the discon_cb is almost instantaneously called after espconn_send, maybe there are a couple of ms between sending something to a tcp server and the discon_cb.

Statistics: Posted by Stational — Wed Sep 14, 2016 10:59 pm


]]>
2016-09-14T11:44:12+08:00 2016-09-14T11:44:12+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2771&p=9821#p9821 <![CDATA[Re: When and how to use espconn_set_keepalive?]]>
for example:

Code:

   int keep_alive = 30;   //keep alive checking per 30s
   espconn_set_opt(my_espconn, ESPCONN_KEEPALIVE);
   espconn_set_keepalive(my_espconn, ESPCONN_KEEPIDLE, &keep_alive);
   keep_alive = 5; //repeat interval = 5s
   espconn_set_keepalive(my_espconn, ESPCONN_KEEPINTVL, &keep_alive);
   keep_alive = 2;//repeat 2times
   espconn_set_keepalive(my_espconn, ESPCONN_KEEPCNT, &keep_alive);


regards,

Statistics: Posted by stupiid — Wed Sep 14, 2016 11:44 am


]]>
2016-09-13T23:02:31+08:00 2016-09-13T23:02:31+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2771&p=9814#p9814 <![CDATA[When and how to use espconn_set_keepalive?]]>
i would like to establish a tcp connection which doesn't get closed after the first data send, i read about the espconn_set_keepalive function which sends heartbeats to the server so it doesn't disconnect (if i understood correctly). But i don't know when i should call the function? In the connectcb?

I tried it like this:

Code:

LOCAL void ICACHE_FLASH_ATTR
tcp_connect_cb(void *arg){
   os_printf("We are connected!\n");
   sint8 ret = espconn_set_keepalive((struct espconn*)arg,ESPCONN_KEEPCNT,(void*)1000);
   if(ret==0)
      os_printf("Set keepalive.\n");
}


But the text didn't get printed on my serial terminal. What did I do wrong?

Any help is very much appreciated!

Statistics: Posted by Stational — Tue Sep 13, 2016 11:02 pm


]]>