aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Stendahl <jakob.stendahl@outlook.com>2018-06-03 17:58:18 +0200
committerJakob Stendahl <jakob.stendahl@outlook.com>2018-06-03 17:58:18 +0200
commit724a4b85c0240bc11c04d8e3967528ff5efc3e6c (patch)
tree276a29795321669b4d96e853ec863a3d1c3537d3
parent47f2f26a4a131c5eae80a11f617d550e887ed850 (diff)
downloadLuxcena-cs-724a4b85c0240bc11c04d8e3967528ff5efc3e6c.tar.gz
Luxcena-cs-724a4b85c0240bc11c04d8e3967528ff5efc3e6c.zip
Added debug prints
-rw-r--r--IOT-clapSensor.ino30
1 files changed, 27 insertions, 3 deletions
diff --git a/IOT-clapSensor.ino b/IOT-clapSensor.ino
index 5fe29e1..cba7e01 100644
--- a/IOT-clapSensor.ino
+++ b/IOT-clapSensor.ino
@@ -15,7 +15,7 @@
// User variables
const String MemoryAccessVersion = "cp-a1";
const String deviceType = "clapSensor"; // This is what kind of device it is, crucial for the homeServer when determing which API to use
-const int wifiConnectionTimeout = 5; // n*1 sec
+const int wifiConnectionTimeout = 10; // n*1 sec
char ssid[30];
char password[30];
char APssid[30];
@@ -45,7 +45,6 @@ int samplePeak = 0;
int sensorthreshold = 600;
int bufferKey[6] = {0, 0, 1, 0, 1, 0};
-
ESP8266WebServer server ( 80 ); // webServer on port 80
void setup ( void ) {
@@ -72,10 +71,11 @@ void setup ( void ) {
MemoryAccess.writeAscii("SSID", ".");
MemoryAccess.writeAscii("Password", "");
MemoryAccess.commit();
- Serial.println("Have set default values.");
+ Serial.println("Had set default values.");
hardReset();
}
+ Serial.println("");
Serial.print("ssid: ");
Serial.println(ssid);
Serial.print("Password: ");
@@ -108,6 +108,17 @@ void setup ( void ) {
Serial.println ( "" );
+ uint8_t cStatus = WiFi.status();
+ if (cStatus == WL_NO_SHIELD) { Serial.println("No shield is connected [code: 255 (WL_NO_SHIELD)]"); }
+ else if (cStatus == WL_IDLE_STATUS) { Serial.println("WiFi connection timed out [code: 0 (WL_IDLE_STATUS)]"); }
+ else if (cStatus == WL_NO_SSID_AVAIL) { Serial.println("SSID not available [code: 1 (WL_NO_SSID_AVAIL)]"); }
+ else if (cStatus == WL_SCAN_COMPLETED) { Serial.println("Networks have been scanned for some reason [code: 2 (WL_SCAN_COMPLETED)]"); }
+ else if (cStatus == WL_CONNECTED) { Serial.println("Network is now connected [code: 3 (WL_CONNECTED)]"); }
+ else if (cStatus == WL_CONNECT_FAILED) { Serial.println("Connection attemt limit reached, could not connect [code: 4 (WL_CONNECT_FAILED)]"); }
+ else if (cStatus == WL_CONNECTION_LOST) { Serial.println("EEEHm, connection was apparently lost right away... [code: 5 (WL_CONNECTION_LOST)]"); }
+ else if (cStatus == WL_DISCONNECTED) { Serial.println("Could not connect [code: 6 (WL_DISCONNECTED)]"); }
+ Serial.println();
+
if ( WiFi.status() == WL_CONNECTED ) {
Serial.print ( "Connected to " );
Serial.println ( ssid );
@@ -145,6 +156,19 @@ void setup ( void ) {
void loop ( void ) {
server.handleClient();
+ uint8_t cStatus = WiFi.status();
+ if (cStatus != WL_CONNECTED) {
+ Serial.println("Something fishy happend to our WiFi: ");
+ if (cStatus == WL_NO_SHIELD) { Serial.println("No shield is connected [code: 255 (WL_NO_SHIELD)]"); }
+ else if (cStatus == WL_IDLE_STATUS) { Serial.println("WiFi connection timed out [code: 0 (WL_IDLE_STATUS)]"); }
+ else if (cStatus == WL_NO_SSID_AVAIL) { Serial.println("SSID not available [code: 1 (WL_NO_SSID_AVAIL)]"); }
+ else if (cStatus == WL_SCAN_COMPLETED) { Serial.println("Networks have been scanned for some reason [code: 2 (WL_SCAN_COMPLETED)]"); }
+ else if (cStatus == WL_CONNECTED) { Serial.println("Network is now connected [code: 3 (WL_CONNECTED)]"); }
+ else if (cStatus == WL_CONNECT_FAILED) { Serial.println("Connection attemt limit reached, could not connect [code: 4 (WL_CONNECT_FAILED)]"); }
+ else if (cStatus == WL_CONNECTION_LOST) { Serial.println("EEEHm, connection was apparently lost right away... [code: 5 (WL_CONNECTION_LOST)]"); }
+ else if (cStatus == WL_DISCONNECTED) { Serial.println("Could not connect [code: 6 (WL_DISCONNECTED)]"); }
+ }
+
if (!sensorActive) { return; } // We can return to the beginning if the sensor is inactive
currentMillis = millis();