Explorar o código

Set espconn's secure buffer size once at initialization (#1466)

Fixes #1457
Yury Popov %!s(int64=7) %!d(string=hai) anos
pai
achega
be263dacde

+ 0 - 1
app/http/httpclient.c

@@ -477,7 +477,6 @@ static void ICACHE_FLASH_ATTR http_dns_callback( const char * hostname, ip_addr_
 
 		if ( req->secure )
 		{
-			espconn_secure_set_size( ESPCONN_CLIENT, 5120 ); /* set SSL buffer size */
 			espconn_secure_connect( conn );
 		} 
 		else 

+ 4 - 0
app/include/user_config.h

@@ -60,6 +60,10 @@ extern void luaL_assertfail(const char *file, int line, const char *message);
 #define NO_INTR_CODE inline
 #endif
 
+// SSL buffer size used only for espconn-layer secure connections.
+// See https://github.com/nodemcu/nodemcu-firmware/issues/1457 for conversation details.
+#define SSL_BUFFER_SIZE 5120
+
 //#define CLIENT_SSL_ENABLE
 //#define MD2_ENABLE
 #define SHA2_ENABLE

+ 0 - 3
app/modules/mqtt.c

@@ -1618,9 +1618,6 @@ static const LUA_REG_TYPE mqtt_map[] = {
 int luaopen_mqtt( lua_State *L )
 {
   luaL_rometatable(L, "mqtt.socket", (void *)mqtt_socket_map);  // create metatable for mqtt.socket
-#ifdef CLIENT_SSL_ENABLE
-  espconn_secure_set_size(ESPCONN_CLIENT, 4096);
-#endif
   return 0;
 }
 

+ 0 - 1
app/modules/net.c

@@ -577,7 +577,6 @@ static void socket_connect(struct espconn *pesp_conn)
   {
 #ifdef CLIENT_SSL_ENABLE
     if(nud->secure){
-      espconn_secure_set_size(ESPCONN_CLIENT, 5120); /* set SSL buffer size */
       espconn_secure_connect(pesp_conn);
     }
     else

+ 5 - 0
app/user/user_main.c

@@ -22,6 +22,7 @@
 #include "driver/uart.h"
 #include "task/task.h"
 #include "mem.h"
+#include "espconn.h"
 
 #ifdef LUA_USE_MODULES_RTCTIME
 #include "rtc/rtctime.h"
@@ -98,6 +99,10 @@ void nodemcu_init(void)
     }
 #endif // defined(FLASH_SAFE_API)
 
+#if defined ( CLIENT_SSL_ENABLE ) && defined ( SSL_BUFFER_SIZE )
+    espconn_secure_set_size(ESPCONN_CLIENT, SSL_BUFFER_SIZE);
+#endif
+
 #if defined ( BUILD_SPIFFS )
     if (!fs_mount()) {
         // Failed to mount -- try reformat

+ 0 - 3
app/websocket/websocketclient.c

@@ -47,8 +47,6 @@
 #define PORT_INSECURE 80
 #define PORT_MAX_VALUE 65535
 
-#define SSL_BUFFER_SIZE 5120
-
 // TODO: user agent configurable
 #define WS_INIT_HEADERS  "GET %s HTTP/1.1\r\n"\
                          "Host: %s:%d\r\n"\
@@ -656,7 +654,6 @@ static void dns_callback(const char *hostname, ip_addr_t *addr, void *arg) {
 
   if (ws->isSecure) {
     NODE_DBG("secure connecting \n");
-    espconn_secure_set_size(ESPCONN_CLIENT, SSL_BUFFER_SIZE);
     espconn_secure_connect(conn);
   }
   else {