GithubHelp home page GithubHelp logo

jjg / restduino Goto Github PK

View Code? Open in Web Editor NEW
285.0 285.0 40.0 885 KB

A sketch to provide a REST-like interface to the Arduino+Ethernet Shield

License: GNU General Public License v3.0

Arduino 0.89% PHP 2.78% CSS 1.46% C++ 6.63% C 0.56% Processing 2.05% HTML 85.62%

restduino's People

Contributors

edwardmgoldberg avatar per1234 avatar snargledorf avatar theskorm 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

restduino's Issues

Error Compiling

Hi,

I have an UNO r3 with an ethernet shield. When compiling I get below error.
To be honest, I have no idea how to start with this error. Hoping you can help me.

warning: NULL used in arithmetic [-Wpointer-arith]

Many thanks in advance!
Dirk

Arduino: 1.6.5 (Windows 7), Board: "Arduino Uno"

Build options changed, rebuilding all

Using library EthernetBonjour in folder: C:\Program Files (x86)\Arduino\libraries\EthernetBonjour (legacy)

Using library SPI in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI
Using library Ethernet in folder: C:\Program Files (x86)\Arduino\libraries\Ethernet

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\libraries\EthernetBonjour -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Program Files (x86)\Arduino\libraries\Ethernet\src C:\Users\dirk\AppData\Local\Temp\build1197526729768169677.tmp\RESTduino.cpp -o C:\Users\dirk\AppData\Local\Temp\build1197526729768169677.tmp\RESTduino.cpp.o

RESTduino.ino: In function 'void loop()':
RESTduino.ino:229:31: warning: NULL used in arithmetic [-Wpointer-arith]
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\libraries\EthernetBonjour -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Program Files (x86)\Arduino\libraries\Ethernet\src -IC:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp -o C:\Users\dirk\AppData\Local\Temp\build1197526729768169677.tmp\EthernetBonjour\EthernetBonjour.cpp.o

C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp: In member function 'int EthernetBonjourClass::_startMDNSSession()':
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:291:94: warning: comparison is always false due to limited range of data type [-Wtype-limits]
if (ethernet_compat_socket(this->_socket, ECSnMrUDP, MDNS_SERVER_PORT, ECSnMrMulticast) < 0)
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp: In member function 'int EthernetBonjourClass::_closeMDNSSession()':
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:306:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp: In member function 'MDNSError_t EthernetBonjourClass::_sendMDNSMessage(uint32_t, uint32_t, int, int)':
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:527:1: warning: label 'errorReturn' defined but not used [-Wunused-label]
errorReturn:
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp: At global scope:
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:311:13: warning: unused parameter 'peerAddress' [-Wunused-parameter]
MDNSError_t EthernetBonjourClass::_sendMDNSMessage(uint32_t peerAddress, uint32_t xid, int type,
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:311:13: warning: unused parameter 'serviceRecord' [-Wunused-parameter]
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp: In member function 'MDNSError_t EthernetBonjourClass::_processMDNSQuery()':
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:602:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i=0; i<qCnt; i++) {
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:656:48: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
ir = (tr > sizeof(DNSHeader_t)) ? sizeof(DNSHeader_t) : tr;
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:552:44: warning: variable 'aCnt' set but not used [-Wunused-but-set-variable]
uint16_t peer_port, udp_len, ptr, qCnt, aCnt, aaCnt, addCnt;
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:552:50: warning: variable 'aaCnt' set but not used [-Wunused-but-set-variable]
uint16_t peer_port, udp_len, ptr, qCnt, aCnt, aaCnt, addCnt;
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:552:57: warning: variable 'addCnt' set but not used [-Wunused-but-set-variable]
uint16_t peer_port, udp_len, ptr, qCnt, aCnt, aaCnt, addCnt;
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:1079:96: warning: 'peer_addr' may be used uninitialized in this function -Wmaybe-uninitializedthis->_sendMDNSMessage(peer_addr, xid, (int)MDNSPacketTypeServiceRecord, j-2);
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\EthernetBonjour.cpp:1079:96: warning: 'xid' may be used uninitialized in this function [-Wmaybe-uninitialized]
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -Wall -Wextra -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\libraries\EthernetBonjour -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Program Files (x86)\Arduino\libraries\Ethernet\src -IC:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetUtil.c -o C:\Users\dirk\AppData\Local\Temp\build1197526729768169677.tmp\EthernetBonjour\utility\EthernetUtil.c.o

C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetUtil.c:64:0: warning: ignoring #pragma mark [-Wunknown-pragmas]
#pragma mark -
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetUtil.c:65:0: warning: ignoring #pragma mark Private [-Wunknown-pragmas]
#pragma mark Private
^
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\libraries\EthernetBonjour -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Program Files (x86)\Arduino\libraries\Ethernet\src -IC:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp -o C:\Users\dirk\AppData\Local\Temp\build1197526729768169677.tmp\EthernetBonjour\utility\EthernetCompat.cpp.o

C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp: In function 'uint16_t ethernet_compat_write_private(uint16_t, uint8_t_, uint16_t)':
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:54:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<len; i++) {
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp: At global scope:
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:66:6: warning: unused parameter 'rxtx_bufsize' [-Wunused-parameter]
void ethernet_compat_init(uint8_t
macAddr, uint8_t* ipAddr, uint16_t rxtx_bufsize)
^
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp: In function 'void ethernet_compat_read_data(int, uint8_t_, uint8_t_, uint16_t)':
C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:121:41: error: invalid conversion from 'uint8_t* {aka unsigned char_}' to 'uint16_t {aka unsigned int}' [-fpermissive]
W5100.read_data(socket, src, dst, len);
^
In file included from C:\Program Files (x86)\Arduino\libraries\Ethernet\src/utility/socket.h:4:0,
from C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:27:
C:\Program Files (x86)\Arduino\libraries\Ethernet\src/utility/w5100.h:148:8: error: initializing argument 2 of 'void W5100Class::read_data(SOCKET, uint16_t, volatile uint8_t_, uint16_t)' [-fpermissive]
void read_data(SOCKET s, volatile uint16_t src, volatile uint8_t * dst, uint16_t len);
^
Error compiling.

Fingerprint Based Biometric Voting Machine using Arduino

Hi I have a problem when checking the code
..
Documents\Arduino\sketch_feb05a\sketch_feb05a.ino: In function 'uint8_t getFingerprintEnroll()':
..
Documents\Arduino\sketch_feb05a\sketch_feb05a.ino:405:7: warning: return-statement with no value, in function returning 'uint8_t {aka unsigned char}' [-fpermissive]

Getting this error while compiling,

C:\Users\YASIR\Documents\RESTduino\RESTduino.ino: In function 'void loop()':

C:\Users\YASIR\Documents\RESTduino\RESTduino.ino:230:31: warning: NULL used in arithmetic [-Wpointer-arith]

         else if(pin[0] != NULL) {

                           ^

C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp: In function 'void ethernet_compat_read_data(int, uint8_t_, uint8_t_, uint16_t)':

C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:121:41: error: invalid conversion from 'uint8_t* {aka unsigned char*}' to 'uint16_t {aka unsigned int}' [-fpermissive]

W5100.read_data(socket, src, dst, len);

                                     ^

In file included from C:\Program Files (x86)\Arduino\libraries\Ethernet\src/utility/socket.h:4:0,

             from C:\Program Files (x86)\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:27:

C:\Program Files (x86)\Arduino\libraries\Ethernet\src/utility/w5100.h:142:8: error: initializing argument 2 of 'void W5100Class::read_data(SOCKET, uint16_t, volatile uint8_t*, uint16_t)' [-fpermissive]

void read_data(SOCKET s, volatile uint16_t src, volatile uint8_t * dst, uint16_t len);

    ^

exit status 1
Error compiling for board Arduino Ethernet.

Low and high are reverse?

Hi,

I have something strange going on here.
When i open http://192.168.1.177/6/LOW the led goes on, and HIGH it turns of.
Am i doing wrong, or is there a bug?

It's a brand new arduino ethernet, just uploaded the sketch, used same ip and mac address as in the example.
attached a led to port 6 and 3v.

Cheers,
Tom

Error during compilation

C:\Users\Tomasz\Documents\Arduino\libraries\EthernetBonjour\utility\EthernetCompat.cpp:27:28: fatal error: utility/socket.h: No such file or directory
#include <utility/socket.h>
compilation terminated.
exit status 1

CORS support

Need to return CORS heaers lest browsers talking directly to RESTDuino become angry.

Interestingly this doesn't seem to impact "write" operations, i.e., you can issue GET requests that are processed by RESTDuino, but the browser rejects the response. I haven't tested it yet, but my guess is that "read" operations will fail altogether.

So, RESTDuino should return the necessary CORS headers to make the browsers know it's OK to talk to RESTDuino.

String Buffer Overflow (not really but not terminated by \0)

Hi guys

If a browser send more than 255 char (buffer size) or missing some \n stuff, the buffer could be not terminated by 0, this crashe the string manipulation after and stop the application

Always more robust when we work with string to assure that a zero exists somewhere marking the end of the string.

I added the 3 lines in the code below all is working fine on my side now ;-)

Charles

if (client)
{
// reset input buffer
index = 0;

// Added clearing buffer starting clean
// ===========================
for (int i = 0; i < (sizeof(clientline)); i++)
clientline[i] = '\0';

...
...

// fill url the buffer
if(c != '\n' && c != '\r' && index < BUFSIZE)
{
clientline[index++] = c;
continue;
}

// Add this new line at this point
// =====================
clientline[index] = '\0' ;

RESTDuino hangs when reading analog values

Hi ,
I made a shell script that reads the analog pin 0 constantly with a delay of 10 seconds, using the curl command.
After the third reading , the arduino hangs out and the program only returns to function if I reset the arduino.
The same thing does not happen if I use a script that switches a led, on and off, with the same frequency.
I am using the following script on a MAC OSX 10.6:
while true
do
curl http://192.169.1.201/a0
sleep 10
done

Is there a minimum delay between readings ?
Thanks in advance

Cross-Origin Resource Feature

Opening this issue as a followup to the posterous thread:
http://jasongullickson.posterous.com/restduino-arduino-hacking-for-the-rest-of-us

"I am looking at either updating the RESTduino sketch to allow JSONP callbacks or CORS headers in order to allow cross-domain requests."

Option 1) JSONP

The idea would you can call RESTduino with:
http://192.168.1.177/a0?callback=functioname

with response of

functioname({"a0":"349"});

Changes to RESTduino.pde I reckon will be quite minor, just need to parse the "?callback" parameter, wrap the JSON in parentheses, and then prepend the value of "callback" to the response.

Option 2) CORS

Or....I might just add "Access-Control-Allow-Origin: * " to the header....a little easier :)

CORS is inherently cleaner, embracing the latest web standards for cross-origin resources. Native XMLHttpRequest can be made in modern browsers without the need for proxies or callback functions.

http://enable-cors.org/

Option 3) BOTH

CORS is so far a relatively new technology, and not compatible with alot of browsers out there. We'll add a "Access-Control-Allow-Origin: *" header to the HTTP response, but also allow JSONP callbacks for another cross-origin method.

Compatible with wireless shield?

Hi,

Sorry this is more of a questions than a issue really, I am considering purchasing a shield that will allow internet connections for my arduino, however I was not sure if I would be able to use this library with a wireless shield. I would have thought it was possible, but I wanted to make sure.

Is there any wireless shields you recommend?

Thanks.

Problem when using static IP

There is a typo on lines 32 and 53 of RESTduino.ino. Instead of STATICPIP, it should be STATICIP (there is an extra P).

Error Compiling Sketch

I got an error compiling my sketch.
Could you help me?

Arduino: 1.6.8 (Windows 7), Board: "Arduino Duemilanove or Diecimila, ATmega328"

RESTduino.ino: In function 'void loop()':
RESTduino.ino:230:31: warning: NULL used in arithmetic [-Wpointer-arith]

         else if(pin[0] != NULL) {

                           ^

sketch\libraries\EthernetBonjour\utility\EthernetCompat.cpp: In function 'void ethernet_compat_read_data(int, uint8_t_, uint8_t_, uint16_t)':

sketch\libraries\EthernetBonjour\utility\EthernetCompat.cpp:121:41: error: invalid conversion from 'uint8_t* {aka unsigned char*}' to 'uint16_t {aka unsigned int}' [-fpermissive]

W5100.read_data(socket, src, dst, len);

                                     ^

In file included from C:\Program Files (x86)\Arduino\libraries\Ethernet\src/utility/socket.h:4:0,

             from sketch\libraries\EthernetBonjour\utility\EthernetCompat.cpp:27:

C:\Program Files (x86)\Arduino\libraries\Ethernet\src/utility/w5100.h:142:8: error: initializing argument 2 of 'void W5100Class::read_data(SOCKET, uint16_t, volatile uint8_t*, uint16_t)' [-fpermissive]

void read_data(SOCKET s, volatile uint16_t src, volatile uint8_t * dst, uint16_t len);

    ^

exit status 1
Error compiling for board Arduino Duemilanove or Diecimila.

Freezes when sending too many requests too quickly

I was trying callback parameters like so for JSONP when I froze the Arduino and Shield:

http://192.168.1.50/ao?callback=junk

One of the Transmission LEDs blinks consistently about once/half second when this freeze happens, and there is no more HTTP reponse from the RESTduino. I have to hard reset the Arduino via unpowering it to get it to work again. Has anyone else had this problem when sending weird URL patterns?

Hardware:

  • Arduino Uno
  • Freetronics Ethernet Shield

SelectedPin Token does not work for above pin 9

When you use RESTduino and use pin 13, REST format address/13/1 does not work, as strtok extrack the correct '13' token but later only last significant character '3' is use for digitial port output.

Solution:

        //  select the pin

// int selectedPin = pin[0] -'0'; delete this line
int selectedPin = atoi (pin); // add this line
Serial.println(selectedPin);

Regards,
Agustin

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.