ESP8266 Developer Zone The Official ESP8266 Forum 2014-10-30T09:38:41+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=8 2014-10-30T09:38:41+08:00 2014-10-30T09:38:41+08:00 https://bbs.espressif.com:443/viewtopic.php?t=8&p=26#p26 <![CDATA[Re: espconn_get_connection_info()]]> espconn_regist_connectcb : register a callback that will be called when connect succeed.
espconn_regist_disconcb: for disconnect
espconn_regist_reconcb: register a reconnect callback which will be called when abnormal disconnection happens or connect fail.
espconn_regist_sentcb: for packet send succeed.
espconn_regist_recvcb: for packet received.

Statistics: Posted by ESP_Faye — Thu Oct 30, 2014 9:38 am


]]>
2014-10-28T17:20:55+08:00 2014-10-28T17:20:55+08:00 https://bbs.espressif.com:443/viewtopic.php?t=8&p=21#p21 <![CDATA[Re: espconn_get_connection_info()]]> It seems that I don't need to call espconn_get_connection_info() since the "state" property is updated by the functions implemented in lwip portion.

In my app I can simply check myConn->state.

Statistics: Posted by muris — Tue Oct 28, 2014 5:20 pm


]]>
2014-10-28T15:36:01+08:00 2014-10-28T15:36:01+08:00 https://bbs.espressif.com:443/viewtopic.php?t=8&p=20#p20 <![CDATA[Re: espconn_get_connection_info()]]>

If this is used to get the info of tcp client that is connected to ESP8266 (which runs as a tcp server), is there a command to query the ESP8266 chip and see the status of a socket connection to a cloud server? What I am trying to do is get the status of current socket connection from ESP8266 to the Cloud server. So this function can't be used for that? Is there a different function to use?

I have a situation where ESP8266 is always connected to the cloud server, but sometimes connection breaks. Then I have a timer that checks whether the connection is still active and if not it would start the re-connect process. Is this approach wrong, or can I simply use the callback functions which are called when connection breaks, such as this one:

Code:

espconn_regist_reconcb(ctrlConn, tcpclient_recon_cb);


It seems logical that espconn_get_connection_info() will get the provided espconn's info and set the "state" property to any of:

/** Current state of the espconn. Non-TCP espconn are always in state ESPCONN_NONE! */
enum espconn_state {
ESPCONN_NONE,
ESPCONN_WAIT,
ESPCONN_LISTEN,
ESPCONN_CONNECT,
ESPCONN_WRITE,
ESPCONN_READ,
ESPCONN_CLOSE
};


Thanks :)

Statistics: Posted by muris — Tue Oct 28, 2014 3:36 pm


]]>
2014-10-28T09:08:37+08:00 2014-10-28T09:08:37+08:00 https://bbs.espressif.com:443/viewtopic.php?t=8&p=16#p16 <![CDATA[Re: espconn_get_connection_info()]]>
costaud wrote:

Code:

remot_info *pinfo = NULL;
espconn_get_connection_info(espconn, &pinfo , 0);


;)


Yes, this is right! there is no need to call os_zalloc
and the description is wrong. :oops: . this api is used to get the info of tcp client that connected to ESP8266(which runs as a tcp server).

Statistics: Posted by ESP_Faye — Tue Oct 28, 2014 9:08 am


]]>
2014-10-28T00:47:16+08:00 2014-10-28T00:47:16+08:00 https://bbs.espressif.com:443/viewtopic.php?t=8&p=15#p15 <![CDATA[Re: espconn_get_connection_info()]]>

Code:

remot_info *pinfo = NULL;
espconn_get_connection_info(espconn, &pinfo , 0);


;)

Statistics: Posted by costaud — Tue Oct 28, 2014 12:47 am


]]>
2014-10-27T19:56:01+08:00 2014-10-27T19:56:01+08:00 https://bbs.espressif.com:443/viewtopic.php?t=8&p=13#p13 <![CDATA[espconn_get_connection_info()]]>
Is there any example on how to use this function espconn_get_connection_info() ?

I would like to check the state of my connection but when I read description in espconn.h I get another explanation:

Code:

/******************************************************************************
 * FunctionName : espconn_get_connection_info
 * Description  : used to specify the function that should be called when disconnect
 * Parameters   : espconn -- espconn to set the err callback
 *                discon_cb -- err callback function to call when err
 * Returns      : none
*******************************************************************************/

sint8 espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags);

It says that this function sets a callback function to be called when connection disconnects?! Do you have a simple example of how this function is actually used?

Is this OK:

Code:

   remot_info *ri = (struct remot_info *)os_zalloc(sizeof(struct remot_info));
   espconn_get_connection_info(myConn, &ri, 0);
   enum espconn_state connInfo = ri->state;

   // connInfo now holds information about myConn connection?

It is a bit difficult to debug so I thought I better ask here before trying when I get home tonight from work.

Thanks!

Statistics: Posted by muris — Mon Oct 27, 2014 7:56 pm


]]>