Skip to content

Commit f453d38

Browse files
committed
added initial support for ESP32
1 parent 3d8d5ce commit f453d38

File tree

5 files changed

+115
-2
lines changed

5 files changed

+115
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ It supports multiple network interfaces like Ethernet, Wifi, and GSM. So you can
99
* Arduino Yun
1010
* Arduino MKR1000 (With SSL/TLS)
1111
* Any ESP8266 variant like NodeMCU
12+
* ESP32
1213
* Texas Instruments CC3200
1314
* SeeedStudio LinkIt ONE (Both GPRS and WiFi)
1415

examples/ESP32/ESP32.ino

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <WiFi.h>
2+
#include <ThingerESP32.h>
3+
4+
#define USERNAME "your_user_name"
5+
#define DEVICE_ID "your_device_id"
6+
#define DEVICE_CREDENTIAL "your_device_credential"
7+
8+
#define SSID "your_wifi_ssid"
9+
#define SSID_PASSWORD "your_wifi_ssid_password"
10+
11+
// define your board pin here
12+
#define LED_PIN 16
13+
14+
ThingerESP32 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
15+
16+
void setup() {
17+
pinMode(LED_PIN, OUTPUT);
18+
19+
thing.add_wifi(SSID, SSID_PASSWORD);
20+
21+
// digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
22+
thing["led"] << digitalPin(LED_PIN);
23+
24+
// resource output example (i.e. reading a sensor value)
25+
thing["millis"] >> outputValue(millis());
26+
27+
// more details at http://docs.thinger.io/arduino/
28+
}
29+
30+
void loop() {
31+
thing.handle();
32+
}

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=thinger.io
2-
version=2.5.7
2+
version=2.5.8
33
author=Alvaro Luis Bustamante <[email protected]>
44
maintainer=Thinger.io <[email protected]>
55
sentence=Arduino library for the Thinger.io Internet of Things Platform.
6-
paragraph=Thinger.io is an open source platform for the Internet of Things. It will allow connecting your things or devices for remote sensing and actuating. Working with several devices like ESP8266, Arduino Ethernet, Arduino Wifi, Arduino MKR1000, Arduino Yun, Adafruit CC3000, Texas Instruments CC3200, ENC28J60, LinkIt ONE.
6+
paragraph=Thinger.io is an open source platform for the Internet of Things. It will allow connecting your things or devices for remote sensing and actuating. Working with several devices like ESP8266, ESP32, Arduino Ethernet, Arduino Wifi, Arduino MKR1000, Arduino Yun, Adafruit CC3000, Texas Instruments CC3200, ENC28J60, LinkIt ONE.
77
category=Communication
88
url=https://github.com/thinger-io/Arduino-Library
99
architectures=*

src/ThingerClient.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,11 @@ bool inverted_digital_pin(protoson::pson& in, int pin, bool& current_state){
342342
}
343343
#endif
344344

345+
/*
346+
* TODO ESP32 library does not implement analogWrite yet
347+
*/
348+
349+
#ifndef ESP32
345350
void analog_pin(protoson::pson& in, int pin){
346351
static int current = in;
347352
if(in.is_empty()){
@@ -352,6 +357,7 @@ void analog_pin(protoson::pson& in, int pin){
352357
analogWrite(pin, current);
353358
}
354359
}
360+
#endif
355361

356362
/**
357363
* AVR and ESP8266 supports reading the PIN state event if they are of output type. So they

src/ThingerESP32.h

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// The MIT License (MIT)
2+
//
3+
// Copyright (c) 2017 THINK BIG LABS SL
4+
// Author: [email protected] (Alvaro Luis Bustamante)
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
23+
24+
#ifndef THINGER_ESP32_H
25+
#define THINGER_ESP32_H
26+
27+
#include "ThingerWifi.h"
28+
29+
/*
30+
* TODO ESP32 library does not contain a WiFiClientSecure client yet, so disable TLS by default
31+
* https://github.com/espressif/arduino-esp32/issues/101
32+
*/
33+
#define _DISABLE_TLS_
34+
#ifndef _DISABLE_TLS_
35+
class ThingerESP32 : public ThingerWifiClient<WiFiClientSecure>{
36+
#else
37+
class ThingerESP32 : public ThingerWifiClient<WiFiClient>{
38+
#endif
39+
40+
public:
41+
ThingerESP32(const char* user, const char* device, const char* device_credential) :
42+
ThingerWifiClient(user, device, device_credential)
43+
{}
44+
45+
~ThingerESP32(){
46+
47+
}
48+
49+
#ifndef _DISABLE_TLS_
50+
protected:
51+
virtual bool connect_socket(){
52+
if(client_.connect(THINGER_SERVER, THINGER_SSL_PORT)){
53+
if(client_.verify(THINGER_TLS_FINGERPRINT, THINGER_TLS_HOST)){
54+
#ifdef _DEBUG_
55+
THINGER_DEBUG("_SOCKET", "SSL/TLS Host Verification Succeed!");
56+
#endif
57+
}else{
58+
#ifdef _DEBUG_
59+
THINGER_DEBUG("_SOCKET", "SSL/TLS Host Verification Error!");
60+
#endif
61+
}
62+
return true;
63+
}
64+
return false;
65+
}
66+
67+
virtual bool secure_connection(){
68+
return true;
69+
}
70+
#endif
71+
72+
};
73+
74+
#endif

0 commit comments

Comments
 (0)