|
ESP8266_RTOS_SDK
v1.4.0
|
Network espconn APIs. More...
Data Structures | |
| struct | _esp_tcp |
| struct | _esp_udp |
| struct | _remot_info |
| struct | espconn |
Macros | |
| #define | ESPCONN_OK 0 |
| #define | ESPCONN_MEM -1 |
| #define | ESPCONN_TIMEOUT -3 |
| #define | ESPCONN_RTE -4 |
| #define | ESPCONN_INPROGRESS -5 |
| #define | ESPCONN_MAXNUM -7 |
| #define | ESPCONN_ABRT -8 |
| #define | ESPCONN_RST -9 |
| #define | ESPCONN_CLSD -10 |
| #define | ESPCONN_CONN -11 |
| #define | ESPCONN_ARG -12 |
| #define | ESPCONN_IF -14 |
| #define | ESPCONN_ISCONN -15 |
Typedefs | |
| typedef void(* | espconn_connect_callback) (void *arg) |
| Connect callback. More... | |
| typedef void(* | espconn_reconnect_callback) (void *arg, sint8 err) |
| Reconnect callback. More... | |
| typedef struct _esp_tcp | esp_tcp |
| typedef struct _esp_udp | esp_udp |
| typedef struct _remot_info | remot_info |
| typedef void(* | espconn_recv_callback) (void *arg, char *pdata, unsigned short len) |
| typedef void(* | espconn_sent_callback) (void *arg) |
| typedef void(* | dns_found_callback) (const char *name, ip_addr_t *ipaddr, void *callback_arg) |
| Callback which is invoked when a hostname is found. More... | |
Enumerations | |
| enum | espconn_type { ESPCONN_INVALID = 0, ESPCONN_TCP = 0x10, ESPCONN_UDP = 0x20 } |
| enum | espconn_state { ESPCONN_NONE, ESPCONN_WAIT, ESPCONN_LISTEN, ESPCONN_CONNECT, ESPCONN_WRITE, ESPCONN_READ, ESPCONN_CLOSE } |
| enum | espconn_option { ESPCONN_START = 0x00, ESPCONN_REUSEADDR = 0x01, ESPCONN_NODELAY = 0x02, ESPCONN_COPY = 0x04, ESPCONN_KEEPALIVE = 0x08, ESPCONN_END } |
| enum | espconn_level { ESPCONN_KEEPIDLE, ESPCONN_KEEPINTVL, ESPCONN_KEEPCNT } |
| enum | { ESPCONN_IDLE = 0, ESPCONN_CLIENT, ESPCONN_SERVER, ESPCONN_BOTH, ESPCONN_MAX } |
Functions | |
| void | espconn_init (void) |
| espconn initialization. More... | |
| sint8 | espconn_connect (struct espconn *espconn) |
| Connect to a TCP server (ESP8266 acting as TCP client). More... | |
| sint8 | espconn_disconnect (struct espconn *espconn) |
| Disconnect a TCP connection. More... | |
| sint8 | espconn_delete (struct espconn *espconn) |
| Delete a transmission. More... | |
| sint8 | espconn_accept (struct espconn *espconn) |
| Creates a TCP server (i.e. accepts connections). More... | |
| sint8 | espconn_create (struct espconn *espconn) |
| Create UDP transmission. More... | |
| uint8 | espconn_tcp_get_max_con (void) |
| Get maximum number of how many TCP connections are allowed. More... | |
| sint8 | espconn_tcp_set_max_con (uint8 num) |
| Set the maximum number of how many TCP connection is allowed. More... | |
| sint8 | espconn_tcp_get_max_con_allow (struct espconn *espconn) |
| Get the maximum number of TCP clients which are allowed to connect to ESP8266 TCP server. More... | |
| sint8 | espconn_tcp_set_max_con_allow (struct espconn *espconn, uint8 num) |
| Set the maximum number of TCP clients allowed to connect to ESP8266 TCP server. More... | |
| sint8 | espconn_regist_time (struct espconn *espconn, uint32 interval, uint8 type_flag) |
| Register timeout interval of ESP8266 TCP server. More... | |
| sint8 | espconn_get_connection_info (struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags) |
| Get the information about a TCP connection or UDP transmission. More... | |
| sint8 | espconn_regist_sentcb (struct espconn *espconn, espconn_sent_callback sent_cb) |
| Register data sent callback which will be called back when data are successfully sent. More... | |
| sint8 | espconn_regist_write_finish (struct espconn *espconn, espconn_connect_callback write_finish_fn) |
| Register a callback which will be called when all sending TCP data is completely write into write-buffer or sent. More... | |
| sint8 | espconn_send (struct espconn *espconn, uint8 *psent, uint16 length) |
| Send data through network. More... | |
| sint8 | espconn_sent (struct espconn *espconn, uint8 *psent, uint16 length) |
| Send data through network. More... | |
| sint16 | espconn_sendto (struct espconn *espconn, uint8 *psent, uint16 length) |
| Send UDP data. More... | |
| sint8 | espconn_regist_connectcb (struct espconn *espconn, espconn_connect_callback connect_cb) |
| Register connection function which will be called back under successful TCP connection. More... | |
| sint8 | espconn_regist_recvcb (struct espconn *espconn, espconn_recv_callback recv_cb) |
| register data receive function which will be called back when data are received. More... | |
| sint8 | espconn_regist_reconcb (struct espconn *espconn, espconn_reconnect_callback recon_cb) |
| Register reconnect callback. More... | |
| sint8 | espconn_regist_disconcb (struct espconn *espconn, espconn_connect_callback discon_cb) |
| Register disconnection function which will be called back under successful TCP disconnection. More... | |
| uint32 | espconn_port (void) |
| Get an available port for network. More... | |
| sint8 | espconn_set_opt (struct espconn *espconn, uint8 opt) |
| Set option of TCP connection. More... | |
| sint8 | espconn_clear_opt (struct espconn *espconn, uint8 opt) |
| Clear option of TCP connection. More... | |
| sint8 | espconn_set_keepalive (struct espconn *espconn, uint8 level, void *optarg) |
| Set configuration of TCP keep alive. More... | |
| sint8 | espconn_get_keepalive (struct espconn *espconn, uint8 level, void *optarg) |
| Get configuration of TCP keep alive. More... | |
| err_t | espconn_gethostbyname (struct espconn *pespconn, const char *hostname, ip_addr_t *addr, dns_found_callback found) |
| DNS function. More... | |
| sint8 | espconn_igmp_join (ip_addr_t *host_ip, ip_addr_t *multicast_ip) |
| Join a multicast group. More... | |
| sint8 | espconn_igmp_leave (ip_addr_t *host_ip, ip_addr_t *multicast_ip) |
| Leave a multicast group. More... | |
| sint8 | espconn_recv_hold (struct espconn *pespconn) |
| Puts in a request to block the TCP receive function. More... | |
| sint8 | espconn_recv_unhold (struct espconn *pespconn) |
| Unblock TCP receiving data (i.e. undo espconn_recv_hold). More... | |
| void | espconn_dns_setserver (char numdns, ip_addr_t *dnsserver) |
| Set default DNS server. Two DNS server is allowed to be set. More... | |
Network espconn APIs.
| #define ESPCONN_ABRT -8 |
Connection aborted.
| #define ESPCONN_ARG -12 |
Illegal argument.
| #define ESPCONN_CLSD -10 |
Connection closed.
| #define ESPCONN_CONN -11 |
Not connected.
| #define ESPCONN_IF -14 |
UDP send error.
| #define ESPCONN_INPROGRESS -5 |
Operation in progress.
| #define ESPCONN_ISCONN -15 |
Already connected.
| #define ESPCONN_MAXNUM -7 |
Total number exceeds the maximum limitation.
| #define ESPCONN_MEM -1 |
Out of memory.
| #define ESPCONN_OK 0 |
No error, everything OK.
| #define ESPCONN_RST -9 |
Connection reset.
| #define ESPCONN_RTE -4 |
Routing problem.
| #define ESPCONN_TIMEOUT -3 |
Timeout.
| typedef void(* dns_found_callback) (const char *name, ip_addr_t *ipaddr, void *callback_arg) |
Callback which is invoked when a hostname is found.
| const | char *name : hostname |
| ip_addr_t | *ipaddr : IP address of the hostname, or to be NULL if the name could not be found (or on any other error). |
| void | *callback_arg : callback argument. |
| typedef void(* espconn_connect_callback) (void *arg) |
Connect callback.
Callback which will be called if successful listening (ESP8266 as TCP server) or connection (ESP8266 as TCP client) callback, register by espconn_regist_connectcb.
| void | *arg : pointer corresponding structure espconn. |
| typedef void(* espconn_reconnect_callback) (void *arg, sint8 err) |
Reconnect callback.
Enter this callback when error occurred, TCP connection broke. This callback is registered by espconn_regist_reconcb.
| void | *arg : pointer corresponding structure espconn. |
| sint8 | err : error code
|
| typedef void(* espconn_recv_callback) (void *arg, char *pdata, unsigned short len) |
A callback prototype to inform about events for a espconn
| enum espconn_level |
| enum espconn_option |
| enum espconn_state |
Current state of the espconn.
| enum espconn_type |
| sint8 espconn_accept | ( | struct espconn * | espconn | ) |
Creates a TCP server (i.e. accepts connections).
| struct | espconn *espconn : the network connection structure |
| sint8 espconn_clear_opt | ( | struct espconn * | espconn, |
| uint8 | opt | ||
| ) |
Clear option of TCP connection.
| struct | espconn *espconn : the TCP connection structure |
| uint8 | opt : enum espconn_option |
| sint8 espconn_connect | ( | struct espconn * | espconn | ) |
Connect to a TCP server (ESP8266 acting as TCP client).
| struct | espconn *espconn : the network connection structure, the espconn to listen to the connection |
| sint8 espconn_create | ( | struct espconn * | espconn | ) |
Create UDP transmission.
| struct | espconn *espconn : the UDP control block structure |
| sint8 espconn_delete | ( | struct espconn * | espconn | ) |
Delete a transmission.
| struct | espconn *espconn : the network connection structure |
| sint8 espconn_disconnect | ( | struct espconn * | espconn | ) |
Disconnect a TCP connection.
| struct | espconn *espconn : the network connection structure |
| void espconn_dns_setserver | ( | char | numdns, |
| ip_addr_t * | dnsserver | ||
| ) |
Set default DNS server. Two DNS server is allowed to be set.
| char | numdns : DNS server ID, 0 or 1 |
| ip_addr_t | *dnsserver : DNS server IP |
| sint8 espconn_get_connection_info | ( | struct espconn * | pespconn, |
| remot_info ** | pcon_info, | ||
| uint8 | typeflags | ||
| ) |
Get the information about a TCP connection or UDP transmission.
| struct | espconn *espconn : the network connection structure |
| remot_info | **pcon_info : connect to client info |
| uint8 | typeflags : 0, regular server; 1, ssl server |
| sint8 espconn_get_keepalive | ( | struct espconn * | espconn, |
| uint8 | level, | ||
| void * | optarg | ||
| ) |
Get configuration of TCP keep alive.
| struct | espconn *espconn : the TCP connection structure |
| uint8 | level : enum espconn_level |
| void* | optarg : value of parameter |
| err_t espconn_gethostbyname | ( | struct espconn * | pespconn, |
| const char * | hostname, | ||
| ip_addr_t * | addr, | ||
| dns_found_callback | found | ||
| ) |
DNS function.
Parse a hostname (string) to an IP address.
| struct | espconn *pespconn : espconn to parse a hostname. |
| const | char *hostname : the hostname. |
| ip_addr_t | *addr : IP address. |
| dns_found_callback | found : callback of DNS |
| sint8 espconn_igmp_join | ( | ip_addr_t * | host_ip, |
| ip_addr_t * | multicast_ip | ||
| ) |
Join a multicast group.
| ip_addr_t | *host_ip : IP of UDP host |
| ip_addr_t | *multicast_ip : IP of multicast group |
| sint8 espconn_igmp_leave | ( | ip_addr_t * | host_ip, |
| ip_addr_t * | multicast_ip | ||
| ) |
Leave a multicast group.
| ip_addr_t | *host_ip : IP of UDP host |
| ip_addr_t | *multicast_ip : IP of multicast group |
| void espconn_init | ( | void | ) |
espconn initialization.
| null |
| uint32 espconn_port | ( | void | ) |
Get an available port for network.
| null |
| sint8 espconn_recv_hold | ( | struct espconn * | pespconn | ) |
Puts in a request to block the TCP receive function.
| struct | espconn *espconn : corresponding TCP connection structure |
| sint8 espconn_recv_unhold | ( | struct espconn * | pespconn | ) |
Unblock TCP receiving data (i.e. undo espconn_recv_hold).
| struct | espconn *espconn : corresponding TCP connection structure |
| sint8 espconn_regist_connectcb | ( | struct espconn * | espconn, |
| espconn_connect_callback | connect_cb | ||
| ) |
Register connection function which will be called back under successful TCP connection.
| struct | espconn *espconn : the TCP connection structure |
| espconn_connect_callback | connect_cb : registered callback function |
| sint8 espconn_regist_disconcb | ( | struct espconn * | espconn, |
| espconn_connect_callback | discon_cb | ||
| ) |
Register disconnection function which will be called back under successful TCP disconnection.
| struct | espconn *espconn : the TCP connection structure |
| espconn_connect_callback | discon_cb : registered callback function |
| sint8 espconn_regist_reconcb | ( | struct espconn * | espconn, |
| espconn_reconnect_callback | recon_cb | ||
| ) |
Register reconnect callback.
| struct | espconn *espconn : the TCP connection structure |
| espconn_reconnect_callback | recon_cb : registered callback function |
| sint8 espconn_regist_recvcb | ( | struct espconn * | espconn, |
| espconn_recv_callback | recv_cb | ||
| ) |
register data receive function which will be called back when data are received.
| struct | espconn *espconn : the network transmission structure |
| espconn_recv_callback | recv_cb : registered callback function |
| sint8 espconn_regist_sentcb | ( | struct espconn * | espconn, |
| espconn_sent_callback | sent_cb | ||
| ) |
Register data sent callback which will be called back when data are successfully sent.
| struct | espconn *espconn : the network connection structure |
| espconn_sent_callback | sent_cb : registered callback function which will be called if the data is successfully sent |
| sint8 espconn_regist_time | ( | struct espconn * | espconn, |
| uint32 | interval, | ||
| uint8 | type_flag | ||
| ) |
Register timeout interval of ESP8266 TCP server.
| struct | espconn *espconn : the TCP connection structure |
| uint32 | interval : timeout interval, unit: second, maximum: 7200 seconds |
| uint8 | type_flag : 0, set for all connections; 1, set for a specific connection
|
| sint8 espconn_regist_write_finish | ( | struct espconn * | espconn, |
| espconn_connect_callback | write_finish_fn | ||
| ) |
Register a callback which will be called when all sending TCP data is completely write into write-buffer or sent.
Need to call espconn_set_opt to enable write-buffer first.
| struct | espconn *espconn : the network connection structure |
| espconn_connect_callback | write_finish_fn : registered callback function which will be called if the data is completely write into write buffer or sent. |
| sint8 espconn_send | ( | struct espconn * | espconn, |
| uint8 * | psent, | ||
| uint16 | length | ||
| ) |
Send data through network.
| struct | espconn *espconn : the network connection structure |
| uint8 | *psent : pointer of data |
| uint16 | length : data length |
| sint16 espconn_sendto | ( | struct espconn * | espconn, |
| uint8 * | psent, | ||
| uint16 | length | ||
| ) |
Send UDP data.
| struct | espconn *espconn : the UDP structure |
| uint8 | *psent : pointer of data |
| uint16 | length : data length |
| sint8 espconn_sent | ( | struct espconn * | espconn, |
| uint8 * | psent, | ||
| uint16 | length | ||
| ) |
Send data through network.
This API is deprecated, please use espconn_send instead.
| struct | espconn *espconn : the network connection structure |
| uint8 | *psent : pointer of data |
| uint16 | length : data length |
| sint8 espconn_set_keepalive | ( | struct espconn * | espconn, |
| uint8 | level, | ||
| void * | optarg | ||
| ) |
Set configuration of TCP keep alive.
| struct | espconn *espconn : the TCP connection structure |
| uint8 | level : To do TCP keep-alive detection every ESPCONN_KEEPIDLE. If there is no response, retry ESPCONN_KEEPCNT times every ESPCONN_KEEPINTVL. If still no response, considers it as TCP connection broke, goes into espconn_reconnect_callback. Notice, keep alive interval is not precise, only for reference, it depends on priority. |
| void* | optarg : value of parameter |
| sint8 espconn_set_opt | ( | struct espconn * | espconn, |
| uint8 | opt | ||
| ) |
Set option of TCP connection.
| struct | espconn *espconn : the TCP connection structure |
| uint8 | opt : option of TCP connection, refer to enum espconn_option
|
| uint8 espconn_tcp_get_max_con | ( | void | ) |
Get maximum number of how many TCP connections are allowed.
| null |
| sint8 espconn_tcp_get_max_con_allow | ( | struct espconn * | espconn | ) |
Get the maximum number of TCP clients which are allowed to connect to ESP8266 TCP server.
| struct | espconn *espconn : the TCP server structure |
| sint8 espconn_tcp_set_max_con | ( | uint8 | num | ) |
Set the maximum number of how many TCP connection is allowed.
| uint8 | num : Maximum number of how many TCP connection is allowed. |
| sint8 espconn_tcp_set_max_con_allow | ( | struct espconn * | espconn, |
| uint8 | num | ||
| ) |
Set the maximum number of TCP clients allowed to connect to ESP8266 TCP server.
| struct | espconn *espconn : the TCP server structure |
| uint8 | num : Maximum number of TCP clients which are allowed |
1.8.10