From adcc50ac6edfb0c5501295a6432180acafeb8df7 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 29 May 2024 16:44:50 +0200 Subject: [PATCH] Revert "Fix network flushes" This reverts commit b88ec44d15394fc18bf2f1e23d4d0263c65ea81d. --- tasmota/tasmota_support/support_device_groups.ino | 3 +-- tasmota/tasmota_support/support_udp.ino | 10 ++++++---- tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino | 6 +----- tasmota/tasmota_xdrv_driver/xdrv_04_light_artnet.ino | 1 + tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino | 10 ++-------- .../tasmota_xdrv_driver/xdrv_52_3_berry_webserver.ino | 2 +- tasmota/tasmota_xdrv_driver/xdrv_63_modbus_bridge.ino | 4 ---- tasmota/tasmota_xdrv_driver/xdrv_81_esp32_webcam.ino | 6 +++--- .../tasmota_xdrv_driver/xdrv_81_esp32_webcam_task.ino | 2 +- tasmota/tasmota_xsns_sensor/xsns_53_sml.ino | 4 ---- 10 files changed, 16 insertions(+), 32 deletions(-) diff --git a/tasmota/tasmota_support/support_device_groups.ino b/tasmota/tasmota_support/support_device_groups.ino index 35d0b9983..63b9eb965 100644 --- a/tasmota/tasmota_support/support_device_groups.ino +++ b/tasmota/tasmota_support/support_device_groups.ino @@ -207,9 +207,8 @@ void DeviceGroupsStart() void DeviceGroupsStop() { -#ifdef ESP8266 device_groups_udp.flush(); -#else +#ifdef ESP32 device_groups_udp.clear(); // New with core3. Does what flush() did in core2; #endif device_groups_up = false; diff --git a/tasmota/tasmota_support/support_udp.ino b/tasmota/tasmota_support/support_udp.ino index ffd677a82..0cb6c4b75 100644 --- a/tasmota/tasmota_support/support_udp.ino +++ b/tasmota/tasmota_support/support_udp.ino @@ -60,12 +60,13 @@ bool UdpDisconnect(void) { if (udp_connected) { // flush any outgoing packet -#ifdef ESP8266 - PortUdp.flush(); - UdpCtx.disconnect(); -#else + PortUdp.flush(); // Does nothing in core3 +#ifdef ESP32 PortUdp.clear(); // New with core3. Does what flush() did in core2; #endif +#ifdef ESP8266 + UdpCtx.disconnect(); +#endif #ifdef USE_DEVICE_GROUPS // stop PortUdp.stop(); @@ -132,6 +133,7 @@ void PollUdp(void) int32_t len = PortUdp.read(packet_buffer, UDP_BUFFER_SIZE -1); packet_buffer[len] = 0; +// PortUdp.flush(); PortUdp.clear(); // New with core3. Does what flush() did in core2; AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet (%d/%d)"), len, pack_len); #endif // ESP32 diff --git a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino index 9f8434f32..de9b796ba 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino @@ -775,11 +775,7 @@ void WSSend(int code, int ctype, const String& content) **********************************************************************************************/ void WSContentBegin(int code, int ctype) { -#ifdef ESP8266 Webserver->client().flush(); -#else - Webserver->client().clear(); // New with core3. Does what flush() did in core2; -#endif WSHeaderSend(); Webserver->setContentLength(CONTENT_LENGTH_UNKNOWN); WSSend(code, ctype, ""); // Signal start of chunked content @@ -3089,7 +3085,7 @@ void HandlePreflightRequest(void) // return a simple status page as text/plain code 200 static void WSReturnSimpleString(const char *msg) { if (nullptr == msg) { msg = ""; } - Webserver->client().clear(); // New with core3. Does what flush() did in core2; + Webserver->client().flush(); WSHeaderSend(); Webserver->send(200, "text/plain", msg); } diff --git a/tasmota/tasmota_xdrv_driver/xdrv_04_light_artnet.ino b/tasmota/tasmota_xdrv_driver/xdrv_04_light_artnet.ino index 076c4a757..342c662f8 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_04_light_artnet.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_04_light_artnet.ino @@ -245,6 +245,7 @@ void ArtNetLoop(void) uint8_t packet_buffer[WS2812_ARTNET_UDP_BUFFER_SIZE]; // buffer to hold incoming UDP/SSDP packet packet_len = ArtNetUdp->read(packet_buffer, WS2812_ARTNET_UDP_BUFFER_SIZE); +// ArtNetUdp->flush(); // Finish reading the current packet ArtNetUdp->clear(); // New with core3. Does what flush() did in core2; #endif // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet %*_H (%d)"), 32, packet_buffer, packet_len); diff --git a/tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino b/tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino index 6b2a3827b..b2316a0f3 100755 --- a/tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino @@ -1386,9 +1386,8 @@ int32_t udp_call(char *url, uint32_t port, char *sbuf) { udp.beginPacket(adr, port); udp.write((const uint8_t*)sbuf, strlen(sbuf)); udp.endPacket(); -#ifdef ESP8266 udp.flush(); -#else +#ifdef ESP32 udp.clear(); // New with core3. Does what flush() did in core2; #endif udp.stop(); @@ -1409,9 +1408,8 @@ void Restart_globvars(void) { void Script_Stop_UDP(void) { if (!glob_script_mem.udp_flags.udp_used) return; if (glob_script_mem.udp_flags.udp_connected) { -#ifdef ESP8266 glob_script_mem.Script_PortUdp.flush(); -#else +#ifdef ESP32 glob_script_mem.Script_PortUdp.clear(); // New with core3. Does what flush() did in core2; #endif glob_script_mem.Script_PortUdp.stop(); @@ -6394,11 +6392,7 @@ void tmod_directModeOutput(uint32_t pin); fvar = -1; if (glob_script_mem.tcp_server) { if (glob_script_mem.tcp_client.connected()) { -#ifdef ESP8266 glob_script_mem.tcp_client.flush(); -#else - glob_script_mem.tcp_client.clear(); -#endif fvar = 0; } } diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webserver.ino index 850c53a10..0349736ee 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webserver.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webserver.ino @@ -184,7 +184,7 @@ extern "C" { if (argc >= 2 && be_isint(vm, 1) && be_isstring(vm, 2)) { int32_t httpcode = be_toint(vm, 1); const char * mimetype = be_tostring(vm, 2); - Webserver->client().clear(); // New with core3. Does what flush() did in core2; + Webserver->client().flush(); WSHeaderSend(); Webserver->setContentLength(CONTENT_LENGTH_UNKNOWN); Webserver->send(httpcode, mimetype, ""); diff --git a/tasmota/tasmota_xdrv_driver/xdrv_63_modbus_bridge.ino b/tasmota/tasmota_xdrv_driver/xdrv_63_modbus_bridge.ino index 5be255f3c..f3031997b 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_63_modbus_bridge.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_63_modbus_bridge.ino @@ -311,11 +311,7 @@ void ModbusBridgeHandle(void) client.write(modbusBridge.buffer + 2, 4); // Don't send CRC nrOfBytes += 4; } -#ifdef ESP8266 client.flush(); -#else - client.clear(); // New with core3. Does what flush() did in core2; -#endif AddLog(LOG_LEVEL_DEBUG, PSTR("MBS: MBRTCP from Modbus deviceAddress %d, writing %d bytes to client"), modbusBridge.buffer[0], nrOfBytes); } } diff --git a/tasmota/tasmota_xdrv_driver/xdrv_81_esp32_webcam.ino b/tasmota/tasmota_xdrv_driver/xdrv_81_esp32_webcam.ino index e9344c328..904e73c84 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_81_esp32_webcam.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_81_esp32_webcam.ino @@ -884,7 +884,7 @@ void HandleImageBasic(void) { } if (_jpg_buf_len) { - Webserver->client().clear(); // New with core3. Does what flush() did in core2; + Webserver->client().flush(); WSHeaderSend(); Webserver->sendHeader(F("Content-disposition"), F("inline; filename=snapshot.jpg")); Webserver->send_P(200, "image/jpeg", (char *)_jpg_buf, _jpg_buf_len); @@ -925,7 +925,7 @@ void HandleWebcamMjpegTask(void) { WcStats.clientfail++; } if (1 == Wc.stream_active) { - Wc.client.clear(); // New with core3. Does what flush() did in core2; + Wc.client.flush(); Wc.client.setTimeout(3); AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Start stream")); Wc.client.print("HTTP/1.1 200 OK\r\n" @@ -990,7 +990,7 @@ void HandleWebcamMjpegTask(void) { } if (0 == Wc.stream_active) { AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Stream exit")); - Wc.client.clear(); // New with core3. Does what flush() did in core2; + Wc.client.flush(); Wc.client.stop(); } } diff --git a/tasmota/tasmota_xdrv_driver/xdrv_81_esp32_webcam_task.ino b/tasmota/tasmota_xdrv_driver/xdrv_81_esp32_webcam_task.ino index a9f9a3488..bf36b2f08 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_81_esp32_webcam_task.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_81_esp32_webcam_task.ino @@ -1888,7 +1888,7 @@ static void WCOperationTask(void *pvParameters){ WcStats.clientfail++; } if (1 == client->active) { - client->client.clear(); // New with core3. Does what flush() did in core2; + client->client.flush(); client->client.setTimeout(3); #ifdef WEBCAM_DEV_DEBUG AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Start stream")); diff --git a/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino b/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino index a06feeac3..e33c324d0 100755 --- a/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino @@ -1550,11 +1550,7 @@ void sml_shift_in(uint32_t meters, uint32_t shard) { memmove(&mp->sbuff[0], &mp->sbuff[6], mp->sbsiz - 6); SML_Decode(meters); if (mp->client) { -#ifdef ESP8266 mp->client->flush(); -#else - mp->client->clear(); // New with core3. Does what flush() did in core2; -#endif } //Hexdump(mp->sbuff + 6, 10); }