larsth / webduino Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/webduino
Automatically exported from code.google.com/p/webduino
Webduino, a web server library for the Arduino platform (C) 2009, Ben Combee and Ran Talbott Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ============ INSTALLATION ============ With Arduino 0016 or earlier, put the WebServer.h file in the hardware/libraries/webduino subdirectory of the arduino tree. With Arduino 0017 or later, add the Webduino folder to the "libraries" folder of your sketchbook directory. See http://arduino.cc/blog/?p=313 for more details on the new setup. You can put the examples in your own sketchbook directory, or in hardware/libraries/webduino/examples, as you prefer. Please let me know right away if you encounter any bugs, or have any suggestions for improvement. ======= SUPPORT ======= Current code is available from http://code.google.com/p/webduino/. There is also a mailing list for developers and users hosted at http://groups.google.com/group/webduino. ======= HISTORY ======= *** Release 1.4.1 Fix some of the examples to use the new readPOSTparam form *** Release 1.4 Major bug fix: Earlier versions of the code wrote to the Server object, not the Client object. This caused problems if multiple connections were attempted at once. Performance improvement: writes from progmem now buffer up to 32 bytes at a time in local RAM. This allows sending larger TCP/IP packets back to the client. Updated WebServer.h to allow it to be included multiple times. Added code to WebServer::read() to abort a connection if no data could be read from the client after 1 second of trying. You can change this timeout by defining WEBDUINO_READ_TIMEOUT_IN_MS before including WebServer.h *** Release 1.3.1 Bug fix release. Found a problem when last header received was the Content-Lenght header that would cause the web server to hang. Thanks to /warmfusion/ on the Google Code site for a great bug report. Added more debugging output when ARDUINO_SERIAL_DEBUGGING is set to 2 or higher. *** Release 1.3 Updated the library to better process POSTs by only reading at most Content-Length bytes. This fixes a problem where the server hangs on some client requests. Updated the read() call to handle slower links where the server may be waiting for more data from the client. Don't stop reading until the connection is terminated or the end of post data. Added WEBDUINO_SERIAL_DEBUGGING define. Add the line #define WEBDUINO_SERIAL_DEBUGGING 1 to your code before the #include <WebServer.h> header to cause the Webduino code to output the HTTP request to the serial port. Modified push() to take an int. You can push(-1) now, but it is ignored. Added readInt() method to read an integer value from the stream. Fixed a possible security hole where you could cause the code to read bad data by sending a POST parameter exactly as long as the buffer. Added emacs style guidelines at top of source file. *** Release 1.2.1 Fixed HelloWorld.pde source file which hadn't been updated for 1.2 library changes. Added additional version history to README. *** Release 1.2 This is an update to Ben Combee's Webduino library that adds some support for parameters passed as part of the URL. I'm pretty sure I haven't added any new bugs, but it should still be considered "beta". 1. The "user callback" functions have two new parameters: the "parameters" part of the URL string, and a flag indicating whether the buffer contains all of them (FALSE if part of them had to be discarded). 2. Added nextURLparam to parse parameters out of the new buffer. This is designed to allow the user code to extract keywords and values in sequence, much like reading a file. It adds some error checking, so that, if the client includes "?password=antidisestablishmentarianism" in the URL, the user code can tell that part of the data was left out of its 16-byte buffers. 3. Renamed readURLparam to readPOSTparam, because the name was confusing with the addition of #2. 4. A new version of processConnection that allows the user to supply a URL buffer and specify the size. The old version that allocates only 32 bytes is still there. *** Release 1.1 New example: Web_Image - serving a PNG fileK New example: Web_AjaxBuzzer - using AJAX libraries from the net httpSuccess call parameters modified to allow adding headers Code cleanups *** Release 1.0 Initial Version
Webduino is an excellent library, but a problem comes when your project
contains several .cpp (or .pde) files.
Since all the implementation of the WebServer class is written in WebServer.h,
when you include this header in more than one .cpp (or .pde) file, the GCC
linker complains of duplicates implementations.
I used this simple solution: I enclosed the whole implementation in a
#ifndef/#endif, so that the WebServer class implementation is not included if a
special #define is set (but still included by default).
In my case, I set the #define on each .cpp files and kept the default behavior
(include implementation) only in the .pde.
I think you should include this hack in the official release.
Original issue reported on code.google.com by benoit.blanchon
on 9 Jul 2010 at 4:33
There's a off-by one error in WebServer::readPOSTparam(). The buffers passed to
the function will not be fully used.
In the beginning the length of the two buffers is decreased to make sure that
the trailing 0 is not overwritten:
// decrement length so we don't write into NUL terminator
--nameLen;
--valueLen;
This already ensures that the NULL terminator is not overwritten, so there's no
need to subtract another character before assigning the read character to the
buffer:
// check against 1 so we don't overwrite the final NUL
if (nameLen > 1)
{
*name++ = ch;
--nameLen;
}
else if (valueLen > 1)
{
*value++ = ch;
--valueLen;
}
It should check against 0 instead of 1.
Example (pseudo-code):
name[2], value[2]
WebServer::readPOSTparam(name, 2, value, 2);
This will decrease both nameLen and valueLen to 1 in the beginning of
WebServer::readPOSTparam() so that the final check "nameLen > 1" and "valueLen
> 1" will fail and the read character isn't stored in name/value.
What version of the product are you using? On what operating system?
1.4.1
Original issue reported on code.google.com by [email protected]
on 3 Nov 2010 at 7:16
What steps will reproduce the problem?
1. Use WebDuino Server.pde
2. Open url using firefox 3.5 and post to valid path
What is the expected output? What do you see instead?
Page is posted to, arduino responds as expected
What version of the product are you using? On what operating system?
WebDuino 1.3
Arduino Dem. 328
Fedora 11
Firefox 3.5 or php 5.3+CURL
Please provide any additional information below.
Using curl directly does not appear to cause this problem, so i wonder if
it caused by http-keep-open type problems.
If you cannot get this working contact me and i shall try and find an
clearer demonstration
Toby
Original issue reported on code.google.com by [email protected]
on 23 Aug 2009 at 7:33
In the function "dispatchCommand()" the verb is processed as follows:
// We now know that the URL contains at least one character. And,
// if the first character is a slash, there's more after it.
if (verb[0] == '/')
{
...search "m_commands" for a suitable handler
}
BUT... if I supply a prefix of "/" in the webserver's constructor
(which is the default!) then it fails because the leading "/" was
discarded in the function "processConnection()" on this line:
dispatchCommand(requestType, buff + urlPrefixLen
ie. The webserver only works if you supply "" as the prefix
in the constructor. Anything else will cause dispatchCommand()
to fail.
The solution is to remove the check for "/" from dispatchCommand()
(it's completely unnecessary anyway...)
Original issue reported on code.google.com by [email protected]
on 19 Jul 2011 at 8:11
What steps will reproduce the problem?
1. Create a "file upload" form, like the following:
<form action='upload.idf' enctype='multipart/form-data' method='post'>
<p>File Name: <input type='text' name='textline' size='12'></p><p>
Please specify a file: <input type='file' name='datafile' size='40'>
</p><div><input type='submit' value='Send'></div></form>
2. Try to process file contents in some way in your sketch.
What is the expected output? What do you see instead?
Expected: To be able to read through file, and use the "expect" function.
Actual: Application hangs.
What version of the product are you using? On what operating system?
v1.4.1 ATMega328
Please provide any additional information below.
This seems to be because the pushback array, and depth counter, are
declared as chars, while everything else is using int.
http://code.google.com/p/webduino/source/browse/v1.4.1/webduino/WebServer.h#209
http://code.google.com/p/webduino/source/browse/v1.4.1/webduino/WebServer.h#210
Changing these to be int seems to solve the problem, but as far as I can
tell, this will double the amount of RAM used by the pushback array, as
ints are two bytes, while chars are a single byte.
Options:
i) Change to int?
ii) Add #define to allow user to choose which to use?
Original issue reported on code.google.com by [email protected]
on 4 Feb 2010 at 9:55
I think this should be readPOSTparam.
Original issue reported on code.google.com by [email protected]
on 29 Oct 2009 at 7:42
The library doesn't support GET requests that have HTML form parameters like
GET /myform?d1=1&d2=0
This is because parameter parsing is only done after headers are all
processed and the GET matching code doesn't deal with question mark characters.
Original issue reported on code.google.com by ben.combee
on 13 Jun 2009 at 8:33
I send you a little sample application of webduino with basic authentication.
Original issue reported on code.google.com by [email protected]
on 9 Jun 2010 at 7:39
Attachments:
Hi, I'm misusing this to send you something that might be of interest; I
combined SDFatlib and modified webduino so I can upload files to the SD card
and serve files from the SD card.
I attached the sketch and two files that can be put on the SD card to get a
file manager that can upload files, delete files, create and delete folders,
navigate folders, etc.
Reason for sending it to you is that -while this works-, I'm not a particularly
good C++ programmer and the code might (will!) need some serious reviewing and
improving before spreading it to a larger audience.
If you're interested in doing so, let me know, if not, I'll just post it in the
general Arduino forum
Some of the changes I had to make to the webduino lib:
changed: int m_pushback[100] instead of char. Otherwise binary files will
fail to load. Related variables were also changed.
added: int WebServer::readNextFormPart(int action) reads sections of
multi-part forms. The action tells it what to look for and what to return.
changed: void WebServer::processHeaders(); added sections where it reads the
multipart-form boundary and filenames.
In order to get everything working, you'll have to change the SD_SELECT to the
correct pin (I believe 4 on the new arduino ethernet shield).
You'll probably also have to set the correct IP Address.
Improvements that are still needed:
- Speed... Serving files works, but it's pretty slow sometimes. Also, if a
browser sends multiple requests, for instance when a css, image or javascript
file also needs to be served, everything slows down badly.
File uploads are pretty slow as well. I'm not sure if changing/ adding
buffers helps. I'm also not sure where the bottleneck is. My code / webduino /
ethernet lib / SPI lib / W5100 chip...?
It might be nice to have a send buffer in Webduino, so it doesn't try to send
each byte at a time when data is written byte-to-byte to the server. I tried
solving this by adding some buffers myself, but that could be implemented much
nicer. Some sort of flush function would have to be added to send all bytes
that are still in a buffer.
Regards
Matthijs
Original issue reported on code.google.com by [email protected]
on 20 Oct 2010 at 2:46
Attachments:
As required, I send the missing file webduinoauth.zip in this section.
Claudio.
Original issue reported on code.google.com by [email protected]
on 13 May 2010 at 7:51
Attachments:
What steps will reproduce the problem?
1. have a project working with webduino and arduino 0022 (all tested on a
debian sid system)
2. upgrade to arduino 1.0
3. building fails:
./WebServer.h:203:16: error: conflicting return type specified for ‘virtual
void WebServer::write(uint8_t)’
/usr/share/arduino/hardware/arduino/cores/arduino/Print.h:48:20: error:
overriding ‘virtual size_t Print::write(uint8_t)’
./WebServer.h:205:16: error: conflicting return type specified for ‘virtual
void WebServer::write(const uint8_t*, size_t)’
the signatures in Print.h were changed in arduino to return size_t while they
returned void in 0022. i tried the "trivial" approach of changing some voids to
size_t in webduino, but there seems to be a little more to it as i got problems
with things being purely virtual when they shouldn't.
Original issue reported on code.google.com by [email protected]
on 19 Dec 2011 at 11:33
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 but no erros,
just stall. It happens to a bunch of them simultaneously (they run on different
ports on the same LAN, so no hardware specific problem
What version of the product are you using? On what operating system?
Latest 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 IPreprograming.
Please provide any additional information below.
While the Arduino is in stall mode, any ping or LAN request are server withouth
problem (you get back full form functionality and digitalbits changes.
Any hint how to at least response with timeout error will be welcome, as this
arduinos will run on an unatended remote location. Any other experiencing the
same behaviour, please report your findinds.
Thanks,
Agustin
Original issue reported on code.google.com by [email protected]
on 3 Jun 2013 at 8:08
What steps will reproduce the problem?
1. Send either a PUT or DELETE request to the server
2. Try to figure out what kind of request it was
3. It will be reported as WebServer::INVALID
What is the expected output? What do you see instead?
The request type should be set to either WebServer::PUT or WebServer::DELETE
instead of WebServer::INVALID
What version of the product are you using? On what operating system?
1.4.1 on Windows
Please provide any additional information below.
This can be easily fixed in WebServer::getRequest(). The result would be the
the library would allow to build truly RESTful services.
Original issue reported on code.google.com by [email protected]
on 2 Nov 2010 at 3:37
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 ?
Original issue reported on code.google.com by BiosLord
on 16 Apr 2011 at 4:09
A use arduino and ethernetsheilde wiznet based.
I load the webserver demo into the arduino all is going well.
I try to connect to the sever using firefox and http://XX.XX.XX.XX the same
network adress as that changed in the demo script and i get a blank page.
Nothing is comming but there are communication between ethershield and browser.
Whats happend
TY
Original issue reported on code.google.com by [email protected]
on 20 Apr 2010 at 8:12
The WebServer provides the very handy method printP to print a string stored in
program space.
So, one basically expect that you can write:
server.printP (PSTR("Hello World !")) ;
/* the PSTR macro is defined in avr/pgmspace.h */
Unfortunately, you can't because the parameter for printP is of type
prog_uchar*, whereas the PSTR macro builds a prog_char*.
The fix is very simple, I just replaced all occurrences of prog_uchar by
prog_char in WebServer.h and now I can use the PSTR macro.
Original issue reported on code.google.com by benoit.blanchon
on 9 Jul 2010 at 4:46
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.