From 3ea8a73c18865585bc235313d4eba3f43007bfdf Mon Sep 17 00:00:00 2001 From: brentru Date: Thu, 10 Oct 2019 09:35:27 -0400 Subject: [PATCH] add set_psk, set_crt for checking if user sets cert/key pair --- adafruit_esp32spi/adafruit_esp32spi.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/adafruit_esp32spi/adafruit_esp32spi.py b/adafruit_esp32spi/adafruit_esp32spi.py index 0926c4d..377c186 100644 --- a/adafruit_esp32spi/adafruit_esp32spi.py +++ b/adafruit_esp32spi/adafruit_esp32spi.py @@ -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) @@ -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 @@ -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): @@ -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]