Skip to main content
Andrew Ivanov
Associate II
May 27, 2019
Solved

I maked simple program with LWiP, and call netconn_bind(conn, IP4_ADDR_ANY, port) halted MCU board nucleo-f767zi.

  • May 27, 2019
  • 2 replies
  • 2199 views

I maked simple program with LWiP. After I got dinamyc address, I tried socket connection and call netconn_bind halted MCU.

My code:

 for(;;)

 {

  if(OK_D == 0)  

  {

    IP_A = gnetif.ip_addr.addr;

    if(IP_A == 0)

    {

      HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET); // led 2

      HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET); // led 3

    } else

    {

      dhcp_stop(&gnetif);

      OK_D = 1;

    }

  } else

    {

      HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET); //led 3

      osDelay(1);

      if(OK_E == 0)

      {

         

        conn = netconn_new(NETCONN_TCP);

        if(conn != NULL)

        {

          HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET); //led 2

          osDelay(1);

          err1 = netconn_bind(conn, IP4_ADDR_ANY, 100);

          osDelay(1);

          err2 = netconn_connect(conn, &IP_Server, 21000);

          if (err1 == ERR_OK)

          {

            OK_E = 1;           

            HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET);

          }

        }

       }

    }

 }

Please, help me resolve this problem.

LWiP settings in CubeMX:

0690X000008wQQqQAM.png

This topic has been closed for replies.
Best answer by Andrew Ivanov

This problem solved as follows, I ran functions netconn_new, netconn_bind, netconn_connect in separate thread. This thread maked with function sys_thread_new.

And, it`s ok in my case.

2 replies

Andrew Ivanov
Associate II
May 27, 2019

I`ts OK. I solve this problem.

Amel NASRI
Technical Moderator
May 30, 2019

Hi @Andrew Ivanov​ ,

Glad to know that your problem is resolved.

It will be more helpful for the Community if you share more details about your findings (what was the issue and how you resolved it?).

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.
Andrew Ivanov
Andrew IvanovAuthorBest answer
Associate II
June 10, 2019

This problem solved as follows, I ran functions netconn_new, netconn_bind, netconn_connect in separate thread. This thread maked with function sys_thread_new.

And, it`s ok in my case.