diff --git a/bin/networking/networking.class b/bin/networking/networking.class index ee8b8b6..9cdd260 100644 Binary files a/bin/networking/networking.class and b/bin/networking/networking.class differ diff --git a/src/networking/networking.java b/src/networking/networking.java index bbec9a9..63a12d7 100644 --- a/src/networking/networking.java +++ b/src/networking/networking.java @@ -16,6 +16,16 @@ public interface networking { // Send the desired temperature on port 7001 static final int sendDesiredTempPORT = 7001; + // Discover protocol receiving port + static final int receiveDiscoverPort=7777; + // Discover protocol sending port + static final int sendDiscoverPORT=7778; + + // Server IP object + String serverIP = new String(); + // Thermostat IP object + String thermostatIP = new String(); + // Listens on receiveCurrentTempPORT and outputs the received string to console. public static void receiveCurrentTemp() throws Exception { ServerSocket listener = new ServerSocket(receiveCurrentTempPORT); @@ -60,8 +70,8 @@ public static void receiveDesiredTemp() throws Exception { } // Sends the current temperature on port sendCurrentTempPORT. - public static void sendCurrentTemp(int currentTemperature, String thermostatIP) throws Exception { - Socket sender = new Socket(thermostatIP, sendCurrentTempPORT); + public static void sendCurrentTemp(int currentTemperature, String serverIP) throws Exception { + Socket sender = new Socket(serverIP, sendCurrentTempPORT); try { while (true) { PrintWriter out = new PrintWriter(sender.getOutputStream(), true); @@ -72,7 +82,7 @@ public static void sendCurrentTemp(int currentTemperature, String thermostatIP) } } - // Sends the desired temperature on port sendCurrentTempPORT. + // Sends the desired temperature on port sendDesiredTempPORT. public static void sendDesiredTemp(int desiredTemperature, String thermostatIP) throws Exception { Socket sender = new Socket(thermostatIP, sendDesiredTempPORT); try { @@ -84,4 +94,14 @@ public static void sendDesiredTemp(int desiredTemperature, String thermostatIP) sender.close(); } } + + // This discover protocol finds other instances of Thermocontroller running on the network, and updates the IP addresses accordingly for the server and the thermostat + public static void getServerIP() { + + } + + public static void getThermostatIP() { + + } + } \ No newline at end of file