You've already forked Adafruit_MQTT_Library
							
							
				mirror of
				https://github.com/adafruit/Adafruit_MQTT_Library.git
				synced 2025-11-03 11:53:11 +03:00 
			
		
		
		
	Merge pull request #156 from brentru/patch-esp-bsp-2-5-1
Fixing example for ESP8266 (BSP 2.5.1)
This commit is contained in:
		@@ -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 ***************************************/
 | 
			
		||||
 | 
			
		||||
@@ -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);
 | 
			
		||||
@@ -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;
 | 
			
		||||
@@ -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() {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
name=Adafruit MQTT Library
 | 
			
		||||
version=1.0.1
 | 
			
		||||
version=1.0.3
 | 
			
		||||
author=Adafruit
 | 
			
		||||
maintainer=Adafruit <info@adafruit.com>
 | 
			
		||||
sentence=MQTT library that supports the FONA, ESP8266, Yun, and generic Arduino Client hardware.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user