--- /dev/null
+import iotcloud.*;
+import java.util.*;
+import java.lang.*;
+import java.io.*;
+
+class Sensor {
+ public static void main(String[] args) throws Exception {
+
+
+ Table t1 = new Table("http://dc-6.calit2.uci.edu/test.iotcloud/", "reallysecret", 361, -1);
+ t1.rebuild();
+
+
+
+ String pingTimerKey = "sensorController";
+ IoTString ipingTimerKey = new IoTString(pingTimerKey);
+
+ String a1 = "sensor";
+ IoTString ia1 = new IoTString(a1);
+
+
+ System.out.println("Starting System");
+
+
+
+
+ while (true) {
+ try {
+
+
+
+ Runtime runTime = Runtime.getRuntime();
+ // Process proc = runTime.exec("/opt/vc/bin/vcgencmd measure_temp | tr -d 'temp=' | tr -d \"'C\"");
+ Process proc = runTime.exec("/opt/vc/bin/vcgencmd measure_temp");
+ BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+ String line = null;
+ String dat = "";
+ while ((line = reader.readLine()) != null) {
+ System.out.println(line);
+ dat = line;
+ }
+ reader.close();
+
+
+
+ String pingTimer = Long.toString(System.currentTimeMillis());
+ IoTString ipingTimer = new IoTString(pingTimer);
+
+
+ IoTString senDat = new IoTString(dat);
+
+ t1.update();
+ t1.startTransaction();
+ t1.addKV(ipingTimerKey, ipingTimer);
+ t1.addKV(ia1, senDat);
+ t1.commitTransaction();
+
+
+
+
+
+
+
+
+
+
+
+
+ Thread.sleep(1000);
+
+ } catch (Error e) {
+ e.printStackTrace();
+
+ Runtime runTime = Runtime.getRuntime();
+ runTime.exec("gpio mode 4 out");
+
+
+ while (true) {
+ runTime.exec("gpio write 4 1");
+ Thread.sleep(500);
+ runTime.exec("gpio write 4 0");
+ Thread.sleep(500);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
IoTString ib2 = new IoTString(b2);
+ String c1 = "sensor";
+ IoTString ic1 = new IoTString(c1);
+
+
String pingTimerKey = "bulbController";
IoTString ipingTimerKey = new IoTString(pingTimerKey);
IoTString ipingTimerKey2 = new IoTString(pingTimerKey2);
+ String pingTimerKey3 = "sensorController";
+ IoTString ipingTimerKey3 = new IoTString(pingTimerKey3);
+
+
t1.createNewKey(ia1, 321);
t1.createNewKey(ia2, 321);
t1.createNewKey(ia3, 321);
t1.createNewKey(ib2, 351);
t1.createNewKey(ipingTimerKey2, 351);
+
+ t1.createNewKey(ic1, 361);
+ t1.createNewKey(ipingTimerKey3, 361);
+
t1.update();
}
}
\ No newline at end of file