Adjusting and cleaning up ZigbeeTest to install Vigilia ZigBee gateway and devices.
[iot2.git] / benchmarks / other / ZigbeeTest / ZigbeeTestMultipurpose.java
diff --git a/benchmarks/other/ZigbeeTest/ZigbeeTestMultipurpose.java b/benchmarks/other/ZigbeeTest/ZigbeeTestMultipurpose.java
new file mode 100644 (file)
index 0000000..8bc1f50
--- /dev/null
@@ -0,0 +1,57 @@
+import java.util.Map;
+import java.net.*;
+import java.io.*;
+import java.util.*;
+
+public class ZigbeeTestMultipurpose implements SmartthingsSensorCallback {
+       public final int SOCKET_SEND_BUFFER_SIZE = 1024;
+       public final int SOCKET_RECEIVE_BUFFER_SIZE = 1024;
+       private static final String MY_IP_ADDRESS = "192.168.1.198";
+       private static final String DEVICE_MAC_ADDRESS = "000d6f000bbd3413"; //Multipurpose sensor
+    private static final String GATEWAY = "192.168.1.192";
+    private static final int LOCAL_COMM_SOCKET = 5957;
+
+    public void newReadingAvailable(int _value, boolean _activeValue) {
+        System.out.println("New Message!!!!");
+        System.out.println("multipurpose : "+ _value);
+        System.out.println("active? : "+ _activeValue);
+    }
+
+       public static void main(String[] args) throws UnknownHostException, SocketException, InterruptedException, IOException {
+
+        String message = "type: policy_set\n";
+        message += "ip_address: " + MY_IP_ADDRESS + "\n"; // local ip address
+        message += "port: " + LOCAL_COMM_SOCKET + "\n";  // port number
+        message += "device_address_long: " + DEVICE_MAC_ADDRESS + "\n";
+        DatagramPacket sendPacket = new DatagramPacket(message.getBytes(), message.getBytes().length, InetAddress.getByName(GATEWAY), 5005);
+        DatagramSocket socket = new DatagramSocket(12345);
+        socket.setSendBufferSize(4096);
+        socket.setReceiveBufferSize(4096);
+        socket.send(sendPacket);
+           socket.setReuseAddress(true);
+           socket.close();
+
+        IoTDeviceAddress zigUdpAddr  = new IoTDeviceAddress(GATEWAY, LOCAL_COMM_SOCKET, 5005,false,false);
+        IoTZigbeeAddress zigAddrLong = new IoTZigbeeAddress(DEVICE_MAC_ADDRESS);
+
+        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);
+        MultipurposeSensor sen = new MultipurposeSensor(devIotSet, zigIotSet);
+        
+        System.out.println("About to init");
+        sen.init();
+
+           ZigbeeTestMultipurpose zTest = new ZigbeeTestMultipurpose();
+           sen.registerCallback(zTest);
+
+        System.out.println("Loop Begin");
+        while (true) {
+
+        }
+    }
+}