Example #1
0
/*****************************************************************************
 * FUNCTION: process_cmd
 *
 * RETURNS: None
 *
 * PARAMS:  None
 *
 * NOTES:   Determines which command has been received and processes it.
 *****************************************************************************/
void process_cmd(void)
{
    BOOL new_arg;
    UINT8 i;


    g_ConsoleContext.argc = 0;
    new_arg = TRUE;

    // Get pointers to each token in the command string
    TokenizeCmdLine(g_ConsoleContext.rxBuf);

    // if command line nothing but white kWFSpace or a linefeed
    if ( g_ConsoleContext.argc == 0u )
    {
        return;   // nothing to do
    }

    // change the command itself (token[0]) to lower case
    for (i = 0; i < strlen((char *)g_ConsoleContext.argv[0]); ++i)
    {
        g_ConsoleContext.argv[0][i] = tolower(g_ConsoleContext.argv[0][i]);
    }


    if ( IS_ECHO_ON() )
    {
        putrsUART("\n\r");
    }

    switch (GetCmdId())
    {

        case HELP_MSG:
            do_help_msg();
			WFConsoleSetMsgFlag();
            break;

        case GET_WF_VERSION_MSG:
            do_get_wfver_cmd();
            break;

        case RESET_HOST:
            Reset();
            break;

        case CLEAR_SCREEN_MSG:
            do_cls_cmd();
            break;
            
#if defined(MRF24WG)
        case WPS_PIN_MSG:
            do_wps_pin_cmd();
            break;
            
        case WPS_PUSHBUTTON_MSG:
            do_wps_push_button_cmd();
            break;
            
        case WPS_GET_CREDENTIALS_MSG:
            do_wps_get_credentials_cmd();
            break;
            
#endif /* MRF24WG */


#if defined(WF_CONSOLE_IFCFGUTIL)
        case IFCONFIG_MSG:
            do_ifconfig_cmd();
            break;

        case IWCONFIG_MSG:
            do_iwconfig_cmd();
            break;
  
        case IWPRIV_MSG:
            do_iwpriv_cmd();
            break;
            
#endif // WF_CONSOLE_IFCFGUTIL

        default:
			WFConsoleSetMsgFlag();
            break;
    }
}
/*****************************************************************************
 * FUNCTION: process_cmd
 *
 * RETURNS: None
 *
 * PARAMS:  None
 *
 * NOTES:   Determines which command has been received and processes it.
 *****************************************************************************/
tZGVoidReturn process_cmd(tZGVoidInput)
{
    tZGBool new_arg;
    tZGU8 i;


    g_ConsoleContext.argc = 0;
    new_arg = kZGBoolTrue;

    // Get pointers to each token in the command string
    TokenizeCmdLine(g_ConsoleContext.rxBuf);

    // if command line nothing but white kZGSpace or a linefeed
    if ( g_ConsoleContext.argc == 0u )
    {
        return;   // nothing to do
    }

    // change the command itself (token[0]) to lower case
    for (i = 0; i < strlen((char *)g_ConsoleContext.argv[0]); ++i)
    {
        g_ConsoleContext.argv[0][i] = tolower(g_ConsoleContext.argv[0][i]);
    }


    if ( IS_ECHO_ON() )
    {
        ZG_PUTRSUART("\n\r");
    }

    switch (GetCmdId())
    {

        case HELP_MSG:
            do_help_msg();
            break;

        case GET_ZG2100_VERSION_MSG:
            do_get_zg2100_version_cmd();
            break;

        case RESET_HOST:
            Reset();
            break;

        case CLEAR_SCREEN_MSG:
            do_cls_cmd();
            break;

        case IFCONFIG_MSG:
            do_ifconfig_cmd();
            break;

        case IWCONFIG_MSG:
            do_iwconfig_cmd();
            break;

        case IWPRIV_MSG:
            do_iwpriv_cmd();
            break;

        default:
            // if we don't match one of the built-in command strings, check to
            // see if we match one of the application-defined command strings
            if (CheckForAppSpecificCommand(g_ConsoleContext.argv[0]))
            {
                ; // nothing else to do
            }
            else
            {

               sprintf((char *) g_ConsoleContext.txBuf, "Unknown cmd: %s\n\r", ARGV[0]);
               ZG_PUTSUART( (char *) g_ConsoleContext.txBuf );

            }
            break;
    }
}