ESP8266 Developer Zone The Official ESP8266 Forum 2015-05-29T09:50:55+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=506 2015-05-29T09:50:55+08:00 2015-05-29T09:50:55+08:00 https://bbs.espressif.com:443/viewtopic.php?t=506&p=1947#p1947 <![CDATA[Re: Field esp_pcb]]>
please refer to this:

Code:

LOCAL void ICACHE_FLASH_ATTR
user_tcp_connect_cb(void *arg)
{
struct espconn *pespconn = arg;
pespconn->reverse = os_malloc(sizeof(my_custom_type));
espconn_regist_recvcb(pespconn, user_tcp_recv_cb);
}

user_tcp_recv_cb(void *arg, char *pusrdata, unsigned short length)
{
struct espconn *pespconn = arg;
my_custom_type* my = (my_custom_type*) pespconn->reverse;

// Do stuff with object (my)
}

Statistics: Posted by ESP_Faye — Fri May 29, 2015 9:50 am


]]>
2015-05-28T14:19:35+08:00 2015-05-28T14:19:35+08:00 https://bbs.espressif.com:443/viewtopic.php?t=506&p=1940#p1940 <![CDATA[Re: Field esp_pcb]]>
I would like to pass my own object between callbacks. For example:

LOCAL void ICACHE_FLASH_ATTR
user_tcp_connect_cb(void *arg)
{
struct espconn *pespconn = arg;
pespconn->esp_pcb = os_malloc(sizeof(my_custom_type));
espconn_regist_recvcb(pespconn, user_tcp_recv_cb);
}

user_tcp_recv_cb(void *arg, char *pusrdata, unsigned short length)
{
struct espconn *pespconn = arg;
my_custom_type* my = (my_custom_type*) pespconn->esp_pcb;

// Do stuff with object (my)
}


Is that correct? Or is there another recommended way for passing data among callbacks?


Thanks!
Antonio.

Statistics: Posted by amsjunior — Thu May 28, 2015 2:19 pm


]]>
2015-05-27T16:09:03+08:00 2015-05-27T16:09:03+08:00 https://bbs.espressif.com:443/viewtopic.php?t=506&p=1917#p1917 <![CDATA[Re: Field esp_pcb]]>
Do you mean the "typedef void *espconn_handle;" in espconn.h ?

It can be used to point to user's own object, but we recommend to use "struct espconn" .

Here is a demo of TCP connection http://bbs.espressif.com/viewtopic.php?f=21&t=232

Statistics: Posted by ESP_Faye — Wed May 27, 2015 4:09 pm


]]>
2015-05-27T13:05:06+08:00 2015-05-27T13:05:06+08:00 https://bbs.espressif.com:443/viewtopic.php?t=506&p=1914#p1914 <![CDATA[Field esp_pcb]]>
the struct espconn has the following field:
espconn_handle esp_pcb;

I'm wondering if this field is used internally by the ESP connection management, or if it's a field that I can use to point to my own object, and then retrieve these it from the callbacks.


Thanks!
Antonio.

Statistics: Posted by amsjunior — Wed May 27, 2015 1:05 pm


]]>