Skip to content

Commit cbc7901

Browse files
committed
merged conflicts
1 parent bce6bfa commit cbc7901

File tree

3 files changed

+39
-23
lines changed

3 files changed

+39
-23
lines changed

adafruit_esp32spi/adafruit_esp32spi_wifimanager.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
# pylint: disable=no-name-in-module
3333

34+
from time import sleep
3435
from micropython import const
3536
from adafruit_esp32spi import adafruit_esp32spi
3637
import adafruit_esp32spi.adafruit_esp32spi_requests as requests
@@ -42,6 +43,7 @@ class ESPSPI_WiFiManager:
4243
NORMAL = const(1)
4344
ENTERPRISE = const(2)
4445

46+
# pylint: disable=too-many-arguments
4547
def __init__(self, esp, secrets, status_pixel=None, attempts=2, connection_type=NORMAL):
4648
"""
4749
:param ESP_SPIcontrol esp: The ESP object we are using
@@ -59,16 +61,27 @@ def __init__(self, esp, secrets, status_pixel=None, attempts=2, connection_type=
5961
self.debug = False
6062
self.ssid = secrets['ssid']
6163
self.password = secrets['password']
62-
self.ent_ssid = secrets['ent_ssid']
63-
self.ent_ident = secrets['ent_ident']
64-
self.ent_user = secrets['ent_user']
65-
self.ent_password = secrets['ent_password']
6664
self.attempts = attempts
6765
self._connection_type = connection_type
6866
requests.set_interface(self.esp)
6967
self.statuspix = status_pixel
7068
self.pixel_status(0)
7169

70+
# Check for WPA2 Enterprise keys in the secrets dictionary and load them if they exist
71+
if secrets.get('ent_ssid'):
72+
self.ent_ssid = secrets['ent_ssid']
73+
else:
74+
self.ent_ssid = secrets['ssid']
75+
if secrets.get('ent_ident'):
76+
self.ent_ident = secrets['ent_ident']
77+
else:
78+
self.ent_ident = ''
79+
if secrets.get('ent_user'):
80+
self.ent_user = secrets['ent_user']
81+
if secrets.get('ent_password'):
82+
self.ent_password = secrets['ent_password']
83+
# pylint: enable=too-many-arguments
84+
7285
def reset(self):
7386
"""
7487
Perform a hard reset on the ESP32

examples/esp32spi_wpa2ent_aio_post.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@
1515
print("WiFi secrets are kept in secrets.py, please add them there!")
1616
raise
1717

18-
# If you are using a board with pre-defined ESP32 Pins:
19-
esp32_cs = DigitalInOut(board.ESP_CS)
20-
esp32_ready = DigitalInOut(board.ESP_BUSY)
21-
esp32_reset = DigitalInOut(board.ESP_RESET)
22-
23-
# If you have an externally connected ESP32:
24-
# esp32_cs = DigitalInOut(board.D9)
25-
# esp32_ready = DigitalInOut(board.D10)
26-
# esp32_reset = DigitalInOut(board.D5)
18+
# ESP32 setup
19+
# If your board does define the three pins listed below,
20+
# you can set the correct pins in the second block
21+
try:
22+
esp32_cs = DigitalInOut(board.ESP_CS)
23+
esp32_ready = DigitalInOut(board.ESP_BUSY)
24+
esp32_reset = DigitalInOut(board.ESP_RESET)
25+
except AttributeError:
26+
esp32_cs = DigitalInOut(board.D9)
27+
esp32_ready = DigitalInOut(board.D10)
28+
esp32_reset = DigitalInOut(board.D5)
2729

2830
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
2931
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)

examples/esp32spi_wpa2ent_simpletest.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ def normalize(v):
2525

2626
print("ESP32 SPI WPA2 Enterprise test")
2727

28-
# For running on the PyPortal, use this block
29-
esp32_cs = DigitalInOut(board.ESP_CS)
30-
esp32_ready = DigitalInOut(board.ESP_BUSY)
31-
esp32_reset = DigitalInOut(board.ESP_RESET)
32-
33-
# For a board that doesn't have the ESP pin definitions, use this block and
34-
# set the pins as needed.
35-
#esp32_cs = DigitalInOut(board.D8)
36-
#esp32_ready = DigitalInOut(board.D5)
37-
#esp32_reset = DigitalInOut(board.D7)
28+
# ESP32 setup
29+
# If your board does define the three pins listed below,
30+
# you can set the correct pins in the second block
31+
try:
32+
esp32_cs = DigitalInOut(board.ESP_CS)
33+
esp32_ready = DigitalInOut(board.ESP_BUSY)
34+
esp32_reset = DigitalInOut(board.ESP_RESET)
35+
except AttributeError:
36+
esp32_cs = DigitalInOut(board.D9)
37+
esp32_ready = DigitalInOut(board.D10)
38+
esp32_reset = DigitalInOut(board.D5)
3839

3940
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
4041
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)

0 commit comments

Comments
 (0)