Converting a serial menu to telnet

    case 'W':
      while (TelnetStream.read() != -1); // discard all other received characters 
      TelnetStream.printf("\nEnter <SSID Password> (with the <>!)\n");
      while (!TelnetStream.available());
      // read in the user input
      TelnetStream.readStringUntil('<'); // ignore everything up to <  (SSID will be overwritten next)
      String ssid1 = TelnetStream.readStringUntil(' ');        // store SSID
      String pass1 = TelnetStream.readStringUntil('>');        // store password
      while (Serial.read() != -1); // discard the reset of the input
      TelnetStream.printf("\n Going to '%s'(%u), '%s'(%u)\n", ssid1.c_str(), ssid1.length(), pass1.c_str(), pass1.length());
      break;
1 Like