MeterLogger
Functions | Variables
espconn.c File Reference
#include "lwip/netif.h"
#include "lwip/inet.h"
#include "netif/etharp.h"
#include "lwip/tcp.h"
#include "lwip/ip.h"
#include "lwip/init.h"
#include "ets_sys.h"
#include "os_type.h"
#include "lwip/mem.h"
#include "lwip/app/espconn_tcp.h"
#include "lwip/app/espconn_udp.h"
#include "lwip/app/espconn.h"
#include "user_interface.h"
Include dependency graph for espconn.c:

Go to the source code of this file.

Functions

static uint8 espconn_tcp_get_buf_count (espconn_buf *pesp_buf)
 
void ICACHE_FLASH_ATTR espconn_copy_partial (struct espconn *pesp_dest, struct espconn *pesp_source)
 
void ICACHE_FLASH_ATTR espconn_list_creat (espconn_msg **phead, espconn_msg *pinsert)
 
void ICACHE_FLASH_ATTR espconn_list_delete (espconn_msg **phead, espconn_msg *pdelete)
 
void ICACHE_FLASH_ATTR espconn_pbuf_create (espconn_buf **phead, espconn_buf *pinsert)
 
void ICACHE_FLASH_ATTR espconn_pbuf_delete (espconn_buf **phead, espconn_buf *pdelete)
 
bool ICACHE_FLASH_ATTR espconn_find_connection (struct espconn *pespconn, espconn_msg **pnode)
 
static uint8 ICACHE_FLASH_ATTR espconn_get_acticve_num (uint8 type)
 
sint8 ICACHE_FLASH_ATTR espconn_connect (struct espconn *espconn)
 
sint8 ICACHE_FLASH_ATTR espconn_create (struct espconn *espconn)
 
sint8 ICACHE_FLASH_ATTR espconn_sent (struct espconn *espconn, uint8 *psent, uint16 length)
 
sint16 ICACHE_FLASH_ATTR espconn_sendto (struct espconn *espconn, uint8 *psent, uint16 length)
 
sint8 espconn_send (struct espconn *espconn, uint8 *psent, uint16 length) __attribute__((alias("espconn_sent")))
 
uint8 ICACHE_FLASH_ATTR espconn_tcp_get_wnd (void)
 
sint8 ICACHE_FLASH_ATTR espconn_tcp_set_wnd (uint8 num)
 
uint16 ICACHE_FLASH_ATTR espconn_tcp_get_mss (void)
 
uint8 ICACHE_FLASH_ATTR espconn_tcp_get_max_con (void)
 
sint8 ICACHE_FLASH_ATTR espconn_tcp_set_max_con (uint8 num)
 
uint8 ICACHE_FLASH_ATTR espconn_tcp_get_max_retran (void)
 
sint8 ICACHE_FLASH_ATTR espconn_tcp_set_max_retran (uint8 num)
 
uint8 ICACHE_FLASH_ATTR espconn_tcp_get_max_syn (void)
 
sint8 ICACHE_FLASH_ATTR espconn_tcp_set_max_syn (uint8 num)
 
sint8 ICACHE_FLASH_ATTR espconn_tcp_get_max_con_allow (struct espconn *espconn)
 
sint8 ICACHE_FLASH_ATTR espconn_tcp_set_max_con_allow (struct espconn *espconn, uint8 num)
 
sint8 ICACHE_FLASH_ATTR espconn_tcp_set_buf_count (struct espconn *espconn, uint8 num)
 
sint8 ICACHE_FLASH_ATTR espconn_regist_sentcb (struct espconn *espconn, espconn_sent_callback sent_cb)
 
sint8 ICACHE_FLASH_ATTR espconn_regist_write_finish (struct espconn *espconn, espconn_connect_callback write_finish_fn)
 
sint8 ICACHE_FLASH_ATTR espconn_regist_connectcb (struct espconn *espconn, espconn_connect_callback connect_cb)
 
sint8 ICACHE_FLASH_ATTR espconn_regist_recvcb (struct espconn *espconn, espconn_recv_callback recv_cb)
 
sint8 ICACHE_FLASH_ATTR espconn_regist_reconcb (struct espconn *espconn, espconn_reconnect_callback recon_cb)
 
sint8 ICACHE_FLASH_ATTR espconn_regist_disconcb (struct espconn *espconn, espconn_connect_callback discon_cb)
 
sint8 ICACHE_FLASH_ATTR espconn_get_connection_info (struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags)
 
sint8 ICACHE_FLASH_ATTR espconn_accept (struct espconn *espconn)
 
sint8 ICACHE_FLASH_ATTR espconn_regist_time (struct espconn *espconn, uint32 interval, uint8 type_flag)
 
sint8 ICACHE_FLASH_ATTR espconn_disconnect (struct espconn *espconn)
 
sint8 ICACHE_FLASH_ATTR espconn_abort (struct espconn *espconn)
 
sint8 ICACHE_FLASH_ATTR espconn_get_packet_info (struct espconn *espconn, struct espconn_packet *infoarg)
 
sint8 ICACHE_FLASH_ATTR espconn_set_opt (struct espconn *espconn, uint8 opt)
 
sint8 ICACHE_FLASH_ATTR espconn_clear_opt (struct espconn *espconn, uint8 opt)
 
sint8 ICACHE_FLASH_ATTR espconn_set_keepalive (struct espconn *espconn, uint8 level, void *optarg)
 
sint8 ICACHE_FLASH_ATTR espconn_get_keepalive (struct espconn *espconn, uint8 level, void *optarg)
 
sint8 ICACHE_FLASH_ATTR espconn_delete (struct espconn *espconn)
 
uint32 ICACHE_FLASH_ATTR espconn_port (void)
 
err_t ICACHE_FLASH_ATTR espconn_gethostbyname (struct espconn *pespconn, const char *hostname, ip_addr_t *addr, dns_found_callback found)
 
void ICACHE_FLASH_ATTR espconn_dns_setserver (u8_t numdns, ip_addr_t *dnsserver)
 

Variables

espconn_msgplink_active = NULL
 
espconn_msgpserver_list = NULL
 
remot_info premot [linkMax]
 
struct espconn_packet pktinfo [2]
 

Function Documentation

◆ espconn_abort()

sint8 ICACHE_FLASH_ATTR espconn_abort ( struct espconn espconn)

Definition at line 972 of file espconn.c.

References ESPCONN_ARG, ESPCONN_CLOSE, espconn_find_connection(), ESPCONN_INPROGRESS, ESPCONN_OK, ESPCONN_TCP, espconn_tcp_disconnect(), ICACHE_FLASH_ATTR, NULL, and espconn::state.

Referenced by mqtt_tcpclient_delete().

973 {
974  espconn_msg *pnode = NULL;
975  bool value = false;
976 
977  if (espconn == NULL) {
978  return ESPCONN_ARG;;
979  } else if (espconn ->type != ESPCONN_TCP)
980  return ESPCONN_ARG;
981 
982  /*Find the node depend on the espconn message*/
983  value = espconn_find_connection(espconn, &pnode);
984 
985  if (value){
986  /*protect for redisconnection*/
987  if (espconn->state == ESPCONN_CLOSE)
988  return ESPCONN_INPROGRESS;
989  espconn_tcp_disconnect(pnode,1); //1 force, 0 normal
990  return ESPCONN_OK;
991  } else
992  return ESPCONN_ARG;
993 }
#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 call graph for this function:
Here is the caller graph for this function:

◆ espconn_accept()

sint8 ICACHE_FLASH_ATTR espconn_accept ( struct espconn espconn)

Definition at line 875 of file espconn.c.

References ESPCONN_ARG, ESPCONN_ISCONN, ESPCONN_OK, ESPCONN_TCP, espconn_tcp_server(), _esp_tcp::local_port, NULL, _espconn_msg::pespconn, plist, _espconn_msg::pnext, espconn::proto, espconn::tcp, and espconn::type.

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 call graph for this function:
Here is the caller graph for this function:

◆ espconn_clear_opt()

sint8 ICACHE_FLASH_ATTR espconn_clear_opt ( struct espconn espconn,
uint8  opt 
)

Definition at line 1092 of file espconn.c.

References ESPCONN_ARG, espconn_delay_enabled, espconn_find_connection(), espconn_keepalive_disable, espconn_keepalive_enabled, ESPCONN_OK, _comon_pkt::espconn_opt, ESPCONN_TCP, NULL, _comon_pkt::pcb, _espconn_msg::pcommon, and espconn::type.

1093 {
1094  espconn_msg *pnode = NULL;
1095  struct tcp_pcb *tpcb;
1096  bool value = false;
1097 
1098  if (espconn == NULL) {
1099  return ESPCONN_ARG;;
1100  } else if (espconn->type != ESPCONN_TCP)
1101  return ESPCONN_ARG;
1102 
1103  /*Find the node depend on the espconn message*/
1104  value = espconn_find_connection(espconn, &pnode);
1105  if (value) {
1106  pnode->pcommon.espconn_opt &= ~opt;
1107  tpcb = pnode->pcommon.pcb;
1108  if (espconn_keepalive_enabled(pnode))
1110 
1111  if (espconn_delay_enabled(pnode))
1112  tcp_nagle_enable(tpcb);
1113 
1114  return ESPCONN_OK;
1115  } else
1116  return ESPCONN_ARG;
1117 }
#define espconn_keepalive_enabled(espconn)
Definition: espconn.h:201
#define NULL
Definition: def.h:47
void * pcb
Definition: espconn.h:150
#define ESPCONN_OK
Definition: espconn.h:20
#define espconn_delay_enabled(espconn)
Definition: espconn.h:196
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
#define espconn_keepalive_disable(pcb)
Definition: espconn_tcp.h:14
enum espconn_option espconn_opt
Definition: espconn.h:165
Here is the call graph for this function:

◆ espconn_connect()

sint8 ICACHE_FLASH_ATTR espconn_connect ( struct espconn espconn)

Definition at line 260 of file espconn.c.

References ip_addr::addr, AP_NETIF, ESPCONN_AP, ESPCONN_AP_STA, ESPCONN_ARG, espconn_get_acticve_num(), ESPCONN_ISCONN, ESPCONN_OK, espconn_printf, ESPCONN_RTE, ESPCONN_STA, ESPCONN_TCP, espconn_tcp_client(), espconn_tcp_get_max_con(), ICACHE_FLASH_ATTR, ip_info::ip, IP4_ADDR, _esp_tcp::local_port, NULL, _espconn_msg::pespconn, plist, _espconn_msg::pnext, espconn::proto, _esp_tcp::remote_ip, STA_NETIF, STATION_GOT_IP, STATION_IDLE, espconn::tcp, espconn::type, wifi_get_ip_info(), wifi_get_opmode(), and wifi_station_get_connect_status().

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 call graph for this function:
Here is the caller graph for this function:

◆ espconn_copy_partial()

void ICACHE_FLASH_ATTR 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 ICACHE_FLASH_ATTR espconn_create ( struct espconn espconn)

Definition at line 334 of file espconn.c.

References ESPCONN_ARG, ESPCONN_ISCONN, ESPCONN_OK, ESPCONN_UDP, espconn_udp_server(), ICACHE_FLASH_ATTR, _esp_udp::local_port, NULL, _espconn_msg::pespconn, plist, _espconn_msg::pnext, espconn::proto, espconn::type, and espconn::udp.

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 call graph for this function:
Here is the caller graph for this function:

◆ espconn_delete()

sint8 ICACHE_FLASH_ATTR espconn_delete ( struct espconn espconn)

Definition at line 1217 of file espconn.c.

References ESPCONN_ARG, espconn_find_connection(), ESPCONN_OK, espconn_tcp_delete(), ESPCONN_UDP, espconn_udp_disconnect(), ICACHE_FLASH_ATTR, and NULL.

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 call graph for this function:
Here is the caller graph for this function:

◆ espconn_disconnect()

sint8 ICACHE_FLASH_ATTR espconn_disconnect ( struct espconn espconn)

Definition at line 942 of file espconn.c.

References ESPCONN_ARG, ESPCONN_CLOSE, espconn_find_connection(), ESPCONN_INPROGRESS, ESPCONN_OK, ESPCONN_TCP, espconn_tcp_disconnect(), ICACHE_FLASH_ATTR, NULL, and espconn::state.

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 call graph for this function:
Here is the caller graph for this function:

◆ espconn_dns_setserver()

void ICACHE_FLASH_ATTR 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 ICACHE_FLASH_ATTR 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_acticve_num()

static uint8 ICACHE_FLASH_ATTR espconn_get_acticve_num ( uint8  type)
static

Definition at line 239 of file espconn.c.

References ICACHE_FLASH_ATTR, NULL, _espconn_msg::pespconn, plist, _espconn_msg::pnext, and espconn::type.

Referenced by espconn_connect().

240 {
242  uint8 num_tcp_active = 0;
243 
244  for (plist = plink_active; plist != NULL; plist = plist->pnext) {
245  if (plist->pespconn != NULL && plist->pespconn->type == type) {
246  num_tcp_active++;
247  }
248  }
249 
250  return num_tcp_active;
251 }
struct _espconn_msg * pnext
Definition: espconn.h:175
#define NULL
Definition: def.h:47
unsigned char uint8
Definition: c_types.h:45
espconn_msg * plink_active
Definition: espconn.c:32
enum espconn_type type
Definition: espconn.h:101
static list_node * plist
Definition: dhcpserver.c:34
struct espconn * pespconn
Definition: espconn.h:169
Here is the caller graph for this function:

◆ espconn_get_connection_info()

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

Definition at line 825 of file espconn.c.

References ESPCONN_ARG, ESPCONN_OK, ESPCONN_TCP, ESPCONN_UDP, ICACHE_FLASH_ATTR, espconn::link_cnt, NULL, os_memcpy, os_memset, _espconn_msg::pcommon, _espconn_msg::pespconn, plink_active, plist, _espconn_msg::pnext, premot, _espconn_msg::preverse, _remot_info::remote_ip, _comon_pkt::remote_ip, _remot_info::remote_port, _comon_pkt::remote_port, _remot_info::state, espconn::state, and espconn::type.

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 ICACHE_FLASH_ATTR espconn_get_keepalive ( struct espconn espconn,
uint8  level,
void *  optarg 
)

Definition at line 1173 of file espconn.c.

References ESPCONN_ARG, espconn_find_connection(), espconn_keepalive_disabled, ESPCONN_KEEPCNT, ESPCONN_KEEPIDLE, ESPCONN_KEEPINTVL, ESPCONN_OK, ESPCONN_TCP, ICACHE_FLASH_ATTR, NULL, _comon_pkt::pcb, _espconn_msg::pcommon, and espconn::type.

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
Here is the call graph for this function:

◆ espconn_get_packet_info()

sint8 ICACHE_FLASH_ATTR espconn_get_packet_info ( struct espconn espconn,
struct espconn_packet infoarg 
)

Definition at line 1004 of file espconn.c.

References ESPCONN_ARG, ESPCONN_CLOSE, espconn_find_connection(), ESPCONN_NONE, ESPCONN_OK, ESPCONN_TCP, ICACHE_FLASH_ATTR, NULL, os_memcpy, _comon_pkt::packet_info, espconn_packet::packseq_nxt, espconn_packet::packseqno, _comon_pkt::pcb, _espconn_msg::pcommon, pktinfo, espconn_packet::snd_buf_size, espconn_packet::snd_queuelen, espconn::state, TCP_SND_QUEUELEN, espconn_packet::total_queuelen, and espconn::type.

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
Here is the call graph for this function:

◆ espconn_gethostbyname()

err_t ICACHE_FLASH_ATTR espconn_gethostbyname ( struct espconn pespconn,
const char *  hostname,
ip_addr_t addr,
dns_found_callback  found 
)

Definition at line 1288 of file espconn.c.

References ICACHE_FLASH_ATTR.

Referenced by MQTT_Connect().

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

◆ espconn_list_creat()

void ICACHE_FLASH_ATTR 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 ICACHE_FLASH_ATTR 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_pbuf_create()

void ICACHE_FLASH_ATTR espconn_pbuf_create ( espconn_buf **  phead,
espconn_buf pinsert 
)

Definition at line 136 of file espconn.c.

References NULL, plist, and _espconn_buf::pnext.

Referenced by espconn_sent().

137 {
139 
140  if (*phead == NULL)
141  *phead = pinsert;
142  else {
143  plist = *phead;
144  while (plist->pnext != NULL) {
145  plist = plist->pnext;
146  }
147  plist->pnext = pinsert;
148  }
149  pinsert->pnext = NULL;
150 }
#define NULL
Definition: def.h:47
struct _espconn_buf * pnext
Definition: espconn.h:146
static list_node * plist
Definition: dhcpserver.c:34
Here is the caller graph for this function:

◆ espconn_pbuf_delete()

void ICACHE_FLASH_ATTR espconn_pbuf_delete ( espconn_buf **  phead,
espconn_buf pdelete 
)

Definition at line 158 of file espconn.c.

References NULL, plist, and _espconn_buf::pnext.

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

159 {
161 
162  plist = *phead;
163  if (plist == NULL){
164  *phead = NULL;
165  } else {
166  if (plist == pdelete){
167  *phead = plist->pnext;
168  } else {
169  while (plist != NULL) {
170  if (plist->pnext == pdelete){
171  plist->pnext = pdelete->pnext;
172  }
173  plist = plist->pnext;
174  }
175  }
176  }
177 }
#define NULL
Definition: def.h:47
struct _espconn_buf * pnext
Definition: espconn.h:146
static list_node * plist
Definition: dhcpserver.c:34
Here is the caller graph for this function:

◆ espconn_port()

uint32 ICACHE_FLASH_ATTR espconn_port ( void  )

Definition at line 1245 of file espconn.c.

References ICACHE_FLASH_ATTR, and os_random().

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 call graph for this function:
Here is the caller graph for this function:

◆ espconn_regist_connectcb()

sint8 ICACHE_FLASH_ATTR espconn_regist_connectcb ( struct espconn espconn,
espconn_connect_callback  connect_cb 
)

Definition at line 751 of file espconn.c.

References _esp_tcp::connect_callback, ESPCONN_ARG, ESPCONN_OK, ICACHE_FLASH_ATTR, NULL, espconn::proto, and espconn::tcp.

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 ICACHE_FLASH_ATTR espconn_regist_disconcb ( struct espconn espconn,
espconn_connect_callback  discon_cb 
)

Definition at line 807 of file espconn.c.

References _esp_tcp::disconnect_callback, ESPCONN_ARG, ESPCONN_OK, ICACHE_FLASH_ATTR, NULL, espconn::proto, and espconn::tcp.

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 ICACHE_FLASH_ATTR espconn_regist_reconcb ( struct espconn espconn,
espconn_reconnect_callback  recon_cb 
)

Definition at line 789 of file espconn.c.

References ESPCONN_ARG, ESPCONN_OK, ICACHE_FLASH_ATTR, NULL, espconn::proto, _esp_tcp::reconnect_callback, and espconn::tcp.

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 ICACHE_FLASH_ATTR espconn_regist_recvcb ( struct espconn espconn,
espconn_recv_callback  recv_cb 
)

Definition at line 770 of file espconn.c.

References ESPCONN_ARG, ESPCONN_OK, ICACHE_FLASH_ATTR, NULL, and espconn::recv_callback.

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 ICACHE_FLASH_ATTR espconn_regist_sentcb ( struct espconn espconn,
espconn_sent_callback  sent_cb 
)

Definition at line 712 of file espconn.c.

References ESPCONN_ARG, ESPCONN_OK, ICACHE_FLASH_ATTR, NULL, and espconn::sent_callback.

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 ICACHE_FLASH_ATTR espconn_regist_time ( struct espconn espconn,
uint32  interval,
uint8  type_flag 
)

Definition at line 905 of file espconn.c.

References ESPCONN_ARG, espconn_find_connection(), ESPCONN_OK, ICACHE_FLASH_ATTR, NULL, _espconn_msg::pcommon, _espconn_msg::pespconn, _espconn_msg::pnext, pserver_list, and _comon_pkt::timeout.

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
Here is the call graph for this function:

◆ espconn_regist_write_finish()

sint8 ICACHE_FLASH_ATTR espconn_regist_write_finish ( struct espconn espconn,
espconn_connect_callback  write_finish_fn 
)

Definition at line 732 of file espconn.c.

References ESPCONN_ARG, ESPCONN_OK, ESPCONN_UDP, ICACHE_FLASH_ATTR, NULL, espconn::proto, espconn::tcp, espconn::type, and _esp_tcp::write_finish_fn.

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_send()

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

Referenced by espconn_sendto(), mqtt_send_keepalive(), MQTT_Task(), and mqtt_tcpclient_connect_cb().

Here is the caller graph for this function:

◆ espconn_sendto()

sint16 ICACHE_FLASH_ATTR espconn_sendto ( struct espconn espconn,
uint8 psent,
uint16  length 
)

Definition at line 448 of file espconn.c.

References __attribute__(), ESPCONN_ARG, espconn_find_connection(), ESPCONN_OK, espconn_send(), ESPCONN_UDP, espconn_udp_sendto(), NULL, and espconn::type.

Referenced by captdnsRecv().

449 {
450  espconn_msg *pnode = NULL;
451  bool value = false;
452  err_t error = ESPCONN_OK;
453 
454  if (espconn == NULL || psent == NULL || length == 0) {
455  return ESPCONN_ARG;
456  }
457 
458  /*Find the node depend on the espconn message*/
459  value = espconn_find_connection(espconn, &pnode);
460  if (value && espconn->type == ESPCONN_UDP)
461  return espconn_udp_sendto(pnode, psent, length);
462  else
463  return ESPCONN_ARG;
464 }
err_t espconn_udp_sendto(void *arg, uint8 *psent, uint16 length)
Definition: espconn_udp.c:183
#define NULL
Definition: def.h:47
#define ESPCONN_OK
Definition: espconn.h:20
#define ESPCONN_ARG
Definition: espconn.h:32
s8_t err_t
Definition: err.h:47
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ espconn_sent()

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

Definition at line 368 of file espconn.c.

References ESPCONN_ARG, espconn_copy_disabled, espconn_copy_enabled, espconn_find_connection(), ESPCONN_MAXNUM, ESPCONN_MEM, ESPCONN_OK, espconn_pbuf_create(), ESPCONN_TCP, espconn_tcp_get_buf_count(), espconn_tcp_write(), ESPCONN_UDP, espconn_udp_sent(), ESPCONN_WRITE, ICACHE_FLASH_ATTR, _espconn_buf::len, NULL, os_zalloc, _espconn_buf::payload, _comon_pkt::pbuf, _comon_pkt::pbuf_num, _comon_pkt::pcb, _espconn_msg::pcommon, _comon_pkt::ptail, _espconn_buf::punsent, espconn::state, TCP_SND_QUEUELEN, _espconn_buf::unsent, and _comon_pkt::write_flag.

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 call graph for this function:
Here is the caller graph for this function:

◆ espconn_set_keepalive()

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

Definition at line 1128 of file espconn.c.

References ESPCONN_ARG, espconn_find_connection(), espconn_keepalive_disabled, ESPCONN_KEEPCNT, ESPCONN_KEEPIDLE, ESPCONN_KEEPINTVL, ESPCONN_OK, ESPCONN_TCP, NULL, _comon_pkt::pcb, _espconn_msg::pcommon, and espconn::type.

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 call graph for this function:
Here is the caller graph for this function:

◆ espconn_set_opt()

sint8 ICACHE_FLASH_ATTR espconn_set_opt ( struct espconn espconn,
uint8  opt 
)

Definition at line 1056 of file espconn.c.

References ESPCONN_ARG, espconn_delay_disabled, espconn_find_connection(), espconn_keepalive_disabled, espconn_keepalive_enable, ESPCONN_OK, _comon_pkt::espconn_opt, ESPCONN_TCP, ICACHE_FLASH_ATTR, NULL, _comon_pkt::pcb, _espconn_msg::pcommon, and espconn::type.

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 call graph for this function:
Here is the caller graph for this function:

◆ espconn_tcp_get_buf_count()

static uint8 ICACHE_FLASH_ATTR espconn_tcp_get_buf_count ( espconn_buf pesp_buf)
static

Definition at line 689 of file espconn.c.

References ICACHE_FLASH_ATTR, NULL, and _espconn_buf::pnext.

Referenced by espconn_sent().

690 {
691  espconn_buf *pbuf_list = pesp_buf;
692  uint8 pbuf_num = 0;
693 
694  /*polling the list get the count of the current node*/
695  while (pbuf_list != NULL){
696  pbuf_list = pbuf_list->pnext;
697  pbuf_num ++;
698  }
699  return pbuf_num;
700 }
#define NULL
Definition: def.h:47
unsigned char uint8
Definition: c_types.h:45
struct _espconn_buf * pnext
Definition: espconn.h:146
Here is the caller graph for this function:

◆ espconn_tcp_get_max_con()

uint8 ICACHE_FLASH_ATTR espconn_tcp_get_max_con ( void  )

Definition at line 528 of file espconn.c.

References MEMP_NUM_TCP_PCB.

Referenced by espconn_connect().

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
Here is the caller graph for this function:

◆ espconn_tcp_get_max_con_allow()

sint8 ICACHE_FLASH_ATTR espconn_tcp_get_max_con_allow ( struct espconn espconn)

Definition at line 618 of file espconn.c.

References _espconn_msg::count_opt, ESPCONN_ARG, ESPCONN_UDP, NULL, _espconn_msg::pespconn, _espconn_msg::pnext, pserver_list, and espconn::type.

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 ICACHE_FLASH_ATTR 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 ICACHE_FLASH_ATTR 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_mss()

uint16 ICACHE_FLASH_ATTR espconn_tcp_get_mss ( void  )

Definition at line 513 of file espconn.c.

References TCP_MSS.

514 {
515  uint16 tcp_num = 0;
516 
517  tcp_num = TCP_MSS;
518 
519  return tcp_num;
520 }
unsigned short uint16
Definition: c_types.h:50
#define TCP_MSS
Definition: opt.h:936

◆ espconn_tcp_get_wnd()

uint8 ICACHE_FLASH_ATTR 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 ICACHE_FLASH_ATTR 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 ICACHE_FLASH_ATTR espconn_tcp_set_max_con ( uint8  num)

Definition at line 543 of file espconn.c.

References ESPCONN_ARG, ESPCONN_OK, linkMax, and MEMP_NUM_TCP_PCB.

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 ICACHE_FLASH_ATTR espconn_tcp_set_max_con_allow ( struct espconn espconn,
uint8  num 
)

Definition at line 640 of file espconn.c.

References _espconn_msg::count_opt, ESPCONN_ARG, ESPCONN_OK, ESPCONN_UDP, MEMP_NUM_TCP_PCB, NULL, _espconn_msg::pespconn, _espconn_msg::pnext, pserver_list, and espconn::type.

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 ICACHE_FLASH_ATTR 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 ICACHE_FLASH_ATTR 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 ICACHE_FLASH_ATTR 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

Variable Documentation

◆ pktinfo

struct espconn_packet pktinfo[2]

◆ plink_active

espconn_msg* plink_active = NULL

Definition at line 32 of file espconn.c.

Referenced by espconn_get_connection_info().

◆ premot

Definition at line 34 of file espconn.c.

Referenced by espconn_get_connection_info().

◆ pserver_list

espconn_msg* pserver_list = NULL