SurferTim:
Just a thought:
Right, which is what I thought might be messing it up? But I have the client.read() function right at the end of the getRequest() function. Do I need to be accounting for the delay of getting the responses? Ill give it a shot right now and let you know. Thanks for the suggestion!
So for reference, here is a COMPLETE walkthrough of my main loop() without any external function references:
void loop() {
client.flush();
Serial.flush();
/* ---------------------------------------- */
/* LISTEN TO RADIO SIGNAL */
/* ---------------------------------------- */
/* do...while loop from "void loop() {...}" */
do {
if ( radio.available() ) {
// Dump the payloads until we've gotten everything
radioDone = false;
while (!radioDone) {
Serial.println();
Serial.print("Just received signal from device #: ");
// Fetch the payload, and see if this was the last one.
radioDone = radio.read( &ID, sizeof(unsigned long) );
Serial.println(ID);
timeToPush = true;
}
}
} while (!timeToPush);
/* ---------------------------------------- */
/* RADIO SIGNAL RECEIVED, ISSUE GET REQUEST */
/* ---------------------------------------- */
/* getRequest(); Function shown here: */
radio.stopListening(); /* Stop radio frequency communication
once radio is pinged. */
timeToPush = false; // Reset once we are out of do...while
Serial.println("Time to push!");
unsigned long user = ID / DIVISOR;
unsigned long total = ID % DIVISOR;
client.stop();
bool connected = client.connect(server, 80);
if (connected) {
client.print("GET /swipes?auth_token=");
/* GET REQUEST OMITTED FOR SECURITY *
* Please trust me that the request *
* itself isnt wrong :P */
client.println("Connection: close");
client.println();
}
else { // == if(!connected) == if (!client.connect(server,80))
lastConnected = false;
// if couldn't make a connection:
if (connectFailCount<3) {
connectFailCount++;
Serial.print("ERROR: connection failure #");
Serial.println(connectFailCount);
client.stop();
}
// if connection failed 5 total times, reset:
else {
connectFailCount = 0;
Serial.print ("ERROR: connection failure CRITICAL!");
Serial.println("Performing connection reset.");
Serial.println("-----------------------------------");
client.stop();
WiFi.disconnect();
delay(1500);
// connectToTheInternet(); Function shown here:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network
}
Serial.println("Connected to the interwebs!");
printWifiStatus();
delay(3000);
}
}
delay(1000);
/* ---------------------------------------- */
/* GET REQUEST COMPLETED, LISTEN TO CLIENT */
/* ---------------------------------------- */
/* listenComm(); Function shown here: */
statusCount=0;
while (client.available() && statusCount<12) {
charRead = client.read();
Serial.print(charRead);
statusCount++;
}
while (client.available()) client.read();
Serial.println("\n---------------------------------------------");
/* ---------------------------------------- */
/* END OF MAIN "VOID LOOP()" */
/* ---------------------------------------- */
}