Skip to content

Commit 602250a

Browse files
authored
Merge pull request #78 from brentru/add-cert-psk-bools
Add booleans for checking if user sets cert/key pair
2 parents 379eed6 + 3ea8a73 commit 602250a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
WL_AP_FAILED = const(9)
134134
# pylint: enable=bad-whitespace
135135

136-
class ESP_SPIcontrol: # pylint: disable=too-many-public-methods
136+
class ESP_SPIcontrol: # pylint: disable=too-many-public-methods, too-many-instance-attributes
137137
"""A class that will talk to an ESP32 module programmed with special firmware
138138
that lets it act as a fast an efficient WiFi co-processor"""
139139
TCP_MODE = const(0)
@@ -143,6 +143,8 @@ class ESP_SPIcontrol: # pylint: disable=too-many-public-methods
143143
# pylint: disable=too-many-arguments
144144
def __init__(self, spi, cs_pin, ready_pin, reset_pin, gpio0_pin=None, *, debug=False):
145145
self._debug = debug
146+
self.set_psk = False
147+
self.set_crt = False
146148
self._buffer = bytearray(10)
147149
self._pbuf = bytearray(1) # buffer for param read
148150
self._sendbuf = bytearray(256) # buffer for command sending
@@ -805,6 +807,7 @@ def set_certificate(self, client_certificate):
805807
resp = self._send_command_get_response(_SET_CLI_CERT, (client_certificate,))
806808
if resp[0][0] != 1:
807809
raise RuntimeError("Failed to set client certificate")
810+
self.set_crt = True
808811
return resp[0]
809812

810813
def set_private_key(self, private_key):
@@ -822,4 +825,5 @@ def set_private_key(self, private_key):
822825
resp = self._send_command_get_response(_SET_PK, (private_key,))
823826
if resp[0][0] != 1:
824827
raise RuntimeError("Failed to set private key.")
828+
self.set_psk = True
825829
return resp[0]

0 commit comments

Comments
 (0)