2018-05-14 05:20 AM
Hello Every One,
I am writing a TCP client on STM32F427 MCU using netconn API. My device is able to connect three times out of ten times. it seems the problem with netconn_connect() api. please help with this.
Note:
netconn_connect() is not coming back with any return value most of the times.void StartDefaultTask(void const * argument)
{ /* init code for LWIP */ MX_LWIP_Init();IP4_ADDR(&local_ip,192,168,100,60);
IP4_ADDR(&remote_ip,192,168,100,61); //192.168.100.61 printf('\r\nremote ip adress:%s\r\n',ip4addr_ntoa(&remote_ip)); printf('\r\nlocal ip adress:%s\r\n',ip4addr_ntoa(&local_ip)); //netif_set_up(&gnetif); conn = netconn_new(NETCONN_TCP); printf('\r\n%d',conn); printf('\r\nstate: %d',conn->state);// this is printing zeros every times if((netconn_bind(conn,&local_ip,23))==ERR_OK)// bind to local device IP{ printf('\nnetconn_bind succeed\n'); //vTaskDelay(100); osDelay(10); if((netconn_connect(conn,&remote_ip,23))==ERR_OK)// Connect to remoter FTP Server { printf('\nconnect\n'); osDelay(10); netconn_write(conn, (char *)'12345678', 8, NETCONN_NOFLAG); printf('\r\nstate: %d',conn->state); osDelay(100); netconn_write(conn, (char *)'12345678', 8, NETCONN_NOFLAG); printf('\r\nstate: %d',conn->state); osDelay(100); netconn_write(conn, (char *)'12345678', 8, NETCONN_NOFLAG); printf('\r\nstate: %d',conn->state); osDelay(100);netconn_close(conn);
netconn_delete(conn);for(;;)
{ printf('\r\nHello'); osDelay(1000);}
/* USER CODE END StartDefaultTask */}