@@ -44,7 +44,7 @@ WiFiClientSecure client;
44
44
Adafruit_MQTT_Client mqtt (&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);
45
45
46
46
// 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" ;
48
48
49
49
/* ***************************** Feeds ***************************************/
50
50
@@ -54,11 +54,6 @@ Adafruit_MQTT_Publish test = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/t
54
54
55
55
/* ************************** Sketch Code ************************************/
56
56
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
-
62
57
void setup () {
63
58
Serial.begin (115200 );
64
59
delay (10 );
@@ -85,8 +80,7 @@ void setup() {
85
80
Serial.println (" IP address: " ); Serial.println (WiFi.localIP ());
86
81
87
82
// check the fingerprint of io.adafruit.com's SSL cert
88
- verifyFingerprint ();
89
-
83
+ client.setFingerprint (fingerprint);
90
84
}
91
85
92
86
uint32_t x=0 ;
@@ -112,28 +106,6 @@ void loop() {
112
106
113
107
}
114
108
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
-
137
109
// Function to connect and reconnect as necessary to the MQTT server.
138
110
// Should be called in the loop function and it will take care if connecting.
139
111
void MQTT_connect () {
0 commit comments