Code Monkey home page Code Monkey logo

arest's People

Contributors

eykamp avatar ivankravets avatar marcoschwartz avatar mathiasbeckius avatar monkeywithacupcake avatar oidatiftla avatar per1234 avatar rpseng 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

arest's Issues

redefinition / previous definition of 'class aREST'

Hello Marco,

I have some trouble using Eclipse as IDE with your usefull aRest-Lib. If I use the Arduino IDE 1.6.0 or 1.6.3 there is no Problem. I can compile and upload the Sketch with aREST.h and Ethernet.h.

Last month I decide to use Eclipse instead of the Arduino IDE. All went well and I use Libs like dht.h, mySensors.h, OneWire.h and so on. But if I use the aRest.h lib I get this error
..../Arduino/libraries/aREST-master/aREST.h:79: error: redefinition of 'class aREST'
..../Arduino/libraries/aREST-master/aREST.h:79: error: previous definition of 'class aREST'

I found the Issue 26 but I think that won't solve my case. I use the latest Build 20150401 for Linux 64 Bit from www.bayens.it/eclipse with the 1.6.0 Arduino. I tried its also with 1.6.3 und 1.5.8 but there are additional Problems but it solves not the main Problem.

Have you any Idear or Hint

Best wishes
Stephan

bug in "functions" (argument transfer)

Hi
the problem is the line
int header_length = functions_names[i].length() + 8;
Even if you would read the rest of the input until end of line, this would result in a normal use like "/led/1" or "/led/0" no argmuents are transfered (as cut the klenth of the function (led=3) and addtional 8 characters (something like /led--------1 would be valid then).

functions limitation?

Hello, Marco. I am currently on the next stage in my home automation project and I am planning to use the main arduino with CC3000 as a master and communicate with other devices via RF using the nrf24. This should reduce overall cost of the system. I noticed a problem, whenever I add more than 5 functions, the arduino mega I am running as the master with wifi goes into a reboot cycle loop just before it enters the void loop() part of the code. Is there a limit to the number of functions available in aREST. If so, I am thinking of using switch case in the meantime to override this and use the parameter in a switch case to control more than 5 things (I am aiming for 16 devices to every CC3000) . for example I can have all lights controlled from one function.

int lights (String c){
switch (c.substring(0,2)){
case 's1':
digitalWrite(switch1,!digitalRead(switch1));
break;
case 's2':
digitalWrite(switch2,!digitalRead(switch1));
break;
default:
}
}

I am not able to access my system to test for a few days, I was wondering if switch case would work with the function.

function String params not properly terminated

The String provided as parameter to a called function is not terminated appropriately. Just printing the same includes the trailing "HTTP" characters from the http request. The Length() function provides the incorrect length as well. In addition it seems like the name of the query parameter is not checked but is just skipped so that with shorter (or omitting the name completely) results get scrambled as well:

Examples:
http://10.0.1.130/text?params=hallo
prints as "hallo HTTP"
http://10.0.1.130/text?text=hallo
prints as "llo HTTP"
http://10.0.1.130/text?hallo
prints as "TTP"

stuck responses / state ?

I've had my system running for about 2 days now almost perfectly (but some mechanical issues); now it won't respond to curl -q -o - http://10.0.0.157/id -- It times out.

I've seen this before but am still unable to track it down to a particular sequence of events. Power cycling has been the only fix so far...

Let me know if you want to see the sketch.

ESP8266 Wifi Support?

Would you consider adding support for the ESP8266 wifi interface?
It's far cheaper than other wifi options for arduino...

Improvement request (read of input)

Improvement request:
Wouldn't if be better to check only after an end of line or "/" was received?
Currently if you have functions named "led", "led_left", "led_right" always only "led" could be user and the others will never be useable.

Get all status in 1 Http request

Hi,

I love you api ! It is great !
Is there any way to read all ports in 1 http request ? (Like geting all analog values at the same time)

Regards,

Teensy 3.1

Hello Marco,
Nice looking project. :)
I am trying to run this on a Teensy3.1 and use the serial on the USB. the problem is with a teensy3.1 to use "HardwareSerial.h" in "aREST.h" i need to set it to "rest.handle(Serial1); " in the example serial program to compile. The teensy 3.1 has 3 hardware serial ports Serial1-3. the problem is the usb is not a hardware port and is accessed via "serial".

The problem is in your serial handler statement on line 114 in aREST.h, how do you think i should change this statement to suite teensy3.1.

TIA
KurtSch

RFC to add new declaration : variable(char *, char *)

Marco,
just started to play with your lib today on a ESP8266, I love it :-)

I'm also using another lib, in this lib I've got a linked list of data. Each linked list entry contains a pointer to a variable name and another to variable value (+ another on next item entry if any). both are char *
Would it be possible to have the option to create variable(char *, char *) ? To be able as a stupid example to do something like that :

MyLinkedList * me = Entry;
rest.variable(me->name, me->value);

I could have done it, but I'm very old school, and I like to know exactly what my code is doing. And to be honest, String class always provided so much pain (mainly because I'm far away for expert in C++) that when I can avoid them I do. All my var affectation and management is done in the other lib, I just need to pass to rest the pointer to the pair of name/values.

Hope this makes sense

Charles

Simplified Javascript Access

Hi Marco,

I have been using your aREST library and admire your work. Thanks! I was keen not to have to add any thing to my browser's capability or set up anything to do with PHP on servers etc. That end I have worked out a way to allow Javascript to access the aREST commands using the XMLHttpRequest(). It looked ideal but threw errors as the browser was rejecting it Arduino on the basis it did not share its domain. I have discovered that adding the line

client.println(F("Access-Control-Allow-Origin: *"));

into the header allowed me access, and I did develop my simplified web page access.

I am a newbie to GitHub so I am not sure how to go about all this. I would like to submit my web page if you are interested for your perusal.

I am not sure how much this change to the header might compromise security generally (it appears to only involve the Arduino end?) or whether using the API was the answer to this problem. I will be interest to hear your comments.

Rob Ward

File: aREST.h
.......
template
void send_http_headers(T client){
client.println(F("HTTP/1.1 200 OK"));
client.println(F("Content-Type: application/json"));
client.println(F("Access-Control-Allow-Origin: *"));
client.println(F("Connection: close"));
client.println();
}

Is there a limit to the amount of functions you can create?

Hi There

Thanks so much for your great library! I am using it extensively to control all sorts of things in my home.

I have created 5 separate functions to control 5 separate items in my home, but when I attempt to create a 6th function, it compiles and uploads to arduino, but I don't get the expected results, almost like there is a bug?

Please let me know, thanks in advance!!

Simplified Javascript Access

Hi Marco,

I have been using your aREST library and admire your work. Thanks! I was keen not to have to add any thing to my browser's capability or set up anything to do with PHP on servers etc. To that end I have worked out a way to allow Javascript to access the aREST commands using the XMLHttpRequest() command. It looked ideal, but threw errors as the browser was rejecting the Arduino/aREST on the basis it did not share its domain. I have discovered that adding the line

client.println(F("Access-Control-Allow-Origin: *"));

into the header allowed me access, and I did develop my simplified web page access.

I am a newbie to GitHub so I am not sure how to go about all this. I would like to submit my web page if you are interested for your perusal.

I am not sure how much this change to the header might compromise security generally (it appears to only involve the Arduino end?) or whether using the API key was an answer to this problem. I will be interested to hear your comments.

Rob Ward

File: aREST.h
.......
template
void send_http_headers(T client){
client.println(F("HTTP/1.1 200 OK"));
client.println(F("Content-Type: application/json"));
client.println(F("Access-Control-Allow-Origin: *"));
client.println(F("Connection: close"));
client.println();
}

Add support for other HTTP methods

Using methods other than HTTP is crucial in RESTful API.

Please consider adding at least PUT method to your implementation. It would be useful for changing states of the outputs.

Thanks.

The library doesn´t respond to the id or name

Hi!
I'm using the library with 2 Arduinos, each of them connected with an XBee, and I'm accesing the IO, variables and functions from another XBee connected directly to the PC. The problem is when I set the Destination Address of the XBee xonnected to the PC as Broadcast, both of the boards will answer in the same way, no matter if I use the name or ID defined in th REST library.
For example, if I put "serial1/digital/8/1" is the same as "serial2/digital/8/1" and in both case, both boards (the one named "serial1" and the "serial2" will activate pin 8).
This is like this or it's an error?
Thanks and best regards!

Compile error with Adafruit_CC3000 WIFI

See:

$ ino clean && ino build
Searching for Board description file (boards.txt) ... /usr/share/arduino/hardware/arduino/boards.txt
Searching for Arduino lib version file (version.txt) ... /usr/share/arduino/lib/version.txt
Detecting Arduino software version ...  1.0.5 (1.0.5)
Searching for Arduino core library ... /usr/share/arduino/hardware/arduino/cores/arduino
Searching for Arduino standard libraries ... /usr/share/arduino/libraries
Searching for Arduino variants directory ... /usr/share/arduino/hardware/arduino/variants
Searching for make ... /usr/bin/make
Searching for avr-gcc ... /usr/bin/avr-gcc
Searching for avr-g++ ... /usr/bin/avr-g++
Searching for avr-ar ... /usr/bin/avr-ar
Searching for avr-objcopy ... /usr/bin/avr-objcopy
src/sketch.ino
Searching for Arduino lib version file (version.txt) ... /usr/share/arduino/lib/version.txt
Detecting Arduino software version ...  1.0.5 (1.0.5)
Scanning dependencies of src
Scanning dependencies of arduino
Scanning dependencies of SPI
Scanning dependencies of aREST
Scanning dependencies of CC3000_MDNS
Scanning dependencies of Ethernet
Scanning dependencies of Adafruit_CC3000
src/sketch.cpp
Linking libaREST.a
CC3000_MDNS/CC3000_MDNS.cpp
lib/CC3000_MDNS/CC3000_MDNS.cpp: In member function 'bool MDNSResponder::begin(const char*, Adafruit_CC3000&, uint32_t)':
lib/CC3000_MDNS/CC3000_MDNS.cpp:153:22: error: 'AF_INET' was not declared in this scope
     int soc = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
                      ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:153:31: error: 'SOCK_DGRAM' was not declared in this scope
     int soc = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
                               ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:153:43: error: 'IPPROTO_UDP' was not declared in this scope
     int soc = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
                                           ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:158:5: error: 'sockaddr_in' was not declared in this scope
     sockaddr_in address;
     ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:158:17: error: expected ';' before 'address'
     sockaddr_in address;
                 ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:159:13: error: 'address' was not declared in this scope
     memset(&address, 0, sizeof(address));
             ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:161:34: error: 'htons' was not declared in this scope
     address.sin_port = htons(5353);
                                  ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:162:66: error: 'htonl' was not declared in this scope
     address.sin_addr.s_addr = htonl(cc3000.IP2U32(224, 0, 0, 251));
                                                                  ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:163:5: error: 'socklen_t' was not declared in this scope
     socklen_t len = sizeof(address);
     ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:163:15: error: expected ';' before 'len'
     socklen_t len = sizeof(address);
               ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:164:20: error: 'sockaddr' was not declared in this scope
     if (bind(soc, (sockaddr*) &address, sizeof(address)) < 0) {
                    ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:164:29: error: expected primary-expression before ')' token
     if (bind(soc, (sockaddr*) &address, sizeof(address)) < 0) {
                             ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:164:56: error: 'bind' was not declared in this scope
     if (bind(soc, (sockaddr*) &address, sizeof(address)) < 0) {
                                                        ^
lib/CC3000_MDNS/CC3000_MDNS.cpp: In member function 'void MDNSResponder::update()':
lib/CC3000_MDNS/CC3000_MDNS.cpp:178:3: error: 'fd_set' was not declared in this scope
   fd_set reads;
   ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:178:10: error: expected ';' before 'reads'
   fd_set reads;
          ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:179:12: error: 'reads' was not declared in this scope
   FD_ZERO(&reads);
            ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:179:17: error: 'FD_ZERO' was not declared in this scope
   FD_ZERO(&reads);
                 ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:180:29: error: 'FD_SET' was not declared in this scope
   FD_SET(_mdnsSocket, &reads);
                             ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:181:55: error: 'select' was not declared in this scope
   select(_mdnsSocket + 1, &reads, NULL, NULL, &timeout);
                                                       ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:182:36: error: 'FD_ISSET' was not declared in this scope
   if (!FD_ISSET(_mdnsSocket, &reads)) {
                                    ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:188:55: error: cannot convert 'uint8_t (*)[20] {aka unsigned char (*)[20]}' to 'uint8_t* {aka unsigned char*}' for argument '2' to 'int16_t recv(SOCKET, uint8_t*, int16_t)'
   int n = recv(_mdnsSocket, &buffer, sizeof(buffer), 0);
                                                       ^
lib/CC3000_MDNS/CC3000_MDNS.cpp:203:53: error: too many arguments to function 'uint16_t send(SOCKET, const uint8_t*, uint16_t)'
         send(_mdnsSocket, _response, _responseLen, 0);
                                                     ^
In file included from lib/CC3000_MDNS/CC3000_MDNS.h:47:0,
                 from lib/CC3000_MDNS/CC3000_MDNS.cpp:32:
/usr/share/arduino/libraries/Ethernet/utility/socket.h:11:17: note: declared here
 extern uint16_t send(SOCKET s, const uint8_t * buf, uint16_t len); // Send data (TCP)
                 ^
.build/uno/Makefile:43: recipe for target '.build/uno/CC3000_MDNS/CC3000_MDNS.o' failed
make: *** [.build/uno/CC3000_MDNS/CC3000_MDNS.o] Error 1
Make failed with code 2

Size optimizations

We need to fix this. I've calculated that aREST and the functionality it provides adds an addition 8.5KB of space. We need to get this down a lot smaller.

Right now I'm in a situation where the 32KB of Flash the Arduino UNO provides is not enough to power the CC3000 plus provide a somewhat set of RESTful Web API(s).

Error when compiling ESP8266.ino

In file included from ESP8266.ino:10:0:
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:879:24: error: '__FlashStringHelper' does not name a type
 void addToBuffer(const __FlashStringHelper *toAdd){
                        ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:879:45: error: ISO C++ forbids declaration of 'toAdd' with no type [-fpermissive]
 void addToBuffer(const __FlashStringHelper *toAdd){
                                             ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h: In member function 'void aREST::send_http_headers()':
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:132:188: error: 'F' was not declared in this scope
   addToBuffer(F("HTTP/1.1 200 OK\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Methods: POST, GET, PUT, OPTIONS\r\nContent-Type: application/json\r\nConnection: close\r\n\r\n"));
                                                                                                                                                                                            ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h: In member function 'bool aREST::send_command(bool)':
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:528:40: error: 'F' was not declared in this scope
      Serial.println(F("Sending command"));
                                        ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:545:45: error: 'F' was not declared in this scope
        addToBuffer(F("{\"message\": \"Pin D"));
                                             ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:556:58: error: 'F' was not declared in this scope
       if (!LIGHTWEIGHT){addToBuffer(F(" set to input\", "));}
                                                          ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:566:60: error: 'F' was not declared in this scope
        if (!LIGHTWEIGHT){addToBuffer(F(" set to output\", "));}
                                                            ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:581:44: error: 'F' was not declared in this scope
         addToBuffer(F("{\"return_value\": "));
                                            ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:589:44: error: 'F' was not declared in this scope
        if (!LIGHTWEIGHT) {addToBuffer(F("{"));}
                                            ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:599:29: error: 'F' was not declared in this scope
            addToBuffer(F(","));
                             ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:602:31: error: 'F' was not declared in this scope
            addToBuffer(F("\"D"));
                               ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:619:46: error: 'F' was not declared in this scope
         addToBuffer(F("{\"message\": \"Pin D"));
                                              ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:638:44: error: 'F' was not declared in this scope
         addToBuffer(F("{\"return_value\": "));
                                            ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:645:44: error: 'F' was not declared in this scope
        if (!LIGHTWEIGHT) {addToBuffer(F("{"));}
                                            ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:655:29: error: 'F' was not declared in this scope
            addToBuffer(F(","));
                             ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:658:31: error: 'F' was not declared in this scope
            addToBuffer(F("\"A"));
                               ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:673:43: error: 'F' was not declared in this scope
      addToBuffer(F("{\"message\": \"Pin D"));
                                           ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:688:28: error: 'F' was not declared in this scope
         addToBuffer(F("{\""));
                            ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:720:41: error: 'F' was not declared in this scope
      addToBuffer(F("{\"return_value\": "));
                                         ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:732:40: error: 'F' was not declared in this scope
       addToBuffer(F("{\"variables\": {"));
                                        ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:758:24: error: 'F' was not declared in this scope
       addToBuffer(F("{"));
                        ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:764:26: error: 'F' was not declared in this scope
      addToBuffer(F("\r\n"));
                          ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:769:32: error: 'F' was not declared in this scope
      addToBuffer(F("\"id\": \""));
                                ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:777:51: error: 'F' was not declared in this scope
      Serial.print(F("State of buffer at the end: "));
                                                   ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h: In member function 'void aREST::addToBuffer(char*)':
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:839:39: error: 'F' was not declared in this scope
     Serial.print(F("Added to buffer: "));
                                       ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h: In member function 'void aREST::addToBuffer(uint16_t)':
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:853:23: error: 'itoa' was not declared in this scope
   itoa(toAdd,number,10);
                       ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h: In member function 'void aREST::addToBuffer(int)':
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:862:23: error: 'itoa' was not declared in this scope
   itoa(toAdd,number,10);
                       ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h: In member function 'void aREST::sendBuffer(T&, uint8_t, uint8_t)':
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:934:39: error: there are no arguments to 'F' that depend on a template parameter, so a declaration of 'F' must be available [-fpermissive]
         Serial.print(F("Sent buffer: "));
                                       ^
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:934:39: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
ESP8266.ino: In function 'void setup()':
ESP8266.ino:37:43: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
ESP8266.ino:38:37: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
ESP8266.ino:41:33: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
ESP8266.ino:44:18: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
ESP8266.ino:45:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
In file included from ESP8266.ino:10:0:
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h: In instantiation of 'void aREST::sendBuffer(T&, uint8_t, uint8_t) [with T = WiFiClient; uint8_t = unsigned char]':
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:251:27:   required from here
/Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:934:39: error: 'F' was not declared in this scope
         Serial.print(F("Sent buffer: "));
                                       ^
Error compiling.

I think it is about Arduino ESP8266 IDE doesn't support __FlashStringHelper right?

ESP8266WiFi.h: No such file or directory

$ git clone https://github.com/esp8266/Arduino.git
$ cd Arduino/build
$ ant dist
$ ...
$ cd arduino-1.6.1/libraries
$ git clone https://github.com/marcoschwartz/aREST

I got this error : ESP8266.ino:9:25: fatal error: ESP8266WiFi.h: No such file or directory

Connection resets with mobile interfacing

I am using an Arduino Mega with the CC3000 wi-fi board. I have a C# app that communicates with asynchronous get commands flawlessly but any command from the android app I am building or from the browser on the phone causes the connection to reset and have to go through setup again. I had the same problem with the PC app but that resolved when you updated the library recently. Any kind of fix or understanding as to what is going on and why the phone causes a different result would be appreciated. It seems that you offer great support to anyone with a problem and I thank you for that.

toHex function

Hello, I am currently implementing your library and an mDNS library in my project using an ethernet shield allowing me to use arduino.local to access the system. http://youtu.be/RrKxl6FkfMI
I am wondering if it is possible to send other datatypes other than string to the function calls. I am trying to send color values to a neopixel LED using params e.g arduino.local/led?params=0xFF0024. I can do it using the toInt() function and then enter the hex value in decimal but that makes it a little harder. Do you have any suggestions or are you planning to implement this functionality later.

Error when using http://[IP-Adr]/digital/a

If i use the statement http://[IP-Adr]/digital/a to get al digital Values I got a result like this
{"D0": 1, "D1": 1, "D2": 1, "D3": 1, "D4": 1, "D5": 1, "D6": 0, "D7": 1, "D8": 0, "D9": 1, "D10": 1, "D11": 1, "D12": o�ÿ�@�<�8�6�z�nnected": true€

I am using Arduino Nano ATMega328.
After this request the Led L is flickering and I can not contact to Arduino via REST. Ping is working.
Themes that there is a Memory problem.

c_str member error

I was getting this error when compiling some code I wrote implementing the aREST library. I commented the offending line in the library on line 277 and everything works fine. I am thinking it was left behind during your debugging.

In file included from WiFi_CC3000_1.ino:5:
C:\Users\Mech\Desktop\arduino-1.5.1r2\hardware\arduino\avr\libraries\aREST/aREST.h: In member function 'void aREST::handle_proto(T&, bool)':
C:\Users\Mech\Desktop\arduino-1.5.1r2\hardware\arduino\avr\libraries\aREST/aREST.h:277: error: 'class String' has no member named 'c_str'

Missing {

Hello,
Before anything else, thank you for sharing this amazing project! :)

I think I found a missing "{" at the aREST library.

When I use the default url, I mean, without parameters, the JSON answer is missing the first "{".
I think the problem is at line 632, where is the code: addToBuffer(F(""id": ""));
I think it should be: addToBuffer(F("{"id": ""));

Please forgive me if I'm wrong.

Best regards,
Eagler

Web Based aRest doesn`t function after update

Hi... Im using aREST for my Arduino Home Automation project. I have problem with the aREST... previously before i updated the aREST my was project functioning well. But after i updated the library, all my rest function does not respond properly (LED control function and custom functions). After that, i revert back the library to the previous one then its working again.

For now, I revert back to aREST library from v 1.9.8 to v1.9.7 to stable operation.

FYI, Im using Web based to control my Arduino.. Im using the CuRL function.

CORS

Hello,

I've started testing with your library and I really like it.
The only thing that I keep running in to is the CORS issue with my AngularJS webapp.

I'm trying to do a POST to set HIGH a digital pin.

What I already tried is to add headers in the void send_http_headers section:
client.print(F("Access-Control-Allow-Origin: *"));
client.print(F("\r\n"));
client.print(F("Access-Control-Allow-Methods: POST, GET, PUT, OPTIONS"));

But this doesn't seem to work.

Does anyone have an idea to enable CORS?

Thanks!

[Due] avr/wdt.h: No such file or directory

I am trying to build the WiFi_CC3000 example for the Arduino Due but keep running into the following error:

WiFi_CC3000.ino:13:21: fatal error: avr/wdt.h: No such file or directory

I am using the Arduino 1.6.0 IDE on OS X 10.10.2 but have also tried with Arduino 1.5.7 which the guide suggests but also receive the same error.

Thanks.

Large memory consumption for Global Variables (Arduino Mega 2560 Rev3)

Hi there, just to inform you.

i seen you have updated library for the UI fix but now it consumption too large memory space for global variable. From previous version the aRest library only used below 30% of my mega global variables memory but now it consume near 90% of it.

Looking forward for you aRest library fix. TQ

Parameterless function

I am currently implementing some functions to turn on and off multiple devices. Since on and off only requires two states, I do not use the params part of the function. I simply check the last state of the pin and toggle as shown below

int switchCon(String c) {
  int state = !digitalRead(switch3);
  digitalWrite(switch3,state);
  return state;
}

Can you add the option for functions that do not need a parameter.

aREST on the Arduino Ethernet shield is not working

Hi,
I am using the aREST Arduino library It is working fine with Serial example.
I am testing the Ethernet shield example I am getting the IP address (server is at 192.168.1.33
) assigned to my Ethernet shield. But when I try to access the GPIO pins via browser it is not working.

http://192.168.1.33/mode/7/o
http://192.168.1.33/digital/7/1

Error in IE : This page can't be displayed
Error in Chrome : This webpage is not available
ERR_CONNECTION_TIMED_OUT
Am I missing something?
Really appreciate your help.
Regards,
Hemant

Add support for UIPEthernet

Hi,

would you be willing to add support for the UIPEthernet library? It is basically a dropin replacement for the standard Ethernet library. But unfortunately you check for usage of ethernet_h which creates compiler errors at the moment.

You just have to add this peace of code
"/ Handle request for UIPEthernet lib

elif defined(UIPETHERNET_H)

void handle(UIPClient& client){

if (client.available()) {

// Handle request
handle_proto(client,true,0);

// Answer
sendBuffer(client,50,5);
client.stop();  

// Reset variables for the next command
reset_status();   

}
}

I can also create a pull request if you prefer this...

Solved: Error: No Matching function for call to 'aREST::handle(EthernetClient&)'

I tried to compile my code, but this is error keep appearing. I tried it in the IDE 1.5.8 and in the 1.5.7 in a Arduino Mega, and this si what i get:

AM.ino: In function 'void loop()':
AM.ino:49:21: error: no matching function for call to 'aREST::handle(EthernetClient&)'
AM.ino:49:21: note: candidates are:
In file included from AM.ino:1:0:
/Users/ps/Documents/Arduino/libraries/aREST/aREST.h:243:6: note: void aREST::handle(HardwareSerial&)
void handle(HardwareSerial& serial){
^
/Users/ps/Documents/Arduino/libraries/aREST/aREST.h:243:6: note: no known conversion for argument 1 from 'EthernetClient' to 'HardwareSerial&'
/Users/ps/Documents/Arduino/libraries/aREST/aREST.h:259:6: note: void aREST::handle(char_)
void handle(char * string) {
^
/Users/ps/Documents/Arduino/libraries/aREST/aREST.h:259:6: note: no known conversion for argument 1 from 'EthernetClient' to 'char_'

What is happening?

Control by Android

Hi Marcos,

Following up my suggestions to alter the header for the aREST http GET reply, I have since been able to drive it from an App in my Android phone. I have also altered the structure of the json text/db of the reply as well to allow more systematic interrogation of the GET reply.

I am wondering if you might be interested in incorporating these type of features?

Rob

arduinocatdoor

PS My door is going to be a sliding door, that one is just a commercial example.

compilie error by making a WiFi Weather Station With Arduino and the CC3000 chip

I use the example from your website.

on
// Handle REST calls
Adafruit_CC3000_ClientRef client = restServer.available();
rest.handle(client);

i got an error : no matching function for call to 'aRest::handle(Adafruit_CC3000_ClientRef&)'
It looks like : it do not compile at a start at
// Start server
restServer.begin();
displayConnectionDetails();
because i also have an error with that displayConnectionDetails();
the error say, he don´t found it in dht22???

/Users/matthias/Documents/Arduino/libraries/aREST-master/aREST.h:79: error: redefinition of 'class aREST'
/Users/matthias/Documents/Arduino/libraries/aREST-master/aREST.h:79: error: previous definition of 'class aREST'
dht22.ino: In function 'void loop()':
dht22:116: error: no matching function for call to 'aREST::handle(Adafruit_CC3000_ClientRef&)'
/Users/matthias/Documents/Arduino/libraries/aREST-master/aREST.h:242: note: candidates are: void aREST::handle(HardwareSerial&)
/Users/matthias/Documents/Arduino/libraries/aREST-master/aREST.h:258: note: void aREST::handle(char*)

ESP8266 / aREST compile issue "'F' was not declared in this scope"

I am trying to compile the example using the ESP8266 Arduino IDE 1.6.1 and aREST installed as instructed. After selecting generic ESP8266 as the board, I verify and the compilation fails with the following error:

Arduino/libraries/aREST/aREST.h:898:38: error: 'F' was not declared in this scope
Serial.print(F("Sending buffer: "));

Any ideas?

Read all digital, analog and variable values with one request

Hi

I am currently using your library to communicate with openhab via REST
It would be nice if I can get all Data form an arduino ATMega328 with one Request.
Example:
http://[IP]/alldata
returns a complete JSON-String like this
{"alldata":
{"digital":
[{"value":0}],
"digital":
[{"value":1}],
"digital":
[{"value":0}],
"digital":
[{"value":0}],
"digital":
[{"value":1}],
"digital":
[{"value":1}],
"digital":
[{"value":0}],
"digital":
[{"value":1}],
"digital":
[{"value":0}],
"digital":
[{"value":0}],
"digital":
[{"value":1}],
"digital":
[{"value":1}],
"digital":
[{"value":0}],
"analog":
[{"value":100}],
"analog":
[{"value":220}],
"analog":
[{"value":50}],
"analog":
[{"value":80}],
"analog":
[{"value":90}],
"analog":
[{"value":90}],
"variable":
[{"functionname": "temperature", "value":22},
{"functionname": "humidity", "value":95},
{"functionname": "NNN", "value":"Next"}]
}
}

I would be verry happy if you will add this function

Best wishes
Stephan

Python calls to Library

First of all thank you for the libraries and the documentation, they have been very helpful. I have an issue though. I am trying to make rest calls to the CC3000 and it doesn't seem to work even though I can ping it. I have also created my own variables and were able to retrieve them through the URL. EX. http://192.168.0.100/temperature. I want to access it through Python so I tried:

import urllib2
response = urllib2.urlopen('http://python.org/')
html = response.read()
print html

We even tried to output this to a file and retrieve it with a browser and we can't retrieve anything from the CC3000 it just hangs. This python code will work though. We were able to get html pages from the Raspberry Pi web server in this manner.

I know java script might work but I really want to use Kivy with python and retrieve my variables from the CC3000 so I can display them with python. Any help would be appreciated.

[Feature] Extend function calls

Hi,

thanks for this great library. It works quite well even with UIPEthernet instead of Wiznet Ethernet...

Are you still working on extending the capabilities of the function api? I would like to implement the basic REST pattern based on functions but that doesn't seem to work currently.

I would like to do something like this:
http://host/lamp/1/on with a single function instead of defining a function for every lamp and using the "params" to pass the action (on/off).

bug in "functions" handling (read input)

Hi
as soon as the function is identified no other characters are read from input
that results in never arguments are available in the function (so your "led" example is always "0"/LOW)
(As pin_selected and state_selected are set to "true" as soon as the function is identified.)

   // Check if function name is in array
   for (int i = 0; i < functions_index; i++){
     if(answer.startsWith(functions_names[i])) {
       //Serial.println(F("Function found"));

       // End here
       command_selected = true;
       pin_selected = true;
       state_selected = true;

       // Set state
       command = "function";
       value = i;

       // Get command
       int header_length = functions_names[i].length() + 8;
       arguments = answer.substring(header_length);

     }

Compilation Error: conversion from 'String' to 'char*'

Hello,

I am currently working from the Arduino Home Automation Projects book in chapter 1. When I load the following code, I get a compilation error as shown below:

I'm using the IDE 1.5.8 if that helps. Thank you for any guidance.

Code:
// Libraries

include <SPI.h>

include <aREST.h>

// Motion sensor ID
String xbee_id = "2";

// Create ArduREST instance
aREST rest = aREST();

void setup() {

// Start Serial
Serial.begin(9600);

// Give name and ID to device
rest.set_id(xbee_id);
}

void loop() {

// Handle REST calls
rest.handle(Serial);

}

Error Message:
HomeAuto_Chap1_RevA.ino.ino: In function 'void setup()':
HomeAuto_Chap1_RevA.ino.ino:17:22: error: no matching function for call to 'aREST::set_id(String&)'
HomeAuto_Chap1_RevA.ino.ino:17:22: note: candidate is:
In file included from HomeAuto_Chap1_RevA.ino.ino:3:0:
E:\Documents\Arduino\Sketches\libraries\aREST/aREST.h:714:6: note: void aREST::set_id(char_)
void set_id(char *device_id){
^
E:\Documents\Arduino\Sketches\libraries\aREST/aREST.h:714:6: note: no known conversion for argument 1 from 'String' to 'char_'
Error compiling.

Improvement request (VARIABLES/FUNCTIONS limit)

Hi

define NUMBER_VARIABLES 2

define NUMBER_FUNCTIONS 2

I searched a while until I found this limits. It would be easier if these values could set from outside the library like:

ifndef NUMBER_FUNCTIONS

define NUMBER_FUNCTIONS 4

endif

ifndef NUMBER_VARIABLES

define NUMBER_VARIABLES 2

endif

comparing two C strings with ==

Starting on line 274:

    // Check for API key
    if(answer.startsWith("X-ApiKey")) {
      char * received_key;
      strcpy(received_key, answer.substring(10).c_str());

      if (received_key == api_key) {
      api_key_match = true;
        //Serial.println("API key match");
      }

Please excuse me if I'm missing something, I'm brand new to Arduino, but I see two things that at least appear to be problematic with the above code. First, you call strcpy with the destination set as an uninitialized char pointer (received_key), and then you compare two char * strings with == instead of strcmp() or similar. Am I missing something? Or did you mean to use the String types there? Or does the Arduino IDE automagically somehow convert char * to String ?

Arduino Yun http headers

In Arduino Yun handle method, turn headers to false.
YunClient object from YunServer.accept() is not a socket. It's a Stream to http body.

JSON string not returned

I seem to be having a problem with rest variables. I have an arduino mega 2560 set up with a DHT22 sensor. I am having some problems with the JSON string not been returned or incomplete when I call the variable like 192.168.x.x/temperature or 192.168.x.x/humidity. I am using an iPhone with the safari browser. I know the request worked because the connection completed but the screen is blank or sometimes a partial string is returned. I added a delay of 100ms after the variables get the value from the DHT sensor and that helps slightly but still the same problem. I seem to be only able to request the temperature or humidity like once every 15s and the JSON string will be complete.

void setup(){
...  
  rest.variable("temperature",&temperature);
  rest.variable("humidity",&humidity);
  rest.variable("heat_index",&heatIndex);
...
}


void loop() {
  // Handle REST calls
  temperature =dht.readTemperature(1);
  humidity=dht.readHumidity();
  heatIndex = dht.computeHeatIndex(temperature, humidity);

  //fanRpm=rpm();
  //current=currentSense();
  mdns.update();
  Adafruit_CC3000_ClientRef client = restServer.available();
  rest.handle(client);
  delay(5);
  u8g.firstPage();  
  do {
    draw();
  } 
  while( u8g.nextPage() );
  restartWifi();
}

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.