Testing Smartthings sensors with some adjustments for 4th benchmark
[iot2.git] / benchmarks / other / ZigbeeTest / ZigbeeTest.java
diff --git a/benchmarks/other/ZigbeeTest/ZigbeeTest.java b/benchmarks/other/ZigbeeTest/ZigbeeTest.java
new file mode 100644 (file)
index 0000000..a90b7b3
--- /dev/null
@@ -0,0 +1,79 @@
+import java.util.Map;
+import java.net.*;
+import java.io.*;
+import java.util.*;
+
+import iotruntime.*;
+import iotruntime.zigbee.*;
+
+//import iotcode.interfaces.*;
+import java.rmi.RemoteException;
+
+public class ZigbeeTest implements MoistureSensorSmartCallback {
+
+    public final int SOCKET_SEND_BUFFER_SIZE = 1024;
+    public final int SOCKET_RECEIVE_BUFFER_SIZE = 1024;
+
+
+    public ZigbeeTest() {
+    }
+
+
+    public void newReadingAvailable(int sensorId, float moisture, long timeStampOfLastReading) {
+        System.out.println("New Message!!!!");
+        System.out.println(moisture);
+        System.out.println("Reading time: " + timeStampOfLastReading);
+    }
+
+
+
+
+
+
+    public static void main(String[] args) throws UnknownHostException, SocketException, InterruptedException, IOException, IOException, RemoteException{
+
+        String message = "type: policy_set\n";
+        //message += "ip_address: " + "192.168.1.1\n"; // local ip address
+               message += "ip_address: " + "192.168.2.108\n"; // local ip address
+        //message += "port: " + "5959\n";  // port number
+               message += "port: " + "5557\n";  // port number
+        message += "device_address_long: " + "000d6f0003ebf2ee" + "\n";
+        //DatagramPacket sendPacket = new DatagramPacket(message.getBytes(), message.getBytes().length, InetAddress.getByName("128.195.204.110"), 5005); // address and port of the gateway
+               DatagramPacket sendPacket = new DatagramPacket(message.getBytes(), message.getBytes().length, InetAddress.getByName("192.168.2.227"), 5005); // address and port of the gateway
+
+        DatagramSocket socket = new DatagramSocket();
+        socket.setSendBufferSize(4096);
+        socket.setReceiveBufferSize(4096);
+
+        socket.send(sendPacket);
+
+
+
+
+        //IoTDeviceAddress zigUdpAddr  = new IoTDeviceAddress("128.195.204.110", 5557, 5005,false,false);
+               IoTDeviceAddress zigUdpAddr  = new IoTDeviceAddress("192.168.2.227", 5557, 5005,false,false);
+        IoTZigbeeAddress zigAddrLong = new IoTZigbeeAddress("000d6f0003ebf2ee");
+
+        Set<IoTZigbeeAddress> zigSet = new HashSet<IoTZigbeeAddress>();
+        zigSet.add(zigAddrLong);
+        IoTSet<IoTZigbeeAddress> zigIotSet = new IoTSet<IoTZigbeeAddress>(zigSet);
+
+        Set<IoTDeviceAddress> devSet = new HashSet<IoTDeviceAddress>();
+        devSet.add(zigUdpAddr);
+        IoTSet<IoTDeviceAddress> devIotSet = new IoTSet<IoTDeviceAddress>(devSet);
+        SpruceSensor sen = new SpruceSensor(devIotSet, zigIotSet);
+        
+        System.out.println("About to init");
+        sen.init();
+
+        ZigbeeTest zTest = new ZigbeeTest();
+
+        sen.registerCallback(zTest);
+
+
+        System.out.println("Loop Begin");
+        while (true) {
+
+        }
+    }
+}