jd-update
flavienhaas 7 years ago
parent d2aaf34eba
commit 35bdf14074

@ -0,0 +1,9 @@
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}

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

Loading…
Cancel
Save