[gnoduino] examples: add back dropped method
- From: Lucian Langa <lucilanga src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnoduino] examples: add back dropped method
- Date: Wed, 24 Sep 2014 19:57:37 +0000 (UTC)
commit 57fd6f6ab2212be6c686311940d1b751337f7814
Author: Pascal de Bruijn <pmjdebruijn pcode nl>
Date: Thu Aug 14 19:06:37 2014 +0200
examples: add back dropped method
.../BarometricPressureWebServer.ino | 45 ++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino
b/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino
index 1ee00c3..697b98e 100644
--- a/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino
+++ b/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino
@@ -130,6 +130,51 @@ void getData() {
Serial.println(" Pa");
}
+void listenForEthernetClients() {
+ // listen for incoming clients
+ EthernetClient client = server.available();
+ if (client) {
+ Serial.println("Got a client");
+ // an http request ends with a blank line
+ boolean currentLineIsBlank = true;
+ while (client.connected()) {
+ if (client.available()) {
+ char c = client.read();
+ // 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
+ if (c == '\n' && currentLineIsBlank) {
+ // send a standard http response header
+ client.println("HTTP/1.1 200 OK");
+ client.println("Content-Type: text/html");
+ client.println();
+ // print the current readings, in HTML format:
+ client.print("Temperature: ");
+ client.print(temperature);
+ client.print(" degrees C");
+ client.println("<br />");
+ client.print("Pressure: " + String(pressure));
+ client.print(" Pa");
+ client.println("<br />");
+ break;
+ }
+ if (c == '\n') {
+ // you're starting a new line
+ currentLineIsBlank = true;
+ }
+ else if (c != '\r') {
+ // you've gotten a character on the current line
+ currentLineIsBlank = false;
+ }
+ }
+ }
+ // give the web browser time to receive the data
+ delay(1);
+ // close the connection:
+ client.stop();
+ }
+}
+
void setup() {
// start the SPI library:
SPI.begin();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]