void InitContinuations( struct netif *pNetIf ) { InterruptTaskContinuation.InitializeCallback( (HAL_CALLBACK_FPN)LPC24XX_EMAC_lwip_recv, pNetIf ); LwipUpTimeCompletion.InitializeForUserMode( (HAL_CALLBACK_FPN)lwip_network_uptime_completion, pNetIf ); LwipUpTimeCompletion.EnqueueDelta64( 2000000 ); }
void lwip_network_uptime_completion(void *arg) { NATIVE_PROFILE_PAL_NETWORK(); BOOL status = ENET_PHY_lwip_get_link_status( ); if(status != LwipNetworkStatus) { struct netif* pNetIf = (struct netif*)arg; if(status) { SOCK_NetworkConfiguration *pNetCfg = &g_NetworkConfig.NetworkInterfaces[0]; ENET_PHY_lwip_set_link_speed( ); netif_set_up( pNetIf ); if(pNetCfg->flags & SOCK_NETWORKCONFIGURATION_FLAGS_DHCP) { dhcp_start( pNetIf ); } Network_PostEvent( NETWORK_EVENT_TYPE__AVAILABILITY_CHANGED, NETWORK_EVENT_FLAGS_IS_AVAILABLE ); } else { netif_set_down( (struct netif*)arg ); Network_PostEvent( NETWORK_EVENT_TYPE__AVAILABILITY_CHANGED, 0); } LwipNetworkStatus = status; } LwipUpTimeCompletion.EnqueueDelta64( 2000000 ); }
void lwip_network_uptime_completion(void *arg) { NATIVE_PROFILE_PAL_NETWORK(); struct netif* pNetIf = (struct netif*)arg; BOOL status = enc28j60_get_link_status(&g_ENC28J60_LWIP_Config.DeviceConfigs[0].SPI_Config); if(status != LwipNetworkStatus) { if(status) { tcpip_callback((sys_timeout_handler)netif_set_link_up, (void*)pNetIf); tcpip_callback((sys_timeout_handler)netif_set_up, (void*)pNetIf); Network_PostEvent( NETWORK_EVENT_TYPE__AVAILABILITY_CHANGED, NETWORK_EVENT_FLAGS_IS_AVAILABLE ); } else { tcpip_callback((sys_timeout_handler)netif_set_link_down, (void*)pNetIf); tcpip_callback((sys_timeout_handler)netif_set_down, (void*)pNetIf); Network_PostEvent( NETWORK_EVENT_TYPE__AVAILABILITY_CHANGED, 0); } Events_Set(SYSTEM_EVENT_FLAG_SOCKET); Events_Set(SYSTEM_EVENT_FLAG_NETWORK); LwipNetworkStatus = status; } LwipUpTimeCompletion.EnqueueDelta64( 2000000 ); }
void InitContinuations( struct netif *pNetIf ) { InterruptTaskContinuation.InitializeCallback( (HAL_CALLBACK_FPN)STM32F4_ETH_LWIP_recv, (void*)pNetIf ); LwipUpTimeCompletion.InitializeForUserMode( (HAL_CALLBACK_FPN)lwip_network_uptime_completion, (void*)pNetIf ); LwipUpTimeCompletion.EnqueueDelta64( 2000000 ); }
void InitContinuations( struct netif* pNetIf ) { InterruptTaskContinuation.InitializeCallback( (HAL_CALLBACK_FPN)enc28j60_lwip_interrupt, &g_ENC28J60_NetIF ); LwipUpTimeCompletion.InitializeForUserMode( (HAL_CALLBACK_FPN)lwip_network_uptime_completion, pNetIf ); LwipUpTimeCompletion.EnqueueDelta64( 500000 ); }
void lwip_network_uptime_completion(void *arg) { NATIVE_PROFILE_PAL_NETWORK(); BOOL status = dm9161_lwip_GetLinkStatus( ) != 0; if(!status) { status = dm9161_lwip_GetLinkStatus( ) != 0; } if(status != LWIP_STATUS_isset(LWIP_STATUS_LinkUp) ) { struct netif* pNetIf = (struct netif*)arg; if(status) { tcpip_timeout(1000, (sys_timeout_handler)netif_set_link_up, (void*)pNetIf); tcpip_timeout(1000, (sys_timeout_handler)netif_set_up, (void*)pNetIf); Network_PostEvent( NETWORK_EVENT_TYPE__AVAILABILITY_CHANGED, NETWORK_EVENT_FLAGS_IS_AVAILABLE ); } else { tcpip_callback((sys_timeout_handler)netif_set_link_down, (void*)pNetIf); tcpip_callback((sys_timeout_handler)netif_set_down, (void*)pNetIf); Network_PostEvent( NETWORK_EVENT_TYPE__AVAILABILITY_CHANGED, 0); } Events_Set(SYSTEM_EVENT_FLAG_SOCKET); Events_Set(SYSTEM_EVENT_FLAG_NETWORK); LWIP_STATUS_setorclear( LWIP_STATUS_LinkUp, status ); } LwipUpTimeCompletion.EnqueueDelta64( 2000000 ); }
void lwip_network_uptime_completion(void *arg) { NATIVE_PROFILE_PAL_NETWORK(); static BOOL isPhyPoweringUp = FALSE; static int nAttempts = 0; BOOL status; /* Power up PHY and wait while it starts */ if (!LwipNetworkStatus && !isPhyPoweringUp) { eth_powerUpPhy(TRUE); isPhyPoweringUp = TRUE; LwipUpTimeCompletion.EnqueueDelta64( 2500000 ); nAttempts++; return; } /* PHY should now have started, get the network status */ isPhyPoweringUp = FALSE; status = eth_isPhyLinkValid(FALSE); /* Check whether network status has changed */ if (status != LwipNetworkStatus) { struct netif* pNetIf = (struct netif*)arg; /* Check status */ if (status) { /* Network is up, open ethernet driver */ SOCK_NetworkConfiguration *pNetCfg = &g_NetworkConfig.NetworkInterfaces[0]; STM32F4_ETH_LWIP_open(pNetIf); netif_set_up( pNetIf ); if(pNetCfg->flags & SOCK_NETWORKCONFIGURATION_FLAGS_DHCP) { dhcp_start( pNetIf ); } nAttempts = 0; Network_PostEvent( NETWORK_EVENT_TYPE__AVAILABILITY_CHANGED, NETWORK_EVENT_FLAGS_IS_AVAILABLE ); } else { /* Network is down, close ethernet driver */ STM32F4_ETH_LWIP_close(FALSE); netif_set_down( (struct netif*)arg ); Network_PostEvent( NETWORK_EVENT_TYPE__AVAILABILITY_CHANGED, 0); } /* Save new network status */ LwipNetworkStatus = status; } /* Power down PHY if network is down */ if (!LwipNetworkStatus) { eth_powerUpPhy(FALSE); } /* Schedule the next network status check */ if (LwipNetworkStatus || (nAttempts < 12) ) { /* When network is up or has been up, check every 5 seconds */ LwipUpTimeCompletion.EnqueueDelta64( 2500000 ); } else { /* When network is down, check only once every minute */ LwipUpTimeCompletion.EnqueueDelta64( 57500000 ); } }