mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
added Michael's AsyncTCP fixes for testing
This commit is contained in:
9
lib/AsyncTCP/library.properties
Normal file
9
lib/AsyncTCP/library.properties
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
name=AsyncTCP
|
||||||
|
version=1.1.1
|
||||||
|
author=Me-No-Dev
|
||||||
|
maintainer=Me-No-Dev
|
||||||
|
sentence=Async TCP Library for ESP32
|
||||||
|
paragraph=Async TCP Library for ESP32
|
||||||
|
category=Other
|
||||||
|
url=https://github.com/me-no-dev/AsyncTCP
|
||||||
|
architectures=*
|
||||||
@@ -85,7 +85,7 @@ typedef struct {
|
|||||||
} lwip_event_packet_t;
|
} lwip_event_packet_t;
|
||||||
|
|
||||||
static QueueHandle_t _async_queue;
|
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;
|
SemaphoreHandle_t _slots_lock;
|
||||||
@@ -226,7 +226,8 @@ static bool _start_async_task() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!_async_service_task_handle) {
|
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) {
|
if (!_async_service_task_handle) {
|
||||||
return false;
|
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 AsyncClient::write(const char * data, size_t size, uint8_t apiflags) {
|
||||||
size_t will_send = add(data, size, apiflags);
|
size_t will_send = add(data, size, apiflags);
|
||||||
if (!will_send || !send()) {
|
if (!will_send) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
while (connected() && !send()) {
|
||||||
|
taskYIELD();
|
||||||
|
}
|
||||||
return will_send;
|
return will_send;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1080,6 +1084,18 @@ bool AsyncClient::getNoDelay() {
|
|||||||
return tcp_nagle_disabled(_pcb);
|
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() {
|
uint16_t AsyncClient::getMss() {
|
||||||
if (!_pcb) {
|
if (!_pcb) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "lwip/pbuf.h"
|
#include "lwip/pbuf.h"
|
||||||
#include "lwip/ip_addr.h"
|
#include "lwip/ip_addr.h"
|
||||||
@@ -36,7 +37,11 @@ extern "C" {
|
|||||||
//If core is not defined, then we are running in Arduino or PIO
|
//If core is not defined, then we are running in Arduino or PIO
|
||||||
#ifndef CONFIG_ASYNC_TCP_RUNNING_CORE
|
#ifndef CONFIG_ASYNC_TCP_RUNNING_CORE
|
||||||
#define CONFIG_ASYNC_TCP_RUNNING_CORE -1 //any available core
|
#define CONFIG_ASYNC_TCP_RUNNING_CORE -1 //any available core
|
||||||
#define CONFIG_ASYNC_TCP_USE_WDT 1 //if enabled, adds between 33us and 200us per event
|
#define CONFIG_ASYNC_TCP_USE_WDT 0 //if enabled, adds between 33us and 200us per event
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_ASYNC_TCP_TASK_PRIORITY
|
||||||
|
#define CONFIG_ASYNC_TCP_TASK_PRIORITY 15
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class AsyncClient;
|
class AsyncClient;
|
||||||
@@ -103,6 +108,8 @@ class AsyncClient {
|
|||||||
void setNoDelay(bool nodelay);
|
void setNoDelay(bool nodelay);
|
||||||
bool getNoDelay();
|
bool getNoDelay();
|
||||||
|
|
||||||
|
void setKeepAlive(uint32_t ms, uint8_t cnt);
|
||||||
|
|
||||||
uint32_t getRemoteAddress();
|
uint32_t getRemoteAddress();
|
||||||
ip6_addr_t getRemoteAddress6();
|
ip6_addr_t getRemoteAddress6();
|
||||||
uint16_t getRemotePort();
|
uint16_t getRemotePort();
|
||||||
|
|||||||
Reference in New Issue
Block a user