[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] Randomly delayed frame (STM32070 package including LwIP
From: |
stevestrong |
Subject: |
Re: [lwip-users] Randomly delayed frame (STM32070 package including LwIP v1.4.1) |
Date: |
Wed, 2 Jan 2019 12:14:54 -0700 (MST) |
I finally managed to get DHCP working, I get a valid IP address assigned by
the router.
I post here the working version from netconf.c, not sure if it is really ok:
********************************************
void LwIP_Periodic_Handle(__IO uint32_t localtime)
{
/* Cyclic lwIP timers check */
sys_check_timeouts(); // v2
#ifdef USE_DHCP
/* Fine DHCP periodic process every 500ms */
if ( (localtime - DHCPfineTimer) >= DHCP_FINE_TIMER_MSECS)
{
DHCPfineTimer = localtime;
if ((DHCP_state != DHCP_ADDRESS_ASSIGNED) &&
(DHCP_state != DHCP_TIMEOUT) &&
(DHCP_state != DHCP_LINK_DOWN))
{
/* toggle LED1 to indicate DHCP on-going process */
ToggleLED(); // STM_EVAL_LEDToggle(LED1);
/* process DHCP state machine */
LwIP_DHCP_Process_Handle();
}
}
#else
(void)(localtime);
#endif
}
********************************************
void LwIP_DHCP_Process_Handle()
{
struct ip4_addr ipaddr;
struct ip4_addr netmask;
struct ip4_addr gw;
switch (DHCP_state)
{
case DHCP_START:
{
DHCP_state = DHCP_WAIT_ADDRESS;
PRINTF(". DHCP_WAIT_ADDRESS .\n");
dhcp_start(&gnetif);
/* IP address should be set to 0 every time we want to assign a new
DHCP address */
IPaddress = 0;
}
break;
case DHCP_WAIT_ADDRESS:
{
/* Read the new IP address */
IPaddress = gnetif.ip_addr.addr;
if (IPaddress!=0)
{
DHCP_state = DHCP_ADDRESS_ASSIGNED;
PRINTF(". DHCP_ADDRESS_ASSIGNED .\n");
/* Stop DHCP */
dhcp_stop(&gnetif);
LEDOn(1); // STM_EVAL_LEDOn(LED1);
}
else
{
struct dhcp * dhcp;
dhcp = netif_get_client_data(&gnetif,
LWIP_NETIF_CLIENT_DATA_INDEX_DHCP);
/* DHCP timeout */
if (dhcp->tries > MAX_DHCP_TRIES)
{
DHCP_state = DHCP_TIMEOUT;
PRINTF(". DHCP_TIMEOUT .\n");
/* Stop DHCP */
dhcp_stop(&gnetif);
/* Static address used */
IP4_ADDR(&ipaddr, IP_ADDR0 ,IP_ADDR1 , IP_ADDR2 , IP_ADDR3 );
IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2,
NETMASK_ADDR3);
IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
netif_set_addr(&gnetif, &ipaddr , &netmask, &gw);
LEDOff(1); // STM_EVAL_LEDOn(LED1);
}
}
}
break;
default: break;
}
}
********************************************
Basicaly, I added sys_check_timeouts() in the periodic handler and removed
the DHCP fine and course timeout routines from DHCP handler because they are
anyway executed by the newly added timeout check function.
However, I am not sure whether the DHCP process is standard conform.
It is weird that the gratuitous ARP request comes after the IP has been
assigned by the router. Is that OK?
I made a wireshark and debug log capture.
dhcp3.jpg <http://lwip.100.n7.nabble.com/file/t2167/dhcp3.jpg>
dhcp3.log <http://lwip.100.n7.nabble.com/file/t2167/dhcp3.log>
It would be nice if someone could have a look on it.
Thank you in advance.
--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html
- Re: [lwip-users] Randomly delayed frame (STM32070 package including LwIP v1.4.1),
stevestrong <=
- Re: [lwip-users] Randomly delayed frame (STM32070 package including LwIP v1.4.1), address@hidden, 2019/01/02
- Re: [lwip-users] Randomly delayed frame (STM32070 package including LwIP v1.4.1), stevestrong, 2019/01/03
- Re: [lwip-users] Randomly delayed frame (STM32070 package including LwIP v1.4.1), stevestrong, 2019/01/04
- Re: [lwip-users] Randomly delayed frame (STM32070 package including LwIP v1.4.1), Jason White, 2019/01/04
- Re: [lwip-users] Randomly delayed frame (STM32070 package including LwIP v1.4.1), stevestrong, 2019/01/04
- Re: [lwip-users] Randomly delayed frame (STM32070 package including LwIP v1.4.1), Jason White, 2019/01/04
- Re: [lwip-users] Randomly delayed frame (STM32070 package including LwIP v1.4.1), address@hidden, 2019/01/04
- Re: [lwip-users] Randomly delayed frame (STM32070 package including LwIP v1.4.1), stevestrong, 2019/01/05