Skip to content

Commit

Permalink
Merge pull request #78 from brentru/add-cert-psk-bools
Browse files Browse the repository at this point in the history
Add booleans for checking if user sets cert/key pair
  • Loading branch information
brentru authored Oct 10, 2019
2 parents 379eed6 + 3ea8a73 commit 602250a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion adafruit_esp32spi/adafruit_esp32spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
WL_AP_FAILED = const(9)
# pylint: enable=bad-whitespace

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

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

0 comments on commit 602250a

Please sign in to comment.