added Michael's AsyncTCP fixes for testing

This commit is contained in:
Proddy
2023-10-22 12:41:16 +02:00
parent fd49f0372a
commit 07bdf28350
3 changed files with 36 additions and 4 deletions

View File

@@ -85,7 +85,7 @@ typedef struct {
} lwip_event_packet_t;
static QueueHandle_t _async_queue;
static TaskHandle_t _async_service_task_handle = NULL;
static TaskHandle_t _async_service_task_handle = NULL;
SemaphoreHandle_t _slots_lock;
@@ -226,7 +226,8 @@ static bool _start_async_task() {
return false;
}
if (!_async_service_task_handle) {
xTaskCreateUniversal(_async_service_task, "async_tcp", 8192 * 2, NULL, 3, &_async_service_task_handle, CONFIG_ASYNC_TCP_RUNNING_CORE);
// xTaskCreateUniversal(_async_service_task, "async_tcp", 8192 * 2, NULL, 3, &_async_service_task_handle, CONFIG_ASYNC_TCP_RUNNING_CORE);
xTaskCreate(_async_service_task, "async_tcp", 8192, NULL, CONFIG_ASYNC_TCP_TASK_PRIORITY, &_async_service_task_handle);
if (!_async_service_task_handle) {
return false;
}
@@ -1040,9 +1041,12 @@ size_t AsyncClient::write(const char * data) {
size_t AsyncClient::write(const char * data, size_t size, uint8_t apiflags) {
size_t will_send = add(data, size, apiflags);
if (!will_send || !send()) {
if (!will_send) {
return 0;
}
while (connected() && !send()) {
taskYIELD();
}
return will_send;
}
@@ -1080,6 +1084,18 @@ bool AsyncClient::getNoDelay() {
return tcp_nagle_disabled(_pcb);
}
void AsyncClient::setKeepAlive(uint32_t ms, uint8_t cnt) {
if (ms != 0) {
_pcb->so_options |= SOF_KEEPALIVE; //Turn on TCP Keepalive for the given pcb
// Set the time between keepalive messages in milli-seconds
_pcb->keep_idle = ms;
_pcb->keep_intvl = ms;
_pcb->keep_cnt = cnt; //The number of unanswered probes required to force closure of the socket
} else {
_pcb->so_options &= ~SOF_KEEPALIVE; //Turn off TCP Keepalive for the given pcb
}
}
uint16_t AsyncClient::getMss() {
if (!_pcb) {
return 0;