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

Issue after adding aws-sdk-arduino-esp8266 version 1.0 to Arduino IDE #2

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6972483
Small bugfix in filenames (case sensitive...), added files for 1.5-co…
Schm1tz1 Jul 2, 2017
949502b
Added example.
Schm1tz1 Jul 2, 2017
9572128
Bugfix in example. Static buffer needed...
Schm1tz1 Jul 2, 2017
c731a23
Update library.properties
Schm1tz1 Jul 2, 2017
d67b585
Update library.properties
Schm1tz1 Jul 2, 2017
e000bd9
Off-by-one array index resulting in buffer overflow
jonathanschoeller Dec 15, 2017
0ffaa48
Update AmazonDynamoDBClient.cpp
brainstain Dec 31, 2017
ed87571
Update ESP8266AWSImplentations.cpp
brainstain Dec 31, 2017
f92f41e
Merge pull request #1 from jonathanschoeller/master
Schm1tz1 Jan 1, 2018
2025b0f
Merge pull request #2 from brainstain/master
Schm1tz1 Jan 1, 2018
e9e5eb7
Initial commit for ESP8266 and ESP32
Burt-Silverman May 9, 2018
15da837
Remove some conditional ESP32/ESP8266 code
Burt-Silverman May 10, 2018
303fce3
Minor changes to suport ARCH_SAM and ARCH_SAMD
Burt-Silverman Jun 6, 2018
c441b94
Mention ARDUINO_ARCH_SAM and ARDUINO_ARCH_SAMD
Burt-Silverman Jun 6, 2018
640703b
Merge pull request #3 from Burt-Silverman/master
Schm1tz1 Jun 6, 2018
7add825
Update library.json
Schm1tz1 Jun 6, 2018
a6beace
Update library.properties
Schm1tz1 Jun 6, 2018
a36a643
Add get_shadow()
debsahu Jul 1, 2018
494c6cb
Update AmazonIOTClient.h
Schm1tz1 Jul 2, 2018
0090907
Merge pull request #4 from debsahu/master
Schm1tz1 Jul 2, 2018
b2a85e3
Use a single tab field separator in keywords.txt
per1234 Jul 15, 2018
daa7607
Merge pull request #5 from per1234/keywords_txt-multiple-tabs
Schm1tz1 Jul 27, 2018
f150efc
Update README.md
Schm1tz1 Aug 22, 2018
9dabe49
Revert library name change
per1234 May 13, 2021
39d80d2
Merge pull request #6 from per1234/revert-name
Schm1tz1 May 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
# Version 1 of the Experimental AWS SDK for Arduino
# Experimental AWS SDK for Arduino

An experimental SDK for contacting AWS Services on Arduino-compatible devices. Currently it supports Amazon DynamoDB, Amazon Kinesis and Amazon SNS. More services coming soon.
An experimental SDK for contacting AWS Services on Arduino-compatible devices. Currently it supports Amazon DynamoDB, Amazon Kinesis, Amazon IOT and Amazon SNS. More services coming soon.

All Amazon DynamoDB operations are supported. The code for creating, serializing, and deserializing Kinesis input and output objects is included, but the devices that the experimental SDK has been tested on do not have readily available HTTPS support. This code has been included so it can be used by those who want to do further experimenting with Kinesis and HTTPS.

The SDK is extensible to non-Arduino-compatible devices by implementing the interfaces in `DeviceIndependentInterfaces.cpp`/`.h`. See `SparkAWSImplementations.cpp`/`.h` and `EdisonAWSImplementations.cpp`/`.h` for examples of this.

## Folder Structure

* /common contains all the common source code
* /sparkcore contains Spark IO Core device-specific implementations
* /edison contains Intel Edison device-specfic implementations
* /galileo contains Intel Galileo device-specific implementations
* /mediatek contains MediaTek LinkIt One device-specific implementations


Depending on the device that you are working, Simply copy the those device-specific implementations to the Common directory so you can test out your samples using Arduino IDE.
* /src contains all the common source code

Happy experimenting!

Expand Down Expand Up @@ -145,17 +138,18 @@ For Galileo/Edison, after the wiring is finished, you should be able to connect

For Spark, after the wiring is finished, you should be able to connect it to your computer via USB, and *Flash* the code. Be sure to refer to the comments in the samples for help.

#### ESP8266
#### ESP8266 and ESP32

You can use these libraries with the [Arduino ESP8266](https://github.com/esp8266/arduino):.
You can use these libraries with the [Arduino ESP8266](https://github.com/esp8266/arduino) or ESP32: or ARDUINO_ARCH_SAM or ARDUINO_ARCH_SAMD.

```
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <HTTPClient.h> //ESP32 case
#include <AmazonIOTClient.h>
#include "Esp8266AWSImplementations.h"
#include "EspAWSImplementations.h"

Esp8266HttpClient httpClient;
Esp8266DateTimeProvider dateTimeProvider;
EspHttpClient httpClient;
EspDateTimeProvider dateTimeProvider;

AmazonIOTClient iotClient;
ActionError actionError;
Expand Down
50 changes: 50 additions & 0 deletions examples/SimpleExample/SimpleExample.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <AmazonIOTClient.h>
#include "ESPAWSImplementations.h"

EspHttpClient httpClient;
EspDateTimeProvider dateTimeProvider;

AmazonIOTClient iotClient;
ActionError actionError;

const char *ssid="MySSID";
const char *password="MyPASS";

void setup() {
Serial.begin(115200);
delay(10);

// Connect to WAP
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());

iotClient.setAWSRegion("eu-west-1");
iotClient.setAWSEndpoint("amazonaws.com");
iotClient.setAWSDomain("foobar.iot.eu-west-1.amazonaws.com");
iotClient.setAWSPath("/things/example-1/shadow");
iotClient.setAWSKeyID("ID");
iotClient.setAWSSecretKey("SECRET");
iotClient.setHttpClient(&httpClient);
iotClient.setDateTimeProvider(&dateTimeProvider);
}

void loop(){

const char* shadow = "{\"state\":{\"reported\": {\"foobar\": \"bar\"}}}";
const char* result = iotClient.update_shadow(shadow, actionError);

Serial.print(result);

delay(60000);
}

7 changes: 7 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Amazon KEYWORD1
AWS KEYWORD2
IoT KEYWORD3
ESP8266 KEYWORD4
ESP32 KEYWORD5
SAM KEYWORD6
SAMD KEYWORD7
13 changes: 13 additions & 0 deletions library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "AWS-SDK-ESP by Schm1tz1 modified by Burt-Silverman",
"keywords": "AWS, SDK, ESP8266, ESP32, IoT, SAM, SAMD",
"description": "SDK for accessing AWS IoT services with many devices.",
"repository":
{
"type": "git",
"url": "https://github.com/Schm1tz1/aws-sdk-arduino-esp8266"
},
"frameworks": "arduino",
"platforms": "*"
}

9 changes: 9 additions & 0 deletions library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=AWS-SDK-ESP
version=0.9.1-beta
author=Roman Schmitz <[email protected]>, Burt Silverman <[email protected]>
maintainer=Roman Schmitz <[email protected]>
sentence=An SDK for AWS using ESP8266, ESP32, SAM, or SAMD SOCs.
paragraph=This library is based on the code by awslabs, svdgraaf and fuzzyhandle. It enables you to easily use AWS IoT Services from an ESP8266 or ESP32 or SAM or SAMD device with Arduino. There are some great tutorials and projects on the web; also check YoutTube and my GitHub-Pages for examples. As I will be using this system quite often, I will try to keep it up-to-date and contribute to the arduino libraries. Feel free to contribute to this code - fork, add your stuff, change things and create pull requests.
category=Communication
url=https://github.com/Schm1tz1/aws-sdk-arduino-esp8266
architectures=*
6 changes: 3 additions & 3 deletions src/AWSClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ char* AWSClient::createRequest(MinimalString &reqPayload) {
return request;
}

char* AWSClient::createCurlRequest(MinimalString &reqPayload) {
const char* AWSClient::createCurlRequest(MinimalString &reqPayload) {
/* Check that all values have been initialized. */
if (awsRegion == 0 || awsEndpoint == 0 || awsSecKey == 0 || awsKeyID == 0
|| httpClient == 0 || dateTimeProvider == 0)
Expand All @@ -345,12 +345,12 @@ char* AWSClient::createCurlRequest(MinimalString &reqPayload) {
return request;
}

char* AWSClient::sendData(const char* data) {
const char* AWSClient::sendData(const char* data) {
char* server = new char[strlen(awsService) + strlen(awsRegion)
+ strlen(awsEndpoint) + 4]();
sprintf(server, "%s.%s.%s", awsService, awsRegion, awsEndpoint);
int port = httpS ? 443 : 80;
char* response = httpClient->send(data, server, port);
const char* response = httpClient->send(data, server, port);
delete[] server;
return response;
}
4 changes: 2 additions & 2 deletions src/AWSClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ class AWSClient {
/* Creates a http request in curl format, given the payload and current GMT
* date in yyyyMMddHHmmss format. Should be exposed to user by extending
* class. Returns 0 if client is unititialized. */
char* createCurlRequest(MinimalString &payload);
const char* createCurlRequest(MinimalString &payload);
/* Sends http data. Returns http response, or null on error. */
char* sendData(const char* data);
const char* sendData(const char* data);
/* Empty constructor. Must also be initialized with init. */
AWSClient();

Expand Down
5 changes: 2 additions & 3 deletions src/AWSClient2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ static const char* CONTENT_LENGTH_HEADER = "content-length:%d";
static const int CONTENT_LENGTH_HEADER_LEN = 15;
static const char* HOST_HEADER = "host:%s.%s.%s";
static const int HOST_HEADER_LEN = 7;
static const char* CONNECTION_HEADER = "Connection:close";
static const int CONNECTION_HEADER_LEN = 16;
static const char* CONTENT_TYPE_HEADER = "content-type:%s";
static const int CONTENT_TYPE_HEADER_LEN = 13;
Expand Down Expand Up @@ -287,12 +286,12 @@ char* AWSClient2::createRequest(MinimalString &reqPayload) {
return request;
}

char* AWSClient2::sendData(const char* data) {
const char* AWSClient2::sendData(const char* data) {
char* server = new char[strlen(awsService) + strlen(awsRegion)
+ strlen(awsEndpoint) + 4]();
sprintf(server, "%s.%s.%s", awsService, awsRegion, awsEndpoint);
int port = httpS ? 443 : 80;
char* response = httpClient->send(data, server, port);
const char* response = httpClient->send(data, server, port);
delete[] server;
return response;
}
2 changes: 1 addition & 1 deletion src/AWSClient2.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class AWSClient2 {
* Returns 0 if client is unititialized. */
char* createRequest(MinimalString &payload);
/* Sends http data. Returns http response, or null on error. */
char* sendData(const char* data);
const char* sendData(const char* data);
/* Empty constructor. Must also be initialized with init. */
AWSClient2();

Expand Down
Loading