2019-05-27 12:56 AM
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:
Solved! Go to Solution.
2019-06-10 05:59 AM
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.
2019-05-27 05:12 AM
I`ts OK. I solve this problem.
2019-05-30 04:54 AM
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 Accept as Solution on the reply which solved your issue or answered your question.
2019-06-10 05:59 AM
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.