enet_lwip例程问题:如果设置 lwip 使用 lwIPInit(g_ui32SysClock, pui8MACArray, 0xc0a80008, 0xffffff00, 0xc0a80001, IPADDR_USE_STATIC); 固定IP时,IP地址无法保存?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
enet_lwip例程问题:如果设置 lwip 使用 lwIPInit(g_ui32SysClock, pui8MACArray, 0xc0a80008, 0xffffff00, 0xc0a80001, IPADDR_USE_STATIC); 固定IP时,IP地址无法保存?
#if LWIP_AUTOIP || LWIP_DHCP
static void
lwIPLinkDetect(void)
{
bool bHaveLink;
struct ip_addr ip_addr;
struct ip_addr net_mask;
struct ip_addr gw_addr;
//
// See if there is an active link.
//
bHaveLink = MAP_EMACPHYRead(EMAC0_BASE, 0, EPHY_BMSR) & EPHY_BMSR_LINKSTAT;
//
// Return without doing anything else if the link state hasn't changed.
//
if(bHaveLink == g_bLinkActive)
{
return;
}
//
// Save the new link state.
//
g_bLinkActive = bHaveLink;
//
//如果设置 DHCP AUTOIP 清空IP地址
//
if((g_ui32IPMode == IPADDR_USE_DHCP)||(g_ui32IPMode == IPADDR_USE_AUTOIP))
{
//
// Clear any address information from the network interface.
//
ip_addr.addr = 0;
net_mask.addr = 0;
gw_addr.addr = 0;
netif_set_addr(&g_sNetIF, &ip_addr, &net_mask, &gw_addr);
}
//
// See if there is a link now.
//
if(bHaveLink)
{
//
// Start DHCP, if enabled.
//
#if LWIP_DHCP
if(g_ui32IPMode == IPADDR_USE_DHCP)
{
dhcp_start(&g_sNetIF);
}
#endif
//
// Start AutoIP, if enabled and DHCP is not.
//
#if LWIP_AUTOIP
if(g_ui32IPMode == IPADDR_USE_AUTOIP)
{
autoip_start(&g_sNetIF);
}
#endif
}
else
{
//
// Stop DHCP, if enabled.
//
#if LWIP_DHCP
if(g_ui32IPMode == IPADDR_USE_DHCP)
{
dhcp_stop(&g_sNetIF);
}
#endif
//
// Stop AutoIP, if enabled and DHCP is not.
//
#if LWIP_AUTOIP
if(g_ui32IPMode == IPADDR_USE_AUTOIP)
{
autoip_stop(&g_sNetIF);
}
#endif
}
}
#endif