From 539b088e82aa08457c1d90e800791b10782a32a3 Mon Sep 17 00:00:00 2001 From: Noah Laptop Date: Thu, 26 Dec 2019 17:50:34 -0500 Subject: [PATCH] fix support for the esp8266 --- src/SSLClient.cpp | 5 +++++ src/SSLClient.h | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/SSLClient.cpp b/src/SSLClient.cpp index 428e275..3529144 100644 --- a/src/SSLClient.cpp +++ b/src/SSLClient.cpp @@ -35,6 +35,8 @@ static constexpr auto VECTKEY_MASK = (0x0000ffffUL); #ifdef __arm__ // should use uinstd.h to define sbrk but Due causes a conflict extern "C" char* sbrk(int incr); +#elif defined(ESP8266) // esp8266 +#define SYSTEM_STACK_END_ADDRESS 0x3FFFC000 #else // __ARM__ extern char *__brkval; #endif // __arm__ @@ -44,6 +46,9 @@ static int freeMemory() { char top; #ifdef __arm__ return &top - reinterpret_cast(sbrk(0)); +#elif defined(ESP8266) // ESP8266 + register volatile uint32_t stackAddress asm("a1"); + return stackAddress-SYSTEM_STACK_END_ADDRESS; #elif defined(CORE_TEENSY) || (ARDUINO > 103 && ARDUINO != 151) return &top - __brkval; #else // __arm__ diff --git a/src/SSLClient.h b/src/SSLClient.h index 17c91d4..79d6827 100644 --- a/src/SSLClient.h +++ b/src/SSLClient.h @@ -358,6 +358,18 @@ public: /** @brief Returns a reference to the client object stored in this class. Take care not to break it. */ Client& getClient() { return m_client; } + /** + * @brief Set the timeout when waiting for an SSL response. + * @param t The timeout value, in milliseconds (defaults to 30 seconds if not set). Do not set to zero. + */ + void setTimeout(unsigned int t) { m_timeout = t; } + + /** + * @brief Get the timeout when waiting for an SSL response. + * @returns The timeout value in milliseconds. + */ + unsigned int getTimeout() const { return m_timeout; } + private: /** @brief Returns an instance of m_client that is polymorphic and can be used by SSLClientImpl */ Client& get_arduino_client() { return m_client; } @@ -419,6 +431,8 @@ private: const DebugLevel m_debug; // store if we are connected in bearssl or not bool m_is_connected; + // store the timeout for SSL internals + unsigned int m_timeout; // store the context values required for SSL br_ssl_client_context m_sslctx; br_x509_minimal_context m_x509ctx;