Skip to content

Commit 3693eb8

Browse files
authored
Merge pull request #156 from brentru/patch-esp-bsp-2-5-1
Fixing example for ESP8266 (BSP 2.5.1)
2 parents bfdece4 + 4caf05c commit 3693eb8

File tree

2 files changed

+3
-31
lines changed

2 files changed

+3
-31
lines changed

examples/adafruitio_secure_esp8266/adafruitio_secure_esp8266.ino

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ WiFiClientSecure client;
4444
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);
4545

4646
// io.adafruit.com SHA1 fingerprint
47-
const char *fingerprint = "77 00 54 2D DA E7 D8 03 27 31 23 99 EB 27 DB CB A5 4C 57 18";
47+
static const char *fingerprint PROGMEM = "77 00 54 2D DA E7 D8 03 27 31 23 99 EB 27 DB CB A5 4C 57 18";
4848

4949
/****************************** Feeds ***************************************/
5050

@@ -54,11 +54,6 @@ Adafruit_MQTT_Publish test = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/t
5454

5555
/*************************** Sketch Code ************************************/
5656

57-
// Bug workaround for Arduino 1.6.6, it seems to need a function declaration
58-
// for some reason (only affects ESP8266, likely an arduino-builder bug).
59-
void MQTT_connect();
60-
void verifyFingerprint();
61-
6257
void setup() {
6358
Serial.begin(115200);
6459
delay(10);
@@ -85,8 +80,7 @@ void setup() {
8580
Serial.println("IP address: "); Serial.println(WiFi.localIP());
8681

8782
// check the fingerprint of io.adafruit.com's SSL cert
88-
verifyFingerprint();
89-
83+
client.setFingerprint(fingerprint);
9084
}
9185

9286
uint32_t x=0;
@@ -112,28 +106,6 @@ void loop() {
112106

113107
}
114108

115-
116-
void verifyFingerprint() {
117-
118-
const char* host = AIO_SERVER;
119-
120-
Serial.print("Connecting to ");
121-
Serial.println(host);
122-
123-
if (! client.connect(host, AIO_SERVERPORT)) {
124-
Serial.println("Connection failed. Halting execution.");
125-
while(1);
126-
}
127-
128-
if (client.verify(fingerprint, host)) {
129-
Serial.println("Connection secure.");
130-
} else {
131-
Serial.println("Connection insecure! Halting execution.");
132-
while(1);
133-
}
134-
135-
}
136-
137109
// Function to connect and reconnect as necessary to the MQTT server.
138110
// Should be called in the loop function and it will take care if connecting.
139111
void MQTT_connect() {

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit MQTT Library
2-
version=1.0.1
2+
version=1.0.3
33
author=Adafruit
44
maintainer=Adafruit <info@adafruit.com>
55
sentence=MQTT library that supports the FONA, ESP8266, Yun, and generic Arduino Client hardware.

0 commit comments

Comments
 (0)