Giter Site home page Giter Site logo

webduino's Introduction

Webduino

This is an Arduino-based Web Server library, originally developed for a class at NYC Resistor. It's called Webduino, and it's an extensible web server library for the Arduino using the Wiznet-based Ethernet shields. It's released under the MIT license allowing all sorts of reuse.

Features

  • URL parameter parsing
  • Handle the following HTTP Methods: GET, HEAD, POST, PUT, DELETE, PATCH
  • Web Forms
  • Images
  • JSON/RESTful interface
  • HTTP Basic Authentication

Installation Notes

With Arduino 1.0, add the Webduino folder to the "libraries" folder of your sketchbook directory.

You can put the examples in your own sketchbook directory, or in hardware/libraries/webduino/examples, as you prefer.

If you get an error message when building the examples similar to "WebServer.h not found", it's a problem with where you put the Webduino folder. The server won't work if the header is directly in the libraries folder.

Resources

Compatible Ethernet Shields

These have all been tested with the library successfully:

Shields using the Microchip ENC28J60 chip won't work with the library as that requires more software support for implementating the TCP/IP stack.

Version history

1.7 released in Jan 2012

  • fixed Google Code issue 4 where expect fails with high-ASCII characters due to sign issues
  • fixed Google Code issue 8 by adding WEBDUINO_NO_IMPLEMENTATION macro that allows including the class definition without the implementation code
  • fixed Google Code issue 9: allowing prog_char* strings for printP
  • added httpServerError() method to output 500 Internal Server Error message
  • added support for HTTP PUT, DELETE, and PATCH methods (see Google Code issue 11
  • fixed Google Code issue 12: off-by-one error in name/value parser (readPOSTparam) where the buffer wouldn't ever be completely filled
  • updated copyright string for 2012 and major authors
  • GitHub fork now the official version; all open issues on Google Code site fixed or closed and moved to GitHub

1.6 released in Jan 2012

  • added checkCredentials and httpUnauthorized methods as well as readHeader method for HTTP Basic Authentication; currently users will have to do the Base64 encoding outside of Webduino and I'm uncertain whether I ever want this inside the library or not...
  • fixed the request parser: previously the command dispatcher would always pass true for tail_complete, even if the tail was incomplete
  • fixed the command dispatcher: previously the default command could not have a tail, but the EPIC FAIL was returned

1.5 released in Dec 2011

  • added a default favicon.ico based on the led.png from the Image example to save resources on Firefox trying to load this file on every request if it can't be loaded
  • added keywords.txt for syntax highlighting in Arduino IDE
  • bumped the version number up in response headers and compiler variables
  • added version history to readme
  • fixed default value for prefix
  • fixed /index.html in Hello World example

releases between Jul 2011 and Dec 2011

  • project forked on GitHub by Chris Lee
  • JSON/RESTful interface
  • header Access-Control-Allow-Origin added
  • code split in .h and .cpp files
  • Arduino 1.0 changes by Dave Falkenburg and others
  • adding CRLF after extraHeaders

1.4.1 released in Nov 2009

  • fix examples to use readPOSTparam method

1.4 released in Sep 2009

  • bug fix for multple connections

1.3.1 released in Aug 2009

  • major bug fix for 1.3 for posts where Content-Length is last header sent

1.3 released in Aug 2009

  • mostly robustness fixes (beta)

1.2.1 released in Aug 2009

  • fixed HelloWorld example

1.2 released in Jul 2009

  • now with GET parameter handling

1.1 released in Apr 2009

1.0 released in Mar 2009

webduino's People

Contributors

cat101 avatar cyberwaelder avatar edvler avatar fornellas avatar jupp0r avatar mkldon avatar ntruchsess avatar phardy avatar raidok avatar ribbons avatar rolfmorel avatar ronnqvist avatar sirleech avatar tfnab avatar unwiredben avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webduino's Issues

loss of data in function int WebServer::read()

In function "int WebServer::read()", when reading the content (m_readingContent is true, m_contentLength is non-zero), if the http body from the client to the server is under transmission (The server has not received the http body yet), the read at line"int ch = m_client.read();" returns -1. In this case m_contentLength is decreased, but the data isn't read. This results in the loss of data.

To fix this issue, m_contentLength should be increased if no data returned. See the code below.

  int ch = m_client.read();
  ...
  if (ch != -1)
  {
    ...
  }
  else
  {
    m_contentLength++; //Jeffrey>> BUG FIX at Line 691. Increase the index if there is no data returned.

    unsigned long now = millis();
    ...
  }

not works on adruino ide 1.6.5, compilation error

Hi again my friend.like we talked on email i put the problems here for arduino ide 1.6.5
If you can make some modification for it will be greate.
Many thanks

file included from C:\Program Files
(x86)\Arduino\libraries\Webduino/WebServer.h:31:0,

             from Imagini.h:1,

             from casa.ino:6:

C:\Program Files
(x86)\Arduino\libraries\Ethernet\src/EthernetClient.h: In member function 'int WebServer::read()':

C:\Program Files
(x86)\Arduino\libraries\Ethernet\src/EthernetClient.h:27:16: note:
candidate
1: virtual bool EthernetClient::operator==(bool)

virtual bool operator==(const bool value) { return bool() == value;
}

            ^

In file included from c:\program files
(x86)\arduino\hardware\tools\avr\avr\include\avr\eeprom.h:570:0,

             from C:\Program Files 

(x86)\Arduino\hardware\arduino\avr\cores\arduino/USBAPI.h:25,

             from C:\Program Files 

(x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:225,

             from C:\Program Files 

(x86)\Arduino\libraries\Ethernet\src/EthernetClient.h:3,

             from C:\Program Files 

(x86)\Arduino\libraries\Webduino/WebServer.h:31,

             from Imagini.h:1,

             from casa.ino:6:

C:\Program Files (x86)\Arduino\libraries\Webduino/WebServer.h:728:19: note:
candidate 2: operator==(int, int)

if (m_client == NULL)

timeout / DOS

Hi, it seems the WEBDUINO_READ_TIMEOUT_IN_MS parameter is not effective in preventing DOS against Webduino: currently I can open a connection to Webduino, and maintain it open as long as I want without sending any request, thus preventing other connections from being processed.
Looking at the current implementation of the read() method, the only way a timeout could occur would be if the m_client.read() call took more time than the timeout, but this never happens as m_client.read() just returns -1 if there is nothing to read. Thus timeout never occurs.
As I see it, to make timeout working we would need to store the timestamp of the last successful read (or initially of the initiation of the connection) in the WebServer object, and check if we exceeded the timeout at each read() call. I can do the change and send a patch if you think this is the correct solution.

Format string from Progmem and print it

Hello,

I'm using your library and I'm enjoying it so far. Thanks!

I have a question, I have a string stored in progmem, what's the best way to format it and print to the webserver?
I tried with server.printf() but seems to be limited to 128 chars

Example of what I mean

P(message) = "Hello %s!";
server.printP(message, "Ricardo");

Changes required for Arduino-1.0

Been playing with arduino-1.0-rc1, and had to make the following patches to get your code working in the 1.0 release.

Hope this helps,

[email protected]

diff --git a/WebServer.cpp b/WebServer.cpp
index 5d9a88d..a781d8b 100644
--- a/WebServer.cpp
+++ b/WebServer.cpp
@@ -60,24 +60,24 @@ void WebServer::addCommand(const char *verb, Command *cmd)
}
}

-void WebServer::write(uint8_t ch)
+size_t WebServer::write(uint8_t ch)
{

  • m_client.write(ch);
  • return m_client.write(ch);
    }

-void WebServer::write(const char *str)
+size_t WebServer::write(const char *str)
{

  • m_client.write(str);
  • return m_client.write(str);
    }

-void WebServer::write(const uint8_t *buffer, size_t size)
+size_t WebServer::write(const uint8_t *buffer, size_t size)
{

  • m_client.write(buffer, size);
  • return m_client.write(buffer, size);
    }

-void WebServer::write(const char *buffer, size_t length)
+size_t WebServer::write(const char *buffer, size_t length)
{

  • m_client.write((const uint8_t *)buffer, length);
  • return m_client.write((const uint8_t *)buffer, length);
    }

void WebServer::writeP(const prog_uchar *data, size_t length)
diff --git a/WebServer.h b/WebServer.h
index bdcd614..4879f44 100644
--- a/WebServer.h
+++ b/WebServer.h
@@ -29,8 +29,8 @@

include <stdlib.h>

include "avr/pgmspace.h"

-#include <Client.h>
-#include <Server.h>
+#include <EthernetClient.h>
+#include <EthernetServer.h>

/********************************************************************

  • CONFIGURATION
    @@ -200,14 +200,14 @@ public:
    void httpSeeOther(const char *otherURL);

    // implementation of write used to implement Print interface

    • virtual void write(uint8_t);
    • virtual void write(const char *str);
    • virtual void write(const uint8_t *buffer, size_t size);
    • void write(const char *data, size_t length);
    • virtual size_t write(uint8_t);
    • virtual size_t write(const char *str);
    • virtual size_t write(const uint8_t *buffer, size_t size);
    • size_t write(const char *data, size_t length);

    private:

    • Server m_server;
    • Client m_client;
    • EthernetServer m_server;
    • EthernetClient m_client;
      const char *m_urlPrefix;

    char m_pushback[32];

lacking support for the OPTIONS method; comments on TRACE

OPTIONS is now the last method (of those I'm aware of and which should be supported) which has not been implemented

if anyone grabs this issue before me (I probably won't get around to it before the weekend) please keep in mind that it's much less trivial than PUT, DELETE, PATCH -- e.g. we should respond to requests such as OPTIONS *

I think we should also discuss whether responses to OPTIONS should be composed manually in the Command functions, using the additional headers parameter of httpSuccess(), or whether when Commands are added to the WebServer the methods should be registered, so that we'd have the full list available for OPTIONS * and could also handle responses to OPTIONS requests outside the Commands themselves making life easier for developers

also I would want to take this opportunity to state that IMHO we should NOT support TRACE as it has been proven to open security holes, e.g. exposure of authentication data

Code doesn't go in .h files

The whole library is a single .h file.

That is not the right way to write a library.

The class definition etc goes in the .h file, the code (WebServer::whatever(...)) goes in a .cpp file.

This is done so that you are able to include the .h file in multiple code files and not have it throw up hundreds of errors about multiple definitions.

As it stands now, you cannot use this library in multiple tabs in your sketch.

Arduino IDE 22 Compile Error

Reported by [email protected], Apr 16, 2011
When I try to compile example , such as Web_Demo I get :

In file included from Web_Demo.cpp:24:
/usr/share/arduino/libraries/webduino/WebServer.h:141: erreur: expected ‘,’ or ‘...’ before ‘*’ token
/usr/share/arduino/libraries/webduino/WebServer.h:141: erreur: ISO C++

... 87 errors later ...

Web_Demo.cpp:98: erreur: ‘htmlHead’ was not declared in this scope

I check my path, and it is good. Any idea ?

Comment 1 by project member ben.combee, Apr 16, 2011
This seems to be an issue with compatibility with the newer Arduino environment. The project needs to be updated for Arduino 22
Status: Accepted
Comment 2 by project member ben.combee, Apr 16, 2011
(No comment was entered for this change.)
Owner: ben.combee
Comment 3 by project member ben.combee, Apr 16, 2011
(No comment was entered for this change.)
Labels: -Priority-Medium Priority-Critical
Comment 4 by [email protected], Apr 16, 2011
Ok, thanks for very fast reply
Comment 5 by [email protected], Apr 25, 2011
I'm having the same issue, also running 22.
Comment 6 by [email protected], May 3, 2011
Add
#include <avr/pgmspace.h>
to the includes. That worked for me.
Comment 7 by [email protected], May 25, 2011
I've got the same problem, but adding:

include <avr/pgmspace.h>

didn't work for me :/

Any ideas?
Comment 8 by [email protected], Jun 5, 2011
It should have worked. Make sure that you put "avr.pgmspace.h" and "SPI.h" before the

include "Ethernet.h"

include "WebServer.h"

so now it will include

include "SPI.h" // new include

include "avr/pgmspace.h" // new include

include "Ethernet.h"

include "WebServer.h"

I'm surprised no one had answered this, as it is broken in arduino-22
Comment 9 by [email protected], Jun 5, 2011
I should also add that you might want to add the

include "avr/pgmspace.h"

to the WebServer.h which is the main webduino file. However the demo file needs the aforementioned SPI.h file to compile as well because the Ethernet.h import needs it. I hope this helps.
Delete comment Comment 10 by [email protected], Today (7 minutes ago)
@ben.combee, are you planning on committing these changes into a new download file?

Cache problem

Without the "Pragma: no-cache" header atleast many version of IE and some mobile browsers cache the results forever. This really becomes a problem with JavaScript UIs and REST interfaces. This could be something that has to be handled by the programmer but implementing it is easy and doesn't waste that much resources either.

SSL support now possible?

Hi there, would the Arduino Duo provide enough power for SSL support? Would be great if SSL is supported in future. Keep up the great work!

HTTP Authentication Freezes Arduino on LONG base64 encoded Username and Password pairs.

Hi,

using HTTP Authentication and WebServer::checkCredentials I discovered that the Arduino Board is freezed if a base64-encoded Username-Password Pair over 50 chars is sent.

The problem resides in WebServer::readHeader, pathed version follows:

  void WebServer::readHeader(char *value, int valueLen)
  {
    int ch;
    memset(value, 0, valueLen);
    --valueLen;
  
    // absorb whitespace
    do
    {
      ch = read();
    } while (ch == ' ' || ch == '\t');
  
    // read rest of line
    do
    {
      if (valueLen > 1)
      {
        *value++=ch;
        --valueLen;
      }
      ch = read();
    } while (ch != '\r');
    push(ch);
  }

Using this patched version, Long username & password (both gt than 15 chars) won't match resulting in a "401 Unauthorized", but (at least) won't be able to freeze the board.

Bye,
-A

Convert png image

Please help, I converted the png image using the directfb-csource utility, but the result is a mixture of octal and characters. Can you please advise me how to get the output in HEX.
Thank you.

"\211PNG\15\12\32\12\0\0\0\15IHDR\0\0\0\20\0\0\0\20\10\2\0\0\0\220\221"
"h6\0\0\0(tEXtCreation\40Time\0\350t\40""5\40""7\40""2018\40""13:47:0"
"3\40+0100\302\347D\343\0\0\0\7tIME\7\342\7\5\21/\7\203:X\202\0\0\0\11"
"pHYs\0\0\13\22\0\0\13\22\1\322\335~\374\0\0\0\4gAMA\0\0\261\217\13\374"
"a\5\0\0\0PIDATx\332c\374\377\237\201$\300\204K\202\221\21\204\210\325"
"\0T\12\264\31\2100\365\340\264\201d'\15\234\6\26\2342\214\330\205\7\304"
"\17\240H\200\261\3773\240G\5\23\36\325X\365\320\337\17\240\364\203\346"
"H\260\40\202\2135y#;\32M\1\0\17!\22$\351\33[\220\0\0\0\0IEND\256B`\202"

inadequate use of pointer leading to crash

This is a nice library, but it caused me some headache. In your code you are passing pointer to ints and that you manipulate the value (line 1183).

void WebServer::getRequest(WebServer::ConnectionType &type, char *request, int *length) {
    --*length; // save room for NUL

I don't get the point of passing a pointer to the int, why not just pass by value, if you are modifying the value (or by reference, if it's not modified)? So you end up in manipulating the value of a variable outside the scope of the function. This is bad an and causes the following pretty strait forward example to crash. I am using a global buffer for the webserver. Passing a pointer to processConnection(char *buff, int *bufflen); does not allow to pass a number directly.

When running the code, len will decrease with each request until it becomes too short or even negative, and then it will stop working.

#include <SPI.h>
#include <Ethernet.h>
#include <WebServer.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(169,254,123,123);
WebServer server("", 80);

int len=64;
char buf[64];

void req(WebServer &server, WebServer::ConnectionType type, char* query, bool complete){
  if(!complete){
    server.httpFail();
    server.print("incomplete, len=");
    server.print(len);
    return;
  }

  if (type == WebServer::HEAD) {
    server.httpSuccess();
    return;
  }

  server.println(query);
  server.print(" len=");
  server.print(len);
}

void setup() {
  Serial.begin(115200);  
  Ethernet.begin(mac,ip);
  server.setDefaultCommand(&req);
  server.begin();
  Serial.println("UP");
}

void loop() {
  server.processConnection(buf, &len);
}

index.htm try to load a page from sd card

Hi.

I'm just begun to use this lib, and I try to fit it with a sketch a have already begun. In that on, my page template is store on the sd card. I do not understand all the example because I'm a newbie in programming in both web page and c++.

I've tried to modify the example and It compile but the page only respond with a bunch on html call text:

0HTTP/1.0 200 OK Server: Webduino/1.7 Access-Control-Allow-Origin: * Content-Type: text/html; charset=utf-8 33HTTP/1.0 200 OK Server: Webduino/1.7 Access-Control-Allow-Origin: * Content-Type: text/html; charset=utf-8 68HTTP/1.0 200 OK Server: Webduino/1.7 Access-Control-Allow-Origin: * Content-Type: text/html; charset=utf-8 79HTTP/1.0 200 OK Server: Webduino/1.7 Access-Control-Allow-Origin: * Content-Type: text/html; charset=utf-8 67HTTP/1.0 200 OK Server: Webduino/1.7 Access-Control-Allow-Origin: * Content-Type: text/html; charset=utf-8 84HTTP/1.0 200 OK Server: Webduino/1.7 Access-Control-Allow-Origin: * Content-Type: text/html; charset=utf-8 89HTTP/1.0 200 OK Server: Webduino/1.7 Access-Control-

here what I've done so far:

void outputPins(WebServer &server, WebServer::ConnectionType type, bool addControls = false) // this function should be replace by loadhtml
{

          // web page request
        // send web page
        webFile = SD.open("index.htm");        // open web page file
        if (webFile) {
          while (webFile.available()) {
            server.httpSuccess();
            server.print(webFile.read()); // send web page to client
          }
          webFile.close();
        }

}

but here is the idea: can it be possible to include file template or file get request on it.. that could very simplify both html and c++ coding.... (so I think so... :P)

and also: Is client post method support nested arrays ?

thanks

PUT requests always returns response status was 0

I'm using Webduino library for implementing a REST API, and while coding and testing, I realized that, when submitting a request by using PUT verb, the application fails. If I just change the code to put it into a different verb (such as PATCH) everything is working properly.

I've went through the library code and there is no visible error (followed the execution by printing with Serial and everything looks good), but I'm getting the following message:

Could not get any response
This seems to be like an error connecting to http://172.16.20.251/servo. The response status was 0.
Check out the W3C XMLHttpRequest Level 2 spec for more details about when this happens.

(using Postman chrome extension).

I tried other tools to generate the put requests and it's failing equally.

How can I use the SD card with Webduino

The wiki says that we can't use SD with the Ethernet without disabling one and enabling the second
i.e: https://github.com/sirleech/Webduino/wiki/Webduino-webserver-hanging-after-a-short-period---fixed-by-disabling-the-SD-card

Another question at Stack Exchange and the answer was nearly the same
http://electronics.stackexchange.com/questions/67212/how-to-avoid-sd-card-and-w1500-spi-mixup-on-the-ethernet-shield

but I found the following article:
http://startingelectronics.com/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-web-server/
When I follow I was able to use the SD & Ethernet together without any restrictions.

My problem now that I can't port the code from the provided link to use Webduino.

addCommand

addCommand does not return a status, therefore there is no indication that use that would exceed the array bounds of the m_commands array has been dropped. Therefore a default maximum of only 8 commands can exist

When the dropped command is then requested, the failure page is then delivered.

quick fix to immediate issue, make the array size user defined in the header to stop dropped commands

webduino on codebender

Hi, I'm Vasilis Georgitzikis from the codebender team. This isn't an Issue with webduino, but I couldn't find a better way to contact you.

In case you haven't heard, codebender is a web platform (including an Arduino IDE) that allows you to code faster and easier through the browser. One of the important features is our ability to remotely program an Arduino /w Ethernet shield of Arduino Ethernet through the network!

I'm writing to notify you that we'll include the webduino library in the list of pre-installed libraries, since I use it extensively and I find it very valuable. Big congrats on that! You might also be interested in trying out codebender. We are currently in closed beta, but I can create an account for you if you're interested.

Stall whith long latency links

What steps will reproduce the problem?

  1. Use standard demo with /form url for digital output control through radio buttons
  2. Use a long latency connection, like radiolink in my case
  3. reach latencies of pings beyond 3.0 ms or more

What is the expected output? What do you see instead?
It works sometimes until latency rise over a threshold (unclear which one). Then the http response never arrives. I tried firebug and Chrome with no console errors, just stall (pending response). It happens to a bunch of them simultaneously (they run on different ports on the same LAN, so no hardware specific problem. (both UNO and Ethernet models).

What version of the product are you using? On what operating system?
Latest sirleech/github version of webduino library on ArduinoUNO plus Ethernet shield, or Arduino Ethernet (both tested). All of them are being used with Ariadne bootloader for remote IP reprogramming.

Please provide any additional information below:
While the Arduino is in stall mode, any ping or LAN (local without radiolink) http request are served without problem (you get back full form functionality and digitalbits changes).

Any hint how to at least respond with timeout error will be welcome, as these arduinos will run on an unattended remote location. Any other experiencing the same behaviour, please report your findings.

Thanks,
Agustin

1.0rc1 branche telnet to x.x.x.x 80 locks-up arduino

Using arduino 1.0 with 1.0rc1 branche webduino.

Telnet to webduino and type any character the arduino lock's up. Connecting to webduino via a browser works fine.
Telnet to previous versions of webduino is working fine.

Split library?

I'm playing around with implementing parts of the new Web-of-Things specs and HTML is therefore not something I would serve. I was therefore thinking it may make sense to split this library into parts, where the protocol stuff is in one library, and the HTML stuff is in another, as these are orthogonal issues?

Updating original Google Code site

I just updated the main page on the Google Code site to note that 1.6 is available here and that this is the main branch for future development. I was wondering if we should move open issues from GC over to the issues tracker here.

W5500 compatibility

Hi,
Using Webduino for years now without issue, but there was one UNO with hw problem and was replaced by a new one with W5500 ethernet shield, and Webduino does not work. Any news about Webduino compatibility with Wiznet W5500 ethernet chip/shield?
Thanks

Compile Errors on Dev Branch (split of Webserver.h into .cpp)

Getting some pretty bad compile errors when trying the new code from @cyberwaelder in Arduino 22:

/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:25: error: 'WebServer' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:25: error: ISO C++ forbids declaration of 'WebServer' with no type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: In function 'int WebServer(const char_, int)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:25: error: only constructors take base initializers
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:32: error: 'defaultFailCmd' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: At global scope:
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:37: error: 'WebServer' is not a class or namespace
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: In function 'void begin()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:39: error: 'm_server' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: At global scope:
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:42: error: 'WebServer' is not a class or namespace
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:42: error: variable or field 'setDefaultCommand' declared void
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:42: error: 'Command' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:42: error: 'cmd' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:47: error: 'WebServer' is not a class or namespace
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:47: error: variable or field 'setFailureCommand' declared void
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:47: error: 'Command' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:47: error: 'cmd' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:52: error: 'WebServer' is not a class or namespace
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:52: error: 'Command' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: In function 'void addCommand(const char_, int_)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:54: error: 'm_cmdCount' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:54: error: 'm_commands' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:54: error: 'SIZE' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: At global scope:
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:61: error: 'WebServer' is not a class or namespace
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:61: error: variable or field 'write' declared void
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:61: error: 'uint8_t' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:66: error: 'WebServer' is not a class or namespace
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: In function 'void write(const char_)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:68: error: 'm_client' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: At global scope:
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:71: error: 'WebServer' is not a class or namespace
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:71: error: expected ',' or '...' before '' token
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:71: error: ISO C++ forbids declaration of 'uint8_t' with no type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: In function 'void write(int)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:73: error: 'm_client' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:73: error: 'buffer' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:73: error: 'size' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: At global scope:
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:76: error: 'WebServer' is not a class or namespace
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:76: error: 'size_t' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: In function 'void write(const char
, int)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:78: error: 'm_client' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:78: error: ISO C++ forbids declaration of 'type name' with no type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:78: error: ISO C++ forbids declaration of 'type name' with no type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:78: error: expected primary-expression before 'const'
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:78: error: expected )' before 'const' /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: At global scope: /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:81: error: 'WebServer' is not a class or namespace /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:81: error: expected ',' or '...' before '*' token /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:81: error: ISO C++ forbids declaration of 'prog_uchar' with no type /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: In function 'void writeP(int)': /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:85: error: 'uint8_t' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:85: error: expected;' before 'buffer'
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:86: error: 'size_t' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:86: error: expected ;' before 'bufferEnd' /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:88: error: 'length' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:90: error: 'bufferEnd' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:92: error: 'm_client' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:92: error: 'buffer' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:96: error: 'buffer' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:96: error: 'bufferEnd' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:96: error: 'data' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:96: error: 'pgm_read_byte' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:99: error: 'bufferEnd' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:100: error: 'm_client' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:100: error: 'buffer' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: At global scope: /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:103: error: 'WebServer' is not a class or namespace /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:103: error: expected ',' or '...' before '*' token /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:103: error: ISO C++ forbids declaration of 'prog_uchar' with no type /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: In function 'void printP(int)': /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:107: error: 'uint8_t' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:107: error: expected;' before 'buffer'
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:108: error: 'size_t' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:108: error: expected ;' before 'bufferEnd' /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:110: error: 'buffer' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:110: error: 'bufferEnd' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:110: error: 'str' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:110: error: 'pgm_read_byte' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:114: error: 'm_client' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:120: error: 'bufferEnd' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:121: error: 'm_client' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:121: error: 'buffer' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: At global scope: /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:124: error: 'WebServer' is not a class or namespace /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: In function 'void printCRLF()': /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:126: error: 'm_client' was not declared in this scope /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:126: error: ISO C++ forbids declaration of 'type name' with no type /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:126: error: ISO C++ forbids declaration of 'type name' with no type /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:126: error: expected primary-expression before 'const' /Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:126: error: expected)' before 'const'
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp: At global scope:
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:129: error: 'WebServer' is not a class or namespace
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:129: error: 'ConnectionType' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:129: error: expected primary-expression before 'char'
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:130: error: expected primary-expression before 'bool'
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:130: error: initializer expression list treated as compound expression
/Applications/Arduino.app/Contents/Resources/Java/libraries/Webduino/WebServer.cpp:131: error: expected ',' or ';' before '{' token

GarageDoorOpener.ino not compiling - Arduino 1.0.6

Hi ,
I am new to Ardiuno. Getting following error during compiling GarageDoorOpener.ino

In file included from Webserver.cpp:4:
/Webduino.h: In member function 'int WebServer::read()':
Webduino.h:729: error: ambiguous overload for 'operator==' in '((WebServer*)this)->WebServer::m_client == 0'
/Webduino.h:729: note: candidates are: operator==(int, int)
C:\Program Files (x86)\Arduino\libraries\Ethernet/EthernetClient.h:27: note: virtual bool EthernetClient::operator==(const EthernetClient&)

Move avr/pgmspace.h include Into Webserver.h

Comment 9 by [email protected], Jun 5, 2011
I should also add that you might want to add the

include "avr/pgmspace.h"

to the WebServer.h which is the main webduino file. However the demo file needs the aforementioned SPI.h file to compile as well because the Ethernet.h import needs it. I hope this helps.

dispatchCommand serves default command with invalid prefix

I have discovered what I believe to be a bug in webduino.

In lines 527 to 530 in the current code, three conditions are tested to determine if a reqeust should be responded to with the default failure command.

  1. requestType == INVALID
  2. strcmp to see if prefix is incorrect
  3. !dispatchCommand(...)

This is done in one if statement with all three conditions OR'd. Note that in this call, dispatchCommand always executes even if the request type is INVALID and the prefix is incorrect. This is the problem.

I've encountered a logic fault with this statement where the prefix can be invalid and dispatchCommand(...) still returns true. In the particular case I had, webduino served the default root page despite receiving a incorrect (or missing) prefix. After serving the default root page Webduino then served the default failure command before calling reset() to close the client connection.

How this happened:
During stability testing of my code I noticed that the hit counter on my default page appeared to be incrementing out of sequence. I had hit it 3 times, and the next day it showed 500+ hits. After lots of debugging with sketch, webduino, and wireshark, I discovered that various windows discovery services were hitting the webduino with lots of http requests, mostly for the root. In the code statement above, the prefix test failed. However, in many cases (500+ in the course of about 30 hrs), the memory location in buffer that dispatchCommand() looks in (buff + urlPrefixLen) happened to contain "/\0" from some previous use of the memory location. dispatchCommand() sees this a request for the default root page. This meant that even with an invalid prefix, dispatchCommand() still served the default root page.

I was able to test and verify that this happened when calling either overload of processConnection(). Additionally, I was able to force the failure by making a call to to the webserver with an invalid prefix that happened to be the same length as the valid prefix. Additionally², with wireshark, I also captured several instances where "webcollage/1.135a" attacks were getting served the default root page and the default failure page (I consider webcollage an attack) as a result of this same logic fault.

My Solutions:
First and foremost, did some firewall reconfiguring on both the router and windows machines to shut down unwanted traffic.
I don't know if you have any experience with windows 7 and all of it's discovery services, but IMHO it's an unholy mess of uncessary traffic on LANs and the internet.

Second, modify webduino to change the logic. One solution in webduino is to do a memcpy() at the begginning of processConnection() to ensure that the allocated buffer is "clean". To me, that seemed like treating the symptom rather than correcting the logic. My preferred solution was to alter the test sequence so that dispatchCommand() is never called if either the request type and prefix are bad.

I tried to post my code on github for about an hour. Won't do that again unless someone can change my now very negative opinion of guthub. So here is an excerpt of my code changes. This is pretty cleaned up. My actual code now has many more debugging statements and I've also added some ip filtereing that supresses any response at all to certain domains/IPs.

/* * Original code starting at line 527 **********
if (requestType == INVALID ||
strncmp(buff, m_urlPrefix, urlPrefixLen) != 0 ||
!dispatchCommand(requestType, buff + urlPrefixLen,
(_bufflen) >= 0))
{
m_failureCmd(_this, requestType, buff, (bufflen) >= 0);
}
*/
// *
* begin changes by me ****************
if(requestType == INVALID || strncmp(buff, m_urlPrefix, urlPrefixLen) != 0 )
{
m_failureCmd(_this, requestType, buff, (_bufflen) >= 0);
}
else if(!dispatchCommand(requestType, buff + urlPrefixLen,(_bufflen) >= 0))
{
m_failureCmd(_this, requestType, buff, (bufflen) >= 0);
}
// *
********* end changes by me *****************

Request content is read one byte at a time

The read() method fetches request content one byte at a time. This introduces quite a significant overhead.

To make it more efficient, the data can be read as a chunk into a read buffer.

Webduino 1.7 and Arduino IDE 1.06

Hi,

I have an issue while compiling code with the Webserver.h library and the version 1.06 of the Arduino IDE (there are no error with version 1.05)

Typical error messages while compiling the Web_HelloWorld.ino sketch are described below

Any idea of how can this be solved?

Thanks in advance
Robert

The error messages are:

In file included from Web_HelloWorld.ino:5:
/Users/Robert/Data/Our Documents/Projets Techniques/Domotic/Arduino/Sketch/libraries/Webduino/WebServer.h: In member function 'int WebServer::read()':
/Users/Robert/Data/Our Documents/Projets Techniques/Domotic/Arduino/Sketch/libraries/Webduino/WebServer.h:729: error: ambiguous overload for 'operator==' in '((WebServer*)this)->WebServer::m_client == 0'
/Users/Robert/Data/Our Documents/Projets Techniques/Domotic/Arduino/Sketch/libraries/Webduino/WebServer.h:729: note: candidates are: operator==(int, int)
/Applications/Arduino-1.06.app/Contents/Resources/Java/libraries/Ethernet/EthernetClient.h:27: note: virtual bool EthernetClient::operator==(const EthernetClient&)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.