MeterLogger
Data Structures | Macros | Typedefs | Enumerations | Functions
espconn.h File Reference
#include "lwip/dns.h"
#include "os_type.h"
Include dependency graph for espconn.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _esp_tcp
 
struct  _esp_udp
 
struct  _remot_info
 
struct  espconn
 
struct  espconn_packet
 
struct  _espconn_buf
 
struct  _comon_pkt
 
struct  _espconn_msg
 
struct  mdns_info
 

Macros

#define espconn_printf(fmt, args...)
 
#define ESPCONN_OK   0 /* No error, everything OK. */
 
#define ESPCONN_MEM   -1 /* Out of memory error. */
 
#define ESPCONN_TIMEOUT   -3 /* Timeout. */
 
#define ESPCONN_RTE   -4 /* Routing problem. */
 
#define ESPCONN_INPROGRESS   -5 /* Operation in progress */
 
#define ESPCONN_MAXNUM   -7 /* Total number exceeds the set maximum*/
 
#define ESPCONN_ABRT   -8 /* Connection aborted. */
 
#define ESPCONN_RST   -9 /* Connection reset. */
 
#define ESPCONN_CLSD   -10 /* Connection closed. */
 
#define ESPCONN_CONN   -11 /* Not connected. */
 
#define ESPCONN_ARG   -12 /* Illegal argument. */
 
#define ESPCONN_IF   -14 /* Low_level error */
 
#define ESPCONN_ISCONN   -15 /* Already connected. */
 
#define ESPCONN_HANDSHAKE   -28 /* ssl handshake failed */
 
#define ESPCONN_RESP_TIMEOUT   -29 /* ssl handshake no response*/
 
#define ESPCONN_PROTO_MSG   -61 /* ssl application invalid */
 
#define ESPCONN_SSL   0x01
 
#define ESPCONN_NORM   0x00
 
#define ESPCONN_STA   0x01
 
#define ESPCONN_AP   0x02
 
#define ESPCONN_AP_STA   0x03
 
#define STA_NETIF   0x00
 
#define AP_NETIF   0x01
 
#define _MDNS_INFO
 
#define linkMax   15
 
#define espconn_delay_disabled(espconn)   (((espconn)->pcommon.espconn_opt & ESPCONN_NODELAY) != 0)
 
#define espconn_delay_enabled(espconn)   (((espconn)->pcommon.espconn_opt & ESPCONN_NODELAY) == 0)
 
#define espconn_reuse_disabled(espconn)   (((espconn)->pcommon.espconn_opt & ESPCONN_REUSEADDR) != 0)
 
#define espconn_copy_disabled(espconn)   (((espconn)->pcommon.espconn_opt & ESPCONN_COPY) != 0)
 
#define espconn_copy_enabled(espconn)   (((espconn)->pcommon.espconn_opt & ESPCONN_COPY) == 0)
 
#define espconn_keepalive_disabled(espconn)   (((espconn)->pcommon.espconn_opt & ESPCONN_KEEPALIVE) != 0)
 
#define espconn_keepalive_enabled(espconn)   (((espconn)->pcommon.espconn_opt & ESPCONN_KEEPALIVE) == 0)
 
#define espconn_TaskPrio   26
 
#define espconn_TaskQueueLen   15
 

Typedefs

typedef void * espconn_handle
 
typedef void(* espconn_connect_callback) (void *arg)
 
typedef void(* espconn_reconnect_callback) (void *arg, sint8 err)
 
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 struct _espconn_buf espconn_buf
 
typedef struct _comon_pkt comon_pkt
 
typedef struct _espconn_msg espconn_msg
 

Enumerations

enum  espconn_type {
  ESPCONN_INVALID = 0, ESPCONN_TCP = 0x10, ESPCONN_UDP = 0x20, 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, 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, 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, ESPCONN_KEEPIDLE,
  ESPCONN_KEEPINTVL, ESPCONN_KEEPCNT
}
 
enum  espconn_sig {
  SIG_ESPCONN_NONE, SIG_ESPCONN_ERRER, SIG_ESPCONN_LISTEN, SIG_ESPCONN_CONNECT,
  SIG_ESPCONN_WRITE, SIG_ESPCONN_SEND, SIG_ESPCONN_READ, SIG_ESPCONN_CLOSE
}
 

Functions

void espconn_copy_partial (struct espconn *pesp_dest, struct espconn *pesp_source)
 
void espconn_list_creat (espconn_msg **phead, espconn_msg *pinsert)
 
void espconn_list_delete (espconn_msg **phead, espconn_msg *pdelete)
 
bool espconn_find_connection (struct espconn *pespconn, espconn_msg **pnode)
 
sint8 espconn_get_connection_info (struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags)
 
sint8 espconn_get_packet_info (struct espconn *espconn, struct espconn_packet *infoarg)
 
sint8 espconn_connect (struct espconn *espconn)
 
sint8 espconn_disconnect (struct espconn *espconn)
 
sint8 espconn_delete (struct espconn *espconn)
 
sint8 espconn_accept (struct espconn *espconn)
 
sint8 espconn_create (struct espconn *espconn)
 
uint8 espconn_tcp_get_wnd (void)
 
sint8 espconn_tcp_set_wnd (uint8 num)
 
uint8 espconn_tcp_get_max_con (void)
 
sint8 espconn_tcp_set_max_con (uint8 num)
 
uint8 espconn_tcp_get_max_retran (void)
 
sint8 espconn_tcp_set_max_retran (uint8 num)
 
uint8 espconn_tcp_get_max_syn (void)
 
sint8 espconn_tcp_set_max_syn (uint8 num)
 
sint8 espconn_tcp_get_max_con_allow (struct espconn *espconn)
 
sint8 espconn_tcp_set_max_con_allow (struct espconn *espconn, uint8 num)
 
sint8 espconn_tcp_set_buf_count (struct espconn *espconn, uint8 num)
 
sint8 espconn_regist_time (struct espconn *espconn, uint32 interval, uint8 type_flag)
 
sint8 espconn_regist_sentcb (struct espconn *espconn, espconn_sent_callback sent_cb)
 
sint8 espconn_regist_write_finish (struct espconn *espconn, espconn_connect_callback write_finish_fn)
 
sint8 espconn_sent (struct espconn *espconn, uint8 *psent, uint16 length)
 
sint8 espconn_regist_connectcb (struct espconn *espconn, espconn_connect_callback connect_cb)
 
sint8 espconn_regist_recvcb (struct espconn *espconn, espconn_recv_callback recv_cb)
 
sint8 espconn_regist_reconcb (struct espconn *espconn, espconn_reconnect_callback recon_cb)
 
sint8 espconn_regist_disconcb (struct espconn *espconn, espconn_connect_callback discon_cb)
 
uint32 espconn_port (void)
 
sint8 espconn_set_opt (struct espconn *espconn, uint8 opt)
 
sint8 espconn_set_keepalive (struct espconn *espconn, uint8 level, void *optarg)
 
sint8 espconn_get_keepalive (struct espconn *espconn, uint8 level, void *optarg)
 
sint8 espconn_gethostbyname (struct espconn *pespconn, const char *name, ip_addr_t *addr, dns_found_callback found)
 
sint8 espconn_igmp_join (ip_addr_t *host_ip, ip_addr_t *multicast_ip)
 
sint8 espconn_igmp_leave (ip_addr_t *host_ip, ip_addr_t *multicast_ip)
 
void espconn_mdns_init (struct mdns_info *info)
 
void espconn_mdns_close (void)
 
void espconn_mdns_server_register (void)
 
void espconn_mdns_server_unregister (void)
 
char * espconn_mdns_get_servername (void)
 
void espconn_mdns_set_servername (const char *name)
 
void espconn_mdns_set_hostname (char *name)
 
char * espconn_mdns_get_hostname (void)
 
void espconn_mdns_disable (void)
 
void espconn_mdns_enable (void)
 
void espconn_dns_setserver (u8_t numdns, ip_addr_t *dnsserver)
 

Macro Definition Documentation

◆ _MDNS_INFO

#define _MDNS_INFO

Definition at line 183 of file espconn.h.

◆ AP_NETIF

#define AP_NETIF   0x01

Definition at line 48 of file espconn.h.

Referenced by espconn_connect().

◆ ESPCONN_ABRT

#define ESPCONN_ABRT   -8 /* Connection aborted. */

Definition at line 27 of file espconn.h.

◆ ESPCONN_AP

#define ESPCONN_AP   0x02

Definition at line 44 of file espconn.h.

Referenced by espconn_connect().

◆ ESPCONN_AP_STA

#define ESPCONN_AP_STA   0x03

Definition at line 45 of file espconn.h.

Referenced by espconn_connect(), espconn_udp_sendto(), and espconn_udp_sent().

◆ ESPCONN_ARG

#define ESPCONN_ARG   -12 /* Illegal argument. */

◆ ESPCONN_CLSD

#define ESPCONN_CLSD   -10 /* Connection closed. */

Definition at line 29 of file espconn.h.

Referenced by espconn_client_err(), and esponn_server_err().

◆ ESPCONN_CONN

#define ESPCONN_CONN   -11 /* Not connected. */

Definition at line 30 of file espconn.h.

Referenced by espconn_client_err(), and esponn_server_err().

◆ espconn_copy_disabled

#define espconn_copy_disabled (   espconn)    (((espconn)->pcommon.espconn_opt & ESPCONN_COPY) != 0)

Definition at line 198 of file espconn.h.

Referenced by espconn_sent(), and espconn_tcp_sent().

◆ espconn_copy_enabled

#define espconn_copy_enabled (   espconn)    (((espconn)->pcommon.espconn_opt & ESPCONN_COPY) == 0)

Definition at line 199 of file espconn.h.

Referenced by espconn_sent().

◆ espconn_delay_disabled

#define espconn_delay_disabled (   espconn)    (((espconn)->pcommon.espconn_opt & ESPCONN_NODELAY) != 0)

Definition at line 195 of file espconn.h.

Referenced by espconn_set_opt().

◆ espconn_delay_enabled

#define espconn_delay_enabled (   espconn)    (((espconn)->pcommon.espconn_opt & ESPCONN_NODELAY) == 0)

Definition at line 196 of file espconn.h.

Referenced by espconn_clear_opt().

◆ ESPCONN_HANDSHAKE

#define ESPCONN_HANDSHAKE   -28 /* ssl handshake failed */

Definition at line 36 of file espconn.h.

◆ ESPCONN_IF

#define ESPCONN_IF   -14 /* Low_level error */

Definition at line 33 of file espconn.h.

Referenced by espconn_udp_sendto(), and espconn_udp_sent().

◆ ESPCONN_INPROGRESS

#define ESPCONN_INPROGRESS   -5 /* Operation in progress */

Definition at line 24 of file espconn.h.

Referenced by espconn_abort(), espconn_disconnect(), and espconn_tcp_delete().

◆ ESPCONN_ISCONN

#define ESPCONN_ISCONN   -15 /* Already connected. */

Definition at line 34 of file espconn.h.

Referenced by espconn_accept(), espconn_connect(), and espconn_create().

◆ espconn_keepalive_disabled

#define espconn_keepalive_disabled (   espconn)    (((espconn)->pcommon.espconn_opt & ESPCONN_KEEPALIVE) != 0)

◆ espconn_keepalive_enabled

#define espconn_keepalive_enabled (   espconn)    (((espconn)->pcommon.espconn_opt & ESPCONN_KEEPALIVE) == 0)

Definition at line 201 of file espconn.h.

Referenced by espconn_clear_opt().

◆ ESPCONN_MAXNUM

#define ESPCONN_MAXNUM   -7 /* Total number exceeds the set maximum*/

Definition at line 25 of file espconn.h.

Referenced by espconn_sent().

◆ ESPCONN_MEM

#define ESPCONN_MEM   -1 /* Out of memory error. */

◆ ESPCONN_NORM

#define ESPCONN_NORM   0x00

Definition at line 41 of file espconn.h.

◆ ESPCONN_OK

#define ESPCONN_OK   0 /* No error, everything OK. */

◆ espconn_printf

#define espconn_printf (   fmt,
  args... 
)

◆ ESPCONN_PROTO_MSG

#define ESPCONN_PROTO_MSG   -61 /* ssl application invalid */

Definition at line 38 of file espconn.h.

◆ ESPCONN_RESP_TIMEOUT

#define ESPCONN_RESP_TIMEOUT   -29 /* ssl handshake no response*/

Definition at line 37 of file espconn.h.

◆ espconn_reuse_disabled

#define espconn_reuse_disabled (   espconn)    (((espconn)->pcommon.espconn_opt & ESPCONN_REUSEADDR) != 0)

Definition at line 197 of file espconn.h.

Referenced by espconn_tcp_disconnect_successful().

◆ ESPCONN_RST

#define ESPCONN_RST   -9 /* Connection reset. */

Definition at line 28 of file espconn.h.

◆ ESPCONN_RTE

#define ESPCONN_RTE   -4 /* Routing problem. */

◆ ESPCONN_SSL

#define ESPCONN_SSL   0x01

Definition at line 40 of file espconn.h.

◆ ESPCONN_STA

#define ESPCONN_STA   0x01

Definition at line 43 of file espconn.h.

Referenced by espconn_connect().

◆ espconn_TaskPrio

#define espconn_TaskPrio   26

◆ espconn_TaskQueueLen

#define espconn_TaskQueueLen   15

Definition at line 204 of file espconn.h.

Referenced by espconn_init().

◆ ESPCONN_TIMEOUT

#define ESPCONN_TIMEOUT   -3 /* Timeout. */

Definition at line 22 of file espconn.h.

Referenced by espconn_client_err(), and esponn_server_err().

◆ linkMax

#define linkMax   15

Definition at line 193 of file espconn.h.

Referenced by espconn_tcp_set_max_con(), and espconn_tcp_set_wnd().

◆ STA_NETIF

#define STA_NETIF   0x00

Definition at line 47 of file espconn.h.

Referenced by espconn_connect().

Typedef Documentation

◆ comon_pkt

typedef struct _comon_pkt comon_pkt

◆ esp_tcp

typedef struct _esp_tcp esp_tcp

◆ esp_udp

typedef struct _esp_udp esp_udp

◆ espconn_buf

typedef struct _espconn_buf espconn_buf

◆ espconn_connect_callback

typedef void(* espconn_connect_callback) (void *arg)

Definition at line 15 of file espconn.h.

◆ espconn_handle

typedef void* espconn_handle

Definition at line 14 of file espconn.h.

◆ espconn_msg

typedef struct _espconn_msg espconn_msg

◆ espconn_reconnect_callback

typedef void(* espconn_reconnect_callback) (void *arg, sint8 err)

Definition at line 16 of file espconn.h.

◆ espconn_recv_callback

typedef void(* espconn_recv_callback) (void *arg, char *pdata, unsigned short len)

A callback prototype to inform about events for a espconn

Definition at line 95 of file espconn.h.

◆ espconn_sent_callback

typedef void(* espconn_sent_callback) (void *arg)

Definition at line 96 of file espconn.h.

◆ remot_info

typedef struct _remot_info remot_info

Enumeration Type Documentation

◆ espconn_level

Enumerator
ESPCONN_KEEPIDLE 
ESPCONN_KEEPINTVL 
ESPCONN_KEEPCNT 
ESPCONN_KEEPIDLE 
ESPCONN_KEEPINTVL 
ESPCONN_KEEPCNT 

Definition at line 124 of file espconn.h.

◆ espconn_option

Enumerator
ESPCONN_START 
ESPCONN_REUSEADDR 
ESPCONN_NODELAY 
ESPCONN_COPY 
ESPCONN_KEEPALIVE 
ESPCONN_END 
ESPCONN_START 
ESPCONN_REUSEADDR 
ESPCONN_NODELAY 
ESPCONN_COPY 
ESPCONN_KEEPALIVE 
ESPCONN_END 

Definition at line 115 of file espconn.h.

115  {
116  ESPCONN_START = 0x00,
117  ESPCONN_REUSEADDR = 0x01,
118  ESPCONN_NODELAY = 0x02,
119  ESPCONN_COPY = 0x04,
120  ESPCONN_KEEPALIVE = 0x08,
122 };

◆ espconn_sig

Enumerator
SIG_ESPCONN_NONE 
SIG_ESPCONN_ERRER 
SIG_ESPCONN_LISTEN 
SIG_ESPCONN_CONNECT 
SIG_ESPCONN_WRITE 
SIG_ESPCONN_SEND 
SIG_ESPCONN_READ 
SIG_ESPCONN_CLOSE 

Definition at line 206 of file espconn.h.

◆ espconn_state

Current state of the espconn. Non-TCP espconn are always in state ESPCONN_NONE!

Enumerator
ESPCONN_NONE 
ESPCONN_WAIT 
ESPCONN_LISTEN 
ESPCONN_CONNECT 
ESPCONN_WRITE 
ESPCONN_READ 
ESPCONN_CLOSE 
ESPCONN_NONE 
ESPCONN_WAIT 
ESPCONN_LISTEN 
ESPCONN_CONNECT 
ESPCONN_WRITE 
ESPCONN_READ 
ESPCONN_CLOSE 

Definition at line 60 of file espconn.h.

◆ espconn_type

Protocol family and type of the espconn

Enumerator
ESPCONN_INVALID 
ESPCONN_TCP 
ESPCONN_UDP 
ESPCONN_INVALID 
ESPCONN_TCP 
ESPCONN_UDP 

Definition at line 51 of file espconn.h.

51  {
52  ESPCONN_INVALID = 0,
53  /* ESPCONN_TCP Group */
54  ESPCONN_TCP = 0x10,
55  /* ESPCONN_UDP Group */
56  ESPCONN_UDP = 0x20,
57 };

Function Documentation

◆ espconn_accept()

sint8 espconn_accept ( struct espconn espconn)

Definition at line 875 of file espconn.c.

Referenced by httpdInit().

876 {
877  sint8 value = ESPCONN_OK;
879 
880  if (espconn == NULL) {
881  return ESPCONN_ARG;
882  } else if (espconn ->type != ESPCONN_TCP)
883  return ESPCONN_ARG;
884 
885  /*check the active node information whether is the same as the entity or not*/
886  for (plist = plink_active; plist != NULL; plist = plist->pnext){
887  if (plist->pespconn && plist->pespconn->type == ESPCONN_TCP){
888  if (espconn->proto.tcp->local_port == plist->pespconn->proto.tcp->local_port){
889  return ESPCONN_ISCONN;
890  }
891  }
892  }
893  value = espconn_tcp_server(espconn);
894 
895  return value;
896 }
esp_tcp * tcp
Definition: espconn.h:105
struct _espconn_msg * pnext
Definition: espconn.h:175
#define NULL
Definition: def.h:47
int local_port
Definition: espconn.h:72
#define ESPCONN_ISCONN
Definition: espconn.h:34
sint8 espconn_tcp_server(struct espconn *espconn)
Definition: espconn_tcp.c:1281
#define ESPCONN_OK
Definition: espconn.h:20
#define ESPCONN_ARG
Definition: espconn.h:32
espconn_msg * plink_active
Definition: espconn.c:32
union espconn::@1 proto
enum espconn_type type
Definition: espconn.h:101
signed char sint8
Definition: c_types.h:47
static list_node * plist
Definition: dhcpserver.c:34
struct espconn * pespconn
Definition: espconn.h:169
Here is the caller graph for this function:

◆ espconn_connect()

sint8 espconn_connect ( struct espconn espconn)

Definition at line 260 of file espconn.c.

Referenced by MQTT_Connect(), and mqtt_dns_found().

261 {
262  struct ip_addr ipaddr;
263  struct ip_info ipinfo;
264  uint8 connect_status = 0;
265  sint8 value = ESPCONN_OK;
267  remot_info *pinfo = NULL;
268 
269  if (espconn == NULL) {
270  return ESPCONN_ARG;
271  } else if (espconn ->type != ESPCONN_TCP)
272  return ESPCONN_ARG;
273 
274  /*Check the active node count whether is the limit or not*/
276  return ESPCONN_ISCONN;
277 
278  /*Check the IP address whether is zero or not in different mode*/
279  if (wifi_get_opmode() == ESPCONN_STA){
280  wifi_get_ip_info(STA_NETIF,&ipinfo);
281  if (ipinfo.ip.addr == 0){
282  return ESPCONN_RTE;
283  }
284  } else if(wifi_get_opmode() == ESPCONN_AP){
285  wifi_get_ip_info(AP_NETIF,&ipinfo);
286  if (ipinfo.ip.addr == 0){
287  return ESPCONN_RTE;
288  }
289  } else if(wifi_get_opmode() == ESPCONN_AP_STA){
290  IP4_ADDR(&ipaddr, espconn->proto.tcp->remote_ip[0],
291  espconn->proto.tcp->remote_ip[1],
292  espconn->proto.tcp->remote_ip[2],
293  espconn->proto.tcp->remote_ip[3]);
294  ipaddr.addr <<= 8;
295  wifi_get_ip_info(AP_NETIF,&ipinfo);
296  ipinfo.ip.addr <<= 8;
297  espconn_printf("softap_addr = %x, remote_addr = %x\n", ipinfo.ip.addr, ipaddr.addr);
298 
299  if (ipaddr.addr != ipinfo.ip.addr){
300  connect_status = wifi_station_get_connect_status();
301  if (connect_status == STATION_GOT_IP){
302  wifi_get_ip_info(STA_NETIF,&ipinfo);
303  if (ipinfo.ip.addr == 0)
304  return ESPCONN_RTE;
305  } else if (connect_status == STATION_IDLE){
306  return ESPCONN_RTE;
307  } else {
308  return connect_status;
309  }
310  }
311  }
312 
313  /*check the active node information whether is the same as the entity or not*/
314  for (plist = plink_active; plist != NULL; plist = plist->pnext){
315  if (plist->pespconn && plist->pespconn->type == ESPCONN_TCP){
316  if (espconn->proto.tcp->local_port == plist->pespconn->proto.tcp->local_port){
317  return ESPCONN_ISCONN;
318  }
319  }
320  }
321 
322  value = espconn_tcp_client(espconn);
323 
324  return value;
325 }
uint8 ICACHE_FLASH_ATTR espconn_tcp_get_max_con(void)
Definition: espconn.c:528
esp_tcp * tcp
Definition: espconn.h:105
struct _espconn_msg * pnext
Definition: espconn.h:175
#define ESPCONN_AP_STA
Definition: espconn.h:45
#define STA_NETIF
Definition: espconn.h:47
#define NULL
Definition: def.h:47
int local_port
Definition: espconn.h:72
#define ESPCONN_ISCONN
Definition: espconn.h:34
#define ESPCONN_OK
Definition: espconn.h:20
uint8 remote_ip[4]
Definition: espconn.h:74
bool wifi_get_ip_info(uint8 if_index, struct ip_info *info)
uint8 wifi_station_get_connect_status(void)
uint8 wifi_get_opmode(void)
#define ESPCONN_RTE
Definition: espconn.h:23
#define ESPCONN_ARG
Definition: espconn.h:32
unsigned char uint8
Definition: c_types.h:45
espconn_msg * plink_active
Definition: espconn.c:32
static uint8 ICACHE_FLASH_ATTR espconn_get_acticve_num(uint8 type)
Definition: espconn.c:239
#define espconn_printf(fmt, args...)
Definition: espconn.h:10
union espconn::@1 proto
#define AP_NETIF
Definition: espconn.h:48
enum espconn_type type
Definition: espconn.h:101
sint8 espconn_tcp_client(struct espconn *espconn)
Definition: espconn_tcp.c:878
signed char sint8
Definition: c_types.h:47
#define ESPCONN_AP
Definition: espconn.h:44
static list_node * plist
Definition: dhcpserver.c:34
struct espconn * pespconn
Definition: espconn.h:169
#define ESPCONN_STA
Definition: espconn.h:43
#define IP4_ADDR(ipaddr, a, b, c, d)
Definition: ip_addr.h:139
Here is the caller graph for this function:

◆ espconn_copy_partial()

void espconn_copy_partial ( struct espconn pesp_dest,
struct espconn pesp_source 
)

Definition at line 46 of file espconn.c.

References _esp_tcp::connect_callback, _esp_tcp::disconnect_callback, ESPCONN_TCP, espconn::link_cnt, _esp_tcp::local_ip, _esp_udp::local_ip, _esp_tcp::local_port, _esp_udp::local_port, os_memcpy, espconn::proto, _esp_tcp::reconnect_callback, espconn::recv_callback, _esp_tcp::remote_ip, _esp_udp::remote_ip, _esp_tcp::remote_port, _esp_udp::remote_port, espconn::reverse, espconn::sent_callback, espconn::state, espconn::tcp, espconn::type, and espconn::udp.

Referenced by espconn_tcp_accept(), espconn_tcp_disconnect_successful(), and espconn_tcp_reconnect().

47 {
48  pesp_dest->type = pesp_source->type;
49  pesp_dest->state = pesp_source->state;
50  if (pesp_source->type == ESPCONN_TCP){
51  pesp_dest->proto.tcp->remote_port = pesp_source->proto.tcp->remote_port;
52  pesp_dest->proto.tcp->local_port = pesp_source->proto.tcp->local_port;
53  os_memcpy(pesp_dest->proto.tcp->remote_ip, pesp_source->proto.tcp->remote_ip, 4);
54  os_memcpy(pesp_dest->proto.tcp->local_ip, pesp_source->proto.tcp->local_ip, 4);
55  pesp_dest->proto.tcp->connect_callback = pesp_source->proto.tcp->connect_callback;
56  pesp_dest->proto.tcp->reconnect_callback = pesp_source->proto.tcp->reconnect_callback;
57  pesp_dest->proto.tcp->disconnect_callback = pesp_source->proto.tcp->disconnect_callback;
58  } else {
59  pesp_dest->proto.udp->remote_port = pesp_source->proto.udp->remote_port;
60  pesp_dest->proto.udp->local_port = pesp_source->proto.udp->local_port;
61  os_memcpy(pesp_dest->proto.udp->remote_ip, pesp_source->proto.udp->remote_ip, 4);
62  os_memcpy(pesp_dest->proto.udp->local_ip, pesp_source->proto.udp->local_ip, 4);
63  }
64  pesp_dest->recv_callback = pesp_source->recv_callback;
65  pesp_dest->sent_callback = pesp_source->sent_callback;
66  pesp_dest->link_cnt = pesp_source->link_cnt;
67  pesp_dest->reverse = pesp_source->reverse;
68 }
esp_udp * udp
Definition: espconn.h:106
int local_port
Definition: espconn.h:83
void * reverse
Definition: espconn.h:112
esp_tcp * tcp
Definition: espconn.h:105
int local_port
Definition: espconn.h:72
uint8 link_cnt
Definition: espconn.h:111
uint8 remote_ip[4]
Definition: espconn.h:74
int remote_port
Definition: espconn.h:71
espconn_connect_callback connect_callback
Definition: espconn.h:75
#define os_memcpy
Definition: osapi.h:36
int remote_port
Definition: espconn.h:82
union espconn::@1 proto
uint8 local_ip[4]
Definition: espconn.h:73
uint8 local_ip[4]
Definition: espconn.h:84
espconn_reconnect_callback reconnect_callback
Definition: espconn.h:76
enum espconn_type type
Definition: espconn.h:101
enum espconn_state state
Definition: espconn.h:103
uint8 remote_ip[4]
Definition: espconn.h:85
espconn_connect_callback disconnect_callback
Definition: espconn.h:77
espconn_recv_callback recv_callback
Definition: espconn.h:109
espconn_sent_callback sent_callback
Definition: espconn.h:110
Here is the caller graph for this function:

◆ espconn_create()

sint8 espconn_create ( struct espconn espconn)

Definition at line 334 of file espconn.c.

Referenced by captdnsInit().

335 {
336  sint8 value = ESPCONN_OK;
338 
339  if (espconn == NULL) {
340  return ESPCONN_ARG;
341  } else if (espconn ->type != ESPCONN_UDP){
342  return ESPCONN_ARG;
343  }
344 
345  /*check the active node information whether is the same as the entity or not*/
346  for (plist = plink_active; plist != NULL; plist = plist->pnext){
347  if (plist->pespconn && plist->pespconn->type == ESPCONN_UDP){
348  if (espconn->proto.udp->local_port == plist->pespconn->proto.udp->local_port){
349  return ESPCONN_ISCONN;
350  }
351  }
352  }
353 
354  value = espconn_udp_server(espconn);
355 
356  return value;
357 }
esp_udp * udp
Definition: espconn.h:106
int local_port
Definition: espconn.h:83
struct _espconn_msg * pnext
Definition: espconn.h:175
#define NULL
Definition: def.h:47
#define ESPCONN_ISCONN
Definition: espconn.h:34
#define ESPCONN_OK
Definition: espconn.h:20
#define ESPCONN_ARG
Definition: espconn.h:32
espconn_msg * plink_active
Definition: espconn.c:32
union espconn::@1 proto
enum espconn_type type
Definition: espconn.h:101
sint8 espconn_udp_server(struct espconn *espconn)
Definition: espconn_udp.c:363
signed char sint8
Definition: c_types.h:47
static list_node * plist
Definition: dhcpserver.c:34
struct espconn * pespconn
Definition: espconn.h:169
Here is the caller graph for this function:

◆ espconn_delete()

sint8 espconn_delete ( struct espconn espconn)

Definition at line 1217 of file espconn.c.

Referenced by captdnsStop(), httpdStop(), and mqtt_tcpclient_delete().

1218 {
1219  espconn_msg *pnode = NULL;
1220  bool value = false;
1221 
1222  if (espconn == NULL) {
1223  return ESPCONN_ARG;
1224  } else if (espconn ->type != ESPCONN_UDP)
1225  return espconn_tcp_delete(espconn);
1226 
1227  /*Find the node depend on the espconn message*/
1228  value = espconn_find_connection(espconn, &pnode);
1229 
1230  if (value){
1231  espconn_udp_disconnect(pnode);
1232  return ESPCONN_OK;
1233  } else
1234  return ESPCONN_ARG;
1235 }
#define NULL
Definition: def.h:47
#define ESPCONN_OK
Definition: espconn.h:20
void espconn_udp_disconnect(espconn_msg *pdiscon)
Definition: espconn_udp.c:338
#define ESPCONN_ARG
Definition: espconn.h:32
bool ICACHE_FLASH_ATTR espconn_find_connection(struct espconn *pespconn, espconn_msg **pnode)
Definition: espconn.c:186
sint8 ICACHE_FLASH_ATTR espconn_tcp_delete(struct espconn *pdeletecon)
Definition: espconn_tcp.c:1335
Here is the caller graph for this function:

◆ espconn_disconnect()

sint8 espconn_disconnect ( struct espconn espconn)

Definition at line 942 of file espconn.c.

Referenced by httpdConnectCb(), httpdSentCb(), httpdStop(), MQTT_Task(), and mqtt_tcpclient_recv().

943 {
944  espconn_msg *pnode = NULL;
945  bool value = false;
946 
947  if (espconn == NULL) {
948  return ESPCONN_ARG;;
949  } else if (espconn ->type != ESPCONN_TCP)
950  return ESPCONN_ARG;
951 
952  /*Find the node depend on the espconn message*/
953  value = espconn_find_connection(espconn, &pnode);
954 
955  if (value){
956  /*protect for redisconnection*/
957  if (espconn->state == ESPCONN_CLOSE)
958  return ESPCONN_INPROGRESS;
959  espconn_tcp_disconnect(pnode,0); //1 force, 0 normal
960  return ESPCONN_OK;
961  } else
962  return ESPCONN_ARG;
963 }
#define NULL
Definition: def.h:47
#define ESPCONN_OK
Definition: espconn.h:20
#define ESPCONN_ARG
Definition: espconn.h:32
void espconn_tcp_disconnect(espconn_msg *pdiscon, u8 type)
Definition: espconn_tcp.c:498
bool ICACHE_FLASH_ATTR espconn_find_connection(struct espconn *pespconn, espconn_msg **pnode)
Definition: espconn.c:186
enum espconn_state state
Definition: espconn.h:103
#define ESPCONN_INPROGRESS
Definition: espconn.h:24
Here is the caller graph for this function:

◆ espconn_dns_setserver()

void espconn_dns_setserver ( u8_t  numdns,
ip_addr_t dnsserver 
)

Definition at line 1302 of file espconn.c.

Referenced by wifi_softap_ip_config().

1303 {
1304  dns_setserver(numdns,dnsserver);
1305 }
Here is the caller graph for this function:

◆ espconn_find_connection()

bool espconn_find_connection ( struct espconn pespconn,
espconn_msg **  pnode 
)

Definition at line 186 of file espconn.c.

References ip_addr::addr, ICACHE_FLASH_ATTR, IP4_ADDR, IPADDR_ANY, NULL, _espconn_msg::pcommon, _espconn_msg::pespconn, plist, _espconn_msg::pnext, espconn::proto, _esp_tcp::remote_ip, _comon_pkt::remote_ip, _esp_tcp::remote_port, _comon_pkt::remote_port, and espconn::tcp.

Referenced by espconn_abort(), espconn_clear_opt(), espconn_delete(), espconn_disconnect(), espconn_get_keepalive(), espconn_get_packet_info(), espconn_recv_hold(), espconn_recv_unhold(), espconn_regist_time(), espconn_sendto(), espconn_sent(), espconn_set_keepalive(), and espconn_set_opt().

187 {
189  struct ip_addr ip_remot;
190  struct ip_addr ip_list;
191 
192  if (pespconn == NULL)
193  return false;
194 
195  /*find the active connection node*/
196  for (plist = plink_active; plist != NULL; plist = plist->pnext){
197  if (pespconn == plist->pespconn) {
198  *pnode = plist;
199  return true;
200  }
201  }
202 
203  /*find the active server node*/
204  for (plist = pserver_list; plist != NULL; plist = plist->pnext){
205  if (pespconn == plist->pespconn) {
206  if (pespconn->proto.tcp == NULL)
207  return false;
208 
209  IP4_ADDR(&ip_remot, pespconn->proto.tcp->remote_ip[0],
210  pespconn->proto.tcp->remote_ip[1],
211  pespconn->proto.tcp->remote_ip[2],
212  pespconn->proto.tcp->remote_ip[3]);
213  if ((ip_remot.addr == IPADDR_ANY) || (pespconn->proto.tcp->remote_port == 0))
214  return false;
215 
216  /*find the active connection node*/
217  for (plist = plink_active; plist != NULL; plist = plist->pnext){
218  IP4_ADDR(&ip_list, plist->pcommon.remote_ip[0],
219  plist->pcommon.remote_ip[1], plist->pcommon.remote_ip[2],
220  plist->pcommon.remote_ip[3]);
221  if ((ip_list.addr == ip_remot.addr) && (pespconn->proto.tcp->remote_port == plist->pcommon.remote_port)) {
222  *pnode = plist;
223  return true;
224  }
225  }
226  return false;
227  }
228  }
229  return false;
230 }
esp_tcp * tcp
Definition: espconn.h:105
int remote_port
Definition: espconn.h:151
struct _espconn_msg * pnext
Definition: espconn.h:175
#define NULL
Definition: def.h:47
uint8 remote_ip[4]
Definition: espconn.h:74
int remote_port
Definition: espconn.h:71
#define IPADDR_ANY
Definition: ip_addr.h:100
comon_pkt pcommon
Definition: espconn.h:170
espconn_msg * plink_active
Definition: espconn.c:32
espconn_msg * pserver_list
Definition: espconn.c:33
uint8 remote_ip[4]
Definition: espconn.h:152
union espconn::@1 proto
static list_node * plist
Definition: dhcpserver.c:34
struct espconn * pespconn
Definition: espconn.h:169
#define IP4_ADDR(ipaddr, a, b, c, d)
Definition: ip_addr.h:139
Here is the caller graph for this function:

◆ espconn_get_connection_info()

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

Definition at line 825 of file espconn.c.

Referenced by captdnsRecv(), espconn_tcp_accept(), and espconn_tcp_delete().

826 {
828 
829  if (pespconn == NULL)
830  return ESPCONN_ARG;
831 
832  os_memset(premot, 0, sizeof(premot));
833  pespconn->link_cnt = 0;
834  plist = plink_active;
835  switch (pespconn->type){
836  case ESPCONN_TCP:
837  while(plist != NULL){
838  if (plist->preverse == pespconn){
839  premot[pespconn->link_cnt].state = plist->pespconn->state;
840  premot[pespconn->link_cnt].remote_port = plist->pcommon.remote_port;
841  os_memcpy(premot[pespconn->link_cnt].remote_ip, plist->pcommon.remote_ip, 4);
842  pespconn->link_cnt ++;
843  }
844  plist = plist->pnext;
845  }
846 
847  break;
848  case ESPCONN_UDP:
849  while(plist != NULL){
850  if (plist->pespconn == pespconn){
851  premot[pespconn->link_cnt].state = plist->pespconn->state;
852  premot[pespconn->link_cnt].remote_port = plist->pcommon.remote_port;
853  os_memcpy(premot[pespconn->link_cnt].remote_ip, plist->pcommon.remote_ip, 4);
854  pespconn->link_cnt ++;
855  }
856  plist = plist->pnext;
857  }
858  break;
859  default:
860  break;
861  }
862  *pcon_info = premot;
863  if (pespconn->link_cnt == 0)
864  return ESPCONN_ARG;
865  return ESPCONN_OK;
866 }
int remote_port
Definition: espconn.h:151
struct _espconn_msg * pnext
Definition: espconn.h:175
#define NULL
Definition: def.h:47
uint8 link_cnt
Definition: espconn.h:111
#define ESPCONN_OK
Definition: espconn.h:20
enum espconn_state state
Definition: espconn.h:89
void * preverse
Definition: espconn.h:173
uint8 remote_ip[4]
Definition: espconn.h:91
#define os_memcpy
Definition: osapi.h:36
#define os_memset
Definition: osapi.h:38
comon_pkt pcommon
Definition: espconn.h:170
#define ESPCONN_ARG
Definition: espconn.h:32
espconn_msg * plink_active
Definition: espconn.c:32
remot_info premot[linkMax]
Definition: espconn.c:34
uint8 remote_ip[4]
Definition: espconn.h:152
enum espconn_type type
Definition: espconn.h:101
enum espconn_state state
Definition: espconn.h:103
static list_node * plist
Definition: dhcpserver.c:34
struct espconn * pespconn
Definition: espconn.h:169
int remote_port
Definition: espconn.h:90
Here is the caller graph for this function:

◆ espconn_get_keepalive()

sint8 espconn_get_keepalive ( struct espconn espconn,
uint8  level,
void *  optarg 
)

Definition at line 1173 of file espconn.c.

1174 {
1175  espconn_msg *pnode = NULL;
1176  bool value = false;
1177  sint8 ret = ESPCONN_OK;
1178 
1179  if (espconn == NULL || optarg == NULL) {
1180  return ESPCONN_ARG;;
1181  } else if (espconn->type != ESPCONN_TCP)
1182  return ESPCONN_ARG;
1183 
1184  /*Find the node depend on the espconn message*/
1185  value = espconn_find_connection(espconn, &pnode);
1186  if (value && espconn_keepalive_disabled(pnode)) {
1187  struct tcp_pcb *pcb = pnode->pcommon.pcb;
1188  switch (level) {
1189  case ESPCONN_KEEPIDLE:
1190  *(int*)optarg = (int)(pcb->keep_idle/1000);
1191  ret = ESPCONN_OK;
1192  break;
1193  case ESPCONN_KEEPINTVL:
1194  *(int*)optarg = (int)(pcb->keep_intvl/1000);
1195  ret = ESPCONN_OK;
1196  break;
1197  case ESPCONN_KEEPCNT:
1198  *(int*)optarg = (int)(pcb->keep_cnt);
1199  ret = ESPCONN_OK;
1200  break;
1201  default:
1202  ret = ESPCONN_ARG;
1203  break;
1204  }
1205  return ret;
1206  } else
1207  return ESPCONN_ARG;
1208 }
#define NULL
Definition: def.h:47
void * pcb
Definition: espconn.h:150
#define ESPCONN_OK
Definition: espconn.h:20
comon_pkt pcommon
Definition: espconn.h:170
#define ESPCONN_ARG
Definition: espconn.h:32
bool ICACHE_FLASH_ATTR espconn_find_connection(struct espconn *pespconn, espconn_msg **pnode)
Definition: espconn.c:186
enum espconn_type type
Definition: espconn.h:101
signed char sint8
Definition: c_types.h:47
#define espconn_keepalive_disabled(espconn)
Definition: espconn.h:200

◆ espconn_get_packet_info()

sint8 espconn_get_packet_info ( struct espconn espconn,
struct espconn_packet infoarg 
)

Definition at line 1004 of file espconn.c.

1005 {
1006  espconn_msg *pnode = NULL;
1007  err_t err;
1008  bool value = false;
1009 
1010  if (espconn == NULL || infoarg == NULL) {
1011  return ESPCONN_ARG;;
1012  } else if (espconn->type != ESPCONN_TCP)
1013  return ESPCONN_ARG;
1014 
1015  /*Find the node depend on the espconn message*/
1016  value = espconn_find_connection(espconn, &pnode);
1017  if (value) {
1018  struct tcp_pcb *pcb = pnode->pcommon.pcb;
1019  if (pcb == NULL)
1020  return ESPCONN_ARG;
1021 
1022  pnode->pcommon.packet_info.packseq_nxt = pcb->rcv_nxt;
1023  pnode->pcommon.packet_info.packseqno = pcb->snd_nxt;
1024  pnode->pcommon.packet_info.snd_buf_size = pcb->snd_buf;
1026  pnode->pcommon.packet_info.snd_queuelen = pnode->pcommon.packet_info.total_queuelen - pcb->snd_queuelen;
1027  os_memcpy(infoarg,(void*)&pnode->pcommon.packet_info, sizeof(struct espconn_packet));
1028  return ESPCONN_OK;
1029  } else {
1030  switch (espconn->state){
1031  case ESPCONN_CLOSE:
1032  os_memcpy(infoarg,(void*)&pktinfo[0], sizeof(struct espconn_packet));
1033  err = ESPCONN_OK;
1034  break;
1035  case ESPCONN_NONE:
1036  os_memcpy(infoarg,(void*)&pktinfo[1], sizeof(struct espconn_packet));
1037  err = ESPCONN_OK;
1038  break;
1039  default:
1040  err = ESPCONN_ARG;
1041  break;
1042  }
1043  return err;
1044  }
1045 }
struct espconn_packet pktinfo[2]
Definition: espconn.c:36
#define NULL
Definition: def.h:47
void * pcb
Definition: espconn.h:150
#define ESPCONN_OK
Definition: espconn.h:20
uint32 packseqno
Definition: espconn.h:135
#define os_memcpy
Definition: osapi.h:36
struct espconn_packet packet_info
Definition: espconn.h:163
comon_pkt pcommon
Definition: espconn.h:170
#define ESPCONN_ARG
Definition: espconn.h:32
s8_t err_t
Definition: err.h:47
uint16 snd_buf_size
Definition: espconn.h:132
uint32 packseq_nxt
Definition: espconn.h:136
bool ICACHE_FLASH_ATTR espconn_find_connection(struct espconn *pespconn, espconn_msg **pnode)
Definition: espconn.c:186
enum espconn_type type
Definition: espconn.h:101
enum espconn_state state
Definition: espconn.h:103
uint16 snd_queuelen
Definition: espconn.h:133
uint16 total_queuelen
Definition: espconn.h:134
#define TCP_SND_QUEUELEN
Definition: opt.h:964

◆ espconn_gethostbyname()

sint8 espconn_gethostbyname ( struct espconn pespconn,
const char *  name,
ip_addr_t addr,
dns_found_callback  found 
)

Definition at line 1288 of file espconn.c.

Referenced by MQTT_Connect().

1289 {
1290  return dns_gethostbyname(hostname, addr, found, pespconn);
1291 }
Here is the caller graph for this function:

◆ espconn_igmp_join()

sint8 espconn_igmp_join ( ip_addr_t host_ip,
ip_addr_t multicast_ip 
)

Definition at line 414 of file espconn_udp.c.

415 {
416  if (igmp_joingroup(host_ip, multicast_ip) != ERR_OK) {
417  LWIP_DEBUGF(ESPCONN_UDP_DEBUG, ("udp_join_multigrup failed!\n"));
418  return -1;
419  };
420 
421  /* join to any IP address at the port */
422  return ESPCONN_OK;
423 }
#define ESPCONN_UDP_DEBUG
Definition: espconn_udp.h:5
#define ESPCONN_OK
Definition: espconn.h:20
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:94
#define ERR_OK
Definition: err.h:52

◆ espconn_igmp_leave()

sint8 espconn_igmp_leave ( ip_addr_t host_ip,
ip_addr_t multicast_ip 
)

Definition at line 396 of file espconn_udp.c.

397 {
398  if (igmp_leavegroup(host_ip, multicast_ip) != ERR_OK) {
399  LWIP_DEBUGF(ESPCONN_UDP_DEBUG, ("udp_leave_multigrup failed!\n"));
400  return -1;
401  };
402 
403  return ESPCONN_OK;
404 }
#define ESPCONN_UDP_DEBUG
Definition: espconn_udp.h:5
#define ESPCONN_OK
Definition: espconn.h:20
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:94
#define ERR_OK
Definition: err.h:52

◆ espconn_list_creat()

void espconn_list_creat ( espconn_msg **  phead,
espconn_msg pinsert 
)

Definition at line 76 of file espconn.c.

References NULL, plist, and _espconn_msg::pnext.

Referenced by espconn_tcp_accept(), espconn_tcp_client(), espconn_tcp_server(), and espconn_udp_server().

77 {
79 // espconn_msg *ptest = NULL;
80  if (*phead == NULL)
81  *phead = pinsert;
82  else {
83  plist = *phead;
84  while (plist->pnext != NULL) {
85  plist = plist->pnext;
86  }
87  plist->pnext = pinsert;
88  }
89  pinsert->pnext = NULL;
90 
91 /* ptest = *phead;
92  while(ptest != NULL){
93  os_printf("espconn_list_creat %p\n", ptest);
94  ptest = ptest->pnext;
95  }*/
96 }
struct _espconn_msg * pnext
Definition: espconn.h:175
#define NULL
Definition: def.h:47
static list_node * plist
Definition: dhcpserver.c:34
Here is the caller graph for this function:

◆ espconn_list_delete()

void espconn_list_delete ( espconn_msg **  phead,
espconn_msg pdelete 
)

Definition at line 104 of file espconn.c.

References NULL, plist, and _espconn_msg::pnext.

Referenced by espconn_Task(), espconn_tcp_client(), espconn_tcp_delete(), and espconn_udp_disconnect().

105 {
107 // espconn_msg *ptest = NULL;
108  plist = *phead;
109  if (plist == NULL){
110  *phead = NULL;
111  } else {
112  if (plist == pdelete){
113  *phead = plist->pnext;
114  } else {
115  while (plist != NULL) {
116  if (plist->pnext == pdelete){
117  plist->pnext = pdelete->pnext;
118  }
119  plist = plist->pnext;
120  }
121  }
122  }
123 /* ptest = *phead;
124  while(ptest != NULL){
125  os_printf("espconn_list_delete %p\n", ptest);
126  ptest = ptest->pnext;
127  }*/
128 }
struct _espconn_msg * pnext
Definition: espconn.h:175
#define NULL
Definition: def.h:47
static list_node * plist
Definition: dhcpserver.c:34
Here is the caller graph for this function:

◆ espconn_mdns_close()

void espconn_mdns_close ( void  )

Definition at line 119 of file espconn_mdns.c.

120 {
121  mdns_close();
122 }

◆ espconn_mdns_disable()

void espconn_mdns_disable ( void  )

Definition at line 37 of file espconn_mdns.c.

38 {
39  mdns_disable();
40 }

◆ espconn_mdns_enable()

void espconn_mdns_enable ( void  )

Definition at line 25 of file espconn_mdns.c.

26 {
27  mdns_enable();
28 }

◆ espconn_mdns_get_hostname()

char* espconn_mdns_get_hostname ( void  )

Definition at line 63 of file espconn_mdns.c.

64 {
65  return (char *)mdns_get_hostname();
66 }

◆ espconn_mdns_get_servername()

char* espconn_mdns_get_servername ( void  )

Definition at line 85 of file espconn_mdns.c.

86 {
87  return (char *)mdns_get_servername();
88 }

◆ espconn_mdns_init()

void espconn_mdns_init ( struct mdns_info info)

Definition at line 131 of file espconn_mdns.c.

132 {
133  mdns_init(info);
134 }

◆ espconn_mdns_server_register()

void espconn_mdns_server_register ( void  )

Definition at line 96 of file espconn_mdns.c.

97 {
98  mdns_server_register();
99 }

◆ espconn_mdns_server_unregister()

void espconn_mdns_server_unregister ( void  )

Definition at line 107 of file espconn_mdns.c.

108 {
109  mdns_server_unregister();
110 }

◆ espconn_mdns_set_hostname()

void espconn_mdns_set_hostname ( char *  name)

Definition at line 50 of file espconn_mdns.c.

51 {
52  mdns_set_hostname(name);
53 }

◆ espconn_mdns_set_servername()

void espconn_mdns_set_servername ( const char *  name)

Definition at line 74 of file espconn_mdns.c.

75 {
76  mdns_set_servername(name);
77 }

◆ espconn_port()

uint32 espconn_port ( void  )

Definition at line 1245 of file espconn.c.

Referenced by MQTT_Connect().

1246 {
1247  uint32 port = 0;
1248  static uint32 randnum = 0;
1249 
1250  do {
1251  port = os_random();
1252 
1253  if (port < 0) {
1254  port = os_random() - port;
1255  }
1256 
1257  port %= 0xc350;
1258 
1259  if (port < 0x400) {
1260  port += 0x400;
1261  }
1262 
1263  } while (port == randnum);
1264 
1265  randnum = port;
1266 
1267  return port;
1268 }
unsigned long os_random(void)
unsigned int uint32
Definition: c_types.h:54
Here is the caller graph for this function:

◆ espconn_regist_connectcb()

sint8 espconn_regist_connectcb ( struct espconn espconn,
espconn_connect_callback  connect_cb 
)

Definition at line 751 of file espconn.c.

Referenced by httpdInit(), and MQTT_Connect().

752 {
753  if (espconn == NULL) {
754  return ESPCONN_ARG;
755  }
756 
757  espconn->proto.tcp->connect_callback = connect_cb;
758  return ESPCONN_OK;
759 }
esp_tcp * tcp
Definition: espconn.h:105
#define NULL
Definition: def.h:47
#define ESPCONN_OK
Definition: espconn.h:20
espconn_connect_callback connect_callback
Definition: espconn.h:75
#define ESPCONN_ARG
Definition: espconn.h:32
union espconn::@1 proto
Here is the caller graph for this function:

◆ espconn_regist_disconcb()

sint8 espconn_regist_disconcb ( struct espconn espconn,
espconn_connect_callback  discon_cb 
)

Definition at line 807 of file espconn.c.

Referenced by httpdConnectCb(), and mqtt_tcpclient_connect_cb().

808 {
809  if (espconn == NULL) {
810  return ESPCONN_ARG;
811  }
812 
813  espconn ->proto.tcp->disconnect_callback = discon_cb;
814  return ESPCONN_OK;
815 }
esp_tcp * tcp
Definition: espconn.h:105
#define NULL
Definition: def.h:47
#define ESPCONN_OK
Definition: espconn.h:20
#define ESPCONN_ARG
Definition: espconn.h:32
union espconn::@1 proto
espconn_connect_callback disconnect_callback
Definition: espconn.h:77
Here is the caller graph for this function:

◆ espconn_regist_reconcb()

sint8 espconn_regist_reconcb ( struct espconn espconn,
espconn_reconnect_callback  recon_cb 
)

Definition at line 789 of file espconn.c.

Referenced by httpdConnectCb(), and MQTT_Connect().

790 {
791  if (espconn == NULL) {
792  return ESPCONN_ARG;
793  }
794 
795  espconn ->proto.tcp->reconnect_callback = recon_cb;
796  return ESPCONN_OK;
797 }
esp_tcp * tcp
Definition: espconn.h:105
#define NULL
Definition: def.h:47
#define ESPCONN_OK
Definition: espconn.h:20
#define ESPCONN_ARG
Definition: espconn.h:32
union espconn::@1 proto
espconn_reconnect_callback reconnect_callback
Definition: espconn.h:76
Here is the caller graph for this function:

◆ espconn_regist_recvcb()

sint8 espconn_regist_recvcb ( struct espconn espconn,
espconn_recv_callback  recv_cb 
)

Definition at line 770 of file espconn.c.

Referenced by captdnsInit(), httpdConnectCb(), and mqtt_tcpclient_connect_cb().

771 {
772  if (espconn == NULL) {
773  return ESPCONN_ARG;
774  }
775 
776  espconn ->recv_callback = recv_cb;
777  return ESPCONN_OK;
778 }
#define NULL
Definition: def.h:47
#define ESPCONN_OK
Definition: espconn.h:20
#define ESPCONN_ARG
Definition: espconn.h:32
espconn_recv_callback recv_callback
Definition: espconn.h:109
Here is the caller graph for this function:

◆ espconn_regist_sentcb()

sint8 espconn_regist_sentcb ( struct espconn espconn,
espconn_sent_callback  sent_cb 
)

Definition at line 712 of file espconn.c.

Referenced by httpdConnectCb(), and mqtt_tcpclient_connect_cb().

713 {
714  if (espconn == NULL) {
715  return ESPCONN_ARG;
716  }
717 
718  espconn ->sent_callback = sent_cb;
719  return ESPCONN_OK;
720 }
#define NULL
Definition: def.h:47
#define ESPCONN_OK
Definition: espconn.h:20
#define ESPCONN_ARG
Definition: espconn.h:32
espconn_sent_callback sent_callback
Definition: espconn.h:110
Here is the caller graph for this function:

◆ espconn_regist_time()

sint8 espconn_regist_time ( struct espconn espconn,
uint32  interval,
uint8  type_flag 
)

Definition at line 905 of file espconn.c.

906 {
907  espconn_msg *pnode = NULL;
908  espconn_msg *ptime_msg = NULL;
909  bool value = false;
910  if ((espconn == NULL) || (type_flag > 0x01))
911  return ESPCONN_ARG;
912 
913  if (type_flag == 0x01){
914  /*set the timeout time for one active connection of the server*/
915  value = espconn_find_connection(espconn, &pnode);
916  if (value){
917  pnode->pcommon.timeout = interval;
918  return ESPCONN_OK;
919  } else
920  return ESPCONN_ARG;
921  } else {
922  /*set the timeout time for all active connection of the server*/
923  ptime_msg = pserver_list;
924  while (ptime_msg != NULL){
925  if (ptime_msg->pespconn == espconn){
926  ptime_msg->pcommon.timeout = interval;
927  return ESPCONN_OK;
928  }
929  ptime_msg = ptime_msg->pnext;
930  }
931  }
932  return ESPCONN_ARG;
933 }
struct _espconn_msg * pnext
Definition: espconn.h:175
#define NULL
Definition: def.h:47
uint32 timeout
Definition: espconn.h:160
#define ESPCONN_OK
Definition: espconn.h:20
comon_pkt pcommon
Definition: espconn.h:170
#define ESPCONN_ARG
Definition: espconn.h:32
espconn_msg * pserver_list
Definition: espconn.c:33
bool ICACHE_FLASH_ATTR espconn_find_connection(struct espconn *pespconn, espconn_msg **pnode)
Definition: espconn.c:186
struct espconn * pespconn
Definition: espconn.h:169

◆ espconn_regist_write_finish()

sint8 espconn_regist_write_finish ( struct espconn espconn,
espconn_connect_callback  write_finish_fn 
)

Definition at line 732 of file espconn.c.

733 {
734  if (espconn == NULL || espconn ->proto.tcp == NULL || espconn->type == ESPCONN_UDP) {
735  return ESPCONN_ARG;
736  }
737 
738  espconn ->proto.tcp->write_finish_fn = write_finish_fn;
739  return ESPCONN_OK;
740 }
esp_tcp * tcp
Definition: espconn.h:105
#define NULL
Definition: def.h:47
#define ESPCONN_OK
Definition: espconn.h:20
#define ESPCONN_ARG
Definition: espconn.h:32
espconn_connect_callback write_finish_fn
Definition: espconn.h:78
union espconn::@1 proto
enum espconn_type type
Definition: espconn.h:101

◆ espconn_sent()

sint8 espconn_sent ( struct espconn espconn,
uint8 psent,
uint16  length 
)

Definition at line 368 of file espconn.c.

Referenced by cgiEspFsHook(), and xmitSendBuff().

369 {
370  espconn_msg *pnode = NULL;
371  bool value = false;
372  err_t error = ESPCONN_OK;
373 
374  if (espconn == NULL || psent == NULL || length == 0) {
375  return ESPCONN_ARG;
376  }
377 
378  /*Find the node depend on the espconn message*/
379  value = espconn_find_connection(espconn, &pnode);
380 
381  if (value){
382  espconn ->state = ESPCONN_WRITE;
383  switch (espconn ->type) {
384  case ESPCONN_TCP:
385  /* calling sent function frequently,make sure last packet has been backup or sent fully*/
386  if (pnode->pcommon.write_flag){
387  espconn_buf *pbuf = NULL;
388  /*If total number of espconn_buf on the unsent lists exceeds the set maximum, return an error */
389  if (espconn_copy_enabled(pnode)){
390  if (espconn_tcp_get_buf_count(pnode->pcommon.pbuf) >= pnode ->pcommon.pbuf_num)
391  return ESPCONN_MAXNUM;
392  } else {
393  struct tcp_pcb *pcb = pnode->pcommon.pcb;
394  if (pcb->snd_queuelen >= TCP_SND_QUEUELEN)
395  return ESPCONN_MAXNUM;
396  }
397 
398  pbuf = (espconn_buf*) os_zalloc(sizeof(espconn_buf));
399  if (pbuf == NULL)
400  return ESPCONN_MEM;
401  else {
402  /*Backup the application packet information for send more data*/
403  pbuf->payload = psent;
404  pbuf->punsent = pbuf->payload;
405  pbuf->unsent = length;
406  pbuf->len = length;
407  /*insert the espconn_pbuf to the list*/
408  espconn_pbuf_create(&pnode->pcommon.pbuf, pbuf);
409  if (pnode->pcommon.ptail == NULL)
410  pnode->pcommon.ptail = pbuf;
411  }
412  /*when set the data copy option. change the flag for next packet*/
413  if (espconn_copy_disabled(pnode))
414  pnode->pcommon.write_flag = false;
415  error = espconn_tcp_write(pnode);
416 // if (error != ESPCONN_OK){
417 // /*send the application packet fail,
418 // * ensure that each allocated is deleted*/
419 // espconn_pbuf_delete(&pnode->pcommon.pbuf, pbuf);
420 // os_free(pbuf);
421 // pbuf = NULL;
422 // }
423  return error;
424  } else
425  return ESPCONN_ARG;
426  break;
427 
428  case ESPCONN_UDP:
429  return espconn_udp_sent(pnode, psent, length);
430  break;
431 
432  default :
433  break;
434  }
435  }
436  return ESPCONN_ARG;
437 }
uint16 unsent
Definition: espconn.h:143
#define espconn_copy_disabled(espconn)
Definition: espconn.h:198
err_t ICACHE_FLASH_ATTR espconn_tcp_write(void *arg)
Definition: espconn_tcp.c:667
static uint8 espconn_tcp_get_buf_count(espconn_buf *pesp_buf)
Definition: espconn.c:689
espconn_buf * ptail
Definition: espconn.h:156
void ICACHE_FLASH_ATTR espconn_pbuf_create(espconn_buf **phead, espconn_buf *pinsert)
Definition: espconn.c:136
uint16 len
Definition: espconn.h:144
#define NULL
Definition: def.h:47
void * pcb
Definition: espconn.h:150
#define ESPCONN_OK
Definition: espconn.h:20
uint8 * punsent
Definition: espconn.h:142
#define os_zalloc(s)
Definition: mem.h:44
uint8 * payload
Definition: espconn.h:141
comon_pkt pcommon
Definition: espconn.h:170
Definition: pbuf.h:76
#define ESPCONN_ARG
Definition: espconn.h:32
s8_t err_t
Definition: err.h:47
#define espconn_copy_enabled(espconn)
Definition: espconn.h:199
uint8 pbuf_num
Definition: espconn.h:162
#define ESPCONN_MAXNUM
Definition: espconn.h:25
bool write_flag
Definition: espconn.h:164
bool ICACHE_FLASH_ATTR espconn_find_connection(struct espconn *pespconn, espconn_msg **pnode)
Definition: espconn.c:186
enum espconn_state state
Definition: espconn.h:103
#define TCP_SND_QUEUELEN
Definition: opt.h:964
espconn_buf * pbuf
Definition: espconn.h:155
err_t espconn_udp_sent(void *arg, uint8 *psent, uint16 length)
Definition: espconn_udp.c:81
#define ESPCONN_MEM
Definition: espconn.h:21
Here is the caller graph for this function:

◆ espconn_set_keepalive()

sint8 espconn_set_keepalive ( struct espconn espconn,
uint8  level,
void *  optarg 
)

Definition at line 1128 of file espconn.c.

Referenced by MQTT_Connect().

1129 {
1130  espconn_msg *pnode = NULL;
1131  bool value = false;
1132  sint8 ret = ESPCONN_OK;
1133 
1134  if (espconn == NULL || optarg == NULL) {
1135  return ESPCONN_ARG;;
1136  } else if (espconn->type != ESPCONN_TCP)
1137  return ESPCONN_ARG;
1138 
1139  /*Find the node depend on the espconn message*/
1140  value = espconn_find_connection(espconn, &pnode);
1141  if (value && espconn_keepalive_disabled(pnode)) {
1142  struct tcp_pcb *pcb = pnode->pcommon.pcb;
1143  switch (level){
1144  case ESPCONN_KEEPIDLE:
1145  pcb->keep_idle = 1000 * (u32_t)(*(int*)optarg);
1146  ret = ESPCONN_OK;
1147  break;
1148  case ESPCONN_KEEPINTVL:
1149  pcb->keep_intvl = 1000 * (u32_t)(*(int*)optarg);
1150  ret = ESPCONN_OK;
1151  break;
1152  case ESPCONN_KEEPCNT:
1153  pcb->keep_cnt = (u32_t)(*(int*)optarg);
1154  ret = ESPCONN_OK;
1155  break;
1156  default:
1157  ret = ESPCONN_ARG;
1158  break;
1159  }
1160  return ret;
1161  } else
1162  return ESPCONN_ARG;
1163 }
#define NULL
Definition: def.h:47
void * pcb
Definition: espconn.h:150
#define ESPCONN_OK
Definition: espconn.h:20
unsigned long u32_t
Definition: cc.h:56
comon_pkt pcommon
Definition: espconn.h:170
#define ESPCONN_ARG
Definition: espconn.h:32
bool ICACHE_FLASH_ATTR espconn_find_connection(struct espconn *pespconn, espconn_msg **pnode)
Definition: espconn.c:186
enum espconn_type type
Definition: espconn.h:101
signed char sint8
Definition: c_types.h:47
#define espconn_keepalive_disabled(espconn)
Definition: espconn.h:200
Here is the caller graph for this function:

◆ espconn_set_opt()

sint8 espconn_set_opt ( struct espconn espconn,
uint8  opt 
)

Definition at line 1056 of file espconn.c.

Referenced by MQTT_Connect().

1057 {
1058  espconn_msg *pnode = NULL;
1059  struct tcp_pcb *tpcb;
1060  bool value = false;
1061 
1062  if (espconn == NULL) {
1063  return ESPCONN_ARG;;
1064  } else if (espconn->type != ESPCONN_TCP)
1065  return ESPCONN_ARG;
1066 
1067  /*Find the node depend on the espconn message*/
1068  value = espconn_find_connection(espconn, &pnode);
1069  if (value) {
1070  pnode->pcommon.espconn_opt |= opt;
1071  tpcb = pnode->pcommon.pcb;
1072  if (espconn_delay_disabled(pnode))
1073  tcp_nagle_disable(tpcb);
1074 
1075  if (espconn_keepalive_disabled(pnode))
1077 
1078  return ESPCONN_OK;
1079  } else
1080  return ESPCONN_ARG;
1081 }
#define espconn_delay_disabled(espconn)
Definition: espconn.h:195
#define NULL
Definition: def.h:47
void * pcb
Definition: espconn.h:150
#define ESPCONN_OK
Definition: espconn.h:20
comon_pkt pcommon
Definition: espconn.h:170
#define espconn_keepalive_enable(pcb)
Definition: espconn_tcp.h:13
#define ESPCONN_ARG
Definition: espconn.h:32
bool ICACHE_FLASH_ATTR espconn_find_connection(struct espconn *pespconn, espconn_msg **pnode)
Definition: espconn.c:186
enum espconn_type type
Definition: espconn.h:101
enum espconn_option espconn_opt
Definition: espconn.h:165
#define espconn_keepalive_disabled(espconn)
Definition: espconn.h:200
Here is the caller graph for this function:

◆ espconn_tcp_get_max_con()

uint8 espconn_tcp_get_max_con ( void  )

Definition at line 528 of file espconn.c.

529 {
530  uint8 tcp_num = 0;
531 
532  tcp_num = MEMP_NUM_TCP_PCB;
533 
534  return tcp_num;
535 }
#define MEMP_NUM_TCP_PCB
Definition: opt.h:251
unsigned char uint8
Definition: c_types.h:45

◆ espconn_tcp_get_max_con_allow()

sint8 espconn_tcp_get_max_con_allow ( struct espconn espconn)

Definition at line 618 of file espconn.c.

Referenced by espconn_tcp_accept().

619 {
620  espconn_msg *pget_msg = NULL;
621  if ((espconn == NULL) || (espconn->type == ESPCONN_UDP))
622  return ESPCONN_ARG;
623 
624  pget_msg = pserver_list;
625  while (pget_msg != NULL){
626  if (pget_msg->pespconn == espconn){
627  return pget_msg->count_opt;
628  }
629  pget_msg = pget_msg->pnext;
630  }
631  return ESPCONN_ARG;
632 }
struct _espconn_msg * pnext
Definition: espconn.h:175
#define NULL
Definition: def.h:47
#define ESPCONN_ARG
Definition: espconn.h:32
espconn_msg * pserver_list
Definition: espconn.c:33
enum espconn_type type
Definition: espconn.h:101
struct espconn * pespconn
Definition: espconn.h:169
uint8 count_opt
Definition: espconn.h:171
Here is the caller graph for this function:

◆ espconn_tcp_get_max_retran()

uint8 espconn_tcp_get_max_retran ( void  )

Definition at line 558 of file espconn.c.

References TCP_MAXRTX.

559 {
560  uint8 tcp_num = 0;
561 
562  tcp_num = TCP_MAXRTX;
563 
564  return tcp_num;
565 }
#define TCP_MAXRTX
Definition: opt.h:910
unsigned char uint8
Definition: c_types.h:45

◆ espconn_tcp_get_max_syn()

uint8 espconn_tcp_get_max_syn ( void  )

Definition at line 588 of file espconn.c.

References TCP_SYNMAXRTX.

589 {
590  uint8 tcp_num = 0;
591 
592  tcp_num = TCP_SYNMAXRTX;
593 
594  return tcp_num;
595 }
#define TCP_SYNMAXRTX
Definition: opt.h:917
unsigned char uint8
Definition: c_types.h:45

◆ espconn_tcp_get_wnd()

uint8 espconn_tcp_get_wnd ( void  )

Definition at line 483 of file espconn.c.

References TCP_MSS, and TCP_WND.

484 {
485  uint8 tcp_num = 0;
486 
487  tcp_num = (TCP_WND / TCP_MSS);
488 
489  return tcp_num;
490 }
#define TCP_WND
Definition: opt.h:903
unsigned char uint8
Definition: c_types.h:45
#define TCP_MSS
Definition: opt.h:936

◆ espconn_tcp_set_buf_count()

sint8 espconn_tcp_set_buf_count ( struct espconn espconn,
uint8  num 
)

Definition at line 665 of file espconn.c.

References ESPCONN_ARG, ESPCONN_OK, ESPCONN_TCP, NULL, _comon_pkt::pbuf_num, _espconn_msg::pcommon, _espconn_msg::pespconn, plist, _espconn_msg::pnext, TCP_SND_QUEUELEN, and espconn::type.

Referenced by espconn_client_connect(), and espconn_tcp_accept().

666 {
668  if (espconn == NULL || (num > TCP_SND_QUEUELEN))
669  return ESPCONN_ARG;
670 
671  /*find the node from the active connection list*/
672  for (plist = plink_active; plist != NULL; plist = plist->pnext){
673  if (plist->pespconn && plist->pespconn == espconn && espconn->type == ESPCONN_TCP){
674  plist->pcommon.pbuf_num = num;
675  return ESPCONN_OK;
676  }
677  }
678 
679  if (plist == NULL)
680  return ESPCONN_ARG;
681 }
struct _espconn_msg * pnext
Definition: espconn.h:175
#define NULL
Definition: def.h:47
#define ESPCONN_OK
Definition: espconn.h:20
comon_pkt pcommon
Definition: espconn.h:170
#define ESPCONN_ARG
Definition: espconn.h:32
espconn_msg * plink_active
Definition: espconn.c:32
uint8 pbuf_num
Definition: espconn.h:162
enum espconn_type type
Definition: espconn.h:101
#define TCP_SND_QUEUELEN
Definition: opt.h:964
static list_node * plist
Definition: dhcpserver.c:34
struct espconn * pespconn
Definition: espconn.h:169
Here is the caller graph for this function:

◆ espconn_tcp_set_max_con()

sint8 espconn_tcp_set_max_con ( uint8  num)

Definition at line 543 of file espconn.c.

544 {
545  if (num == 0 || num > linkMax)
546  return ESPCONN_ARG;
547 
548  MEMP_NUM_TCP_PCB = num;
549  return ESPCONN_OK;
550 }
#define ESPCONN_OK
Definition: espconn.h:20
#define MEMP_NUM_TCP_PCB
Definition: opt.h:251
#define ESPCONN_ARG
Definition: espconn.h:32
#define linkMax
Definition: espconn.h:193

◆ espconn_tcp_set_max_con_allow()

sint8 espconn_tcp_set_max_con_allow ( struct espconn espconn,
uint8  num 
)

Definition at line 640 of file espconn.c.

641 {
642  espconn_msg *pset_msg = NULL;
643  if ((espconn == NULL) || (num > MEMP_NUM_TCP_PCB) || (espconn->type == ESPCONN_UDP))
644  return ESPCONN_ARG;
645 
646  pset_msg = pserver_list;
647  while (pset_msg != NULL){
648  if (pset_msg->pespconn == espconn){
649  pset_msg->count_opt = num;
650  return ESPCONN_OK;
651  }
652  pset_msg = pset_msg->pnext;
653  }
654  return ESPCONN_ARG;
655 }
struct _espconn_msg * pnext
Definition: espconn.h:175
#define NULL
Definition: def.h:47
#define ESPCONN_OK
Definition: espconn.h:20
#define MEMP_NUM_TCP_PCB
Definition: opt.h:251
#define ESPCONN_ARG
Definition: espconn.h:32
espconn_msg * pserver_list
Definition: espconn.c:33
enum espconn_type type
Definition: espconn.h:101
struct espconn * pespconn
Definition: espconn.h:169
uint8 count_opt
Definition: espconn.h:171

◆ espconn_tcp_set_max_retran()

sint8 espconn_tcp_set_max_retran ( uint8  num)

Definition at line 573 of file espconn.c.

References ESPCONN_ARG, ESPCONN_OK, and TCP_MAXRTX.

574 {
575  if (num == 0 || num > 12)
576  return ESPCONN_ARG;
577 
578  TCP_MAXRTX = num;
579  return ESPCONN_OK;
580 }
#define TCP_MAXRTX
Definition: opt.h:910
#define ESPCONN_OK
Definition: espconn.h:20
#define ESPCONN_ARG
Definition: espconn.h:32

◆ espconn_tcp_set_max_syn()

sint8 espconn_tcp_set_max_syn ( uint8  num)

Definition at line 603 of file espconn.c.

References ESPCONN_ARG, ESPCONN_OK, and TCP_SYNMAXRTX.

604 {
605  if (num == 0 || num > 12)
606  return ESPCONN_ARG;
607 
608  TCP_SYNMAXRTX = num;
609  return ESPCONN_OK;
610 }
#define ESPCONN_OK
Definition: espconn.h:20
#define TCP_SYNMAXRTX
Definition: opt.h:917
#define ESPCONN_ARG
Definition: espconn.h:32

◆ espconn_tcp_set_wnd()

sint8 espconn_tcp_set_wnd ( uint8  num)

Definition at line 498 of file espconn.c.

References ESPCONN_ARG, ESPCONN_OK, linkMax, TCP_MSS, and TCP_WND.

499 {
500  if (num == 0 || num > linkMax)
501  return ESPCONN_ARG;
502 
503  TCP_WND = (num * TCP_MSS);
504  return ESPCONN_OK;
505 }
#define ESPCONN_OK
Definition: espconn.h:20
#define TCP_WND
Definition: opt.h:903
#define ESPCONN_ARG
Definition: espconn.h:32
#define linkMax
Definition: espconn.h:193
#define TCP_MSS
Definition: opt.h:936