@@ -44,7 +44,7 @@ WiFiClientSecure client;
4444Adafruit_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-
6257void 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
9286uint32_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.
139111void MQTT_connect () {
0 commit comments