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/eslint-plugin": "^7.0.2",
|
||||||
"@typescript-eslint/parser": "^7.0.2",
|
"@typescript-eslint/parser": "^7.0.2",
|
||||||
"concurrently": "^8.2.2",
|
"concurrently": "^8.2.2",
|
||||||
"eslint": "^8.56.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-import-resolver-typescript": "^3.6.1",
|
"eslint-import-resolver-typescript": "^3.6.1",
|
||||||
"eslint-plugin-autofix": "^1.1.0",
|
"eslint-plugin-autofix": "^1.1.0",
|
||||||
|
|||||||
@@ -856,10 +856,10 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@eslint/js@npm:8.56.0":
|
"@eslint/js@npm:8.57.0":
|
||||||
version: 8.56.0
|
version: 8.57.0
|
||||||
resolution: "@eslint/js@npm:8.56.0"
|
resolution: "@eslint/js@npm:8.57.0"
|
||||||
checksum: 10/97a4b5ccf7e24f4d205a1fb0f21cdcd610348ecf685f6798a48dd41ba443f2c1eedd3050ff5a0b8f30b8cf6501ab512aa9b76e531db15e59c9ebaa41f3162e37
|
checksum: 10/3c501ce8a997cf6cbbaf4ed358af5492875e3550c19b9621413b82caa9ae5382c584b0efa79835639e6e0ddaa568caf3499318e5bdab68643ef4199dce5eb0a0
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -901,14 +901,14 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@humanwhocodes/config-array@npm:^0.11.13":
|
"@humanwhocodes/config-array@npm:^0.11.14":
|
||||||
version: 0.11.13
|
version: 0.11.14
|
||||||
resolution: "@humanwhocodes/config-array@npm:0.11.13"
|
resolution: "@humanwhocodes/config-array@npm:0.11.14"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@humanwhocodes/object-schema": "npm:^2.0.1"
|
"@humanwhocodes/object-schema": "npm:^2.0.2"
|
||||||
debug: "npm:^4.1.1"
|
debug: "npm:^4.3.1"
|
||||||
minimatch: "npm:^3.0.5"
|
minimatch: "npm:^3.0.5"
|
||||||
checksum: 10/9f655e1df7efa5a86822cd149ca5cef57240bb8ffd728f0c07cc682cc0a15c6bdce68425fbfd58f9b3e8b16f79b3fd8cb1e96b10c434c9a76f20b2a89f213272
|
checksum: 10/3ffb24ecdfab64014a230e127118d50a1a04d11080cbb748bc21629393d100850496456bbcb4e8c438957fe0934430d731042f1264d6a167b62d32fc2863580a
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -919,10 +919,10 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@humanwhocodes/object-schema@npm:^2.0.1":
|
"@humanwhocodes/object-schema@npm:^2.0.2":
|
||||||
version: 2.0.1
|
version: 2.0.2
|
||||||
resolution: "@humanwhocodes/object-schema@npm:2.0.1"
|
resolution: "@humanwhocodes/object-schema@npm:2.0.2"
|
||||||
checksum: 10/dbddfd0465aecf92ed845ec30d06dba3f7bb2496d544b33b53dac7abc40370c0e46b8787b268d24a366730d5eeb5336ac88967232072a183905ee4abf7df4dab
|
checksum: 10/ef915e3e2f34652f3d383b28a9a99cfea476fa991482370889ab14aac8ecd2b38d47cc21932526c6d949da0daf4a4a6bf629d30f41b0caca25e146819cbfa70e
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -1867,7 +1867,7 @@ __metadata:
|
|||||||
alova: "npm:^2.17.0"
|
alova: "npm:^2.17.0"
|
||||||
async-validator: "npm:^4.2.5"
|
async-validator: "npm:^4.2.5"
|
||||||
concurrently: "npm:^8.2.2"
|
concurrently: "npm:^8.2.2"
|
||||||
eslint: "npm:^8.56.0"
|
eslint: "npm:^8.57.0"
|
||||||
eslint-config-prettier: "npm:^9.1.0"
|
eslint-config-prettier: "npm:^9.1.0"
|
||||||
eslint-import-resolver-typescript: "npm:^3.6.1"
|
eslint-import-resolver-typescript: "npm:^3.6.1"
|
||||||
eslint-plugin-autofix: "npm:^1.1.0"
|
eslint-plugin-autofix: "npm:^1.1.0"
|
||||||
@@ -3979,15 +3979,15 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"eslint@npm:^8.56.0":
|
"eslint@npm:^8.57.0":
|
||||||
version: 8.56.0
|
version: 8.57.0
|
||||||
resolution: "eslint@npm:8.56.0"
|
resolution: "eslint@npm:8.57.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@eslint-community/eslint-utils": "npm:^4.2.0"
|
"@eslint-community/eslint-utils": "npm:^4.2.0"
|
||||||
"@eslint-community/regexpp": "npm:^4.6.1"
|
"@eslint-community/regexpp": "npm:^4.6.1"
|
||||||
"@eslint/eslintrc": "npm:^2.1.4"
|
"@eslint/eslintrc": "npm:^2.1.4"
|
||||||
"@eslint/js": "npm:8.56.0"
|
"@eslint/js": "npm:8.57.0"
|
||||||
"@humanwhocodes/config-array": "npm:^0.11.13"
|
"@humanwhocodes/config-array": "npm:^0.11.14"
|
||||||
"@humanwhocodes/module-importer": "npm:^1.0.1"
|
"@humanwhocodes/module-importer": "npm:^1.0.1"
|
||||||
"@nodelib/fs.walk": "npm:^1.2.8"
|
"@nodelib/fs.walk": "npm:^1.2.8"
|
||||||
"@ungap/structured-clone": "npm:^1.2.0"
|
"@ungap/structured-clone": "npm:^1.2.0"
|
||||||
@@ -4023,7 +4023,7 @@ __metadata:
|
|||||||
text-table: "npm:^0.2.0"
|
text-table: "npm:^0.2.0"
|
||||||
bin:
|
bin:
|
||||||
eslint: bin/eslint.js
|
eslint: bin/eslint.js
|
||||||
checksum: 10/ef6193c6e4cef20774b985a5cc2fd4bf6d3c4decd423117cbc4a0196617861745db291217ad3c537bc3a160650cca965bc818f55e1f3e446af1fcb293f9940a5
|
checksum: 10/00496e218b23747a7a9817bf58b522276d0dc1f2e546dceb4eea49f9871574088f72f1f069a6b560ef537efa3a75261b8ef70e51ef19033da1cc4c86a755ef15
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -29,15 +29,15 @@
|
|||||||
#ifndef LIBRETINY
|
#ifndef LIBRETINY
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#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"
|
||||||
#include "lwip/ip6_addr.h"
|
#include "lwip/ip6_addr.h"
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <semphr.h>
|
#include <semphr.h>
|
||||||
#include <lwip/pbuf.h>
|
#include <lwip/pbuf.h>
|
||||||
}
|
}
|
||||||
#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 0
|
#define CONFIG_ASYNC_TCP_USE_WDT 0
|
||||||
@@ -46,11 +46,22 @@ 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
|
#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
|
#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
|
#endif
|
||||||
|
|
||||||
class AsyncClient;
|
class AsyncClient;
|
||||||
@@ -59,132 +70,136 @@ class AsyncClient;
|
|||||||
#define ASYNC_WRITE_FLAG_COPY 0x01 //will allocate new buffer to hold the data while sending (else will hold reference to the data given)
|
#define ASYNC_WRITE_FLAG_COPY 0x01 //will allocate new buffer to hold the data while sending (else will hold reference to the data given)
|
||||||
#define ASYNC_WRITE_FLAG_MORE 0x02 //will not send PSH flag, meaning that there should be more data to be sent before the application should react.
|
#define ASYNC_WRITE_FLAG_MORE 0x02 //will not send PSH flag, meaning that there should be more data to be sent before the application should react.
|
||||||
|
|
||||||
typedef std::function<void(void*, AsyncClient*)> AcConnectHandler;
|
typedef std::function<void(void *, AsyncClient *)> AcConnectHandler;
|
||||||
typedef std::function<void(void*, AsyncClient*, size_t len, uint32_t time)> AcAckHandler;
|
typedef std::function<void(void *, AsyncClient *, size_t len, uint32_t time)> AcAckHandler;
|
||||||
typedef std::function<void(void*, AsyncClient*, int8_t error)> AcErrorHandler;
|
typedef std::function<void(void *, AsyncClient *, int8_t error)> AcErrorHandler;
|
||||||
typedef std::function<void(void*, AsyncClient*, void *data, size_t len)> AcDataHandler;
|
typedef std::function<void(void *, AsyncClient *, void * data, size_t len)> AcDataHandler;
|
||||||
typedef std::function<void(void*, AsyncClient*, struct pbuf *pb)> AcPacketHandler;
|
typedef std::function<void(void *, AsyncClient *, struct pbuf * pb)> AcPacketHandler;
|
||||||
typedef std::function<void(void*, AsyncClient*, uint32_t time)> AcTimeoutHandler;
|
typedef std::function<void(void *, AsyncClient *, uint32_t time)> AcTimeoutHandler;
|
||||||
|
|
||||||
struct tcp_pcb;
|
struct tcp_pcb;
|
||||||
struct ip_addr;
|
struct ip_addr;
|
||||||
|
|
||||||
class AsyncClient {
|
class AsyncClient {
|
||||||
public:
|
public:
|
||||||
AsyncClient(tcp_pcb* pcb = 0);
|
AsyncClient(tcp_pcb * pcb = 0);
|
||||||
~AsyncClient();
|
~AsyncClient();
|
||||||
|
|
||||||
AsyncClient & operator=(const AsyncClient &other);
|
AsyncClient & operator=(const AsyncClient & other);
|
||||||
AsyncClient & operator+=(const AsyncClient &other);
|
AsyncClient & operator+=(const AsyncClient & other);
|
||||||
|
|
||||||
bool operator==(const AsyncClient &other);
|
bool operator==(const AsyncClient & other);
|
||||||
|
|
||||||
bool operator!=(const AsyncClient &other) {
|
bool operator!=(const AsyncClient & other) {
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
bool connect(IPAddress ip, uint16_t port);
|
bool connect(IPAddress ip, uint16_t port);
|
||||||
bool connect(IPv6Address ip, uint16_t port);
|
bool connect(IPv6Address ip, uint16_t port);
|
||||||
bool connect(const char *host, uint16_t port);
|
bool connect(const char * host, uint16_t port);
|
||||||
void close(bool now = false);
|
void close(bool now = false);
|
||||||
void stop();
|
void stop();
|
||||||
int8_t abort();
|
int8_t abort();
|
||||||
bool free();
|
bool free();
|
||||||
|
|
||||||
bool canSend();//ack is not pending
|
bool canSend(); //ack is not pending
|
||||||
size_t space();//space available in the TCP window
|
size_t space(); //space available in the TCP window
|
||||||
size_t add(const char* data, size_t size, uint8_t apiflags=ASYNC_WRITE_FLAG_COPY);//add for sending
|
size_t add(const char * data, size_t size, uint8_t apiflags = ASYNC_WRITE_FLAG_COPY); //add for sending
|
||||||
bool send();//send all data added with the method above
|
bool send(); //send all data added with the method above
|
||||||
|
|
||||||
//write equals add()+send()
|
//write equals add()+send()
|
||||||
size_t write(const char* data);
|
size_t write(const char * data);
|
||||||
size_t write(const char* data, size_t size, uint8_t apiflags=ASYNC_WRITE_FLAG_COPY); //only when canSend() == true
|
size_t write(const char * data, size_t size, uint8_t apiflags = ASYNC_WRITE_FLAG_COPY); //only when canSend() == true
|
||||||
|
|
||||||
uint8_t state();
|
uint8_t state();
|
||||||
bool connecting();
|
bool connecting();
|
||||||
bool connected();
|
bool connected();
|
||||||
bool disconnecting();
|
bool disconnecting();
|
||||||
bool disconnected();
|
bool disconnected();
|
||||||
bool freeable();//disconnected or disconnecting
|
bool freeable(); //disconnected or disconnecting
|
||||||
|
|
||||||
uint16_t getMss();
|
uint16_t getMss();
|
||||||
|
|
||||||
uint32_t getRxTimeout();
|
uint32_t getRxTimeout();
|
||||||
void setRxTimeout(uint32_t timeout);//no RX data timeout for the connection in seconds
|
void setRxTimeout(uint32_t timeout); //no RX data timeout for the connection in seconds
|
||||||
|
|
||||||
uint32_t getAckTimeout();
|
uint32_t getAckTimeout();
|
||||||
void setAckTimeout(uint32_t timeout);//no ACK timeout for the last sent packet in milliseconds
|
void setAckTimeout(uint32_t timeout); //no ACK timeout for the last sent packet in milliseconds
|
||||||
|
|
||||||
void setNoDelay(bool nodelay);
|
void setNoDelay(bool nodelay);
|
||||||
bool getNoDelay();
|
bool getNoDelay();
|
||||||
|
|
||||||
uint32_t getRemoteAddress();
|
uint32_t getRemoteAddress();
|
||||||
ip6_addr_t getRemoteAddress6();
|
ip6_addr_t getRemoteAddress6();
|
||||||
uint16_t getRemotePort();
|
uint16_t getRemotePort();
|
||||||
uint32_t getLocalAddress();
|
uint32_t getLocalAddress();
|
||||||
ip6_addr_t getLocalAddress6();
|
ip6_addr_t getLocalAddress6();
|
||||||
uint16_t getLocalPort();
|
uint16_t getLocalPort();
|
||||||
|
|
||||||
//compatibility
|
//compatibility
|
||||||
IPAddress remoteIP();
|
IPAddress remoteIP();
|
||||||
IPv6Address remoteIP6();
|
IPv6Address remoteIP6();
|
||||||
uint16_t remotePort();
|
uint16_t remotePort();
|
||||||
IPAddress localIP();
|
IPAddress localIP();
|
||||||
IPv6Address localIP6();
|
IPv6Address localIP6();
|
||||||
uint16_t localPort();
|
uint16_t localPort();
|
||||||
|
|
||||||
void onConnect(AcConnectHandler cb, void* arg = 0); //on successful connect
|
void onConnect(AcConnectHandler cb, void * arg = 0); //on successful connect
|
||||||
void onDisconnect(AcConnectHandler cb, void* arg = 0); //disconnected
|
void onDisconnect(AcConnectHandler cb, void * arg = 0); //disconnected
|
||||||
void onAck(AcAckHandler cb, void* arg = 0); //ack received
|
void onAck(AcAckHandler cb, void * arg = 0); //ack received
|
||||||
void onError(AcErrorHandler cb, void* arg = 0); //unsuccessful connect or error
|
void onError(AcErrorHandler cb, void * arg = 0); //unsuccessful connect or error
|
||||||
void onData(AcDataHandler cb, void* arg = 0); //data received (called if onPacket is not used)
|
void onData(AcDataHandler cb, void * arg = 0); //data received (called if onPacket is not used)
|
||||||
void onPacket(AcPacketHandler cb, void* arg = 0); //data received
|
void onPacket(AcPacketHandler cb, void * arg = 0); //data received
|
||||||
void onTimeout(AcTimeoutHandler cb, void* arg = 0); //ack timeout
|
void onTimeout(AcTimeoutHandler cb, void * arg = 0); //ack timeout
|
||||||
void onPoll(AcConnectHandler cb, void* arg = 0); //every 125ms when connected
|
void onPoll(AcConnectHandler cb, void * arg = 0); //every 125ms when connected
|
||||||
|
|
||||||
void ackPacket(struct pbuf * pb);//ack pbuf from onPacket
|
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
|
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 * errorToString(int8_t error);
|
||||||
const char * stateToString();
|
const char * stateToString();
|
||||||
|
|
||||||
//Do not use any of the functions below!
|
//Do not use any of the functions below!
|
||||||
static int8_t _s_poll(void *arg, struct tcp_pcb *tpcb);
|
static int8_t _s_poll(void * arg, struct tcp_pcb * tpcb);
|
||||||
static int8_t _s_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *pb, int8_t err);
|
static int8_t _s_recv(void * arg, struct tcp_pcb * tpcb, struct pbuf * pb, int8_t err);
|
||||||
static int8_t _s_fin(void *arg, struct tcp_pcb *tpcb, int8_t err);
|
static int8_t _s_fin(void * arg, struct tcp_pcb * tpcb, int8_t err);
|
||||||
static int8_t _s_lwip_fin(void *arg, struct tcp_pcb *tpcb, int8_t err);
|
static int8_t _s_lwip_fin(void * arg, struct tcp_pcb * tpcb, int8_t err);
|
||||||
static void _s_error(void *arg, int8_t err);
|
static void _s_error(void * arg, int8_t err);
|
||||||
static int8_t _s_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len);
|
static int8_t _s_sent(void * arg, struct tcp_pcb * tpcb, uint16_t len);
|
||||||
static int8_t _s_connected(void* arg, void* tpcb, int8_t err);
|
static int8_t _s_connected(void * arg, void * tpcb, int8_t err);
|
||||||
static void _s_dns_found(const char *name, struct ip_addr *ipaddr, void *arg);
|
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);
|
int8_t _recv(tcp_pcb * pcb, pbuf * pb, int8_t err);
|
||||||
tcp_pcb * pcb(){ return _pcb; }
|
tcp_pcb * pcb() {
|
||||||
|
return _pcb;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _connect(ip_addr_t addr, uint16_t port);
|
bool _connect(ip_addr_t addr, uint16_t port);
|
||||||
|
|
||||||
tcp_pcb* _pcb;
|
tcp_pcb * _pcb;
|
||||||
int8_t _closed_slot;
|
int8_t _closed_slot;
|
||||||
|
|
||||||
AcConnectHandler _connect_cb;
|
AcConnectHandler _connect_cb;
|
||||||
void* _connect_cb_arg;
|
void * _connect_cb_arg;
|
||||||
AcConnectHandler _discard_cb;
|
AcConnectHandler _discard_cb;
|
||||||
void* _discard_cb_arg;
|
void * _discard_cb_arg;
|
||||||
AcAckHandler _sent_cb;
|
AcAckHandler _sent_cb;
|
||||||
void* _sent_cb_arg;
|
void * _sent_cb_arg;
|
||||||
AcErrorHandler _error_cb;
|
AcErrorHandler _error_cb;
|
||||||
void* _error_cb_arg;
|
void * _error_cb_arg;
|
||||||
AcDataHandler _recv_cb;
|
AcDataHandler _recv_cb;
|
||||||
void* _recv_cb_arg;
|
void * _recv_cb_arg;
|
||||||
AcPacketHandler _pb_cb;
|
AcPacketHandler _pb_cb;
|
||||||
void* _pb_cb_arg;
|
void * _pb_cb_arg;
|
||||||
AcTimeoutHandler _timeout_cb;
|
AcTimeoutHandler _timeout_cb;
|
||||||
void* _timeout_cb_arg;
|
void * _timeout_cb_arg;
|
||||||
AcConnectHandler _poll_cb;
|
AcConnectHandler _poll_cb;
|
||||||
void* _poll_cb_arg;
|
void * _poll_cb_arg;
|
||||||
|
|
||||||
bool _ack_pcb;
|
bool _ack_pcb;
|
||||||
uint32_t _tx_last_packet;
|
uint32_t _tx_last_packet;
|
||||||
uint32_t _rx_ack_len;
|
uint32_t _rx_ack_len;
|
||||||
uint32_t _rx_last_packet;
|
uint32_t _rx_last_packet;
|
||||||
@@ -194,19 +209,19 @@ class AsyncClient {
|
|||||||
uint16_t _connect_port;
|
uint16_t _connect_port;
|
||||||
|
|
||||||
int8_t _close();
|
int8_t _close();
|
||||||
void _free_closed_slot();
|
void _free_closed_slot();
|
||||||
void _allocate_closed_slot();
|
void _allocate_closed_slot();
|
||||||
int8_t _connected(void* pcb, int8_t err);
|
int8_t _connected(void * pcb, int8_t err);
|
||||||
void _error(int8_t err);
|
void _error(int8_t err);
|
||||||
int8_t _poll(tcp_pcb* pcb);
|
int8_t _poll(tcp_pcb * pcb);
|
||||||
int8_t _sent(tcp_pcb* pcb, uint16_t len);
|
int8_t _sent(tcp_pcb * pcb, uint16_t len);
|
||||||
int8_t _fin(tcp_pcb* pcb, int8_t err);
|
int8_t _fin(tcp_pcb * pcb, int8_t err);
|
||||||
int8_t _lwip_fin(tcp_pcb* pcb, int8_t err);
|
int8_t _lwip_fin(tcp_pcb * pcb, int8_t err);
|
||||||
void _dns_found(struct ip_addr *ipaddr);
|
void _dns_found(struct ip_addr * ipaddr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AsyncClient* prev;
|
AsyncClient * prev;
|
||||||
AsyncClient* next;
|
AsyncClient * next;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AsyncServer {
|
class AsyncServer {
|
||||||
@@ -215,30 +230,30 @@ class AsyncServer {
|
|||||||
AsyncServer(IPv6Address addr, uint16_t port);
|
AsyncServer(IPv6Address addr, uint16_t port);
|
||||||
AsyncServer(uint16_t port);
|
AsyncServer(uint16_t port);
|
||||||
~AsyncServer();
|
~AsyncServer();
|
||||||
void onClient(AcConnectHandler cb, void* arg);
|
void onClient(AcConnectHandler cb, void * arg);
|
||||||
void begin();
|
void begin();
|
||||||
void end();
|
void end();
|
||||||
void setNoDelay(bool nodelay);
|
void setNoDelay(bool nodelay);
|
||||||
bool getNoDelay();
|
bool getNoDelay();
|
||||||
uint8_t status();
|
uint8_t status();
|
||||||
|
|
||||||
//Do not use any of the functions below!
|
//Do not use any of the functions below!
|
||||||
static int8_t _s_accept(void *arg, tcp_pcb* newpcb, int8_t err);
|
static int8_t _s_accept(void * arg, tcp_pcb * newpcb, int8_t err);
|
||||||
static int8_t _s_accepted(void *arg, AsyncClient* client);
|
static int8_t _s_accepted(void * arg, AsyncClient * client);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint16_t _port;
|
uint16_t _port;
|
||||||
bool _bind4 = false;
|
bool _bind4 = false;
|
||||||
bool _bind6 = false;
|
bool _bind6 = false;
|
||||||
IPAddress _addr;
|
IPAddress _addr;
|
||||||
IPv6Address _addr6;
|
IPv6Address _addr6;
|
||||||
bool _noDelay;
|
bool _noDelay;
|
||||||
tcp_pcb* _pcb;
|
tcp_pcb * _pcb;
|
||||||
AcConnectHandler _connect_cb;
|
AcConnectHandler _connect_cb;
|
||||||
void* _connect_cb_arg;
|
void * _connect_cb_arg;
|
||||||
|
|
||||||
int8_t _accept(tcp_pcb* newpcb, int8_t err);
|
int8_t _accept(tcp_pcb * newpcb, int8_t err);
|
||||||
int8_t _accepted(AsyncClient* client);
|
int8_t _accepted(AsyncClient * client);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -316,12 +316,11 @@ void NetworkSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ARDUINO_EVENT_ETH_START:
|
case ARDUINO_EVENT_ETH_START:
|
||||||
ETH.setHostname(emsesp::EMSESP::system_.hostname().c_str());
|
|
||||||
|
|
||||||
// configure for static IP
|
// configure for static IP
|
||||||
if (_state.staticIPConfig) {
|
if (_state.staticIPConfig) {
|
||||||
ETH.config(_state.localIP, _state.gatewayIP, _state.subnetMask, _state.dnsIP1, _state.dnsIP2);
|
ETH.config(_state.localIP, _state.gatewayIP, _state.subnetMask, _state.dnsIP1, _state.dnsIP2);
|
||||||
}
|
}
|
||||||
|
ETH.setHostname(emsesp::EMSESP::system_.hostname().c_str());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARDUINO_EVENT_ETH_GOT_IP:
|
case ARDUINO_EVENT_ETH_GOT_IP:
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ build_flags =
|
|||||||
-D ARDUINOJSON_USE_DOUBLE=0
|
-D ARDUINOJSON_USE_DOUBLE=0
|
||||||
-D ARDUINOTRACE_ENABLE=0
|
-D ARDUINOTRACE_ENABLE=0
|
||||||
-D CONFIG_ETH_ENABLED
|
-D CONFIG_ETH_ENABLED
|
||||||
-D CONFIG_ASYNC_TCP_STACK_SIZE=8192
|
-D CONFIG_ASYNC_TCP_STACK_SIZE=5120
|
||||||
|
|
||||||
unbuild_flags =
|
unbuild_flags =
|
||||||
${common.core_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
|
// check free mem
|
||||||
#ifndef EMSESP_STANDALONE
|
#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) {
|
if (operation == Operation::PUBLISH) {
|
||||||
mqtt_message_id_++;
|
mqtt_message_id_++;
|
||||||
mqtt_publish_fails_++;
|
mqtt_publish_fails_++;
|
||||||
|
|||||||
Reference in New Issue
Block a user