ESP8266 Developer Zone The Official ESP8266 Forum 2015-06-26T15:58:15+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=630 2015-06-26T15:58:15+08:00 2015-06-26T15:58:15+08:00 https://bbs.espressif.com:443/viewtopic.php?t=630&p=2413#p2413 <![CDATA[Re: struct espconn pointer in callbacks]]>
espconn pointer of connected callback, recv callback , sent callback would be the same, they are provided by SDK espconn.

espconn pointer of disconnected callback, reconnect callback are the same, they are malloc by user app.

Sorry that may confuse you..

Statistics: Posted by ESP_Faye — Fri Jun 26, 2015 3:58 pm


]]>
2015-06-25T14:47:40+08:00 2015-06-25T14:47:40+08:00 https://bbs.espressif.com:443/viewtopic.php?t=630&p=2395#p2395 <![CDATA[Re: struct espconn pointer in callbacks]]>

It seems that "espconn1" and "espconn2" are the same pointer, aren't them ?


That's my whole point: they are not guaranteed to be! And experimentally I can confirm that this is indeed the case. It's particularly bad when you get a disconnect callback. I see some pretty systematic cases where the pointer you get is different from the one I previously got for the same connection and the structure that the old pointer refers to has been reused for a new connection!

Statistics: Posted by tve — Thu Jun 25, 2015 2:47 pm


]]>
2015-06-25T13:44:38+08:00 2015-06-25T13:44:38+08:00 https://bbs.espressif.com:443/viewtopic.php?t=630&p=2394#p2394 <![CDATA[Re: struct espconn pointer in callbacks]]>

- I get an espconn_connect_callback(arg), where arg points to an espconn struct, let's call this "espconn1"
- I then receive an espconn_recv_callback(arg), where arg points to a different espconn struct, call this "espconn2"


It seems that "espconn1" and "espconn2" are the same pointer, aren't them ? :?

Statistics: Posted by Her Mary — Thu Jun 25, 2015 1:44 pm


]]>
2015-06-25T13:04:03+08:00 2015-06-25T13:04:03+08:00 https://bbs.espressif.com:443/viewtopic.php?t=630&p=2393#p2393 <![CDATA[Re: struct espconn pointer in callbacks]]>
Could you comment on my first post?

Statistics: Posted by tve — Thu Jun 25, 2015 1:04 pm


]]>
2015-06-25T10:30:10+08:00 2015-06-25T10:30:10+08:00 https://bbs.espressif.com:443/viewtopic.php?t=630&p=2392#p2392 <![CDATA[Re: struct espconn pointer in callbacks]]>
Sorry that at_upgrade.c may lead to some misunderstanding.

Code:

static void ICACHE_FLASH_ATTR
at_upDate_discon_cb(void *arg)
{
  struct espconn *pespconn = (struct espconn *)arg;
   ....
}


This pointer is same as the one zalloced in "at_exeCmdCiupdate"

Code:

void ICACHE_FLASH_ATTR
at_exeCmdCiupdate(uint8_t id)
{
  pespconn = (struct espconn *)os_zalloc(sizeof(struct espconn));
  ......
}


These two will be the same pointer. It is malloc by AT app, and free by AT app.

So sorry for these may bother you.

Statistics: Posted by ESP_Faye — Thu Jun 25, 2015 10:30 am


]]>
2015-06-23T03:22:24+08:00 2015-06-23T03:22:24+08:00 https://bbs.espressif.com:443/viewtopic.php?t=630&p=2347#p2347 <![CDATA[Re: struct espconn pointer in callbacks]]> See line 85 of examples/at/user/at_upgrade.c

Statistics: Posted by tve — Tue Jun 23, 2015 3:22 am


]]>
2015-06-20T13:16:59+08:00 2015-06-20T13:16:59+08:00 https://bbs.espressif.com:443/viewtopic.php?t=630&p=2323#p2323 <![CDATA[struct espconn pointer in callbacks]]>

void *arg : pointer corresponding structure espconn. This pointer may be
different in different callbacks, please don’t use this pointer directly to
distinguish one from another in multiple connections, use remote_ip and
remote_port in espconn instead.

How is this supposed to work?

Take the following situation:
- I get an espconn_connect_callback(arg), where arg points to an espconn struct, let's call this "espconn1"
- I then receive an espconn_recv_callback(arg), where arg points to a different espconn struct, call this "espconn2"
- In the receive callback I want to send a response, I thus need to call espconn_sent, do I use espconn1 or espconn2 for this?
- After the receive callback completes, I have a timer firing and I need to send some more data on this same connection, so I need to call espconn_sent again, do I now use espconn1 or esconn2 for this?

Statistics: Posted by tve — Sat Jun 20, 2015 1:16 pm


]]>