@@ -39,7 +39,7 @@ class ESPSPI_WiFiManager:
3939 """
4040 A class to help manage the Wifi connection
4141 """
42- def __init__ (self , esp , secrets , status_pixel = None , attempts = 2 ):
42+ def __init__ (self , esp , secrets , status_pixel = None , attempts = 2 , debug = False ):
4343 """
4444 :param ESP_SPIcontrol esp: The ESP object we are using
4545 :param dict secrets: The WiFi and Adafruit IO secrets dict (See examples)
@@ -50,9 +50,9 @@ def __init__(self, esp, secrets, status_pixel=None, attempts=2):
5050 """
5151 # Read the settings
5252 self ._esp = esp
53- self .debug = False
53+ self .debug = debug
5454 self .ssid = secrets ['ssid' ]
55- self .password = secrets [ 'password' ]
55+ self .password = secrets . get ( 'password' , None )
5656 self .attempts = attempts
5757 requests .set_interface (self ._esp )
5858 self .statuspix = status_pixel
@@ -99,12 +99,16 @@ def create_ap(self):
9999 Attempt to initialize in Access Point (AP) mode.
100100 Other WiFi devices will be able to connect to the created Access Point
101101 """
102+ failure_count = 0
102103 while not self ._esp .ap_listening :
103104 try :
104105 if self .debug :
105106 print ("Waiting for AP to be initialized..." )
106107 self .pixel_status ((100 ,0 ,0 ))
107- self ._esp .create_AP (bytes .ssid , 'utf-8' ), bytes (self .password , 'utf-8' )
108+ if (self .password ):
109+ self ._esp .create_AP (bytes (self .ssid , 'utf-8' ), bytes (self .password , 'utf-8' ))
110+ else :
111+ self ._esp .create_AP (bytes (self .ssid , 'utf-8' ), None )
108112 failure_count = 0
109113 self .pixel_status ((0 ,100 ,0 ))
110114 except (ValueError , RuntimeError ) as error :
@@ -114,6 +118,7 @@ def create_ap(self):
114118 failure_count = 0
115119 self .reset ()
116120 continue
121+ print ("Access Point created! Connect to ssid: {}" .format (self .ssid ))
117122
118123 def get (self , url , ** kw ):
119124 """
0 commit comments