Skip to content

Commit

Permalink
Merge pull request #156 from brentru/patch-esp-bsp-2-5-1
Browse files Browse the repository at this point in the history
Fixing example for ESP8266 (BSP 2.5.1)
  • Loading branch information
brentru authored May 20, 2019
2 parents bfdece4 + 4caf05c commit 3693eb8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 31 deletions.
32 changes: 2 additions & 30 deletions examples/adafruitio_secure_esp8266/adafruitio_secure_esp8266.ino
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ WiFiClientSecure client;
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);

// io.adafruit.com SHA1 fingerprint
const char *fingerprint = "77 00 54 2D DA E7 D8 03 27 31 23 99 EB 27 DB CB A5 4C 57 18";
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";

/****************************** Feeds ***************************************/

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

/*************************** Sketch Code ************************************/

// Bug workaround for Arduino 1.6.6, it seems to need a function declaration
// for some reason (only affects ESP8266, likely an arduino-builder bug).
void MQTT_connect();
void verifyFingerprint();

void setup() {
Serial.begin(115200);
delay(10);
Expand All @@ -85,8 +80,7 @@ void setup() {
Serial.println("IP address: "); Serial.println(WiFi.localIP());

// check the fingerprint of io.adafruit.com's SSL cert
verifyFingerprint();

client.setFingerprint(fingerprint);
}

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

}


void verifyFingerprint() {

const char* host = AIO_SERVER;

Serial.print("Connecting to ");
Serial.println(host);

if (! client.connect(host, AIO_SERVERPORT)) {
Serial.println("Connection failed. Halting execution.");
while(1);
}

if (client.verify(fingerprint, host)) {
Serial.println("Connection secure.");
} else {
Serial.println("Connection insecure! Halting execution.");
while(1);
}

}

// Function to connect and reconnect as necessary to the MQTT server.
// Should be called in the loop function and it will take care if connecting.
void MQTT_connect() {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Adafruit MQTT Library
version=1.0.1
version=1.0.3
author=Adafruit
maintainer=Adafruit <[email protected]>
sentence=MQTT library that supports the FONA, ESP8266, Yun, and generic Arduino Client hardware.
Expand Down

0 comments on commit 3693eb8

Please sign in to comment.