36
36
from adafruit_esp32spi import adafruit_esp32spi
37
37
import adafruit_esp32spi .adafruit_esp32spi_requests as requests
38
38
39
- class WiFiConnType : # pylint: disable=too-few-public-methods
40
- """An enum-like class representing the different types of WiFi connections
41
- that can be made. The values can be referenced like ``WiFiConnType.normal``.
42
- Possible values are
43
- - ``ThermocoupleType.normal``
44
- - ``ThermocoupleType.enterprise``
45
- """
46
- # pylint: disable=invalid-name
47
- normal = 1
48
- enterprise = 2
49
-
50
39
class ESPSPI_WiFiManager :
51
40
"""
52
41
A class to help manage the Wifi connection
@@ -75,7 +64,7 @@ def __init__(self, esp, secrets, status_pixel=None, attempts=2, connection_type=
75
64
self .ent_ssid = secrets ['ent_ssid' ]
76
65
self .ent_ident = secrets ['ent_ident' ]
77
66
self .ent_user = secrets ['ent_user' ]
78
- self .ent_passwd = secrets ['ent_passwd ' ]
67
+ self .ent_password = secrets ['ent_password ' ]
79
68
self .attempts = attempts
80
69
self ._connection_type = connection_type
81
70
requests .set_interface (self .esp )
@@ -128,12 +117,12 @@ def connect_normal(self):
128
117
Attempt a regular style WiFi connection
129
118
"""
130
119
failure_count = 0
131
- while not self .esp .is_connected :
120
+ while not self ._esp .is_connected :
132
121
try :
133
122
if self .debug :
134
123
print ("Connecting to AP..." )
135
124
self .pixel_status ((100 , 0 , 0 ))
136
- self .esp .connect_AP (bytes (self .ssid , 'utf-8' ), bytes (self .password , 'utf-8' ))
125
+ self ._esp .connect_AP (bytes (self .ssid , 'utf-8' ), bytes (self .password , 'utf-8' ))
137
126
failure_count = 0
138
127
self .pixel_status ((0 , 100 , 0 ))
139
128
except (ValueError , RuntimeError ) as error :
@@ -149,12 +138,12 @@ def connect_enterprise(self):
149
138
Attempt an enterprise style WiFi connection
150
139
"""
151
140
failure_count = 0
152
- self .esp .wifi_set_network (bytes (self .ent_ssid , 'utf-8' ))
153
- self .esp .wifi_set_entidentity (bytes (self .ent_ident , 'utf-8' ))
154
- self .esp .wifi_set_entusername (bytes (self .ent_user , 'utf-8' ))
155
- self .esp .wifi_set_entpassword (bytes (self .ent_password , 'utf-8' ))
156
- self .esp .wifi_set_entenable ()
157
- while not self .esp .is_connected :
141
+ self ._esp .wifi_set_network (bytes (self .ent_ssid , 'utf-8' ))
142
+ self ._esp .wifi_set_entidentity (bytes (self .ent_ident , 'utf-8' ))
143
+ self ._esp .wifi_set_entusername (bytes (self .ent_user , 'utf-8' ))
144
+ self ._esp .wifi_set_entpassword (bytes (self .ent_password , 'utf-8' ))
145
+ self ._esp .wifi_set_entenable ()
146
+ while not self ._esp .is_connected :
158
147
try :
159
148
if self .debug :
160
149
print ("Waiting for the ESP32 to connect to the WPA2 Enterprise AP..." )
0 commit comments