mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
@@ -57,7 +57,7 @@
|
||||
"@typescript-eslint/eslint-plugin": "^7.0.2",
|
||||
"@typescript-eslint/parser": "^7.0.2",
|
||||
"concurrently": "^8.2.2",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-import-resolver-typescript": "^3.6.1",
|
||||
"eslint-plugin-autofix": "^1.1.0",
|
||||
|
||||
@@ -856,10 +856,10 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@eslint/js@npm:8.56.0":
|
||||
version: 8.56.0
|
||||
resolution: "@eslint/js@npm:8.56.0"
|
||||
checksum: 10/97a4b5ccf7e24f4d205a1fb0f21cdcd610348ecf685f6798a48dd41ba443f2c1eedd3050ff5a0b8f30b8cf6501ab512aa9b76e531db15e59c9ebaa41f3162e37
|
||||
"@eslint/js@npm:8.57.0":
|
||||
version: 8.57.0
|
||||
resolution: "@eslint/js@npm:8.57.0"
|
||||
checksum: 10/3c501ce8a997cf6cbbaf4ed358af5492875e3550c19b9621413b82caa9ae5382c584b0efa79835639e6e0ddaa568caf3499318e5bdab68643ef4199dce5eb0a0
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -901,14 +901,14 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@humanwhocodes/config-array@npm:^0.11.13":
|
||||
version: 0.11.13
|
||||
resolution: "@humanwhocodes/config-array@npm:0.11.13"
|
||||
"@humanwhocodes/config-array@npm:^0.11.14":
|
||||
version: 0.11.14
|
||||
resolution: "@humanwhocodes/config-array@npm:0.11.14"
|
||||
dependencies:
|
||||
"@humanwhocodes/object-schema": "npm:^2.0.1"
|
||||
debug: "npm:^4.1.1"
|
||||
"@humanwhocodes/object-schema": "npm:^2.0.2"
|
||||
debug: "npm:^4.3.1"
|
||||
minimatch: "npm:^3.0.5"
|
||||
checksum: 10/9f655e1df7efa5a86822cd149ca5cef57240bb8ffd728f0c07cc682cc0a15c6bdce68425fbfd58f9b3e8b16f79b3fd8cb1e96b10c434c9a76f20b2a89f213272
|
||||
checksum: 10/3ffb24ecdfab64014a230e127118d50a1a04d11080cbb748bc21629393d100850496456bbcb4e8c438957fe0934430d731042f1264d6a167b62d32fc2863580a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -919,10 +919,10 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@humanwhocodes/object-schema@npm:^2.0.1":
|
||||
version: 2.0.1
|
||||
resolution: "@humanwhocodes/object-schema@npm:2.0.1"
|
||||
checksum: 10/dbddfd0465aecf92ed845ec30d06dba3f7bb2496d544b33b53dac7abc40370c0e46b8787b268d24a366730d5eeb5336ac88967232072a183905ee4abf7df4dab
|
||||
"@humanwhocodes/object-schema@npm:^2.0.2":
|
||||
version: 2.0.2
|
||||
resolution: "@humanwhocodes/object-schema@npm:2.0.2"
|
||||
checksum: 10/ef915e3e2f34652f3d383b28a9a99cfea476fa991482370889ab14aac8ecd2b38d47cc21932526c6d949da0daf4a4a6bf629d30f41b0caca25e146819cbfa70e
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -1867,7 +1867,7 @@ __metadata:
|
||||
alova: "npm:^2.17.0"
|
||||
async-validator: "npm:^4.2.5"
|
||||
concurrently: "npm:^8.2.2"
|
||||
eslint: "npm:^8.56.0"
|
||||
eslint: "npm:^8.57.0"
|
||||
eslint-config-prettier: "npm:^9.1.0"
|
||||
eslint-import-resolver-typescript: "npm:^3.6.1"
|
||||
eslint-plugin-autofix: "npm:^1.1.0"
|
||||
@@ -3979,15 +3979,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"eslint@npm:^8.56.0":
|
||||
version: 8.56.0
|
||||
resolution: "eslint@npm:8.56.0"
|
||||
"eslint@npm:^8.57.0":
|
||||
version: 8.57.0
|
||||
resolution: "eslint@npm:8.57.0"
|
||||
dependencies:
|
||||
"@eslint-community/eslint-utils": "npm:^4.2.0"
|
||||
"@eslint-community/regexpp": "npm:^4.6.1"
|
||||
"@eslint/eslintrc": "npm:^2.1.4"
|
||||
"@eslint/js": "npm:8.56.0"
|
||||
"@humanwhocodes/config-array": "npm:^0.11.13"
|
||||
"@eslint/js": "npm:8.57.0"
|
||||
"@humanwhocodes/config-array": "npm:^0.11.14"
|
||||
"@humanwhocodes/module-importer": "npm:^1.0.1"
|
||||
"@nodelib/fs.walk": "npm:^1.2.8"
|
||||
"@ungap/structured-clone": "npm:^1.2.0"
|
||||
@@ -4023,7 +4023,7 @@ __metadata:
|
||||
text-table: "npm:^0.2.0"
|
||||
bin:
|
||||
eslint: bin/eslint.js
|
||||
checksum: 10/ef6193c6e4cef20774b985a5cc2fd4bf6d3c4decd423117cbc4a0196617861745db291217ad3c537bc3a160650cca965bc818f55e1f3e446af1fcb293f9940a5
|
||||
checksum: 10/00496e218b23747a7a9817bf58b522276d0dc1f2e546dceb4eea49f9871574088f72f1f069a6b560ef537efa3a75261b8ef70e51ef19033da1cc4c86a755ef15
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
@@ -38,7 +38,15 @@ extern "C"{
|
||||
* */
|
||||
|
||||
typedef enum {
|
||||
LWIP_TCP_SENT, LWIP_TCP_RECV, LWIP_TCP_FIN, LWIP_TCP_ERROR, LWIP_TCP_POLL, LWIP_TCP_CLEAR, LWIP_TCP_ACCEPT, LWIP_TCP_CONNECTED, LWIP_TCP_DNS
|
||||
LWIP_TCP_SENT,
|
||||
LWIP_TCP_RECV,
|
||||
LWIP_TCP_FIN,
|
||||
LWIP_TCP_ERROR,
|
||||
LWIP_TCP_POLL,
|
||||
LWIP_TCP_CLEAR,
|
||||
LWIP_TCP_ACCEPT,
|
||||
LWIP_TCP_CONNECTED,
|
||||
LWIP_TCP_DNS
|
||||
} lwip_event_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -78,7 +86,7 @@ typedef struct {
|
||||
};
|
||||
} lwip_event_packet_t;
|
||||
|
||||
static xQueueHandle _async_queue;
|
||||
static QueueHandle_t _async_queue;
|
||||
static TaskHandle_t _async_service_task_handle = NULL;
|
||||
|
||||
|
||||
@@ -97,7 +105,8 @@ static uint32_t _closed_index = []() {
|
||||
|
||||
static inline bool _init_async_event_queue() {
|
||||
if (!_async_queue) {
|
||||
_async_queue = xQueueCreate(32, sizeof(lwip_event_packet_t *));
|
||||
_async_queue =
|
||||
xQueueCreate(CONFIG_ASYNC_TCP_QUEUE, sizeof(lwip_event_packet_t *)); // double queue to 128 see https://github.com/emsesp/EMS-ESP32/issues/177
|
||||
if (!_async_queue) {
|
||||
return false;
|
||||
}
|
||||
@@ -216,8 +225,7 @@ static void _stop_async_task(){
|
||||
}
|
||||
*/
|
||||
|
||||
static bool customTaskCreateUniversal(
|
||||
TaskFunction_t pxTaskCode,
|
||||
static bool customTaskCreateUniversal(TaskFunction_t pxTaskCode,
|
||||
const char * const pcName,
|
||||
const uint32_t usStackDepth,
|
||||
void * const pvParameters,
|
||||
@@ -240,7 +248,13 @@ static bool _start_async_task(){
|
||||
return false;
|
||||
}
|
||||
if (!_async_service_task_handle) {
|
||||
customTaskCreateUniversal(_async_service_task, "async_tcp", CONFIG_ASYNC_TCP_STACK_SIZE, NULL, 3, &_async_service_task_handle, CONFIG_ASYNC_TCP_RUNNING_CORE);
|
||||
customTaskCreateUniversal(_async_service_task,
|
||||
"async_tcp",
|
||||
CONFIG_ASYNC_TCP_STACK_SIZE,
|
||||
NULL,
|
||||
CONFIG_ASYNC_TCP_TASK_PRIORITY,
|
||||
&_async_service_task_handle,
|
||||
CONFIG_ASYNC_TCP_RUNNING_CORE);
|
||||
if (!_async_service_task_handle) {
|
||||
return false;
|
||||
}
|
||||
@@ -584,8 +598,7 @@ AsyncClient::AsyncClient(tcp_pcb* pcb)
|
||||
, _ack_timeout(ASYNC_MAX_ACK_TIME)
|
||||
, _connect_port(0)
|
||||
, prev(NULL)
|
||||
, next(NULL)
|
||||
{
|
||||
, next(NULL) {
|
||||
_pcb = pcb;
|
||||
_closed_slot = -1;
|
||||
if (_pcb) {
|
||||
@@ -1232,41 +1245,71 @@ bool AsyncClient::canSend(){
|
||||
|
||||
const char * AsyncClient::errorToString(int8_t error) {
|
||||
switch (error) {
|
||||
case ERR_OK: return "OK";
|
||||
case ERR_MEM: return "Out of memory error";
|
||||
case ERR_BUF: return "Buffer error";
|
||||
case ERR_TIMEOUT: return "Timeout";
|
||||
case ERR_RTE: return "Routing problem";
|
||||
case ERR_INPROGRESS: return "Operation in progress";
|
||||
case ERR_VAL: return "Illegal value";
|
||||
case ERR_WOULDBLOCK: return "Operation would block";
|
||||
case ERR_USE: return "Address in use";
|
||||
case ERR_ALREADY: return "Already connected";
|
||||
case ERR_CONN: return "Not connected";
|
||||
case ERR_IF: return "Low-level netif error";
|
||||
case ERR_ABRT: return "Connection aborted";
|
||||
case ERR_RST: return "Connection reset";
|
||||
case ERR_CLSD: return "Connection closed";
|
||||
case ERR_ARG: return "Illegal argument";
|
||||
case -55: return "DNS failed";
|
||||
default: return "UNKNOWN";
|
||||
case ERR_OK:
|
||||
return "OK";
|
||||
case ERR_MEM:
|
||||
return "Out of memory error";
|
||||
case ERR_BUF:
|
||||
return "Buffer error";
|
||||
case ERR_TIMEOUT:
|
||||
return "Timeout";
|
||||
case ERR_RTE:
|
||||
return "Routing problem";
|
||||
case ERR_INPROGRESS:
|
||||
return "Operation in progress";
|
||||
case ERR_VAL:
|
||||
return "Illegal value";
|
||||
case ERR_WOULDBLOCK:
|
||||
return "Operation would block";
|
||||
case ERR_USE:
|
||||
return "Address in use";
|
||||
case ERR_ALREADY:
|
||||
return "Already connected";
|
||||
case ERR_CONN:
|
||||
return "Not connected";
|
||||
case ERR_IF:
|
||||
return "Low-level netif error";
|
||||
case ERR_ABRT:
|
||||
return "Connection aborted";
|
||||
case ERR_RST:
|
||||
return "Connection reset";
|
||||
case ERR_CLSD:
|
||||
return "Connection closed";
|
||||
case ERR_ARG:
|
||||
return "Illegal argument";
|
||||
case -55:
|
||||
return "DNS failed";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
const char * AsyncClient::stateToString() {
|
||||
switch (state()) {
|
||||
case 0: return "Closed";
|
||||
case 1: return "Listen";
|
||||
case 2: return "SYN Sent";
|
||||
case 3: return "SYN Received";
|
||||
case 4: return "Established";
|
||||
case 5: return "FIN Wait 1";
|
||||
case 6: return "FIN Wait 2";
|
||||
case 7: return "Close Wait";
|
||||
case 8: return "Closing";
|
||||
case 9: return "Last ACK";
|
||||
case 10: return "Time Wait";
|
||||
default: return "UNKNOWN";
|
||||
case 0:
|
||||
return "Closed";
|
||||
case 1:
|
||||
return "Listen";
|
||||
case 2:
|
||||
return "SYN Sent";
|
||||
case 3:
|
||||
return "SYN Received";
|
||||
case 4:
|
||||
return "Established";
|
||||
case 5:
|
||||
return "FIN Wait 1";
|
||||
case 6:
|
||||
return "FIN Wait 2";
|
||||
case 7:
|
||||
return "Close Wait";
|
||||
case 8:
|
||||
return "Closing";
|
||||
case 9:
|
||||
return "Last ACK";
|
||||
case 10:
|
||||
return "Time Wait";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1317,8 +1360,8 @@ AsyncServer::AsyncServer(IPAddress addr, uint16_t port)
|
||||
, _noDelay(false)
|
||||
, _pcb(0)
|
||||
, _connect_cb(0)
|
||||
, _connect_cb_arg(0)
|
||||
{}
|
||||
, _connect_cb_arg(0) {
|
||||
}
|
||||
|
||||
AsyncServer::AsyncServer(IPv6Address addr, uint16_t port)
|
||||
: _port(port)
|
||||
@@ -1327,8 +1370,8 @@ AsyncServer::AsyncServer(IPv6Address addr, uint16_t port)
|
||||
, _noDelay(false)
|
||||
, _pcb(0)
|
||||
, _connect_cb(0)
|
||||
, _connect_cb_arg(0)
|
||||
{}
|
||||
, _connect_cb_arg(0) {
|
||||
}
|
||||
|
||||
AsyncServer::AsyncServer(uint16_t port)
|
||||
: _port(port)
|
||||
@@ -1339,8 +1382,8 @@ AsyncServer::AsyncServer(uint16_t port)
|
||||
, _noDelay(false)
|
||||
, _pcb(0)
|
||||
, _connect_cb(0)
|
||||
, _connect_cb_arg(0)
|
||||
{}
|
||||
, _connect_cb_arg(0) {
|
||||
}
|
||||
|
||||
AsyncServer::~AsyncServer() {
|
||||
end();
|
||||
|
||||
@@ -46,11 +46,22 @@ extern "C" {
|
||||
//If core is not defined, then we are running in Arduino or PIO
|
||||
#ifndef CONFIG_ASYNC_TCP_RUNNING_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 5
|
||||
#endif
|
||||
|
||||
// stack usage measured: ESP32: ~2.3K, ESP32S3: ~3.5k
|
||||
#ifndef CONFIG_ASYNC_TCP_STACK_SIZE
|
||||
#define CONFIG_ASYNC_TCP_STACK_SIZE 8192 * 2
|
||||
#define CONFIG_ASYNC_TCP_STACK_SIZE 5120
|
||||
#endif
|
||||
|
||||
|
||||
// maybe enlarge queue to 64 or 128 see https://github.com/emsesp/EMS-ESP32/issues/177
|
||||
#ifndef CONFIG_ASYNC_TCP_QUEUE
|
||||
#define CONFIG_ASYNC_TCP_QUEUE 32
|
||||
#endif
|
||||
|
||||
class AsyncClient;
|
||||
@@ -143,7 +154,9 @@ class AsyncClient {
|
||||
|
||||
void ackPacket(struct pbuf * pb); //ack pbuf from onPacket
|
||||
size_t ack(size_t len); //ack data that you have not acked using the method below
|
||||
void ackLater(){ _ack_pcb = false; } //will not ack the current packet. Call from onData
|
||||
void ackLater() {
|
||||
_ack_pcb = false;
|
||||
} //will not ack the current packet. Call from onData
|
||||
|
||||
const char * errorToString(int8_t error);
|
||||
const char * stateToString();
|
||||
@@ -159,7 +172,9 @@ class AsyncClient {
|
||||
static void _s_dns_found(const char * name, struct ip_addr * ipaddr, void * arg);
|
||||
|
||||
int8_t _recv(tcp_pcb * pcb, pbuf * pb, int8_t err);
|
||||
tcp_pcb * pcb(){ return _pcb; }
|
||||
tcp_pcb * pcb() {
|
||||
return _pcb;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool _connect(ip_addr_t addr, uint16_t port);
|
||||
|
||||
@@ -316,12 +316,11 @@ void NetworkSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info)
|
||||
break;
|
||||
|
||||
case ARDUINO_EVENT_ETH_START:
|
||||
ETH.setHostname(emsesp::EMSESP::system_.hostname().c_str());
|
||||
|
||||
// configure for static IP
|
||||
if (_state.staticIPConfig) {
|
||||
ETH.config(_state.localIP, _state.gatewayIP, _state.subnetMask, _state.dnsIP1, _state.dnsIP2);
|
||||
}
|
||||
ETH.setHostname(emsesp::EMSESP::system_.hostname().c_str());
|
||||
break;
|
||||
|
||||
case ARDUINO_EVENT_ETH_GOT_IP:
|
||||
|
||||
@@ -32,7 +32,7 @@ build_flags =
|
||||
-D ARDUINOJSON_USE_DOUBLE=0
|
||||
-D ARDUINOTRACE_ENABLE=0
|
||||
-D CONFIG_ETH_ENABLED
|
||||
-D CONFIG_ASYNC_TCP_STACK_SIZE=8192
|
||||
-D CONFIG_ASYNC_TCP_STACK_SIZE=5120
|
||||
|
||||
unbuild_flags =
|
||||
${common.core_unbuild_flags}
|
||||
|
||||
@@ -592,7 +592,7 @@ bool Mqtt::queue_message(const uint8_t operation, const std::string & topic, con
|
||||
}
|
||||
// check free mem
|
||||
#ifndef EMSESP_STANDALONE
|
||||
if (ESP.getFreeHeap() < 60 * 1204 || ESP.getMaxAllocHeap() < 40 * 1024) {
|
||||
if (ESP.getFreeHeap() < 60 * 1024 || ESP.getMaxAllocHeap() < 40 * 1024) {
|
||||
if (operation == Operation::PUBLISH) {
|
||||
mqtt_message_id_++;
|
||||
mqtt_publish_fails_++;
|
||||
|
||||
Reference in New Issue
Block a user