From f243b06726f184749f11807d773b05d58be1338f Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 21 Nov 2019 11:08:30 +0100 Subject: [PATCH] Make TLS certificate storage PUYA compatible --- tasmota/xdrv_02_mqtt.ino | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index bf5dc27c2..49f35d579 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -1134,7 +1134,9 @@ void CmndTlsKey(void) { memcpy(spi_buffer + tls_obj_store_offset + entry->start, bin_buf, entry->len); } - TlsWriteSpiBuffer(spi_buffer); + if (ESP.flashEraseSector(tls_spi_start_sector)) { + ESP.flashWrite(tls_spi_start_sector * SPI_FLASH_SEC_SIZE, (uint32_t*) spi_buffer, SPI_FLASH_SEC_SIZE); + } free(spi_buffer); free(bin_buf); } @@ -1146,26 +1148,6 @@ void CmndTlsKey(void) { } } - -extern "C" { -#include "spi_flash.h" -} - -void TlsWriteSpiBuffer(uint8_t *buf) { - bool ret = false; - SpiFlashOpResult res; - - noInterrupts(); - res = spi_flash_erase_sector(tls_spi_start_sector); - if (SPI_FLASH_RESULT_OK == res) { - res = spi_flash_write(tls_spi_start_sector * SPI_FLASH_SEC_SIZE, (uint32_t*) buf, SPI_FLASH_SEC_SIZE); - if (SPI_FLASH_RESULT_OK == res) { - ret = true; - } - } - interrupts(); -} - #ifdef DEBUG_DUMP_TLS // Dump TLS Flash data - don't activate in production to protect your private keys uint32_t bswap32(uint32_t x) {