Reconnect

To help others, my final solution below. This wasn't an IOT issue - it was me overflowing a string!

I grab each incoming char, add it to a buffer, compare the buffer instead.

I'm sure there are optimisations that can be applied here - there must be a smart way to use pointers and strings for instance but this works for me :slight_smile:

Happy coding everyone.

Again @ubidefeo - thank you!

  char searchWord[] = "rain"; //what are we looking for in the response from the webserver
  int bufferLen = strlen(searchWord)-1;
  char searchBuffer[bufferLen] = {};
  int bufferFillPos = 0; //where are we when filling the searchBuffer
  
  
  bool foundStringFromResponse = false; 
  
  while (webclient.connected()) {  //read the whole response
    
    // grab the data coming back from the server
    char currentChar = webclient.read();  //read the next character
  
    //add it to the buffer
    if (bufferFillPos < bufferLen) {  //buffer not full
      searchBuffer[bufferFillPos] = currentChar;
      bufferFillPos++;
    } else {  //buffer is full
        
      //move everything down the buffer
      int i;
      for (i = 1; i <= bufferLen; i++) {
        searchBuffer[i-1] = searchBuffer[i];
      }
      
      //add the next character to the end of the buffer
      searchBuffer[bufferFillPos] = currentChar;
    }
    
    if (strcmp(searchBuffer,searchWord) == 0) {
      foundStringFromResponse = true;
    }
    
  
  }
  
  return foundStringFromResponse;