예제 #1
0
static void cmd_webserver(Stream *chp, int argc, char* argv[])
{
   if (argc < 1) {
      chprintf(chp, "Usage: webserver on|off|info|auth\r\n");
   }
   else if (strncasecmp("on", argv[0], 2) == 0) { 
     chprintf(chp, "***** HTTP SERVER ON *****\r\n");
     SET_BYTE_PARAM(HTTP_ON, 1);
     wifi_restart();
   }
   else if (strncasecmp("off", argv[0], 2) == 0) {
     chprintf(chp, "***** HTTP SERVER OFF *****\r\n");
     SET_BYTE_PARAM(HTTP_ON, 0);
     wifi_restart();
   }
   else if (strncasecmp("info", argv[0], 2) == 0) {
      chprintf(chp, "Webserver is %s\r\n", (GET_BYTE_PARAM(HTTP_ON) ? "on" : "off"));
   }
   else if (strncasecmp("auth", argv[0], 3) == 0) {
      chprintf(chp, "Enter username: "******"Enter password: "******"Ok\r\n");
      }
   }
}
예제 #2
0
/**
 * @brief   Shell thread function.
 *
 * @param[in] p         pointer to a @p BaseSequentialStream object
 */
THD_FUNCTION(shellThread, p) {
  int n;
  BaseSequentialStream *chp = ((ShellConfig *)p)->sc_channel;
  const ShellCommand *scp = ((ShellConfig *)p)->sc_commands;
  char *lp, *cmd, *tokp, line[SHELL_MAX_LINE_LENGTH];
  char *args[SHELL_MAX_ARGUMENTS + 1];

  chprintf(chp, "\r\nChibiOS/RT Shell\r\n");
  while (true) {
    chprintf(chp, "ch> ");
    if (shellGetLine(chp, line, sizeof(line))) {
#if (SHELL_CMD_EXIT_ENABLED == TRUE) && !defined(_CHIBIOS_NIL_)
      chprintf(chp, "\r\nlogout");
      break;
#else
      /* Putting a delay in order to avoid an endless loop trying to read
         an unavailable stream.*/
      osalThreadSleepMilliseconds(100);
#endif
    }
    lp = parse_arguments(line, &tokp);
    cmd = lp;
    n = 0;
    while ((lp = parse_arguments(NULL, &tokp)) != NULL) {
      if (n >= SHELL_MAX_ARGUMENTS) {
        chprintf(chp, "too many arguments\r\n");
        cmd = NULL;
        break;
      }
      args[n++] = lp;
    }
    args[n] = NULL;
    if (cmd != NULL) {
      if (strcmp(cmd, "exit") == 0) {
        if (n > 0) {
          usage(chp, "exit");
          continue;
        }
        break;
      }
      else if (strcmp(cmd, "help") == 0) {
        if (n > 0) {
          usage(chp, "help");
          continue;
        }
        chprintf(chp, "Commands: help exit ");
        list_commands(chp, shell_local_commands);
        if (scp != NULL)
          list_commands(chp, scp);
        chprintf(chp, "\r\n");
      }
      else if (cmdexec(shell_local_commands, chp, cmd, n, args) &&
          ((scp == NULL) || cmdexec(scp, chp, cmd, n, args))) {
        chprintf(chp, "%s", cmd);
        chprintf(chp, " ?\r\n");
      }
    }
  }
  shellExit(MSG_OK);
}
예제 #3
0
static void cmd_converse(Stream *chp, int argc, char* argv[])
{
  (void) argc;
  (void) argv; 
  
  static FBUF packet; 
  chprintf(chp, "***** CONVERSE MODE. Ctrl-D to exit *****\r\n");
  radio_require();
  mon_activate(true); 
  fbq_t* outframes = hdlc_get_encoder_queue();
  
  while (!shellGetLine(chp, buf, BUFSIZE)) { 
    addr_t from, to; 
    GET_PARAM(MYCALL, &from);
    GET_PARAM(DEST, &to);       
    addr_t digis[7];
    uint8_t ndigis = GET_BYTE_PARAM(NDIGIS); 
    GET_PARAM(DIGIS, &digis);  
    fbuf_new(&packet);
    ax25_encode_header(&packet, &from, &to, digis, ndigis, FTYPE_UI, PID_NO_L3);
    fbuf_putstr(&packet, buf);                        
    fbq_put(outframes, packet);
  }
  mon_activate(false);
  radio_release();
}
예제 #4
0
/**
 * @brief   Shell thread function.
 *
 * @param[in] p         pointer to a @p BaseSequentialStream object
 * @return              Termination reason.
 * @retval RDY_OK       terminated by command.
 * @retval RDY_RESET    terminated by reset condition on the I/O channel.
 *
 * @notapi
 */
static msg_t shell_thread(void *p) {
  int n;
  BaseSequentialStream *chp = ((ShellConfig *)p)->sc_channel;
  const ShellCommand *scp = ((ShellConfig *)p)->sc_commands;
  char *lp, *cmd, *tokp, line[SHELL_MAX_LINE_LENGTH];
  char *args[SHELL_MAX_ARGUMENTS + 1];

  chRegSetThreadName("shell");
  chprintf(chp, "\r\nChibiOS/RT Shell\r\n");
  while (TRUE) {
    chprintf(chp, "mamad_OS> ");
    if (shellGetLine(chp, line, sizeof(line))) {
      chprintf(chp, "\r\nlogout");
      break;
    }
    lp = _strtok(line, " \t", &tokp);
    cmd = lp;
    n = 0;
    while ((lp = _strtok(NULL, " \t", &tokp)) != NULL) {
      if (n >= SHELL_MAX_ARGUMENTS) {
        chprintf(chp, "too many arguments\r\n");
        cmd = NULL;
        break;
      }
      args[n++] = lp;
    }
    args[n] = NULL;
    if (cmd != NULL) {
      if (strcasecmp(cmd, "exit") == 0) {
        if (n > 0) {
          usage(chp, "exit");
          continue;
        }
        break;
      }
      else if (strcasecmp(cmd, "help") == 0) {
        if (n > 0) {
          usage(chp, "help");
          continue;
        }
//         chprintf(chp, "Commands: help exit ");
	chprintf(chp, "Available Commands : \r\n");
	chprintf(chp,"help\r\n");
        list_commands(chp, local_commands);
        if (scp != NULL)
          list_commands(chp, scp);
        chprintf(chp, "\r\n");
      }
      else if (cmdexec(local_commands, chp, cmd, n, args) &&
          ((scp == NULL) || cmdexec(scp, chp, cmd, n, args))) {
        chprintf(chp, "%s", cmd);
        chprintf(chp, " ?\r\n");
      }
    }
  }
  shellExit(RDY_OK);
  /* Never executed, silencing a warning.*/
  return 0;
}
예제 #5
0
thread_t* myshell_start()
{  
    char line[10]; 
    chprintf(shell_cfg.sc_channel, "\r\n");
    shellGetLine(shell_cfg.sc_channel, line, sizeof(line));
    sleep(10);
    chprintf(shell_cfg.sc_channel, "\r\n\r\nWelcome to Polaric Hacker v. 2.0\r\n");   
    return shellCreate(&shell_cfg, SHELL_WA_SIZE, NORMALPRIO);
}
예제 #6
0
파일: Shell.cpp 프로젝트: avsbot/Nucleo
void shellStart(const ShellConfig *p) 
{
  int n;
  Stream *chp = p->sc_channel;
  const ShellCommand *scp = p->sc_commands;
  char *lp, *cmd, *tokp, line[SHELL_MAX_LINE_LENGTH];
  char *args[SHELL_MAX_ARGUMENTS + 1];

  chp->printf("\r\nEmbed/RX Shell\r\n");
  while (true) {
    chp->printf(">> ");
    if (shellGetLine(chp, line, sizeof(line))) {
      chp->printf("\r\nlogout");
      break;
    }
    lp = _strtok(line, " \t", &tokp);
    cmd = lp;
    n = 0;
    while ((lp = _strtok(NULL, " \t", &tokp)) != NULL) {
      if (n >= SHELL_MAX_ARGUMENTS) {
        chp->printf("too many arguments\r\n");
        cmd = NULL;
        break;
      }
      args[n++] = lp;
    }
    args[n] = NULL;
    if (cmd != NULL) {
      if (strcasecmp(cmd, "exit") == 0) {
        if (n > 0) {
          shellUsage(chp, "exit");
          continue;
        }
				// Break here breaks the outer loop
				// hence, we exit the shell.
        break;
      }
      else if (strcasecmp(cmd, "help") == 0) {
        if (n > 0) {
          shellUsage(chp, "help");
          continue;
        }
        chp->printf("Commands: help exit ");
        list_commands(chp, local_commands);
        if (scp != NULL)
          list_commands(chp, scp);
        chp->printf("\r\n");
      }
      else if (cmdexec(local_commands, chp, cmd, n, args) &&
          ((scp == NULL) || cmdexec(scp, chp, cmd, n, args))) {
        chp->printf("%s", cmd);
        chp->printf(" ?\r\n");
      }
    }
  }
}
예제 #7
0
파일: console.c 프로젝트: hsteinhaus/px4esc
static char* getline(const char* prompt)
{
	static char _linebuf[32];
	memset(_linebuf, 0, sizeof(_linebuf));
	if (prompt)
		lowsyslog(prompt);
	if (!shellGetLine((BaseSequentialStream*) &STDIN_SD, _linebuf, sizeof(_linebuf)))
		return _linebuf;
	return NULL;
}
예제 #8
0
/**
 * @brief   Shell thread function.
 *
 * @param[in] p         pointer to a @p BaseSequentialStream object
 */
static THD_FUNCTION(shell_thread, p) {
  int n;
  BaseSequentialStream *chp = ((ShellConfig *)p)->sc_channel;
  const ShellCommand *scp = ((ShellConfig *)p)->sc_commands;
  char *lp, *cmd, *tokp, line[SHELL_MAX_LINE_LENGTH];
  char *args[SHELL_MAX_ARGUMENTS + 1];

  chRegSetThreadName("shell");
  chprintf(chp, "\r\nChibiOS/RT Shell\r\n");
  while (true) {
    chprintf(chp, "ch> ");
    if (shellGetLine(chp, line, sizeof(line))) {
      chprintf(chp, "\r\nlogout");
      break;
    }
    lp = _strtok(line, " \t", &tokp);
    cmd = lp;
    n = 0;
    while ((lp = _strtok(NULL, " \t", &tokp)) != NULL) {
      if (n >= SHELL_MAX_ARGUMENTS) {
        chprintf(chp, "too many arguments\r\n");
        cmd = NULL;
        break;
      }
      args[n++] = lp;
    }
    args[n] = NULL;
    if (cmd != NULL) {
      if (strcasecmp(cmd, "exit") == 0) {
        if (n > 0) {
          usage(chp, "exit");
          continue;
        }
        break;
      }
      else if (strcasecmp(cmd, "help") == 0) {
        if (n > 0) {
          usage(chp, "help");
          continue;
        }
        chprintf(chp, "Commands: help exit ");
        list_commands(chp, local_commands);
        if (scp != NULL)
          list_commands(chp, scp);
        chprintf(chp, "\r\n");
      }
      else if (cmdexec(local_commands, chp, cmd, n, args) &&
          ((scp == NULL) || cmdexec(scp, chp, cmd, n, args))) {
        chprintf(chp, "%s", cmd);
        chprintf(chp, " ?\r\n");
      }
    }
  }
  shellExit(MSG_OK);
}
예제 #9
0
파일: shell.c 프로젝트: Amirelecom/brush-v1
/**
 * @brief Shell thread function.
 *
 * @param[in] p pointer to a @p BaseChannel object
 * @return Termination reason.
 * @retval RDY_OK terminated by command.
 * @retval RDY_RESET terminated by reset condition on the I/O channel.
 */
static msg_t shell_thread(void *p) {
  int n;
  msg_t msg = RDY_OK;
  BaseChannel *chp = ((ShellConfig *)p)->sc_channel;
  const ShellCommand *scp = ((ShellConfig *)p)->sc_commands;
  char *lp, *cmd, *tokp, line[SHELL_MAX_LINE_LENGTH];
  char *args[SHELL_MAX_ARGUMENTS + 1];

  shellPrintLine(chp, "");
  shellPrintLine(chp, "ChibiOS/RT Shell");
  while (TRUE) {
    shellPrint(chp, "ch> ");
    if (shellGetLine(chp, line, sizeof(line))) {
      shellPrint(chp, "\nlogout");
      break;
    }
    lp = strtok_r(line, " \009", &tokp);
    cmd = lp;
    n = 0;
    while ((lp = strtok_r(NULL, " \009", &tokp)) != NULL) {
      if (n >= SHELL_MAX_ARGUMENTS) {
        shellPrintLine(chp, "too many arguments");
        cmd = NULL;
        break;
      }
      args[n++] = lp;
    }
    args[n] = NULL;
    if (cmd != NULL) {
      if (strcasecmp(cmd, "exit") == 0) {
        if (n > 0)
          usage(chp, "exit");
        break;
      }
      else if (strcasecmp(cmd, "help") == 0) {
        if (n > 0)
          usage(chp, "help");
        shellPrint(chp, "Commands: help exit ");
        list_commands(chp, local_commands);
        if (scp != NULL)
          list_commands(chp, scp);
        shellPrintLine(chp, "");
      }
      else if (cmdexec(local_commands, chp, cmd, n, args) &&
          ((scp == NULL) || cmdexec(scp, chp, cmd, n, args))) {
        shellPrint(chp, cmd);
        shellPrintLine(chp, " ?");
      }
    }
  }
  chSysLock();
  chEvtBroadcastI(&shell_terminated);
  return msg;
}
예제 #10
0
static void cmd_softap(Stream *chp, int argc, char* argv[]) 
{
   if (argc < 1) {
     chprintf(chp, "Usage: softap info|auth\r\n");
   }
   else if (strncasecmp("info", argv[0], 2) == 0) {
     chprintf(chp, "       AP SSID: %s\r\n",  wifi_doCommand("AP.SSID", buf));     
     chprintf(chp, " AP IP address: %s\r\n",  wifi_doCommand("AP.IP", buf));
   }
   else if (strncasecmp("auth", argv[0], 3) == 0) {
     chprintf(chp, "Enter password: "******"Ok\r\n");
     }
     else
       chprintf(chp, "ERROR. AP password must be at least 8 characters\r\n");
   }
}
예제 #11
0
static void cmd_connect(Stream *chp, int argc, char* argv[])
{
   if (argc < 2) {
      chprintf(chp, "Usage: connect <host> <port>\r\n");
      return;
   }
   int port = atoi(argv[1]);
   int res = inet_open(argv[0], port);
   if (res == 0) {
      chprintf(chp, "**** Connected to %s, Ctrl-D to exit **** \r\n", argv[0]);
      inet_mon_on(true);
      inet_disable_read(true);
      sleep(10);
      while (!shellGetLine(chp, buf, BUFSIZE) && inet_is_connected())  
          inet_write(buf);
      inet_close();
      inet_mon_on(false);
      inet_disable_read(false);
   }
   else
     chprintf(chp, "ERROR. Cannot connect: %d\r\n", res);
}
예제 #12
0
파일: main.cpp 프로젝트: vpcola/NucleoCC3K
static void cmd_settime(BaseSequentialStream *chp, int argc, char *argv[])
{
    (void)argv;
    if (argc > 0) return;

    RTC_TIME tm;
    char line[SHELL_MAX_LINE_LENGTH];

    DS1307 rtc(&I2C_DRIVER);


    chprintf(chp, "Enter the date (date 1..31): ", NULL);
    shellGetLine(chp, line, sizeof(line));
    tm.date = atol(line);
    chprintf(chp, "Enter the date (month 1..12): ", NULL);
    shellGetLine(chp, line, sizeof(line));
    tm.mon = atol(line);
    chprintf(chp, "Enter the date (year): ", NULL);
    shellGetLine(chp, line, sizeof(line));
    tm.year = atol(line);
    chprintf(chp, "Enter the time (hours 0..23): ", NULL);
    shellGetLine(chp, line, sizeof(line));
    tm.hour = atol(line);
    chprintf(chp, "Enter the time (minutes 0..59): ", NULL);
    shellGetLine(chp, line, sizeof(line));
    tm.min = atol(line);
    chprintf(chp, "Enter the time (seconds 0..59): ", NULL);
    shellGetLine(chp, line, sizeof(line));
    tm.sec = atol(line);
    chprintf(chp, "Setting RTC with %04d/%02d/%02d %02d:%02d:%02d\r\n",
             tm.year, tm.mon, tm.date, tm.hour, tm.min, tm.sec);
    // TODO some validation here
    tm.year = tm.year - 1900;
    tm.mon = tm.mon - 1; // Months since Jan (0-11)

    if(!rtc.set_time(tm))
      chprintf(chp, "Failed setting up RTC time\r\n", NULL);
}
예제 #13
0
파일: main.cpp 프로젝트: vpcola/NucleoCC3K
static void cmd_setup_cc3000(BaseSequentialStream *chp, int argc, char *argv[])
{
    char ssid_name[32];
    char ssid_key[40];
    char ssid_sectype[3];
    unsigned long sectype;
    unsigned char rval;

    (void)argv;
    if(argc > 0)
    {
        chprintf(chp, "Usage: smartcfg\r\n");
        return;
    }

    chprintf(chp, "Enter Security profile: \r\n");
    chprintf(chp, "  [0] Unsecured\r\n");
    chprintf(chp, "  [1] WEP\r\n");
    chprintf(chp, "  [2] WPA\r\n");
    chprintf(chp, "  [3] WPA2\r\n");

    shellGetLine(chp, ssid_sectype, 3);
    sectype = ssid_sectype[0] - '0';

    chprintf(chp, "Enter the AP SSID\r\n");
    shellGetLine(chp, ssid_name, 32);

    chprintf(chp, "Enter SSID Key\r\n");
    shellGetLine(chp, ssid_key, 40);

    chprintf(chp, "Type[%d]\r\n", sectype);
    chprintf(chp, "SSID[%s]\r\n", ssid_name);
    chprintf(chp, "Passkey[%s]\r\n", ssid_key);

    chprintf(chp, "Disabling connection policy ...\r\n");
    wlan_ioctl_set_connection_policy(DISABLE, DISABLE, DISABLE);

    chprintf(chp, "Adding profile ...\r\n");
    rval = wlan_add_profile(sectype,
            (unsigned char *) ssid_name,
            strlen(ssid_name),
            NULL,
            0,
            0x18,
            0x1e,
            0x2,
            (unsigned char *) ssid_key,
            strlen(ssid_key)
            );

    if (rval != 255)
    {
        chprintf(chp, "Add profile returned: %d\r\n", rval);

        chprintf(chp, "Enabling auto connect ...\r\n");
        wlan_ioctl_set_connection_policy(DISABLE, DISABLE, ENABLE);
        chprintf(chp, "Restarting wlan ...\r\n");
        wlan_stop();
        chThdSleep(MS2ST(500));
        wlan_start(0);

        return;

    }else
    {
        // TODO: Delete profiles and add again
        chprintf(chp, "Error adding profile (list full) ...\r\n");
        return;
    }

    chprintf(chp, "Lan profile added!\r\n");
}
예제 #14
0
파일: shell.c 프로젝트: Koensw/Robot-PWS
/**
 * @brief   Shell thread function.
 *
 * @param[in] p         pointer to a @p BaseSequentialStream object
 * @return              Termination reason.
 * @retval RDY_OK       terminated by command.
 * @retval RDY_RESET    terminated by reset condition on the I/O channel.
 */
static msg_t shell_thread(void *p) {
  int n;
  msg_t msg = RDY_OK;
  BaseSequentialStream *chp = ((ShellConfig *)p)->sc_channel;
  const ShellCommand *scp = ((ShellConfig *)p)->sc_commands;
  char *lp, *cmd, *tokp, line[SHELL_MAX_LINE_LENGTH];
  char *args[SHELL_MAX_ARGUMENTS + 1];

  chRegSetThreadName("shell");
  chprintf(chp, "\r\nChibiOS/RT Shell\r\n");
  while (TRUE) {
    chprintf(chp, "ch> ");
    if (shellGetLine(chp, line, sizeof(line))) {
      chprintf(chp, "\r\nlogout");
      break;
    }
    lp = _strtok(line, " \009", &tokp);
    cmd = lp;
    n = 0;
    while ((lp = _strtok(NULL, " \009", &tokp)) != NULL) {
      if (n >= SHELL_MAX_ARGUMENTS) {
        chprintf(chp, "too many arguments\r\n");
        cmd = NULL;
        break;
      }
      args[n++] = lp;
    }
    args[n] = NULL;
    if (cmd != NULL) {
      if (strcasecmp(cmd, "exit") == 0) {
        if (n > 0) {
          usage(chp, "exit");
          continue;
        }
        break;
      }
      else if (strcasecmp(cmd, "help") == 0) {
        if (n > 0) {
          usage(chp, "help");
          continue;
        }
        chprintf(chp, "Commands: help exit ");
        list_commands(chp, local_commands);
        if (scp != NULL)
          list_commands(chp, scp);
        chprintf(chp, "\r\n");
      }
      else if (cmdexec(local_commands, chp, cmd, n, args) &&
          ((scp == NULL) || cmdexec(scp, chp, cmd, n, args))) {
        chprintf(chp, "%s", cmd);
        chprintf(chp, " ?\r\n");
      }
    }
  }
  /* Atomically broadcasting the event source and terminating the thread,
     there is not a chSysUnlock() because the thread terminates upon return.*/
  chSysLock();
  chEvtBroadcastI(&shell_terminated);
  chThdExitS(msg);
  return 0; /* Never executed.*/
}
예제 #15
0
파일: shell.c 프로젝트: mabl/ChibiOS
/**
 * @brief   Shell thread function.
 *
 * @param[in] p         pointer to a @p BaseSequentialStream object
 */
THD_FUNCTION(shellThread, p) {
  int n;
  ShellConfig *scfg = p;
  BaseSequentialStream *chp = scfg->sc_channel;
  const ShellCommand *scp = scfg->sc_commands;
  char *lp, *cmd, *tokp, line[SHELL_MAX_LINE_LENGTH];
  char *args[SHELL_MAX_ARGUMENTS + 1];

#if SHELL_USE_HISTORY == TRUE
  *(scfg->sc_histbuf) = 0;
  ShellHistory hist = {
                       scfg->sc_histbuf,
                       scfg->sc_histsize,
                       0,
                       0,
                       0
  };
  ShellHistory *shp = &hist;
#else
  ShellHistory *shp = NULL;
#endif

  chprintf(chp, SHELL_NEWLINE_STR);
  chprintf(chp, "ChibiOS/RT Shell"SHELL_NEWLINE_STR);
  while (true) {
    chprintf(chp, SHELL_PROMPT_STR);
    if (shellGetLine(scfg, line, sizeof(line), shp)) {
#if (SHELL_CMD_EXIT_ENABLED == TRUE) && !defined(_CHIBIOS_NIL_)
      chprintf(chp, SHELL_NEWLINE_STR);
      chprintf(chp, "logout");
      break;
#else
      /* Putting a delay in order to avoid an endless loop trying to read
         an unavailable stream.*/
      osalThreadSleepMilliseconds(100);
#endif
    }
    lp = parse_arguments(line, &tokp);
    cmd = lp;
    n = 0;
    while ((lp = parse_arguments(NULL, &tokp)) != NULL) {
      if (n >= SHELL_MAX_ARGUMENTS) {
        chprintf(chp, "too many arguments"SHELL_NEWLINE_STR);
        cmd = NULL;
        break;
      }
      args[n++] = lp;
    }
    args[n] = NULL;
    if (cmd != NULL) {
      if (strcmp(cmd, "help") == 0) {
        if (n > 0) {
          shellUsage(chp, "help");
          continue;
        }
        chprintf(chp, "Commands: help ");
        list_commands(chp, shell_local_commands);
        if (scp != NULL)
          list_commands(chp, scp);
        chprintf(chp, SHELL_NEWLINE_STR);
      }
      else if (cmdexec(shell_local_commands, chp, cmd, n, args) &&
          ((scp == NULL) || cmdexec(scp, chp, cmd, n, args))) {
        chprintf(chp, "%s", cmd);
        chprintf(chp, " ?"SHELL_NEWLINE_STR);
      }
    }
  }
  shellExit(MSG_OK);
}
예제 #16
0
static void cmd_wifi(Stream *chp, int argc, char* argv[])
{
   if (argc < 1) {
      chprintf(chp, "Usage: wifi on|off|info|ap|shell\r\n");
      return;
   } 
   if (strncasecmp("info", argv[0], 3) == 0) {
      if (wifi_is_enabled()) {
        chprintf(chp, "    Stn status: %s\r\n",  wifi_status(buf));
        chprintf(chp, "  Connected to: %s\r\n",  wifi_doCommand("CONF", buf));
        chprintf(chp, "    IP address: %s\r\n",  wifi_doCommand("IP", buf));
        chprintf(chp, "   MAC address: %s\r\n",  wifi_doCommand("MAC", buf));
      
        chprintf(chp, "\r\n");
        chprintf(chp, "       AP SSID: %s\r\n",  wifi_doCommand("AP.SSID", buf));     
        chprintf(chp, " AP IP address: %s\r\n",  wifi_doCommand("AP.IP", buf));
      }
      else
        chprintf(chp, " WIFI is off\r\n");

      chprintf(chp, "\r\nConfigured access points:\r\n");
      for (int i=0; i<N_WIFIAP; i++) {
         GET_PARAM_I(WIFIAP, i, &wifiap);
         if (strlen(wifiap.ssid) == 0)
            chprintf(chp, " %d: -\r\n", i+1);
         else
            chprintf(chp," %d: %s : '%s'\r\n", i+1, wifiap.ssid, wifiap.passwd);
      }
   }
   else if (strncasecmp("ap", argv[0], 2) == 0) {
      if (argc < 2)
         chprintf(chp, "Usage: wifi ap <1-%d>\r\n", N_WIFIAP);
      else {
         int i = atoi(argv[1]);
         if (i < 1 || i > 4) {
            chprintf(chp, "Argument must be a number 1-4\r\n");
            return; 
         }
         chprintf(chp, "Enter SSID: ");
         shellGetLine(chp, wifiap.ssid, 32);
         if (strlen(wifiap.ssid) > 0) {
            chprintf(chp, "Enter Password: "******"_OPEN_");
         chprintf(chp, "Ok\r\n");
         SET_PARAM_I(WIFIAP, i-1, &wifiap);
      }
   }
   else if (strncasecmp("shell", argv[0], 2) == 0) {
     chprintf(chp, "***** WIFI DEVICE SHELL. Ctrl-D to exit *****\r\n");
     wifi_shell(chp);
   }
   else if (strncasecmp("on", argv[0], 2) == 0) { 
     wifi_enable();
     chprintf(chp, "***** WIFI MODULE ON *****\r\n");
   }
   else if (strncasecmp("off", argv[0], 2) == 0) {
     chprintf(chp, "***** WIFI MODULE OFF *****\r\n");
     wifi_disable();
   }
}