|
|
|
@ -15,17 +15,13 @@ EthernetServer server(80);
|
|
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
|
// Open serial communications and wait for port to open:
|
|
|
|
|
Serial.begin(9600);
|
|
|
|
|
while (!Serial) {
|
|
|
|
|
; // wait for serial port to connect. Needed for native USB port only
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SerialUSB.begin(9600);
|
|
|
|
|
|
|
|
|
|
// start the Ethernet connection and the server:
|
|
|
|
|
Ethernet.begin(mac, ip);
|
|
|
|
|
server.begin();
|
|
|
|
|
Serial.print("server is at ");
|
|
|
|
|
Serial.println(Ethernet.localIP());
|
|
|
|
|
SerialUSB.print("server is at ");
|
|
|
|
|
SerialUSB.println(Ethernet.localIP());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -33,13 +29,13 @@ void loop() {
|
|
|
|
|
// listen for incoming clients
|
|
|
|
|
EthernetClient client = server.available();
|
|
|
|
|
if (client) {
|
|
|
|
|
Serial.println("new client");
|
|
|
|
|
SerialUSB.println("new client");
|
|
|
|
|
// an http request ends with a blank line
|
|
|
|
|
boolean currentLineIsBlank = true;
|
|
|
|
|
while (client.connected()) {
|
|
|
|
|
if (client.available()) {
|
|
|
|
|
char c = client.read();
|
|
|
|
|
Serial.write(c);
|
|
|
|
|
SerialUSB.write(c);
|
|
|
|
|
// if you've gotten to the end of the line (received a newline
|
|
|
|
|
// character) and the line is blank, the http request has ended,
|
|
|
|
|
// so you can send a reply
|
|
|
|
|