Skip to content

Commit

Permalink
Some changes to networking.
Browse files Browse the repository at this point in the history
  • Loading branch information
pid1 committed Feb 8, 2015
1 parent ae1494e commit 930797e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Binary file modified bin/networking/networking.class
Binary file not shown.
26 changes: 23 additions & 3 deletions src/networking/networking.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand All @@ -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() {

}

}

0 comments on commit 930797e

Please sign in to comment.