Terminal string not getting updated

Here’s some code. Completely untested but based on what @Gunner has mentioned.

(I know it could be condensed a lot but it’s just an example)

You should be able to use it as a base to get you going:


int iState = 0;

BLYNK_WRITE(Vx){

  String tInput = param.asStr();

  switch (iState){

    case 0:
      terminal.println("Main menu");
      terminal.println("Type CC to change WiFi credentials");
      terminal.flush();
      iState = 1;
      break;

    case 1:
      if (tInput == "CC"){
        iState = 2;
      } else if (tInput == "Exit"){
        iState = 0;
      }
      break;

    case 2:
      terminal.println("Current credentials:");
      terminal.print("SSID: ");
      terminal.println(ssid);
      terminal.print("Pass: ");
      terminal.println(pass);
      terminal.println("");
      terminal.println("Change details?");
      terminal.println("Type Y or N");
      terminal.flush();
      iState = 3;
      break;

    case 3:
      if (tInput == "Y"){
        iState = 4;
      } else if (tInput == "N"){
        iState = 0;
      }
      break;

    case 4:
      terminal.println("Enter new SSID");
      terminal.flush();
      iState = 5;
      break;

    case 5:
      ssid = tInput;
      terminal.println("Enter new pass");
      terminal.flush();
      iState = 6;
      break;

    case 6:
      pass = tInput;
      terminal.println("You entered:");
      terminal.print("SSID: ");
      terminal.println(ssid);
      terminal.print("Pass: ");
      terminal.println(pass);
      terminal.println("");
      terminal.println("Save or change details?");
      terminal.println("Type S or C");
      terminal.flush();
      iState = 7;
      break;

    case 7:
      if (tInput == "S"){
        iState = 8;
      } else if (tInput == "C"){
        iState = 4;
      }
      break;

    case 8:
      terminal.println("Credentials saved.");
      terminal.println("");
      terminal.flush();
      iState = 0;
      break;
  }
}

2 Likes