Exemplo n.º 1
0
/************************************************************************
* NAME: fapp_show
*
* DESCRIPTION: Shows all system settings.
************************************************************************/
void fapp_get_cmd( fnet_shell_desc_t desc, int argc, char ** argv )
{
    int index;

    if(argc == 1) /* Print all prameters. */
    {
        for (index = 0; index < FAPP_SET_CMD_NUM; ++index)
        {
            fnet_shell_printf(desc, FAPP_GET_OPT_FORMAT, fapp_setget_cmd_table[index].option);
            fapp_setget_cmd_table[index].get(desc);
        }
    }
    else /* Print one parameter. */
    {
       
        for (index = 0; index < FAPP_SET_CMD_NUM; index++)
        {
            if(fnet_strcasecmp(fapp_setget_cmd_table[index].option, argv[1]) == 0)
            {
                fnet_shell_printf(desc, FAPP_GET_OPT_FORMAT, fapp_setget_cmd_table[index].option);
                fapp_setget_cmd_table[index].get(desc);
                return;
            }
        }

        fnet_shell_println(desc, FAPP_PARAM_ERR, argv[1]);
    }
    
}
Exemplo n.º 2
0
/************************************************************************
* NAME: fapp_netif_addr_print
*
* DESCRIPTION: Print Interface IP addresses. 
************************************************************************/
void fapp_netif_addr_print(fnet_shell_desc_t desc, fnet_address_family_t family, fnet_netif_desc_t netif, fnet_bool_t print_type)
{
	fnet_char_t    ip_str[FNET_IP_ADDR_STR_SIZE]={0};
    
#if FNET_CFG_IP4
    if((family & AF_INET)==AF_INET)
    {
        fnet_ip4_addr_t local_ip;
        
        local_ip = fnet_netif_get_ip4_addr(netif);
        fnet_shell_printf(desc, FAPP_SHELL_INFO_FORMAT_S, "IPv4 Address", fnet_inet_ntoa(*(struct in_addr *)(&local_ip), ip_str) ); 
        if(print_type)
        {
            fnet_shell_println(desc," <%s>", fnet_netif_get_ip4_addr_automatic(netif) ? "automatic" : "manual");
        }
        else
        {
            fnet_shell_println(desc, "");  
        }
    }
#endif /* FNET_CFG_IP4 */
#if FNET_CFG_IP6
    if((family & AF_INET6)==AF_INET6)
    {
        fnet_bool_t                 result;
        fnet_index_t                n;
        fnet_netif_ip6_addr_info_t  addr_info;
        
        /* Print all assigned IPv6 addreses.*/
        n=0u;
        for(;;) 
        {
            result = fnet_netif_get_ip6_addr (netif, n, &addr_info);
            
            if(result == FNET_TRUE)
            {
                fnet_inet_ntop(AF_INET6, (fnet_uint8_t*)(&addr_info.address), ip_str, sizeof(ip_str));
                            
                fnet_shell_printf(desc, FAPP_SHELL_INFO_FORMAT_S, "IPv6 Address", ip_str);
                if(print_type)
                {
                    fnet_shell_println(desc," <%s> ScopeID:%d", (addr_info.type == FNET_NETIF_IP6_ADDR_TYPE_AUTOCONFIGURABLE)  ? "autoconfigurable" : "manual", fnet_netif_get_scope_id(netif)); 
                }
                else
                {
                    fnet_shell_println(desc,"");    
                }
            }
            else
            {
               break;
            }

            n++;
        }
    }
#endif /* FNET_CFG_IP6 */
}
Exemplo n.º 3
0
/************************************************************************
* 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);
}
Exemplo n.º 4
0
/************************************************************************
* NAME: fapp_set_cmd
*
* DESCRIPTION: Sets system options.
************************************************************************/
void fapp_set_cmd( fnet_shell_desc_t desc, int argc, char ** argv )
{
    int index;

    if(argc == 1) /* Print all set options with syntax description. */
    {
        fnet_shell_println(desc, "Valid 'set' options:");

        for (index = 0; index < FAPP_SET_CMD_NUM; ++index)
        {
            fnet_shell_println(desc, FAPP_SET_OPT_FORMAT, fapp_setget_cmd_table[index].option, fapp_setget_cmd_table[index].syntax);
        }
    }
    else if(argc != 3)
    {
        fnet_shell_println(desc, FAPP_PARAM_ERR, "");
    }
    else /* Set parameter */
    {
        for (index = 0; index < FAPP_SET_CMD_NUM; index++)
        {
            if(fnet_strcasecmp(fapp_setget_cmd_table[index].option, argv[1]) == 0)
            {
                fapp_setget_cmd_table[index].set(desc, argv[2]);
                /* Print the result value. */
                fnet_shell_printf(desc, FAPP_GET_OPT_FORMAT, fapp_setget_cmd_table[index].option);
                fapp_setget_cmd_table[index].get(desc);
                goto EXIT;
            }
        }

        fnet_shell_println(desc, FAPP_PARAM_ERR, argv[1]);
    }
EXIT:
    return;    
}