@@ -50,44 +50,61 @@ def __init__(self, esp, settings, status_neopixel=None):
50
50
self .neo_status (0 )
51
51
52
52
def connect (self ):
53
+ """
54
+ Attempt to connect to WiFi using the current settings
55
+ """
53
56
if self .debug :
54
57
if self ._esp .status == adafruit_esp32spi .WL_IDLE_STATUS :
55
58
print ("ESP32 found and in idle mode" )
56
59
print ("Firmware vers." , self ._esp .firmware_version )
57
60
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' ]))
60
63
while not self ._esp .is_connected :
61
64
try :
62
65
if self .debug :
63
66
print ("Connecting to AP..." )
64
67
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' ))
66
69
self .neo_status ((0 , 100 , 0 ))
67
- except (ValueError , RuntimeError ) as e :
70
+ except (ValueError , RuntimeError ) as error :
68
71
if self .debug :
69
- print ("Failed to connect, retrying\n " , e )
72
+ print ("Failed to connect, retrying\n " , error )
70
73
continue
71
74
72
75
def get (self , url , ** kw ):
76
+ """
77
+ Pass the Get request to requests and update Status NeoPixel
78
+ """
73
79
self .neo_status ((100 , 100 , 0 ))
74
80
return_val = requests .get (url , ** kw )
75
81
self .neo_status ((0 , 0 , 100 ))
76
82
return return_val
77
83
78
84
def post (self , url , ** kw ):
85
+ """
86
+ Pass the Post request to requests and update Status NeoPixel
87
+ """
79
88
self .neo_status ((100 , 100 , 0 ))
80
89
return_val = requests .post (url , ** kw )
81
90
self .neo_status ((0 , 0 , 100 ))
82
91
return return_val
83
92
84
93
def ping (self , host ):
94
+ """
95
+ Pass the Ping request to requests and update Status NeoPixel
96
+ """
97
+ self .neo_status ((100 , 100 , 0 ))
85
98
#Blink the LED Green
86
99
#Send Stuff to Requests
87
100
#stop Blinking LED
88
101
#Return Result
102
+ self .neo_status ((0 , 0 , 100 ))
89
103
return None
90
104
91
105
def neo_status (self , value ):
106
+ """
107
+ Change Status NeoPixel if it was defined
108
+ """
92
109
if self .neopix :
93
110
self .neopix .fill (value )
0 commit comments