From: rtrimana Date: Wed, 25 Apr 2018 17:46:30 +0000 (-0700) Subject: Shortening keys and data; changing slot number from 4 to 2 to fit in 8 sensors (16... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bd0bc635132396af4cac0968f7996f6e951ff79c;p=iotcloud.git Shortening keys and data; changing slot number from 4 to 2 to fit in 8 sensors (16 key-value pairs) --- diff --git a/version2/src/C/Sensor-Arduino.ino b/version2/src/C/Sensor-Arduino.ino index 86e6101..2521bae 100644 --- a/version2/src/C/Sensor-Arduino.ino +++ b/version2/src/C/Sensor-Arduino.ino @@ -14,7 +14,7 @@ SYSTEM_THREAD(ENABLED) #define ERRPIN D7 // Error pin #define DHTTYPE DHT22 // DHT 22 (AM2302) // IoTCloud -#define SLEEP_TIME 300 // Sleep time in seconds +#define SLEEP_TIME 120 // Sleep time in seconds #define RETRY_SLEEP_TIME 15 // Sleep time in seconds #define RETRY_TIME 10000 // stop trying after 10 seconds #define CONNECTION_DELAY 2100000 // Need to delay after connecting WiFi to wait for sensor @@ -74,8 +74,8 @@ void setup() { if (!waitFor(WiFi.ready, RETRY_TIME)) System.sleep(SLEEP_MODE_DEEP, RETRY_SLEEP_TIME); // Check if we already got an IP from the router - while(WiFi.localIP().toString().equals("0.0.0.0")) { } - // Add delay if needed (for the humidity sensor we need ~2s delay) + while(!WiFi.localIP()); + // Add delay if needed (for the humidity sensor we need ~2s delay) if (micros() < CONNECTION_DELAY) // Delays are in millis but micros() returns microsecond time delay((CONNECTION_DELAY - micros())/1000); @@ -97,6 +97,7 @@ void setup() { int64_t mac4 = (int64_t) mac[4]; int64_t mac5 = (int64_t) mac[5]; machineId = (mac4 * 256) + mac5; + //machineId = (int64_t) mac[5]; // Shorter version of machine ID // IoTCloud library timer = TimingSingleton_getInstance(); @@ -104,6 +105,7 @@ void setup() { transStatusList = new MyVector(); IoTString *baseurl = new IoTString("http://dc-6.calit2.uci.edu/test.iotcloud/"); IoTString *password = new IoTString("reallysecret"); + // TODO: Profiling //Serial.print("Time begin rebuilding table: "); //Serial.println(micros()); @@ -112,7 +114,7 @@ void setup() { baseurl->releaseRef(); password->releaseRef(); - + // TODO: Profiling //Serial.print("Time end setup: "); //Serial.println(micros()); } @@ -120,6 +122,7 @@ void setup() { void loop() { // Wait until sensor is ready //delay(2000); + // TODO: Profiling //Serial.print("Time begin loop: "); //Serial.println(micros()); // Read humidity @@ -131,10 +134,10 @@ void loop() { return; // Humidity // Key - sprintf(keyBuffer, "humid%d", machineId); + sprintf(keyBuffer, "h%04x", machineId); IoTString * iKeyHumid = new IoTString(keyBuffer); // Do updates for the temperature - sprintf(dataBuffer, "%f", humid); + sprintf(dataBuffer, "%0.2f", humid); IoTString * iValueHumid = new IoTString(dataBuffer); // Check and create a new key if it isn't created yet @@ -145,10 +148,10 @@ void loop() { // Temperature // Key - sprintf(keyBuffer, "tempF%d", machineId); + sprintf(keyBuffer, "t%04x", machineId); IoTString * iKeyTempF = new IoTString(keyBuffer); // Do updates for the temperature - sprintf(dataBuffer, "%f", tempF); + sprintf(dataBuffer, "%0.2f", tempF); IoTString * iValueTempF = new IoTString(dataBuffer); // Check and create a new key if it isn't created yet @@ -175,7 +178,7 @@ void loop() { // Turn off sensor digitalWrite(PWRPIN, LOW); - // TODO: Profiling! + // TODO: Profiling //Serial.print("Time end loop: "); //Serial.println(micros()); //while(true) { } diff --git a/version2/src/C/SlotBuffer.h b/version2/src/C/SlotBuffer.h index 6bb369d..75e0536 100755 --- a/version2/src/C/SlotBuffer.h +++ b/version2/src/C/SlotBuffer.h @@ -9,7 +9,7 @@ * @version 1.0 */ -#define SlotBuffer_DEFAULT_SIZE 4 +#define SlotBuffer_DEFAULT_SIZE 2 class SlotBuffer { private: