Verze 2.0.0 odsud https://github.com/esphome/ESPAsyncTCP/releases/tag/v2.0.0
This commit is contained in:
parent
a2ab207446
commit
3115cbb0cf
13
README.md
13
README.md
@ -1,11 +1,13 @@
|
|||||||
# ESPAsyncTCP
|
# ESPAsyncTCP
|
||||||
|
|
||||||
Lokálně udržovaná verze ESPAsyncTCP knihovny, používaná ve všech projektech s ESP8266, postavena na https://github.com/OttoWinter/ESPAsyncTCP
|
|
||||||
|
|
||||||
A fork of the [AsyncTCP](https://github.com/me-no-dev/AsyncTCP) library by [@me-no-dev](https://github.com/me-no-dev) for [ESPHome](https://esphome.io).
|
A fork of the [AsyncTCP](https://github.com/me-no-dev/AsyncTCP) library by [@me-no-dev](https://github.com/me-no-dev) for [ESPHome](https://esphome.io).
|
||||||
|
|
||||||
### Async TCP Library for ESP8266 Arduino
|
### Async TCP Library for ESP8266 Arduino
|
||||||
|
|
||||||
|
For ESP32 look [HERE](https://github.com/me-no-dev/AsyncTCP)
|
||||||
|
|
||||||
|
[![Join the chat at https://gitter.im/me-no-dev/ESPAsyncWebServer](https://badges.gitter.im/me-no-dev/ESPAsyncWebServer.svg)](https://gitter.im/me-no-dev/ESPAsyncWebServer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
This is a fully asynchronous TCP library, aimed at enabling trouble-free, multi-connection network environment for Espressif's ESP8266 MCUs.
|
This is a fully asynchronous TCP library, aimed at enabling trouble-free, multi-connection network environment for Espressif's ESP8266 MCUs.
|
||||||
|
|
||||||
This library is the base for [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer)
|
This library is the base for [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer)
|
||||||
@ -22,3 +24,10 @@ This class is really similar to the ```AsyncPrinter```, but it differs in the fa
|
|||||||
|
|
||||||
## SyncClient
|
## SyncClient
|
||||||
It is exactly what it sounds like. This is a standard, blocking TCP Client, similar to the one included in ```ESP8266WiFi```
|
It is exactly what it sounds like. This is a standard, blocking TCP Client, similar to the one included in ```ESP8266WiFi```
|
||||||
|
|
||||||
|
## Libraries and projects that use AsyncTCP
|
||||||
|
- [ESP Async Web Server](https://github.com/me-no-dev/ESPAsyncWebServer)
|
||||||
|
- [Async MQTT client](https://github.com/marvinroger/async-mqtt-client)
|
||||||
|
- [arduinoWebSockets](https://github.com/Links2004/arduinoWebSockets)
|
||||||
|
- [ESP8266 Smart Home](https://github.com/baruch/esp8266_smart_home)
|
||||||
|
- [KBox Firmware](https://github.com/sarfata/kbox-firmware)
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
{
|
{
|
||||||
"name":"ESPAsyncTCP",
|
"name":"ESPAsyncTCP-esphome",
|
||||||
"description":"Asynchronous TCP Library for ESP8266",
|
"description":"Asynchronous TCP Library for ESP8266",
|
||||||
"keywords":"async,tcp",
|
"keywords":"async,tcp",
|
||||||
"authors":
|
"authors":
|
||||||
{
|
{
|
||||||
"name": "Hristo Gochkov",
|
"name": "Hristo Gochkov",
|
||||||
"maintainer": false
|
"maintainer": true
|
||||||
},
|
},
|
||||||
"repository":
|
"repository":
|
||||||
{
|
{
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.xpablo.cz/xPablo.cz/ESPAsyncTCP.git"
|
"url": "https://github.com/esphome/ESPAsyncTCP.git"
|
||||||
},
|
},
|
||||||
"version": "1.2.3",
|
"version": "2.0.0",
|
||||||
"license": "LGPL-3.0",
|
"license": "LGPL-3.0",
|
||||||
"frameworks": "arduino",
|
"frameworks": "arduino",
|
||||||
"platforms": "espressif8266",
|
"platforms": "espressif8266",
|
@ -1,9 +0,0 @@
|
|||||||
name=ESPAsyncTCP
|
|
||||||
version=1.2.3
|
|
||||||
author=Me-No-Dev
|
|
||||||
maintainer=xPablo
|
|
||||||
sentence=Async TCP Library for ESP8266 and ESP31B
|
|
||||||
paragraph=Async TCP Library for ESP8266 and ESP31B
|
|
||||||
category=Other
|
|
||||||
url=https://git.xpablo.cz/xPablo.cz/ESPAsyncTCP.git
|
|
||||||
architectures=*
|
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef _DEBUG_PRINT_MACROS_H
|
#ifndef _DEBUG_PRINT_MACROS_H
|
||||||
#define _DEBUG_PRINT_MACROS_H
|
#define _DEBUG_PRINT_MACROS_H
|
||||||
// Some customizable print macros to suite the debug needs de jour.
|
// Some customizable print macros to suite the debug needs de jour.
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
// Debug macros
|
// Debug macros
|
||||||
// #include <pgmspace.h>
|
// #include <pgmspace.h>
|
||||||
|
@ -244,8 +244,8 @@ bool AsyncClient::connect(IPAddress ip, uint16_t port){
|
|||||||
#endif
|
#endif
|
||||||
if (_pcb) //already connected
|
if (_pcb) //already connected
|
||||||
return false;
|
return false;
|
||||||
ip_addr_t addr;
|
IPAddress addr;
|
||||||
addr.addr = ip;
|
addr = ip;
|
||||||
#if LWIP_VERSION_MAJOR == 1
|
#if LWIP_VERSION_MAJOR == 1
|
||||||
netif* interface = ip_route(&addr);
|
netif* interface = ip_route(&addr);
|
||||||
if (!interface){ //no route to host
|
if (!interface){ //no route to host
|
||||||
@ -264,10 +264,7 @@ bool AsyncClient::connect(IPAddress ip, uint16_t port){
|
|||||||
#endif
|
#endif
|
||||||
tcp_arg(pcb, this);
|
tcp_arg(pcb, this);
|
||||||
tcp_err(pcb, &_s_error);
|
tcp_err(pcb, &_s_error);
|
||||||
size_t err = tcp_connect(pcb, &addr, port,(tcp_connected_fn)&_s_connected);
|
size_t err = tcp_connect(pcb, addr, port,(tcp_connected_fn)&_s_connected);
|
||||||
if (err != ERR_OK) {
|
|
||||||
tcp_close(pcb);
|
|
||||||
}
|
|
||||||
return (ERR_OK == err);
|
return (ERR_OK == err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,13 +273,13 @@ bool AsyncClient::connect(const char* host, uint16_t port, bool secure){
|
|||||||
#else
|
#else
|
||||||
bool AsyncClient::connect(const char* host, uint16_t port){
|
bool AsyncClient::connect(const char* host, uint16_t port){
|
||||||
#endif
|
#endif
|
||||||
ip_addr_t addr;
|
IPAddress addr;
|
||||||
err_t err = dns_gethostbyname(host, &addr, (dns_found_callback)&_s_dns_found, this);
|
err_t err = dns_gethostbyname(host, addr, (dns_found_callback)&_s_dns_found, this);
|
||||||
if(err == ERR_OK) {
|
if(err == ERR_OK) {
|
||||||
#if ASYNC_TCP_SSL_ENABLED
|
#if ASYNC_TCP_SSL_ENABLED
|
||||||
return connect(IPAddress(addr.addr), port, secure);
|
return connect(addr, port, secure);
|
||||||
#else
|
#else
|
||||||
return connect(IPAddress(addr.addr), port);
|
return connect(addr, port);
|
||||||
#endif
|
#endif
|
||||||
} else if(err == ERR_INPROGRESS) {
|
} else if(err == ERR_INPROGRESS) {
|
||||||
#if ASYNC_TCP_SSL_ENABLED
|
#if ASYNC_TCP_SSL_ENABLED
|
||||||
@ -331,7 +328,7 @@ AsyncClient& AsyncClient::operator=(const AsyncClient& other){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AsyncClient::operator==(const AsyncClient &other) {
|
bool AsyncClient::operator==(const AsyncClient &other) {
|
||||||
return (_pcb != NULL && other._pcb != NULL && (_pcb->remote_ip.addr == other._pcb->remote_ip.addr) && (_pcb->remote_port == other._pcb->remote_port));
|
return (_pcb != NULL && other._pcb != NULL && (IPAddress(_pcb->remote_ip) == IPAddress(other._pcb->remote_ip)) && (_pcb->remote_port == other._pcb->remote_port));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncClient::abort(){
|
void AsyncClient::abort(){
|
||||||
@ -708,9 +705,9 @@ void AsyncClient::_dns_found(const ip_addr *ipaddr){
|
|||||||
#endif
|
#endif
|
||||||
if(ipaddr){
|
if(ipaddr){
|
||||||
#if ASYNC_TCP_SSL_ENABLED
|
#if ASYNC_TCP_SSL_ENABLED
|
||||||
connect(IPAddress(ipaddr->addr), _connect_port, _pcb_secure);
|
connect(ipaddr, _connect_port, _pcb_secure);
|
||||||
#else
|
#else
|
||||||
connect(IPAddress(ipaddr->addr), _connect_port);
|
connect(ipaddr, _connect_port);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if(_error_cb)
|
if(_error_cb)
|
||||||
@ -846,23 +843,12 @@ uint16_t AsyncClient::getMss(){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AsyncClient::getRemoteAddress() {
|
|
||||||
if(!_pcb)
|
|
||||||
return 0;
|
|
||||||
return _pcb->remote_ip.addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t AsyncClient::getRemotePort() {
|
uint16_t AsyncClient::getRemotePort() {
|
||||||
if(!_pcb)
|
if(!_pcb)
|
||||||
return 0;
|
return 0;
|
||||||
return _pcb->remote_port;
|
return _pcb->remote_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AsyncClient::getLocalAddress() {
|
|
||||||
if(!_pcb)
|
|
||||||
return 0;
|
|
||||||
return _pcb->local_ip.addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t AsyncClient::getLocalPort() {
|
uint16_t AsyncClient::getLocalPort() {
|
||||||
if(!_pcb)
|
if(!_pcb)
|
||||||
@ -871,7 +857,9 @@ uint16_t AsyncClient::getLocalPort() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IPAddress AsyncClient::remoteIP() {
|
IPAddress AsyncClient::remoteIP() {
|
||||||
return IPAddress(getRemoteAddress());
|
if(!_pcb)
|
||||||
|
return IPAddress(0);
|
||||||
|
return _pcb->remote_ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t AsyncClient::remotePort() {
|
uint16_t AsyncClient::remotePort() {
|
||||||
@ -879,7 +867,9 @@ uint16_t AsyncClient::remotePort() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IPAddress AsyncClient::localIP() {
|
IPAddress AsyncClient::localIP() {
|
||||||
return IPAddress(getLocalAddress());
|
if(!_pcb)
|
||||||
|
return IPAddress(0);
|
||||||
|
return _pcb->local_ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t AsyncClient::localPort() {
|
uint16_t AsyncClient::localPort() {
|
||||||
@ -1088,7 +1078,7 @@ AsyncServer::AsyncServer(IPAddress addr, uint16_t port)
|
|||||||
|
|
||||||
AsyncServer::AsyncServer(uint16_t port)
|
AsyncServer::AsyncServer(uint16_t port)
|
||||||
: _port(port)
|
: _port(port)
|
||||||
, _addr((uint32_t) IPADDR_ANY)
|
, _addr(IP_ANY_TYPE)
|
||||||
, _noDelay(false)
|
, _noDelay(false)
|
||||||
, _pcb(0)
|
, _pcb(0)
|
||||||
, _connect_cb(0)
|
, _connect_cb(0)
|
||||||
@ -1127,15 +1117,15 @@ void AsyncServer::begin(){
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int8_t err;
|
int8_t err;
|
||||||
tcp_pcb* pcb = tcp_new();
|
tcp_pcb* pcb = tcp_new_ip_type(IPADDR_TYPE_ANY);
|
||||||
if (!pcb){
|
if (!pcb){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcp_setprio(pcb, TCP_PRIO_MIN);
|
tcp_setprio(pcb, TCP_PRIO_MIN);
|
||||||
ip_addr_t local_addr;
|
IPAddress local_addr;
|
||||||
local_addr.addr = (uint32_t) _addr;
|
local_addr = _addr;
|
||||||
err = tcp_bind(pcb, &local_addr, _port);
|
err = tcp_bind(pcb, local_addr, _port);
|
||||||
// Failures are ERR_ISCONN or ERR_USE
|
// Failures are ERR_ISCONN or ERR_USE
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
tcp_close(pcb);
|
tcp_close(pcb);
|
||||||
|
@ -237,9 +237,7 @@ class AsyncClient {
|
|||||||
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();
|
|
||||||
uint16_t getRemotePort();
|
uint16_t getRemotePort();
|
||||||
uint32_t getLocalAddress();
|
|
||||||
uint16_t getLocalPort();
|
uint16_t getLocalPort();
|
||||||
|
|
||||||
IPAddress remoteIP();
|
IPAddress remoteIP();
|
||||||
|
Loading…
Reference in New Issue
Block a user