3434from adafruit_esp32spi import adafruit_esp32spi
3535import adafruit_esp32spi .adafruit_esp32spi_requests as requests
3636
37+ class WiFiConnType : # pylint: disable=too-few-public-methods
38+ """An enum-like class representing the different types of WiFi connections
39+ that can be made. The values can be referenced like ``WiFiConnType.normal``.
40+ Possible values are
41+ - ``ThermocoupleType.normal``
42+ - ``ThermocoupleType.enterprise``
43+ """
44+ # pylint: disable=invalid-name
45+ normal = 1
46+ enterprise = 2
47+
3748class ESPSPI_WiFiManager :
3849 """
3950 A class to help manage the Wifi connection
4051 """
41- def __init__ (self , esp , secrets , status_pixel = None , attempts = 2 , con_type = 1 ):
52+ def __init__ (self , esp , secrets , status_pixel = None , attempts = 2 , wificonntype = WiFiConnType . normal ):
4253 """
4354 :param ESP_SPIcontrol esp: The ESP object we are using
4455 :param dict secrets: The WiFi and Adafruit IO secrets dict (See examples)
4556 :param status_pixel: (Optional) The pixel device - A NeoPixel, DotStar,
4657 or RGB LED (default=None)
4758 :type status_pixel: NeoPixel, DotStar, or RGB LED
4859 :param int attempts: (Optional) Failed attempts before resetting the ESP32 (default=2)
49- :param int con_type: (Optional) Type of WiFi connection to make: normal=1, WPA2 Enterprise=2
60+ :param const con_type: (Optional) Type of WiFi connection: normal=1, WPA2 Enterprise=2
61+ :param ~adafruit_esp32spi_wifimanager.WiFiConnType wificonntype: The type of WiFi \
62+ connection to make. The default is "normal".
5063 """
5164 # Read the settings
5265 self ._esp = esp
@@ -58,7 +71,7 @@ def __init__(self, esp, secrets, status_pixel=None, attempts=2, con_type=1):
5871 self .ent_user = secrets ['ent_user' ]
5972 self .ent_passwd = secrets ['ent_passwd' ]
6073 self .attempts = attempts
61- self .con_type = con_type
74+ self .wificonntype = wificonntype
6275 requests .set_interface (self ._esp )
6376 self .statuspix = status_pixel
6477 self .pixel_status (0 )
@@ -83,7 +96,7 @@ def connect(self):
8396 for access_pt in self ._esp .scan_networks ():
8497 print ("\t %s\t \t RSSI: %d" % (str (access_pt ['ssid' ], 'utf-8' ), access_pt ['rssi' ]))
8598 failure_count = 0
86- if self .con_type == 1 :
99+ if self .wificonntype == WiFiConnType . normal :
87100 while not self ._esp .is_connected :
88101 try :
89102 if self .debug :
@@ -99,7 +112,7 @@ def connect(self):
99112 failure_count = 0
100113 self .reset ()
101114 continue
102- elif self .con_type == 2 :
115+ elif self .wificonntype == WiFiConnType . enterprise :
103116 self ._esp .wifi_set_network (bytes (self .ent_ssid , 'utf-8' ))
104117 self ._esp .wifi_set_entidentity (bytes (self .ent_ident , 'utf-8' ))
105118 self ._esp .wifi_set_entusername (bytes (self .ent_user , 'utf-8' ))
0 commit comments