From fa8d00a7362dc75dd1ea25d66d70d07f20d56431 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 5 Jul 2020 10:00:04 +0200 Subject: [PATCH] [ESP8266] Fixed variable scope --- src/modules/ESP8266/ESP8266.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/ESP8266/ESP8266.cpp b/src/modules/ESP8266/ESP8266.cpp index c7e23b00..c07a96e8 100644 --- a/src/modules/ESP8266/ESP8266.cpp +++ b/src/modules/ESP8266/ESP8266.cpp @@ -7,7 +7,8 @@ ESP8266::ESP8266(Module* module) { int16_t ESP8266::begin(long speed) { // set module properties - _mod->AtLineFeed = "\r\n"; + char lf[3] = "\r\n"; + memcpy(_mod->AtLineFeed, lf, strlen(lf)); _mod->baudrate = speed; _mod->init(RADIOLIB_USE_UART); @@ -89,13 +90,13 @@ int16_t ESP8266::openTransportConnection(const char* host, const char* protocol, // build AT command const char* atStr = "AT+CIPSTART=\""; - uint8_t cmdLen = strlen(atStr) + strlen(protocol) + strlen(host) + strlen(portStr) + 5; - if((strcmp(protocol, "TCP") == 0) && (tcpKeepAlive > 0)) { - cmdLen += strlen(tcpKeepAliveStr) + 1; - } #ifdef RADIOLIB_STATIC_ONLY char cmd[RADIOLIB_STATIC_ARRAY_SIZE]; #else + uint8_t cmdLen = strlen(atStr) + strlen(protocol) + strlen(host) + strlen(portStr) + 5; + if((strcmp(protocol, "TCP") == 0) && (tcpKeepAlive > 0)) { + cmdLen += strlen(tcpKeepAliveStr) + 1; + } char* cmd = new char[cmdLen + 1]; #endif strcpy(cmd, atStr);