Field esp_pcb
Field esp_pcb
Postby amsjunior » Wed May 27, 2015 1:05 pm
Hi there,
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.
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.
Re: Field esp_pcb
Postby ESP_Faye » Wed May 27, 2015 4:09 pm
Hi,
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
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
Re: Field esp_pcb
Postby amsjunior » Thu May 28, 2015 2:19 pm
Thanks Espressif_Faye.
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.
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.
Re: Field esp_pcb
Postby ESP_Faye » Fri May 29, 2015 9:50 am
Hi,
please refer to this:
please refer to this:
Code: Select all
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)
}
Who is online
Users browsing this forum: No registered users and 26 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.