Skip to content

Commit 7843da7

Browse files
committed
Update server.ino
1 parent fddfef1 commit 7843da7

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

server/server.ino

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void setup() {
4343

4444
void loop() {
4545
// Read inputs
46-
if(digitalRead(IN_PIN_POWER_LED) > 0)
46+
if(digitalRead(IN_PIN_POWER_LED) == 0)
4747
powerLed = true;
4848
else
4949
powerLed = false;
@@ -57,7 +57,7 @@ void loop() {
5757
request = "";
5858
while (client.connected()) {
5959
if (client.available()) {
60-
char reqChar = client.read(); // read 1 byte (character) from client
60+
char reqChar = client.read(); // Read 1 byte (character) from client
6161

6262
if(currentLineIsBlank == true)
6363
continue;
@@ -84,8 +84,8 @@ void loop() {
8484
}
8585
}
8686

87-
delay(1); // give the web browser time to receive the data
88-
client.stop(); // close the connection
87+
delay(1); // Give the web browser time to receive the data
88+
client.stop();
8989
}
9090

9191
// Control outputs
@@ -124,16 +124,18 @@ void sendResponse(String req, EthernetClient client) {
124124
}
125125
// Other actions
126126
else {
127-
if(req == "powerStatus")
128-
client.write(powerLed);
129-
else if(req == "powerOn" && !powerLed)
130-
powerOn = true;
131-
else if(req == "standBy" && powerLed)
132-
standBy = true;
133-
else if(req == "reset" && powerLed)
134-
reset = true;
135-
else if(req == "kill" && powerLed)
136-
kill = true;
127+
if(req == "powerStatus") {
128+
if(powerLed) client.write("powerStatus:on");
129+
else client.write("powerStatus:off");
130+
}
131+
else if(req == "powerOn")
132+
if (!powerLed) powerOn = true;
133+
else if(req == "standBy")
134+
if (powerLed) standBy = true;
135+
else if(req == "reset")
136+
if (powerLed) reset = true;
137+
else if(req == "kill")
138+
if (powerLed) kill = true;
137139
else
138140
client.println("HTTP/1.1 404 Not Found\n\r");
139141
}

0 commit comments

Comments
 (0)