Git Product home page Git Product logo

arduino-restclient's Introduction

WiFi RestClient for Arduino

HTTP Request library for Arduino and the WiFi shield. I modified the original Ethernet-only version to use on Intel Edison, should work fine with other Arduino WiFi devices though.

I think aJSON would be really helpful to integrate as a next step.

Install

Clone (or download and unzip) the repository to ~/Documents/Arduino/libraries where ~/Documents/Arduino is your sketchbook directory.

> cd ~/Documents/Arduino
> mkdir libraries
> cd libraries
> git clone https://github.com/rexstjohn/arduino-restclient.git RestClient

Usage

Include

You need to have the WiFi library already included.

#include <WiFi.h>
#include <SPI.h>
#include "RestClient.h"

RestClient(host/ip, [port])

Constructor to create an RestClient object to make requests against.

Use domain name and default to port 80, add your WiFi SSID and password:

RestClient client = RestClient("google.com", SSID, PW);

connect()

Sets up WiFiClient using the provided SSID and PW

  client.connect()

Note: you can have multiple RestClient objects but only need to call this once.

Note: if you have multiple Arduinos on the same network, you'll need to give each one a different mac address.

begin(char* ssid, char *pw)

It just wraps the WiFiClient call to begin and connects.

RESTful methods

All methods return an HTTP status code or 0 if there was an error.

get(const char* path)

get(const char* path, String* response)

Start making requests!

int statusCode = client.get("/"));

Pass in a string by reference for the response:

String response = "";
int statusCode = client.get("/", &response);

post(const char* path, const char* body)

post(const char* path, String* response)

post(const char* path, const char* body, String* response)

String response = "";
int statusCode = client.post("/", &response);
statusCode = client.post("/", "foo=bar");
response = "";
statusCode = client.post("/", "foo=bar", &response);

put(const char* path, const char* body)

put(const char* path, String* response)

put(const char* path, const char* body, String* response)

String response = "";
int statusCode = client.put("/", &response);
statusCode = client.put("/", "foo=bar");
response = "";
statusCode = client.put("/", "foo=bar", &response);

del(const char* path)

del(const char* path, const char* body)

del(const char* path, String* response)

del(const char* path, const char* body, String* response)

String response = "";
int statusCode = client.del("/", &response);

arduino-restclient's People

Contributors

csquared avatar ianmercer avatar rexsaurus avatar

Watchers

 avatar  avatar

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.