mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
Fix network flushes
This commit is contained in:
parent
27c35befdf
commit
b88ec44d15
@ -207,8 +207,9 @@ void DeviceGroupsStart()
|
|||||||
|
|
||||||
void DeviceGroupsStop()
|
void DeviceGroupsStop()
|
||||||
{
|
{
|
||||||
|
#ifdef ESP8266
|
||||||
device_groups_udp.flush();
|
device_groups_udp.flush();
|
||||||
#ifdef ESP32
|
#else
|
||||||
device_groups_udp.clear(); // New with core3. Does what flush() did in core2;
|
device_groups_udp.clear(); // New with core3. Does what flush() did in core2;
|
||||||
#endif
|
#endif
|
||||||
device_groups_up = false;
|
device_groups_up = false;
|
||||||
|
@ -60,12 +60,11 @@ bool UdpDisconnect(void)
|
|||||||
{
|
{
|
||||||
if (udp_connected) {
|
if (udp_connected) {
|
||||||
// flush any outgoing packet
|
// flush any outgoing packet
|
||||||
PortUdp.flush(); // Does nothing in core3
|
|
||||||
#ifdef ESP32
|
|
||||||
PortUdp.clear(); // New with core3. Does what flush() did in core2;
|
|
||||||
#endif
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
PortUdp.flush();
|
||||||
UdpCtx.disconnect();
|
UdpCtx.disconnect();
|
||||||
|
#else
|
||||||
|
PortUdp.clear(); // New with core3. Does what flush() did in core2;
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
// stop
|
// stop
|
||||||
@ -133,7 +132,6 @@ void PollUdp(void)
|
|||||||
|
|
||||||
int32_t len = PortUdp.read(packet_buffer, UDP_BUFFER_SIZE -1);
|
int32_t len = PortUdp.read(packet_buffer, UDP_BUFFER_SIZE -1);
|
||||||
packet_buffer[len] = 0;
|
packet_buffer[len] = 0;
|
||||||
// PortUdp.flush();
|
|
||||||
PortUdp.clear(); // New with core3. Does what flush() did in core2;
|
PortUdp.clear(); // New with core3. Does what flush() did in core2;
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet (%d/%d)"), len, pack_len);
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet (%d/%d)"), len, pack_len);
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
|
@ -775,7 +775,11 @@ void WSSend(int code, int ctype, const String& content)
|
|||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
void WSContentBegin(int code, int ctype) {
|
void WSContentBegin(int code, int ctype) {
|
||||||
|
#ifdef ESP8266
|
||||||
Webserver->client().flush();
|
Webserver->client().flush();
|
||||||
|
#else
|
||||||
|
Webserver->client().clear(); // New with core3. Does what flush() did in core2;
|
||||||
|
#endif
|
||||||
WSHeaderSend();
|
WSHeaderSend();
|
||||||
Webserver->setContentLength(CONTENT_LENGTH_UNKNOWN);
|
Webserver->setContentLength(CONTENT_LENGTH_UNKNOWN);
|
||||||
WSSend(code, ctype, ""); // Signal start of chunked content
|
WSSend(code, ctype, ""); // Signal start of chunked content
|
||||||
@ -3085,7 +3089,7 @@ void HandlePreflightRequest(void)
|
|||||||
// return a simple status page as text/plain code 200
|
// return a simple status page as text/plain code 200
|
||||||
static void WSReturnSimpleString(const char *msg) {
|
static void WSReturnSimpleString(const char *msg) {
|
||||||
if (nullptr == msg) { msg = ""; }
|
if (nullptr == msg) { msg = ""; }
|
||||||
Webserver->client().flush();
|
Webserver->client().clear(); // New with core3. Does what flush() did in core2;
|
||||||
WSHeaderSend();
|
WSHeaderSend();
|
||||||
Webserver->send(200, "text/plain", msg);
|
Webserver->send(200, "text/plain", msg);
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,6 @@ void ArtNetLoop(void)
|
|||||||
uint8_t packet_buffer[WS2812_ARTNET_UDP_BUFFER_SIZE]; // buffer to hold incoming UDP/SSDP packet
|
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);
|
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;
|
ArtNetUdp->clear(); // New with core3. Does what flush() did in core2;
|
||||||
#endif
|
#endif
|
||||||
// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet %*_H (%d)"), 32, packet_buffer, packet_len);
|
// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet %*_H (%d)"), 32, packet_buffer, packet_len);
|
||||||
|
@ -1386,8 +1386,9 @@ int32_t udp_call(char *url, uint32_t port, char *sbuf) {
|
|||||||
udp.beginPacket(adr, port);
|
udp.beginPacket(adr, port);
|
||||||
udp.write((const uint8_t*)sbuf, strlen(sbuf));
|
udp.write((const uint8_t*)sbuf, strlen(sbuf));
|
||||||
udp.endPacket();
|
udp.endPacket();
|
||||||
|
#ifdef ESP8266
|
||||||
udp.flush();
|
udp.flush();
|
||||||
#ifdef ESP32
|
#else
|
||||||
udp.clear(); // New with core3. Does what flush() did in core2;
|
udp.clear(); // New with core3. Does what flush() did in core2;
|
||||||
#endif
|
#endif
|
||||||
udp.stop();
|
udp.stop();
|
||||||
@ -1408,8 +1409,9 @@ void Restart_globvars(void) {
|
|||||||
void Script_Stop_UDP(void) {
|
void Script_Stop_UDP(void) {
|
||||||
if (!glob_script_mem.udp_flags.udp_used) return;
|
if (!glob_script_mem.udp_flags.udp_used) return;
|
||||||
if (glob_script_mem.udp_flags.udp_connected) {
|
if (glob_script_mem.udp_flags.udp_connected) {
|
||||||
|
#ifdef ESP8266
|
||||||
glob_script_mem.Script_PortUdp.flush();
|
glob_script_mem.Script_PortUdp.flush();
|
||||||
#ifdef ESP32
|
#else
|
||||||
glob_script_mem.Script_PortUdp.clear(); // New with core3. Does what flush() did in core2;
|
glob_script_mem.Script_PortUdp.clear(); // New with core3. Does what flush() did in core2;
|
||||||
#endif
|
#endif
|
||||||
glob_script_mem.Script_PortUdp.stop();
|
glob_script_mem.Script_PortUdp.stop();
|
||||||
@ -6392,7 +6394,11 @@ void tmod_directModeOutput(uint32_t pin);
|
|||||||
fvar = -1;
|
fvar = -1;
|
||||||
if (glob_script_mem.tcp_server) {
|
if (glob_script_mem.tcp_server) {
|
||||||
if (glob_script_mem.tcp_client.connected()) {
|
if (glob_script_mem.tcp_client.connected()) {
|
||||||
|
#ifdef ESP8266
|
||||||
glob_script_mem.tcp_client.flush();
|
glob_script_mem.tcp_client.flush();
|
||||||
|
#else
|
||||||
|
glob_script_mem.tcp_client.clear();
|
||||||
|
#endif
|
||||||
fvar = 0;
|
fvar = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ extern "C" {
|
|||||||
if (argc >= 2 && be_isint(vm, 1) && be_isstring(vm, 2)) {
|
if (argc >= 2 && be_isint(vm, 1) && be_isstring(vm, 2)) {
|
||||||
int32_t httpcode = be_toint(vm, 1);
|
int32_t httpcode = be_toint(vm, 1);
|
||||||
const char * mimetype = be_tostring(vm, 2);
|
const char * mimetype = be_tostring(vm, 2);
|
||||||
Webserver->client().flush();
|
Webserver->client().clear(); // New with core3. Does what flush() did in core2;
|
||||||
WSHeaderSend();
|
WSHeaderSend();
|
||||||
Webserver->setContentLength(CONTENT_LENGTH_UNKNOWN);
|
Webserver->setContentLength(CONTENT_LENGTH_UNKNOWN);
|
||||||
Webserver->send(httpcode, mimetype, "");
|
Webserver->send(httpcode, mimetype, "");
|
||||||
|
@ -311,7 +311,11 @@ void ModbusBridgeHandle(void)
|
|||||||
client.write(modbusBridge.buffer + 2, 4); // Don't send CRC
|
client.write(modbusBridge.buffer + 2, 4); // Don't send CRC
|
||||||
nrOfBytes += 4;
|
nrOfBytes += 4;
|
||||||
}
|
}
|
||||||
|
#ifdef ESP8266
|
||||||
client.flush();
|
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);
|
AddLog(LOG_LEVEL_DEBUG, PSTR("MBS: MBRTCP from Modbus deviceAddress %d, writing %d bytes to client"), modbusBridge.buffer[0], nrOfBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -884,7 +884,7 @@ void HandleImageBasic(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_jpg_buf_len) {
|
if (_jpg_buf_len) {
|
||||||
Webserver->client().flush();
|
Webserver->client().clear(); // New with core3. Does what flush() did in core2;
|
||||||
WSHeaderSend();
|
WSHeaderSend();
|
||||||
Webserver->sendHeader(F("Content-disposition"), F("inline; filename=snapshot.jpg"));
|
Webserver->sendHeader(F("Content-disposition"), F("inline; filename=snapshot.jpg"));
|
||||||
Webserver->send_P(200, "image/jpeg", (char *)_jpg_buf, _jpg_buf_len);
|
Webserver->send_P(200, "image/jpeg", (char *)_jpg_buf, _jpg_buf_len);
|
||||||
@ -925,7 +925,7 @@ void HandleWebcamMjpegTask(void) {
|
|||||||
WcStats.clientfail++;
|
WcStats.clientfail++;
|
||||||
}
|
}
|
||||||
if (1 == Wc.stream_active) {
|
if (1 == Wc.stream_active) {
|
||||||
Wc.client.flush();
|
Wc.client.clear(); // New with core3. Does what flush() did in core2;
|
||||||
Wc.client.setTimeout(3);
|
Wc.client.setTimeout(3);
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Start stream"));
|
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Start stream"));
|
||||||
Wc.client.print("HTTP/1.1 200 OK\r\n"
|
Wc.client.print("HTTP/1.1 200 OK\r\n"
|
||||||
@ -990,7 +990,7 @@ void HandleWebcamMjpegTask(void) {
|
|||||||
}
|
}
|
||||||
if (0 == Wc.stream_active) {
|
if (0 == Wc.stream_active) {
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Stream exit"));
|
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Stream exit"));
|
||||||
Wc.client.flush();
|
Wc.client.clear(); // New with core3. Does what flush() did in core2;
|
||||||
Wc.client.stop();
|
Wc.client.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1888,7 +1888,7 @@ static void WCOperationTask(void *pvParameters){
|
|||||||
WcStats.clientfail++;
|
WcStats.clientfail++;
|
||||||
}
|
}
|
||||||
if (1 == client->active) {
|
if (1 == client->active) {
|
||||||
client->client.flush();
|
client->client.clear(); // New with core3. Does what flush() did in core2;
|
||||||
client->client.setTimeout(3);
|
client->client.setTimeout(3);
|
||||||
#ifdef WEBCAM_DEV_DEBUG
|
#ifdef WEBCAM_DEV_DEBUG
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Start stream"));
|
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Start stream"));
|
||||||
|
@ -1550,7 +1550,11 @@ void sml_shift_in(uint32_t meters, uint32_t shard) {
|
|||||||
memmove(&mp->sbuff[0], &mp->sbuff[6], mp->sbsiz - 6);
|
memmove(&mp->sbuff[0], &mp->sbuff[6], mp->sbsiz - 6);
|
||||||
SML_Decode(meters);
|
SML_Decode(meters);
|
||||||
if (mp->client) {
|
if (mp->client) {
|
||||||
|
#ifdef ESP8266
|
||||||
mp->client->flush();
|
mp->client->flush();
|
||||||
|
#else
|
||||||
|
mp->client->clear(); // New with core3. Does what flush() did in core2;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
//Hexdump(mp->sbuff + 6, 10);
|
//Hexdump(mp->sbuff + 6, 10);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user