/************************************************************************ * NAME: fapp_boot * * DESCRIPTION: ************************************************************************/ static void fapp_boot(fnet_shell_desc_t desc) { /* Bootloader. */ #if FAPP_CFG_BOOTLOADER /* The bootloader wait some time for a key over a serial connection.*/ /* The wait time is given by the boot_delay parameter.*/ fnet_time_t delay; const struct boot_mode *mode; mode = fapp_boot_mode_by_index (fapp_params_boot_config.mode); if(mode->handler) { delay = fapp_params_boot_config.delay; fnet_shell_printf(desc, FAPP_BOOT_STR, mode->name, delay); while(delay > 0u) { delay--; if( fnet_shell_getchar(desc) != FNET_ERR) { break; } fnet_timer_delay(FNET_TIMER_TICK_IN_SEC); /* 1 sec. delay. */ fnet_shell_printf(desc, "\b\b\b\b %3d", delay); } fnet_shell_println(desc, ""); if(delay == 0u) { /* Auto-start*/ mode->handler(desc); } } else #endif { /* Default startup script. */ #if FAPP_CFG_STARTUP_SCRIPT_ENABLED fnet_shell_println(desc, "Startup script: %s", FAPP_CFG_STARTUP_SCRIPT); fnet_shell_script(desc, FAPP_CFG_STARTUP_SCRIPT ); #endif } FNET_COMP_UNUSED_ARG(desc); }
/************************************************************************ * NAME: fapp_dhcp_callback_discover * * DESCRIPTION: Event handler callback on new IP from DHCP client. ************************************************************************/ static void fapp_dhcp_callback_discover(fnet_dhcp_desc_t dhcp_desc, fnet_netif_desc_t netif, void *shl_desc ) { fnet_shell_desc_t desc = (fnet_shell_desc_t) shl_desc; FNET_COMP_UNUSED_ARG(netif); FNET_COMP_UNUSED_ARG(dhcp_desc); if(fapp_dhcp_discover_counter == 0) { fnet_shell_unblock((fnet_shell_desc_t)shl_desc); fapp_dhcp_on_ctrlc((fnet_shell_desc_t)shl_desc); /* Cancel DHCP.*/ if(fapp_dhcp_autoip == FNET_TRUE) { fnet_shell_script(desc, "autoip"); } } else { fapp_dhcp_discover_counter--; fnet_shell_println(desc, FAPP_DHCP_DISCOVER_STR); } }
/************************************************************************ * NAME: fapp_boot_mode_script * * DESCRIPTION: ************************************************************************/ static void fapp_boot_mode_script(fnet_shell_desc_t desc) { fnet_shell_println(desc, "\n%s",fapp_params_boot_config.script); fnet_shell_script(desc, fapp_params_boot_config.script); }