Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to `RestClient::begin(unsigned char*) #17

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
62 changes: 15 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# RestClient for Arduino
# RestClient for Arduino ESP8266 WiFi modules

HTTP Request library for Arduino and the Ethernet shield.
HTTP Request library for Arduino and the ESP8266 WiFi SOC modules

This library now supports SSL! To use with SSL, you need to include the SHA1 fingerprint of the certificate of the site you are connecting to. You can get this by using a desktop browser and inspecting the SSL cert used at the site. Please note: this is FRAGILE, if the site updates their SSL, your code will break. But, there is not enough memory on the ESP8266 to store all the rool certs, so this is a working method. Se the example below.

This library is derived almost entirely from the great work done here: https://github.com/csquared/arduino-restclient

# Install

Expand All @@ -10,19 +14,13 @@ where `~/Documents/Arduino` is your sketchbook directory.
> cd ~/Documents/Arduino
> mkdir libraries
> cd libraries
> git clone https://github.com/csquared/arduino-restclient.git RestClient
> git clone https://github.com/dakaz/esp8266-restclient.git RestClient

# Usage

### Include

You need to have the `Ethernet` library already included.

```c++
#include <Ethernet.h>
#include <SPI.h>
#include "RestClient.h"
```
You need to have the `ESP8266` board support already included.

### RestClient(host/ip, [port])

Expand All @@ -38,50 +36,20 @@ Use a local IP and an explicit port:
RestClient client = RestClient("192.168.1.50",5000);
```

### dhcp()

Sets up `EthernetClient` with a mac address of `DEADBEEFFEED`. Returns `true` or `false` to indicate if setting up DHCP
was successful or not

```c++
client.dhcp()
```

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(byte mac[])

It just wraps the `EthernetClient` call to `begin` and DHCPs.
Use this if you need to explicitly set the mac address.

Use a local IP, an explicit port to an SSL site and (must include the 1 to turn on SSL):
```c++
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
if (client.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
}
RestClient client = RestClient("www.kudoso.com",443, 1);
```

### Manual Ethernet Setup

You can skip the above methods and just configure the EthernetClient yourself:

Use a local IP, an explicit port to an SSL site and verify the certificate with its fingerprint:
```c++
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//the IP address for the shield:
byte ip[] = { 192, 168, 2, 11 };
Ethernet.begin(mac,ip);
RestClient client = RestClient("www.kudoso.com",443, "EE 16 77 79 55 58 92 46 FB 18 40 99 2E 17 7E AB 32 0A 4A 88");
```

```c++
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
Ethernet.begin(mac);
```
### dhcp()

This is especially useful for debugging network connection issues.
Sets up `EthernetClient` with a mac address of `DEADBEEFFEED`. Returns `true` or `false` to indicate if setting up DHCP
was successful or not

## RESTful methods

Expand Down
Loading