@@ -123,7 +123,7 @@ class ESP_SPIcontrol: # pylint: disable=too-many-public-methods
123
123
TLS_MODE = const (2 )
124
124
125
125
# 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 ):
127
127
self ._debug = debug
128
128
self ._buffer = bytearray (10 )
129
129
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)
138
138
self ._cs .direction = Direction .OUTPUT
139
139
self ._ready .direction = Direction .INPUT
140
140
self ._reset .direction = Direction .OUTPUT
141
- self ._gpio0 .direction = Direction .INPUT
141
+ if self ._gpio0 :
142
+ self ._gpio0 .direction = Direction .INPUT
142
143
self .reset ()
143
144
# pylint: enable=too-many-arguments
144
145
145
146
def reset (self ):
146
147
"""Hard reset the ESP32 using the reset pin"""
147
- self ._gpio0 .direction = Direction .OUTPUT
148
148
if self ._debug :
149
149
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
151
153
self ._cs .value = True
152
154
self ._reset .value = False
153
155
time .sleep (0.01 ) # reset
154
156
self ._reset .value = True
155
157
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
157
160
158
161
def _wait_for_ready (self ):
159
162
"""Wait until the ready pin goes low"""
@@ -338,7 +341,7 @@ def get_scan_networks(self):
338
341
'ssid', 'rssi' and 'encryption' entries, one for each AP found"""
339
342
self ._send_command (_SCAN_NETWORKS )
340
343
names = self ._wait_response_cmd (_SCAN_NETWORKS )
341
- print ("SSID names:" , names )
344
+ # print("SSID names:", names)
342
345
APs = [] # pylint: disable=invalid-name
343
346
for i , name in enumerate (names ):
344
347
a_p = {'ssid' : name }
@@ -466,7 +469,7 @@ def ping(self, dest, ttl=250):
466
469
dest = self .get_host_by_name (dest )
467
470
# ttl must be between 0 and 255
468
471
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 , )))
470
473
return struct .unpack ('<H' , resp [0 ])[0 ]
471
474
472
475
def get_socket (self ):
0 commit comments