Skip to content

Commit 4a709ff

Browse files
author
brentru
committed
update for a master airlift example
1 parent 4b32850 commit 4a709ff

File tree

4 files changed

+37
-20
lines changed

4 files changed

+37
-20
lines changed

examples/adafruitio_secure_pyportal/adafruitio_secure_pyportal.ino renamed to examples/adafruitio_secure_airlift/adafruitio_secure_airlift.ino

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,42 @@
1-
/***************************************************
2-
Adafruit MQTT Library PyPortal Adafruit IO SSL/TLS Example
1+
/****************************************************************
2+
Adafruit MQTT Library, Adafruit IO SSL/TLS Example for AirLift
33
44
Must use the latest version of nina-fw from:
55
https://github.com/adafruit/nina-fw
66
7-
Adafruit PyPortal: https://www.adafruit.com/product/4116
7+
Works great with Adafruit AirLift ESP32 Co-Processors!
8+
--> https://www.adafruit.com/product/4201
9+
--> https://www.adafruit.com/product/4116
810
911
Adafruit invests time and resources providing this open source code,
1012
please support Adafruit and open-source hardware by purchasing
1113
products from Adafruit!
1214
1315
Written by Brent Rubell for Adafruit Industries.
1416
MIT license, all text above must be included in any redistribution
15-
****************************************************/
17+
*******************************************************************/
18+
1619
#include <WiFiNINA.h>
1720
#include <SPI.h>
21+
22+
// For AirLift Breakout/Wing/Shield: Configure the following to match the ESP32 Pins!
23+
#if !defined(SPIWIFI_SS)
24+
// Don't change the names of these #define's! they match the variant ones
25+
#define SPIWIFI SPI
26+
#define SPIWIFI_SS 11 // Chip select pin
27+
#define SPIWIFI_ACK 10 // a.k.a BUSY or READY pin
28+
#define ESP32_RESETN 9 // Reset pin
29+
#define ESP32_GPIO0 -1 // Not connected
30+
#define SET_PINS 1 // Pins were set using this IFNDEF
31+
#endif
32+
1833
#include "Adafruit_MQTT.h"
1934
#include "Adafruit_MQTT_Client.h"
2035

2136
/************************* WiFi Access Point *********************************/
2237

2338
#define WLAN_SSID "WLAN_SSID"
24-
#define WLAN_PASS "WLAN_PASSWORD"
39+
#define WLAN_PASS "WIFI_PASSWORD"
2540
int keyIndex = 0; // your network key Index number (needed only for WEP)
2641

2742
int status = WL_IDLE_STATUS;
@@ -59,13 +74,17 @@ void setup()
5974
; // wait for serial port to connect. Needed for native USB port only
6075
}
6176

62-
// check for the WiFi module:
63-
if (WiFi.status() == WL_NO_MODULE)
77+
// if the AirLift's pins were defined above...
78+
#ifdef SET_PINS
79+
Serial.println("Setting pins...");
80+
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
81+
#endif
82+
83+
// check for the wifi module
84+
while (WiFi.status() == WL_NO_MODULE)
6485
{
6586
Serial.println("Communication with WiFi module failed!");
66-
// don't continue
67-
while (true)
68-
;
87+
delay(1000);
6988
}
7089

7190
String fv = WiFi.firmwareVersion();
@@ -74,17 +93,15 @@ void setup()
7493
Serial.println("Please upgrade the firmware");
7594
}
7695

77-
// attempt to connect to WiFi network:
78-
while (status != WL_CONNECTED)
96+
// attempt to connect to Wifi network:
97+
Serial.print("Attempting to connect to SSID: ");
98+
Serial.println(WLAN_SSID);
99+
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
100+
do
79101
{
80-
Serial.print("Attempting to connect to WLAN_SSID: ");
81-
Serial.println(WLAN_SSID);
82-
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
83102
status = WiFi.begin(WLAN_SSID, WLAN_PASS);
84-
85-
// wait 10 seconds for connection:
86-
delay(10000);
87-
}
103+
delay(100); // wait until connected
104+
} while (status != WL_CONNECTED);
88105
Serial.println("Connected to wifi");
89106
printWiFiStatus();
90107
}

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.0
2+
version=1.0.1
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)