diff --git a/examples/platforms/nrf52840/openthread-core-nrf52840-config.h b/examples/platforms/nrf52840/openthread-core-nrf52840-config.h index 99980de38..ee3367f49 100644 --- a/examples/platforms/nrf52840/openthread-core-nrf52840-config.h +++ b/examples/platforms/nrf52840/openthread-core-nrf52840-config.h @@ -115,4 +115,12 @@ */ #define SETTINGS_CONFIG_PAGE_NUM 4 +/** + * @def OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE + * + * The size of mbedTLS heap buffer when DTLS is enabled. + * + */ +#define OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE (4096 * sizeof(void *)) + #endif // OPENTHREAD_CORE_NRF52840_CONFIG_H_ diff --git a/src/core/crypto/mbedtls.hpp b/src/core/crypto/mbedtls.hpp index eb575d563..66bdf47ca 100644 --- a/src/core/crypto/mbedtls.hpp +++ b/src/core/crypto/mbedtls.hpp @@ -40,6 +40,8 @@ #include #endif +#include + #include namespace Thread { @@ -62,9 +64,9 @@ public: enum { #if OPENTHREAD_ENABLE_DTLS - kMemorySize = 2048 * sizeof(void *), ///< Size of memory buffer (bytes). + kMemorySize = OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE, ///< Size of memory buffer (bytes). #else - kMemorySize = 384, ///< Size of memory buffer (bytes). + kMemorySize = 384, ///< Size of memory buffer (bytes). #endif }; diff --git a/src/core/openthread-core-default-config.h b/src/core/openthread-core-default-config.h index c58ebf7a8..709eb5e5a 100644 --- a/src/core/openthread-core-default-config.h +++ b/src/core/openthread-core-default-config.h @@ -677,4 +677,14 @@ #define OPENTHREAD_CONFIG_ENABLE_AUTO_START_SUPPORT 1 #endif +/** + * @def OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE + * + * The size of mbedTLS heap buffer when DTLS is enabled. + * + */ +#ifndef OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE +#define OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE (2048 * sizeof(void *)) +#endif + #endif // OPENTHREAD_CORE_DEFAULT_CONFIG_H_