     Serial.println(F("unable to initialise the CC3000!"));
     while(1);
   }
-  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
-    Serial.println(F("wireless connection failed!"));
-    while(1);
-  }
-  Serial.println(F("wireless connection successful."));
 
-  while (!cc3000.checkDHCP()) {
-    delay(100);
-  }
+  reconnectToAP();
 
   uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
   if (!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv)) {

}


void updateWeb() {
  Serial.println(F("Sending data..."));


    Serial.println(F("Done."));
  } else {
    Serial.println(F("Web server connection failed."));
    if (!cc3000.checkConnected()) {
      Serial.println(F("Wifi appears down, attempting to reconnect..."));
      reconnectToAP();
    }
  }
}
