@@ -48,12 +48,12 @@ def __init__(self, esp, secrets, status_pixel=None, attempts=2):
4848 :param int attempts: (Optional) Failed attempts before resetting the ESP32 (default=2)
4949 """
5050 # Read the settings
51- self ._esp = esp
51+ self .esp = esp
5252 self .debug = False
5353 self .ssid = secrets ['ssid' ]
5454 self .password = secrets ['password' ]
5555 self .attempts = attempts
56- requests .set_interface (self ._esp )
56+ requests .set_interface (self .esp )
5757 self .statuspix = status_pixel
5858 self .pixel_status (0 )
5959
@@ -63,26 +63,26 @@ def reset(self):
6363 """
6464 if self .debug :
6565 print ("Resetting ESP32" )
66- self ._esp .reset ()
66+ self .esp .reset ()
6767
6868 def connect (self ):
6969 """
7070 Attempt to connect to WiFi using the current settings
7171 """
7272 if self .debug :
73- if self ._esp .status == adafruit_esp32spi .WL_IDLE_STATUS :
73+ if self .esp .status == adafruit_esp32spi .WL_IDLE_STATUS :
7474 print ("ESP32 found and in idle mode" )
75- print ("Firmware vers." , self ._esp .firmware_version )
76- print ("MAC addr:" , [hex (i ) for i in self ._esp .MAC_address ])
77- for access_pt in self ._esp .scan_networks ():
75+ print ("Firmware vers." , self .esp .firmware_version )
76+ print ("MAC addr:" , [hex (i ) for i in self .esp .MAC_address ])
77+ for access_pt in self .esp .scan_networks ():
7878 print ("\t %s\t \t RSSI: %d" % (str (access_pt ['ssid' ], 'utf-8' ), access_pt ['rssi' ]))
7979 failure_count = 0
80- while not self ._esp .is_connected :
80+ while not self .esp .is_connected :
8181 try :
8282 if self .debug :
8383 print ("Connecting to AP..." )
8484 self .pixel_status ((100 , 0 , 0 ))
85- self ._esp .connect_AP (bytes (self .ssid , 'utf-8' ), bytes (self .password , 'utf-8' ))
85+ self .esp .connect_AP (bytes (self .ssid , 'utf-8' ), bytes (self .password , 'utf-8' ))
8686 failure_count = 0
8787 self .pixel_status ((0 , 100 , 0 ))
8888 except (ValueError , RuntimeError ) as error :
@@ -105,7 +105,7 @@ def get(self, url, **kw):
105105 :return: The response from the request
106106 :rtype: Response
107107 """
108- if not self ._esp .is_connected :
108+ if not self .esp .is_connected :
109109 self .connect ()
110110 self .pixel_status ((0 , 0 , 100 ))
111111 return_val = requests .get (url , ** kw )
@@ -124,7 +124,7 @@ def post(self, url, **kw):
124124 :return: The response from the request
125125 :rtype: Response
126126 """
127- if not self ._esp .is_connected :
127+ if not self .esp .is_connected :
128128 self .connect ()
129129 self .pixel_status ((0 , 0 , 100 ))
130130 return_val = requests .post (url , ** kw )
@@ -142,7 +142,7 @@ def put(self, url, **kw):
142142 :return: The response from the request
143143 :rtype: Response
144144 """
145- if not self ._esp .is_connected :
145+ if not self .esp .is_connected :
146146 self .connect ()
147147 self .pixel_status ((0 , 0 , 100 ))
148148 return_val = requests .put (url , ** kw )
@@ -161,7 +161,7 @@ def patch(self, url, **kw):
161161 :return: The response from the request
162162 :rtype: Response
163163 """
164- if not self ._esp .is_connected :
164+ if not self .esp .is_connected :
165165 self .connect ()
166166 self .pixel_status ((0 , 0 , 100 ))
167167 return_val = requests .patch (url , ** kw )
@@ -180,7 +180,7 @@ def delete(self, url, **kw):
180180 :return: The response from the request
181181 :rtype: Response
182182 """
183- if not self ._esp .is_connected :
183+ if not self .esp .is_connected :
184184 self .connect ()
185185 self .pixel_status ((0 , 0 , 100 ))
186186 return_val = requests .delete (url , ** kw )
@@ -196,22 +196,22 @@ def ping(self, host, ttl=250):
196196 :return: The response time in milliseconds
197197 :rtype: int
198198 """
199- if not self ._esp .is_connected :
199+ if not self .esp .is_connected :
200200 self .connect ()
201201 self .pixel_status ((0 , 0 , 100 ))
202- response_time = self ._esp .ping (host , ttl = ttl )
202+ response_time = self .esp .ping (host , ttl = ttl )
203203 self .pixel_status (0 )
204204 return response_time
205205
206206 def ip_address (self ):
207207 """
208208 Returns a formatted local IP address, update status pixel.
209209 """
210- if not self ._esp .is_connected :
210+ if not self .esp .is_connected :
211211 self .connect ()
212212 self .pixel_status ((0 , 0 , 100 ))
213213 self .pixel_status (0 )
214- return self ._esp .pretty_ip (self ._esp .ip_address )
214+ return self .esp .pretty_ip (self .esp .ip_address )
215215
216216 def pixel_status (self , value ):
217217 """
@@ -230,6 +230,6 @@ def signal_strength(self):
230230 """
231231 Returns receiving signal strength indicator in dBm
232232 """
233- if not self ._esp .is_connected :
233+ if not self .esp .is_connected :
234234 self .connect ()
235- return self ._esp .rssi ()
235+ return self .esp .rssi ()
0 commit comments