@@ -123,7 +123,7 @@ class ESP_SPIcontrol: # pylint: disable=too-many-public-methods
123123 TLS_MODE = const (2 )
124124
125125 # pylint: disable=too-many-arguments
126- def __init__ (self , spi , cs_pin , ready_pin , reset_pin , gpio0_pin , * , debug = False ):
126+ def __init__ (self , spi , cs_pin , ready_pin , reset_pin , gpio0_pin = None , * , debug = False ):
127127 self ._debug = debug
128128 self ._buffer = bytearray (10 )
129129 self ._pbuf = bytearray (1 ) # buffer for param read
@@ -138,22 +138,25 @@ def __init__(self, spi, cs_pin, ready_pin, reset_pin, gpio0_pin, *, debug=False)
138138 self ._cs .direction = Direction .OUTPUT
139139 self ._ready .direction = Direction .INPUT
140140 self ._reset .direction = Direction .OUTPUT
141- self ._gpio0 .direction = Direction .INPUT
141+ if self ._gpio0 :
142+ self ._gpio0 .direction = Direction .INPUT
142143 self .reset ()
143144 # pylint: enable=too-many-arguments
144145
145146 def reset (self ):
146147 """Hard reset the ESP32 using the reset pin"""
147- self ._gpio0 .direction = Direction .OUTPUT
148148 if self ._debug :
149149 print ("Reset ESP32" )
150- self ._gpio0 .value = True # not bootload mode
150+ if self ._gpio0 :
151+ self ._gpio0 .direction = Direction .OUTPUT
152+ self ._gpio0 .value = True # not bootload mode
151153 self ._cs .value = True
152154 self ._reset .value = False
153155 time .sleep (0.01 ) # reset
154156 self ._reset .value = True
155157 time .sleep (0.75 ) # wait for it to boot up
156- self ._gpio0 .direction = Direction .INPUT
158+ if self ._gpio0 :
159+ self ._gpio0 .direction = Direction .INPUT
157160
158161 def _wait_for_ready (self ):
159162 """Wait until the ready pin goes low"""
@@ -338,7 +341,7 @@ def get_scan_networks(self):
338341 'ssid', 'rssi' and 'encryption' entries, one for each AP found"""
339342 self ._send_command (_SCAN_NETWORKS )
340343 names = self ._wait_response_cmd (_SCAN_NETWORKS )
341- print ("SSID names:" , names )
344+ # print("SSID names:", names)
342345 APs = [] # pylint: disable=invalid-name
343346 for i , name in enumerate (names ):
344347 a_p = {'ssid' : name }
@@ -466,7 +469,7 @@ def ping(self, dest, ttl=250):
466469 dest = self .get_host_by_name (dest )
467470 # ttl must be between 0 and 255
468471 ttl = max (0 , min (ttl , 255 ))
469- resp = self ._send_command_get_response (_PING_CMD , (dest , (ttl )))
472+ resp = self ._send_command_get_response (_PING_CMD , (dest , (ttl , )))
470473 return struct .unpack ('<H' , resp [0 ])[0 ]
471474
472475 def get_socket (self ):
0 commit comments