Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit 5987225

Browse files
author
Me No Dev
committed
add setter and getter for ack timeout
if set to 0 it will not timeout
1 parent 0f2292b commit 5987225

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/ESPAsyncTCP.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ AsyncClient::AsyncClient(tcp_pcb* pcb):
5252
, _ack_pcb(true)
5353
, _rx_last_packet(0)
5454
, _rx_since_timeout(0)
55+
, _ack_timeout(ASYNC_MAX_ACK_TIME)
5556
, _connect_port(0)
5657
, prev(NULL)
5758
, next(NULL)
@@ -306,7 +307,7 @@ int8_t AsyncClient::_poll(tcp_pcb* pcb){
306307
}
307308
uint32_t now = millis();
308309
// ACK Timeout
309-
if(_pcb_busy && (now - _pcb_sent_at) >= ASYNC_MAX_ACK_TIME){
310+
if(_pcb_busy && _ack_timeout && (now - _pcb_sent_at) >= _ack_timeout){
310311
_pcb_busy = false;
311312
if(_timeout_cb)
312313
_timeout_cb(_timeout_cb_arg, this, (now - _pcb_sent_at));
@@ -383,6 +384,14 @@ uint32_t AsyncClient::getRxTimeout(){
383384
return _rx_since_timeout;
384385
}
385386

387+
uint32_t AsyncClient::getAckTimeout(){
388+
return _ack_timeout;
389+
}
390+
391+
void AsyncClient::setAckTimeout(uint32_t timeout){
392+
_ack_timeout = timeout;
393+
}
394+
386395
void AsyncClient::setNoDelay(bool nodelay){
387396
if(!_pcb)
388397
return;

src/ESPAsyncTCP.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class AsyncClient {
7070
uint32_t _rx_ack_len;
7171
uint32_t _rx_last_packet;
7272
uint32_t _rx_since_timeout;
73+
uint32_t _ack_timeout;
7374
uint16_t _connect_port;
7475

7576
int8_t _close();
@@ -129,6 +130,8 @@ class AsyncClient {
129130

130131
uint32_t getRxTimeout();
131132
void setRxTimeout(uint32_t timeout);//no RX data timeout for the connection in seconds
133+
uint32_t getAckTimeout();
134+
void setAckTimeout(uint32_t timeout);//no ACK timeout for the last sent packet in milliseconds
132135
void setNoDelay(bool nodelay);
133136
bool getNoDelay();
134137
uint32_t getRemoteAddress();

0 commit comments

Comments
 (0)