@@ -50,44 +50,61 @@ def __init__(self, esp, settings, status_neopixel=None):
5050 self .neo_status (0 )
5151
5252 def connect (self ):
53+ """
54+ Attempt to connect to WiFi using the current settings
55+ """
5356 if self .debug :
5457 if self ._esp .status == adafruit_esp32spi .WL_IDLE_STATUS :
5558 print ("ESP32 found and in idle mode" )
5659 print ("Firmware vers." , self ._esp .firmware_version )
5760 print ("MAC addr:" , [hex (i ) for i in self ._esp .MAC_address ])
58- for ap in self ._esp .scan_networks ():
59- print ("\t %s\t \t RSSI: %d" % (str (ap ['ssid' ], 'utf-8' ), ap ['rssi' ]))
61+ for access_point in self ._esp .scan_networks ():
62+ print ("\t %s\t \t RSSI: %d" % (str (access_point ['ssid' ], 'utf-8' ), access_point ['rssi' ]))
6063 while not self ._esp .is_connected :
6164 try :
6265 if self .debug :
6366 print ("Connecting to AP..." )
6467 self .neo_status ((100 , 0 , 0 ))
65- self ._esp .connect_AP (bytes (self .ssid ,'utf-8' ), bytes (self .password ,'utf-8' ))
68+ self ._esp .connect_AP (bytes (self .ssid , 'utf-8' ), bytes (self .password , 'utf-8' ))
6669 self .neo_status ((0 , 100 , 0 ))
67- except (ValueError , RuntimeError ) as e :
70+ except (ValueError , RuntimeError ) as error :
6871 if self .debug :
69- print ("Failed to connect, retrying\n " , e )
72+ print ("Failed to connect, retrying\n " , error )
7073 continue
7174
7275 def get (self , url , ** kw ):
76+ """
77+ Pass the Get request to requests and update Status NeoPixel
78+ """
7379 self .neo_status ((100 , 100 , 0 ))
7480 return_val = requests .get (url , ** kw )
7581 self .neo_status ((0 , 0 , 100 ))
7682 return return_val
7783
7884 def post (self , url , ** kw ):
85+ """
86+ Pass the Post request to requests and update Status NeoPixel
87+ """
7988 self .neo_status ((100 , 100 , 0 ))
8089 return_val = requests .post (url , ** kw )
8190 self .neo_status ((0 , 0 , 100 ))
8291 return return_val
8392
8493 def ping (self , host ):
94+ """
95+ Pass the Ping request to requests and update Status NeoPixel
96+ """
97+ self .neo_status ((100 , 100 , 0 ))
8598 #Blink the LED Green
8699 #Send Stuff to Requests
87100 #stop Blinking LED
88101 #Return Result
102+ self .neo_status ((0 , 0 , 100 ))
89103 return None
90104
91105 def neo_status (self , value ):
106+ """
107+ Change Status NeoPixel if it was defined
108+ """
92109 if self .neopix :
93110 self .neopix .fill (value )
0 commit comments