From 380858c781273a2cb2567b034df803c158ad8552 Mon Sep 17 00:00:00 2001 From: Jonathan Roemer Date: Mon, 27 Apr 2015 17:42:37 -0400 Subject: [PATCH] Hardcoded 192.168.1.2 for the server and 192.168.1.3 for testing and, possibly, demo. If I have multicast working reliably by Friday, I'll switch it over. Method defnitions have not changed, so those can be relied on by any other packages. The IP strings are just ignored by the method. --- src/server/server.java | 3 ++- src/thermostat/ThermostatDevice.java | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/server/server.java b/src/server/server.java index 3d92233..cbab7e3 100644 --- a/src/server/server.java +++ b/src/server/server.java @@ -89,7 +89,8 @@ public String getDevicesFromEmail(String email) { // Sends the desired temperature on port sendDesiredTempPORT public void sendDesiredTemp(String desiredTemperature, String thermostatIP) throws Exception { // Opens a sending port - Socket sender = new Socket(thermostatIP, 7002); + // Replace this with the thermostatIP string if we get multicast working + Socket sender = new Socket("192.168.1.3", 7002); try { while (true) { // Instantiate a printwriter so we can write to the output stream diff --git a/src/thermostat/ThermostatDevice.java b/src/thermostat/ThermostatDevice.java index f3417bb..94d2324 100644 --- a/src/thermostat/ThermostatDevice.java +++ b/src/thermostat/ThermostatDevice.java @@ -24,6 +24,7 @@ public class ThermostatDevice extends ThermostatNetworking implements Deviceable private Timer clock; private String serialNumber; String desiredTempString; + String serverIP; // Threaded listener thread Thread thermostatListener; @@ -58,7 +59,7 @@ public void sensorUpdateEvent(Sensorable sensor) { private void updateServer(DataObject dataReading){ //this.sendIP("192.168.1.2"); try { - this.sendCurrentTemp(dataReading.getValue()); + this.sendCurrentTemp(dataReading.getValue(), serverIP); } catch(Exception e){ System.out.println("Error sending to server"); } @@ -91,10 +92,11 @@ public void sendIP(String ipAddress) { */ // CONVERT THIS TO INT - public void sendCurrentTemp(String currentTemp) throws IOException { + public void sendCurrentTemp(String currentTemp, String serverIP) throws IOException { // Sends the current temperature on port sendCurrentTempPORT // Open a sending port - Socket sender = new Socket("192.168.1.3", 7000); + // Replace this with the serverIP string if we get multicast working + Socket sender = new Socket("192.168.1.2", 7000); try { while (true) { // Instantiate a printwriter so we can write to the output stream