Memory Leak
Posted: Thu Jul 12, 2018 8:42 pm
I am trying to connect to a tcp server (which is a esp8266 softAP) using another esp8266 (which is in statoinAP mode)
I am getting error code 1, which is ESPCONN_MEM(out of memory error). I have been struggling for a very long time but i can't find out why i am getting the error. Can you please help me. My code is as follows.
I am getting error code 1, which is ESPCONN_MEM(out of memory error). I have been struggling for a very long time but i can't find out why i am getting the error. Can you please help me. My code is as follows.
Code: Select all
ets_uart_printf("TCP CLIENT CONNECT INIT\r\n ");
char tcpserverip[10];
TcpSTAClientConn.proto.tcp = &ConnTcp;
TcpSTAClientConn.type = ESPCONN_TCP;
TcpSTAClientConn.state = ESPCONN_NONE;
os_sprintf(tcpserverip, "%s", "10.10.10.1");
uint32_t ip = ipaddr_addr(tcpserverip);
os_memcpy(TcpSTAClientConn.proto.tcp->remote_ip, &ip, 4);
TcpSTAClientConn.proto.tcp->local_port = espconn_port();
TcpSTAClientConn.proto.tcp->remote_port = 2345;
espconn_regist_connectcb(&TcpSTAClientConn, tcp_connect_cb);
espconn_regist_reconcb(&TcpSTAClientConn, tcp_reconnect_cb);
espconn_regist_disconcb(&TcpSTAClientConn, tcp_disconnect_cb);
//#ifdef PLATFORM_DEBUG
ets_uart_printf("Start espconn_connect to " IPSTR ":%d\r\n\r", IP2STR(TcpSTAClientConn.proto.tcp->remote_ip), TcpSTAClientConn.proto.tcp->remote_port);
//#endif
//#ifdef LWIP_DEBUG
ets_uart_printf("Start espconn_connect local port %u\r\n\r", TcpSTAClientConn.proto.tcp->local_port);
//#endif
int espcon_status = espconn_connect(&TcpSTAClientConn);
//#ifdef PLATFORM_DEBUG
switch(espcon_status)
{
case ESPCONN_OK:
ets_uart_printf("TCP CLINET created.\r\n");
tcpClientFalg = 1;
break;
case ESPCONN_RTE:
ets_uart_printf("Error connection, routing problem.\r\n\r");
break;
case ESPCONN_TIMEOUT:
ets_uart_printf("Error connection, timeout.\r\n\r");
break;
default:
ets_uart_printf("Connection error: %d\r\n\r", espcon_status);
}
espconn_sent(&TcpSTAClientConn,"TCP Connected\n\r",strlen("TCP Connected\n\r"));
//#endif