diff --git a/WLAN_Thermometer.ino b/WLAN_Thermometer.ino index d8e0975..aecc789 100644 --- a/WLAN_Thermometer.ino +++ b/WLAN_Thermometer.ino @@ -25,14 +25,16 @@ #define MEDIAN_SAMPLES 60 #define ONBOARD_LED 2 #define NTP_TIMEOUT 15000 -void check_mode(void); LiquidCrystal_I2C lcd(LCD_I2C_ADDR, LCD_COL, LCD_ROW); looper sched; RunningMedian samples = RunningMedian(MEDIAN_SAMPLES); float temp_min = (analogRead(TEMP_SENS_PIN) / 2048.0) * 330.0; float temp_max = temp_min; +float temp = (analogRead(TEMP_SENS_PIN) / 2048.0) * 330.0; bool led_state; +String header; +WiFiServer server(80); void setup() { @@ -123,6 +125,8 @@ void setup() DateTime.forceUpdate(); } + server.begin(); + sched.addJob(show_temperature, KRATE_TEMP); sched.addJob(show_time, KRATE_TIME); @@ -134,6 +138,74 @@ void setup() void loop() { sched.scheduler(); + + WiFiClient client = server.available(); // Listen for incoming clients + + if (client) { // If a new client connects, + Serial.println("New Client."); // print a message out in the serial port + String currentLine = ""; // make a String to hold incoming data from the client + while (client.connected()) + { // loop while the client's connected + if (client.available()) { // if there's bytes to read from the client, + char c = client.read(); // read a byte, then + Serial.write(c); // print it out the serial monitor + header += c; + if (c == '\n') { // if the byte is a newline character + // if the current line is blank, you got two newline characters in a row. + // that's the end of the client HTTP request, so send a response: + if (currentLine.length() == 0) { + // checking if header is valid + // YWRtaW46c3RhYWdhcg== (user:pass) admin:staagar + if (header.indexOf("YWRtaW46c3RhYWdhcg==") >= 0) { + client.println("HTTP/1.1 200 OK"); + client.println("Content-type:text/html"); + client.println("Connection: close"); + client.println(); + client.println("\n"); + client.println("\n"); + client.println("\n"); + client.println("
\n"); + client.println("