Need Help With "If" Statments being ignored

(Couldn't Read My Category DropMenu, So Srry if this isn't the right spot)
Kinda had this a while back, However i cant seem to find anyway or any form/post that can help figure out why no if statements Will Execute even with the variable Being set to match the if statement.

in short does anyone have an idea why any if Statements i put below (in OR out of the While Loop) Gets ignored, even With Different setups, this code has been troublesome.

As Seen one of my if statements should work here:

I marked alot of extra/Older Code to Prevent confusion, Along with trying to figure out the probem

Second Screen Shot:

Arduino and Settings Im Working With:(Not The Script Im Using In Background)

(Also I Changed My Password For Obvious Reasons)
Code Itself (215 Lines, Srry For Any Messy Or Hard to Read Code):

#include <ESP8266WiFi.h>

const char* ssid = "TELUS0361";
const char* password = "PassWord"; 
int Port=1337;
WiFiServer server(Port);
String Input="";
String Temp="";
String Temp1="";
const char* Temp2="";
const char* TempC1=""; 
int A1Val = 0;
bool debounce=false;
bool CTC=false;


void printWiFiStatus();
void Reconnect();
void Debounce();



#include <WiFiUdp.h>
#include <I2S.h>

#ifndef STASSID
#define STASSID "your-ssid"
#define STAPSK  "your-password"
#endif

WiFiUDP udp;
String LIP = "";//Local IP
const int port = Port;//Local Port
int16_t buffer[100][2]; // Temp staging for samples

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(115200);
  delay(250);
  Serial.println();
  digitalWrite(LED_BUILTIN, LOW);
  WiFi.begin(ssid, password);
  digitalWrite(LED_BUILTIN, HIGH);
  Serial.printf("Connection status: %d\n", WiFi.status());
  delay(750);
  while (WiFi.status() != WL_CONNECTED)
  {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(500);
    digitalWrite(LED_BUILTIN, LOW);
    Serial.print(".");
    if(Serial.available()){
      //if serial is availible
      Input = Serial.readStringUntil('\n');//get User input
       if (!Input.indexOf(ssid) > 0){//if Not The Same As SSID then
          Serial.print("Changed SSID To:");
          Serial.println(ssid);
          digitalWrite(LED_BUILTIN, HIGH);
          delay(250);
          WiFi.begin(ssid, password);
          Serial.print("Reconnecting");
          delay(250);
          digitalWrite(LED_BUILTIN, LOW);
       }
    }
  }
  Serial.println();
  delay(250);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(250);
  digitalWrite(LED_BUILTIN, LOW);
  Serial.printf("Connection status: %d\n", WiFi.status());
  Serial.println("Connected, IP address: ");
  Serial.println(WiFi.localIP());
  Serial.println("Wifi Port: ");
  Serial.println(Port);
  digitalWrite(LED_BUILTIN, HIGH);
 //   Serial.println("Testing Port..");
 //   delay(1000);
 //   i2s_rxtx_begin(true, false); // Enable I2S RX
 //   i2s_set_rate(11025);
 //   digitalWrite(LED_BUILTIN, LOW);
 //   delay(250);
 //   digitalWrite(LED_BUILTIN, HIGH);
 //   Serial.print("\nStart the listener on ");
 //   Serial.print(WiFi.localIP());
 //   Serial.print(":");
 //   Serial.print(Port);
 //   //Serial.println("ex:  nc -u -p 8266 -l | play -t raw -r 11025 -b 16 -c 2 -e signed-integer -");
 //   digitalWrite(LED_BUILTIN, LOW);
 //   delay(250);
 //   digitalWrite(LED_BUILTIN, HIGH);
 //   Temp2 = WiFi.localIP();
 //   LIP = Temp2;
 //   LIP.replace(" ", ",");
 //   Serial.println(LIP);
 //   delay(250);
 //   udp.beginPacket(LIP, Port);
 //   udp.write("I2S Receiver\r\n");
 //   udp.endPacket();
 //   digitalWrite(LED_BUILTIN, LOW);
 //   delay(250);
 //   digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  Serial.println("connecting Server");
  server.begin();
  //printWiFiStatus();
  Serial.println("----------------------");
  Serial.println("Starting Server Client");
  Serial.println("----------------------");
}

//Attempt Reconnect
void Reconnect(){
while (WiFi.status() != WL_CONNECTED)
  {
    digitalWrite(LED_BUILTIN, LOW);
    delay(1000);
     if(Serial.available()){
      //if serial is availible
      Input = Serial.readStringUntil('\n');//get User input
       if (!Input.indexOf(ssid) > 0){//if Not The Same As SSID then
          Serial.print("Changed SSID To:");
          Serial.println(ssid);
          digitalWrite(LED_BUILTIN, HIGH);
          delay(250);
          digitalWrite(LED_BUILTIN, LOW);
          WiFi.begin(ssid, password);
          Serial.print("Reconnecting");
          delay(250);
          digitalWrite(LED_BUILTIN, HIGH);
          delay(250);
          digitalWrite(LED_BUILTIN, LOW);
       }   
     }
    digitalWrite(LED_BUILTIN, HIGH);
    Serial.print(".");
  }
   if (WiFi.status() == WL_CONNECTED){
      delay(1000);
      Serial.println("connecting Server");
      server.begin();
      //printWiFiStatus();
      Serial.println("----------------------");
      Serial.println("Starting Server Client");
      Serial.println("----------------------"); 
   }
}


void loop() {
  // Check if module is still connected to WiFi.
  if (WiFi.status() != WL_CONNECTED) {
    Reconnect();
    // Print the new IP to Serial.
    printWiFiStatus();
  }
  
 WiFiClient client = server.available();

  if (client) {
    Serial.println("Client connected.");
    while (client.connected()) {
      if (client.connected()){//Check Connection To Client
       CTC=true;
      }else{
       CTC=false;
      }
      //Check For Inputs
      if (client.available() && CTC==true) {
        char command = client.read();
        //Serial.print(command);
        delay(100);//This If is Being Ignored For some reason
        Input = client.readStringUntil('\n');//get User input
         //if (isdigit(Input) {
         // Temp = Temp+Input;//Save Numbers
         
         //}
       if (!Input.indexOf(Input) > 0) { //if Not The Same As SSID then
          Serial.println("Final Print V2 Worked");
          Temp1 = Input;
          A1Val = Temp.toInt();
          Serial.printf("Temp Storage :", Temp1);
          Serial.println(" ");
          Serial.printf("A1Val: ", A1Val);
          Serial.println(" ");
          Serial.println(Temp1);
          Serial.println(A1Val);
       }

      }
//         if (!isdigit(command) && debounce==false){//Save Input to String  
//           Temp1 = Temp1+command;//Save Letters
//           Serial.println(Temp1);
//           Serial.println(" ");
//           //Debounce();
//           delay(100);
//           if (command==';'){
//            debounce = true;
//           }
//         }//else{
//          Serial.println("Ignored Digit ");
//          debounce = false;
//         //}
//   
//      }   
     //Debounce();
/* -----------------------------
 * -----------------------------
 * -----------------------------
 * -----------------------------
 * -----------------------------
 * -----------------------------
 * -----------------------------
 * -----------------------------
 */
  //These Ifs Do Not Work, Ignored
 //Set Commands Based Off "Input"
  if (Temp1 == "High;") {//Changed This To "==" No Error Still No Serial Text
    digitalWrite(LED_BUILTIN, LOW);
    Serial.println("LED is now on.");
    delay(100);
    //Temp1="";
  }
  if (Input.equals("Low;")) {//Tried Using The "Input" Varible, Still Nope
    digitalWrite(LED_BUILTIN, HIGH);
    Serial.println("LED is now off.");
    delay(100);
    //Temp1="";
  }
  if (Temp1.equals("Read;")) {//Also Tried Wothout The ";", But Still Nope
    Serial.println("A1: ");
    Serial.println(A1Val);
    Serial.println("--------");
    Serial.println("Temp1: ");
    Serial.println(Temp1);
    delay(100);
    //Temp1="";
  }
/* -----------------------------
 * -----------------------------
 * -----------------------------
 * -----------------------------
 * -----------------------------
 * -----------------------------
 * -----------------------------
 * -----------------------------
 */
    //Loop Based Code Runs Below(When Connected)
    
    
    }

 }else{//Loop Based Code Runs Below(When Not Connected)
  //move this to CTC=false; Line:120
    Serial.println("Client disconnected.");
    digitalWrite(LED_BUILTIN, HIGH);
    delay(250);
    digitalWrite(LED_BUILTIN, LOW);
    client.stop();
 }

}

//Get Connection Status
void printWiFiStatus() {
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

You can quickly figure it out is you put serial print() statements in your code before the "if" and print the values being used in the "if".
Paul

CTC = client.connected();

Is easier to type.

umm

  if (Input.equals("Low;")) {//Tried Using The "Input" Varible, Still Nope
    digitalWrite(LED_BUILTIN, HIGH);
    Serial.println("LED is now off.");
    delay(100);
    //Temp1="";
  }

Yea i did
With every if in my project, the problem is The Ifs i mentioned dont work, even with matching statment, i even showed that in a screen shot, the value on the serial is from that varible, i should see my serial.print, however in my screenshot2 it clearly is not working as it should

Thxs ill Changed that later instead of a if else.

Tried Digging Further And Found that Any String Being Compared To Any Other String Gets Ignored Even With Setting The Variable At start, i even moved it to a void Function(), Still Getting Ignored, This Seems to be a IDE Problem? I Cant See the board being the issue as it works normally in any other script, in a while loop or not, but Strings get Ignored in This Specific Loop.

More Debugging:

It's unrelated to the problem at hand, but why all those capitals?

Please post some code that demonstrates this, not a picture of a portion of some code.

And yeah, your misuse of capitals makes your text hard to read.

To the first one, partially from the school i went to, they forced some odd and bad habits, plus my keyboard shift key goes off when my macro buttons are enabled(Not sure why either)

also here, this is what ended up fixing it on the node/ESP8266:

Serial.println("SetCMD:");
  Serial.println(Temp);
  Serial.println(Temp1);
 delay(250);
 Temp1=String(Temp1);//Does Nothing
// Input.trim();//Does Not Help in any way
//-----Fixed-----
 Temp1.trim();//This Helped Along with moving it outside of the while loop(For Forum)
//For some reason Adding a trim Fixed it, all i did. 
//But when i added this in the while loop, it gets ignored. Odd but it works now
//-----Fixed-----
  if (Temp1 == "IH") {//Changed This To "==" No Error Still No Serial Text
    digitalWrite(LED_BUILTIN, LOW);
    Serial.println("--------");
    Serial.println("LED is now on.");
    delay(100);
    //Temp1="";
  }
  if (Temp1 == "IL") {//Tried Using The "Input" Varible, Still Nope
    digitalWrite(LED_BUILTIN, HIGH);
    Serial.println("--------");
    Serial.println("LED is now off.");
    delay(100);
    //Temp1="";
  }
  if (Temp1 == "RCD") {//Also Tried Wothout The ";", But Still Nope
    Serial.println("--------");
    Serial.println("Temp Number: ");
    Serial.println(Temp);
    Serial.println("--------");
    Serial.println("Temp String: ");
    Serial.println(Temp1);
    Serial.println("--------");
    delay(100);
    //Temp1="";
  }
  if (Temp1 == "Wifi") {//Also Tried Wothout The ";", But Still Nope
    Serial.println("--------");
    Serial.println("SSID: ");
    Serial.println(ssid);
    Serial.println("--------");
    Serial.println("Port: ");
    Serial.println(Port);
    Serial.println("--------");
    Serial.println("IP Address: ");
    Serial.println(WiFi.localIP());
    Serial.println("--------");
    Serial.println("Wifi Status: ");
    Serial.println(WiFi.status());
    Serial.println("--------");
    delay(100);
    //Temp1="";
  }

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.