Loe and behold, I've fucked up again.
void Ethercheck(){
//Ethernet Client
if (client.connected()) {
if (client.available()) {
// read incoming bytes:
char inChar = client.read();
// Serial.print (inChar);
// add incoming byte to end of line:
currentLine[index++] = inChar;
currentLine[index] = '\0';
// if you get a newline, clear the line:
if (inChar == '\n') {
previousTweet == tweet;
}
// if the current line ends with <text>, it will
// be followed by the tweet:
if (strncmp(currentLine,"<text>")==0) {
// tweet is beginning. Clear the tweet string:
readingTweet = true;
}
// if you're currently reading the bytes of a tweet,
// add them to the tweet String:
if (readingTweet) {
if (inChar != '<') {
tweet[index++] = inChar;
// currentLine[index] = '\0';
}
else {
// if you got a "<" character,
// you've reached the end of the tweet:
readingTweet = false;
if (tweet != previousTweet){
Serial.println(tweet);
// close the connection to the server:
Serial.println(F("disconnecting"));
client.stop();
if (firstTweetRead != false){
if (strncmp(tweet,"<text>")==0) {
//if( waterLevel is higher than said amount){
Serial.println (F("Making coffee"));
tweetString.begin();
tweetString = " Making coffee now, random number: ";
randNumber = random(1000);
tweetString.print (randNumber);
make();
}
}
else{
firstTweetRead = true;
}
}
else {
Serial.println(F("no new tweets"));
Serial.println(F("disconnecting"));
client.stop();
}
}
}
}
}
else if (millis() - lastAttemptTime > requestInterval) {
// if you're not connected, and fifteen seconds have passed since
// your last connection, then attempt to connect again:
client.flush();
totalCount++;
Serial.print (F("Total count:"));
Serial.println(totalCount);
connectToServer();
}
}
setup
connecting to server...connected
making HTTP request...
Total count:1
connecting to server...
I'm not sure how to use the strncmp(). I thought this would be correct.
PaulS, Thanks for helping me with every stage of this project. I'd say I was teaching myself but that would be a lie.