cancel
Showing results for 
Search instead for 
Did you mean: 

lwip tcp server implementation troubleshooting

ark2
Associate III
void Tcp_Task(void const * argument)
 
{
 
  /* USER CODE BEGIN Tcp_Task */
 
  struct netconn *conn, *newconn;
 
  err_t err, accept_err;
 
  struct netbuf *buf;
 
  void *data;
 
  u16_t len;
 
 
  LWIP_UNUSED_ARG(argument);
 
  conn = netconn_new(NETCONN_TCP);
 
  if (conn!=NULL)
 
  {  
 
    // netconn_bind(conn, NULL, port 번호)
 
    err = netconn_bind(conn, NULL, 5001);
 
    
 
    if (err == ERR_OK)
 
    {
 
      netconn_listen(conn);
 
      
 
      while (1) 
 
      {
 
        accept_err = netconn_accept(conn, &newconn);
 
    
 
        if (accept_err == ERR_OK) 
 
        {
 
          while (netconn_recv(newconn, &buf) == ERR_OK) 
 
          {
 
    HAL_GPIO_WritePin(GPIOK, GPIO_PIN_3, GPIO_PIN_SET);
 
    HAL_GPIO_WritePin(GPIOK, GPIO_PIN_5, GPIO_PIN_SET);
 
    osDelay(100);
 
    HAL_GPIO_WritePin(GPIOK, GPIO_PIN_3, GPIO_PIN_RESET);
 
    HAL_GPIO_WritePin(GPIOK, GPIO_PIN_5, GPIO_PIN_RESET);
 
    osDelay(100);
 
            do 
 
            {
 
              netbuf_data(buf, &data, &len);
 
              memcpy(receivemsg, data, len);
 
              // 송신 메시지 �?성
 
              transmitmsg = procPacket();
 
 
              // 메시지 길�?�를 불러오는 함수
 
              msg_len = getsendPackSize();
 
              
 
              // 메시지 송신
 
              netconn_write(newconn, transmitmsg, msg_len, NETCONN_COPY);
 
            } 
 
            while (netbuf_next(buf) >= 0);
 
            netbuf_delete(buf);
 
          }
 
          netconn_close(newconn);
 
          netconn_delete(newconn);
 
        }
 
       osDelay(100);
 
      }
 
    }
 
    else
 
    {
 
      netconn_delete(newconn);
 
    }
 
  }
 
 
  /* Infinite loop */
 
    for(;;)
 
    {
 
      osDelay(100);
 
    }
 
  /* USER CODE END Tcp_Task */
 
}

I made this sauce to implement lwip tcp server

If I try to remove the st-link wire and do it without debugging, the server won't connect

I try to find a way, but I don't know where the problem is

If the LED on the board blinks, it means it's down

Is there a problem with why the server is not working?

If you turn it to debugging, you receive it without any problems, generate a message, and then send it

Then isn't there a problem with the sauce?

I think it's a server problem because the connection itself is not working without debugging

But if it's a circuit problem, I think it's weird to be a server when you debug it

I don't know where to look

If you see that the LED is blinking, the code seems to work normally, but strangely, it is not connected to the client

All the LEDs are working, but the conn n_n netcon = new (NETCONN_TCP); I think there's something in the same part, but if this is a problem, shouldn't it not be debugged?

The test went well by implementing a message response, but if I don't debug it, I can't connect to the client, so I can't get an answer

Not only this, but I also tried to implement a server (source code is different) using bw16 module (wfi module) with stm32, but I couldn't connect to wifi even if I connected anything

Reference Site : https://m.blog.naver.com/eziya76/221867311729

0693W00000WKVIYQA5.png0693W00000WKVIOQA5.png0693W00000WKVHkQAP.png0693W00000WKVHaQAP.png

0 REPLIES 0