Fixes for tcpasync (#20411)

This commit is contained in:
s-hadinger 2024-01-06 17:03:51 +01:00 committed by GitHub
parent af2b90caac
commit 15b40801d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 14 deletions

View File

@ -12,7 +12,7 @@ import sys
sys.path().push('src/embedded') # allow to import from src/embedded
# globals that need to exist to make compilation succeed
var globs = "path,ctypes_bytes_dyn,tasmota,ccronexpr,gpio,light,webclient,load,MD5,lv,light_state,udp,I2C_Driver,"
var globs = "path,ctypes_bytes_dyn,tasmota,ccronexpr,gpio,light,webclient,load,MD5,lv,light_state,udp,I2C_Driver,tcpserver,"
"lv_clock,lv_clock_icon,lv_signal_arcs,lv_signal_bars,lv_wifi_arcs_icon,lv_wifi_arcs,"
"lv_wifi_bars_icon,lv_wifi_bars,"
"_lvgl,"

View File

@ -557,8 +557,7 @@ class Tasmota
# iterate and call each closure
var i = 0
var sz = size(fl)
while i < sz
while i < size(fl)
# note: this is not guarded in try/except for performance reasons. The inner function must not raise exceptions
fl[i]()
i += 1

View File

@ -110,12 +110,12 @@ be_local_closure(Tasmota_fast_loop, /* name */
0x600C000C, // 0005 GETGBL R3 G12
0x5C100200, // 0006 MOVE R4 R1
0x7C0C0200, // 0007 CALL R3 1
0x14100403, // 0008 LT R4 R2 R3
0x78120003, // 0009 JMPF R4 #000E
0x94100202, // 000A GETIDX R4 R1 R2
0x7C100000, // 000B CALL R4 0
0x140C0403, // 0008 LT R3 R2 R3
0x780E0003, // 0009 JMPF R3 #000E
0x940C0202, // 000A GETIDX R3 R1 R2
0x7C0C0000, // 000B CALL R3 0
0x00080502, // 000C ADD R2 R2 K2
0x7001FFF9, // 000D JMP #0008
0x7001FFF6, // 000D JMP #0005
0x80000000, // 000E RET 0
})
)

View File

@ -186,8 +186,7 @@ public:
stop();
break;
default:
// AddLog(LOG_LEVEL_DEBUG, "BRY: tcpclientasync unexpected: RES: %d, ERR: %d", res, errno);
stop();
// AddLog(LOG_LEVEL_DEBUG, "BRY: tcpclientasync unexpected: RES: %d, ERR: %d, sockfd=%d", res, errno, sockfd);
break;
}
} else {

View File

@ -38,8 +38,6 @@ class WiFiServerAsync {
public:
void listenOnLocalhost(){}
WiFiServerAsync(uint16_t port=80, uint8_t max_clients=4):sockfd(-1),_accepted_sockfd(-1),_addr(),_port(port),_max_clients(max_clients),_listening(false),_noDelay(false) {
}
WiFiServerAsync(const IPAddress& addr, uint16_t port=80, uint8_t max_clients=4):sockfd(-1),_accepted_sockfd(-1),_addr(addr),_port(port),_max_clients(max_clients),_listening(false),_noDelay(false) {
@ -117,8 +115,11 @@ AsyncTCPClient * WiFiServerAsync::availableAsync(){
int val = 1;
if(setsockopt(client_sock, SOL_SOCKET, SO_KEEPALIVE, (char*)&val, sizeof(int)) == ESP_OK) {
val = _noDelay;
if(setsockopt(client_sock, IPPROTO_TCP, TCP_NODELAY, (char*)&val, sizeof(int)) == ESP_OK)
return new AsyncTCPClient(client_sock);
if(setsockopt(client_sock, IPPROTO_TCP, TCP_NODELAY, (char*)&val, sizeof(int)) == ESP_OK) {
if (fcntl(client_sock, F_SETFL, fcntl(sockfd, F_GETFL, 0) | O_NONBLOCK ) == ESP_OK) { // set non-blocking
return new AsyncTCPClient(client_sock);
}
}
}
}
return new AsyncTCPClient();