/** * Periodic write and sleep to cloud. * @author Rahmadi Trimananda * @version 1.0 */ #include "Table.h" #include "IoTString.h" #include "TimingSingleton.h" #include "TransactionStatus.h" #define SLEEP_TIME 300 // in seconds TimingSingleton *timer; bool foundError; MyVector * transStatusList; char keyBuffer[80]; char dataBuffer[80]; Table *t1; IoTString *iKeyA; IoTString *iValueA; void setup() { // TODO: This test uses the Serial library // Please install "screen" on your machine and run // it on the serial port right after flashing the // firmware onto the Particle board. // e.g. sudo screen /dev/ttyACM0 Serial.begin(); timer = TimingSingleton_getInstance(); foundError = false; transStatusList = new MyVector(); IoTString *baseurl = new IoTString("http://dc-6.calit2.uci.edu/test.iotcloud/"); IoTString *password = new IoTString("reallysecret"); t1 = new Table(baseurl, password, 321, -1); t1->rebuild(); baseurl->releaseRef(); password->releaseRef(); } void loop() { // Key sprintf(keyBuffer, "sensor0"); iKeyA = new IoTString(keyBuffer); // Do Updates for the keys sprintf(dataBuffer, "data92617"); iValueA = new IoTString(dataBuffer); t1->startTransaction(); t1->put(iKeyA, iValueA); transStatusList->add(t1->commitTransaction()); t1->update(); iKeyA->releaseRef(); iValueA->releaseRef(); System.sleep(SLEEP_MODE_DEEP, SLEEP_TIME); }