Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit dbd4700

Browse files
authored
v1.1.0 to fix issue with slow browsers or network
### Releases v1.1.0 1. Fix issue with slow browsers or network 2. Remove hard-code if possible 3. Improve debug messages by adding functions to display `error/state messages` instead of `cryptic error/state number` 4. Clean up
1 parent d738e36 commit dbd4700

19 files changed

+716
-175
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1515
Please ensure to specify the following:
1616

1717
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18-
* `RP2040` Core Version (e.g. RP2040 core v2.4.0)
18+
* `RP2040` Core Version (e.g. RP2040 core v2.5.4)
1919
* `RP2040` Board type (e.g. RASPBERRY_PI_PICO_W)
2020
* Contextual information (e.g. what you were trying to achieve)
2121
* Simplest possible steps to reproduce
@@ -28,13 +28,13 @@ Please ensure to specify the following:
2828

2929
```
3030
Arduino IDE version: 1.8.19
31-
RP2040 core v2.4.0
31+
RP2040 core v2.5.4
3232
RASPBERRY_PI_PICO_W Module
3333
OS: Ubuntu 20.04 LTS
34-
Linux xy-Inspiron-3593 5.15.0-41-generic #44~20.04.1-Ubuntu SMP Fri Jun 24 13:27:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
34+
Linux xy-Inspiron-3593 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3535
3636
Context:
37-
I encountered a crash while using Ethernet Async_AdvancedWebServer.
37+
I encountered a crash while using Async_AdvancedWebServer
3838
3939
Steps to reproduce:
4040
1. ...

README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AsyncTCP_RP2040W
22

3-
[![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncTCP_RP2040W.svg?)](https://www.ardu-badge.com/AsyncTCP_RP2040W)
3+
[![arduino-library-badge](http://www.ardu-badge.com/badge/AsyncTCP_RP2040W.svg?)](http://www.ardu-badge.com/AsyncTCP_RP2040W)
44
[![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncTCP_RP2040W.svg)](https://github.com/khoih-prog/AsyncTCP_RP2040W/releases)
55
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
66
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/AsyncTCP_RP2040W.svg)](http://github.com/khoih-prog/AsyncTCP_RP2040W/issues)
@@ -51,7 +51,7 @@ This library is based on, modified from:
5151

5252
1. [Hristo Gochkov's ESPAsyncTCP](https://github.com/me-no-dev/ESPAsyncTCP)
5353

54-
to apply the better and faster **asynchronous** feature of the **powerful** [ESPAsyncTCP Library](https://github.com/me-no-dev/ESPAsyncTCP) into **RASPBERRY_PI_PICO_W with CYW43439 WiFi**, and will be the base for future and more advanced Async libraries, such as AsyncWebServer_RP2040W, AsyncHTTPRequest_RP2040W, AsyncHTTPSRequest_RP2040W
54+
to apply the better and faster **asynchronous** feature of the **powerful** [ESPAsyncTCP Library](https://github.com/me-no-dev/ESPAsyncTCP) into **RASPBERRY_PI_PICO_W with CYW43439 WiFi**, and will be the base for future and more advanced Async libraries, such as `AsyncWebServer_RP2040W`, `AsyncHTTPRequest_RP2040W`, `AsyncHTTPSRequest_RP2040W`
5555

5656

5757
#### Why Async is better
@@ -81,7 +81,7 @@ to apply the better and faster **asynchronous** feature of the **powerful** [ESP
8181
## Prerequisites
8282

8383
1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [![GitHub release](https://img.shields.io/github/release/arduino/Arduino.svg)](https://github.com/arduino/Arduino/releases/latest)
84-
2. [`Earle Philhower's arduino-pico core v2.4.0+`](https://github.com/earlephilhower/arduino-pico) for **RASPBERRY_PI_PICO_W with CYW43439 WiFi**, etc. [![GitHub release](https://img.shields.io/github/release/earlephilhower/arduino-pico.svg)](https://github.com/earlephilhower/arduino-pico/releases/latest)
84+
2. [`Earle Philhower's arduino-pico core v2.5.4+`](https://github.com/earlephilhower/arduino-pico) for **RASPBERRY_PI_PICO_W with CYW43439 WiFi**, etc. [![GitHub release](https://img.shields.io/github/release/earlephilhower/arduino-pico.svg)](https://github.com/earlephilhower/arduino-pico/releases/latest)
8585

8686
---
8787
---
@@ -98,9 +98,9 @@ You can also use this link [![arduino-library-badge](https://www.ardu-badge.com/
9898
Another way to install is to:
9999

100100
1. Navigate to [**AsyncTCP_RP2040W**](https://github.com/khoih-prog/AsyncTCP_RP2040W) page.
101-
2. Download the latest release `AsyncTCP_RP2040W-master.zip`.
102-
3. Extract the zip file to `AsyncTCP_RP2040W-master` directory
103-
4. Copy whole `AsyncTCP_RP2040W-master` folder to Arduino libraries' directory such as `~/Arduino/libraries/`.
101+
2. Download the latest release `AsyncTCP_RP2040W-main.zip`.
102+
3. Extract the zip file to `AsyncTCP_RP2040W-main` directory
103+
4. Copy whole `AsyncTCP_RP2040W-main` folder to Arduino libraries' directory such as `~/Arduino/libraries/`.
104104

105105
### VS Code & PlatformIO
106106

@@ -114,11 +114,7 @@ Another way to install is to:
114114

115115
## Orignal documentation
116116

117-
For ESP32, check [AsyncTCP Library](https://github.com/me-no-dev/AsyncTCP)
118-
119-
[Join the ESPAsyncWebServer chat](https://gitter.im/me-no-dev/ESPAsyncWebServer) [![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)
120-
121-
This is a fully asynchronous TCP library, aimed at enabling trouble-free, multi-connection network environment for Espressif's ESP8266 MCUs.
117+
Check [AsyncTCP Library](https://github.com/me-no-dev/AsyncTCP)
122118

123119
### AsyncClient and AsyncServer
124120

@@ -138,6 +134,13 @@ This class is really similar to the `AsyncPrinter`, but it can buffer some of th
138134

139135
It is exactly what it sounds like. This is a standard, synchronous blocking TCP Client you're used to.
140136

137+
---
138+
---
139+
140+
### Libraries currently depend on this library
141+
142+
1. [AsyncWebServer_RP2040W](https://github.com/khoih-prog/AsyncWebServer_RP2040W) [![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncWebServer_RP2040W.svg)](https://github.com/khoih-prog/AsyncWebServer_RP2040W/releases/latest)
143+
2. [AsyncHTTPRequest_RP2040W](https://github.com/khoih-prog/AsyncHTTPRequest_RP2040W) [![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncHTTPRequest_RP2040W.svg)](https://github.com/khoih-prog/AsyncHTTPRequest_RP2040W/releases/latest)
141144

142145
---
143146
---
@@ -166,7 +169,7 @@ Sometimes, the library will only work if you update the board core to the latest
166169

167170
### Issues
168171

169-
Submit issues to: [AsyncTCP_RP2040W issues](https://github.com/khoih-prog/AsyncTCP_RP2040W/issues)
172+
Submit issues to: [AsyncTCP_RP2040W issues](https://github.com/khoih-prog/AsyncTCP_RP2040W/issues)
170173

171174
---
172175

@@ -222,6 +225,7 @@ If you want to contribute to this project:
222225

223226
## Copyright
224227

225-
Copyright 2022- Khoi Hoang
228+
- Copyright 2016- Hristo Gochkov
229+
- Copyright 2022- Khoi Hoang
226230

227231

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@
1111
## Table of Contents
1212

1313
* [Changelog](#changelog)
14+
* [Releases v1.1.0](#Releases-v110)
1415
* [Initial Releases v1.0.0](#Initial-Releases-v100)
1516

1617
---
1718
---
1819

1920
## Changelog
2021

22+
### Releases v1.1.0
23+
24+
1. Fix issue with slow browsers or network
25+
2. Remove hard-code if possible
26+
3. Improve debug messages by adding functions to display `error/state messages` instead of `cryptic error/state number`
27+
4. Clean up
28+
2129

2230
### Initial Releases v1.0.0
2331

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "AsyncTCP_RP2040W",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"keywords": "http, communication, async, websocket, webserver, async-webserver, async-tcp, async-udp, async-websocket, async-http, ssl, tls, rp2040, rp2040w, raspberry-pi-pico-w, cyw43439, wifi",
55
"description": "Asynchronous TCP Library for RASPBERRY_PI_PICO_W using CYW43439 WiFi with arduino-pico core. This library is the base for future and more advanced Async libraries, such as AsyncWebServer_RP2040W, AsyncHTTPRequest_RP2040W, AsyncHTTPSRequest_RP2040W",
66
"authors":

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=AsyncTCP_RP2040W
2-
version=1.0.0
2+
version=1.1.0
33
author=Hristo Gochkov,Khoi Hoang
44
maintainer=Khoi Hoang <[email protected]>
55
sentence=Asynchronous TCP Library for RASPBERRY_PI_PICO_W using CYW43439 WiFi with arduino-pico core

platformio/platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ upload_speed = 921600
3838
;monitor_port = COM11
3939

4040
; Checks for the compatibility with frameworks and dev/platforms
41+
; Adjust as necessary
4142
lib_compat_mode = strict
4243
lib_ldf_mode = chain+
4344
;lib_ldf_mode = deep+

src/AsyncPrinter.cpp

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
1313
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
1414
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15-
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
15+
You should have received a copy of the GNU General Public License along with this program.
16+
If not, see <https://www.gnu.org/licenses/>.
1617
17-
Version: 1.0.0
18+
Version: 1.1.0
1819
1920
Version Modified By Date Comments
2021
------- ----------- ---------- -----------
2122
1.0.0 K Hoang 13/08/2022 Initial coding for RP2040W with CYW43439 WiFi
23+
1.1.0 K Hoang 25/09/2022 Fix issue with slow browsers or network. Clean up. Remove hard-code if possible
2224
*****************************************************************************************************************************/
2325
/*
2426
Asynchronous TCP library for Espressif MCUs
@@ -48,6 +50,8 @@
4850
#include "AsyncPrinter.h"
4951
#include "debug.h"
5052

53+
/////////////////////////////////////////////////////////
54+
5155
AsyncPrinter::AsyncPrinter()
5256
: _client(NULL)
5357
, _data_cb(NULL)
@@ -59,6 +63,8 @@ AsyncPrinter::AsyncPrinter()
5963
, next(NULL)
6064
{}
6165

66+
/////////////////////////////////////////////////////////
67+
6268
AsyncPrinter::AsyncPrinter(AsyncClient *client, size_t txBufLen)
6369
: _client(client)
6470
, _data_cb(NULL)
@@ -78,23 +84,31 @@ AsyncPrinter::AsyncPrinter(AsyncClient *client, size_t txBufLen)
7884
}
7985
}
8086

87+
/////////////////////////////////////////////////////////
88+
8189
AsyncPrinter::~AsyncPrinter()
8290
{
8391
_on_close();
8492
}
8593

94+
/////////////////////////////////////////////////////////
95+
8696
void AsyncPrinter::onData(ApDataHandler cb, void *arg)
8797
{
8898
_data_cb = cb;
8999
_data_arg = arg;
90100
}
91101

102+
/////////////////////////////////////////////////////////
103+
92104
void AsyncPrinter::onClose(ApCloseHandler cb, void *arg)
93105
{
94106
_close_cb = cb;
95107
_close_arg = arg;
96108
}
97109

110+
/////////////////////////////////////////////////////////
111+
98112
int AsyncPrinter::connect(IPAddress ip, uint16_t port)
99113
{
100114
if (_client != NULL && connected())
@@ -123,6 +137,8 @@ int AsyncPrinter::connect(IPAddress ip, uint16_t port)
123137
return 0;
124138
}
125139

140+
/////////////////////////////////////////////////////////
141+
126142
int AsyncPrinter::connect(const char *host, uint16_t port)
127143
{
128144
if (_client != NULL && connected())
@@ -151,6 +167,8 @@ int AsyncPrinter::connect(const char *host, uint16_t port)
151167
return 0;
152168
}
153169

170+
/////////////////////////////////////////////////////////
171+
154172
void AsyncPrinter::_onConnect(AsyncClient *c)
155173
{
156174
ASYNCTCP_RP2040W_UNUSED(c);
@@ -172,11 +190,15 @@ void AsyncPrinter::_onConnect(AsyncClient *c)
172190
_attachCallbacks();
173191
}
174192

193+
/////////////////////////////////////////////////////////
194+
175195
AsyncPrinter::operator bool()
176196
{
177197
return connected();
178198
}
179199

200+
/////////////////////////////////////////////////////////
201+
180202
AsyncPrinter & AsyncPrinter::operator=(const AsyncPrinter &other)
181203
{
182204
if (_client != NULL)
@@ -207,11 +229,15 @@ AsyncPrinter & AsyncPrinter::operator=(const AsyncPrinter &other)
207229
return *this;
208230
}
209231

232+
/////////////////////////////////////////////////////////
233+
210234
size_t AsyncPrinter::write(uint8_t data)
211235
{
212236
return write(&data, 1);
213237
}
214238

239+
/////////////////////////////////////////////////////////
240+
215241
size_t AsyncPrinter::write(const uint8_t *data, size_t len)
216242
{
217243
if (_tx_buffer == NULL || !connected())
@@ -248,17 +274,23 @@ size_t AsyncPrinter::write(const uint8_t *data, size_t len)
248274
return len;
249275
}
250276

277+
/////////////////////////////////////////////////////////
278+
251279
bool AsyncPrinter::connected()
252280
{
253281
return (_client != NULL && _client->connected());
254282
}
255283

284+
/////////////////////////////////////////////////////////
285+
256286
void AsyncPrinter::close()
257287
{
258288
if (_client != NULL)
259289
_client->close(true);
260290
}
261291

292+
/////////////////////////////////////////////////////////
293+
262294
size_t AsyncPrinter::_sendBuffer()
263295
{
264296
size_t available = _tx_buffer->available();
@@ -285,12 +317,16 @@ size_t AsyncPrinter::_sendBuffer()
285317
return sent;
286318
}
287319

320+
/////////////////////////////////////////////////////////
321+
288322
void AsyncPrinter::_onData(void *data, size_t len)
289323
{
290324
if (_data_cb)
291325
_data_cb(_data_arg, this, (uint8_t*)data, len);
292326
}
293327

328+
/////////////////////////////////////////////////////////
329+
294330
void AsyncPrinter::_on_close()
295331
{
296332
if (_client != NULL)
@@ -309,6 +345,8 @@ void AsyncPrinter::_on_close()
309345
_close_cb(_close_arg, this);
310346
}
311347

348+
/////////////////////////////////////////////////////////
349+
312350
void AsyncPrinter::_attachCallbacks()
313351
{
314352
_client->onPoll([](void *obj, AsyncClient * c)
@@ -337,3 +375,5 @@ void AsyncPrinter::_attachCallbacks()
337375
((AsyncPrinter*)(obj))->_onData(data, len);
338376
}, this);
339377
}
378+
379+
/////////////////////////////////////////////////////////

src/AsyncPrinter.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
1313
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
1414
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15-
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
15+
You should have received a copy of the GNU General Public License along with this program.
16+
If not, see <https://www.gnu.org/licenses/>.
1617
17-
Version: 1.0.0
18+
Version: 1.1.0
1819
1920
Version Modified By Date Comments
2021
------- ----------- ---------- -----------
2122
1.0.0 K Hoang 13/08/2022 Initial coding for RP2040W with CYW43439 WiFi
23+
1.1.0 K Hoang 25/09/2022 Fix issue with slow browsers or network. Clean up. Remove hard-code if possible
2224
*****************************************************************************************************************************/
2325
/*
2426
Asynchronous TCP library for Espressif MCUs
@@ -53,6 +55,8 @@ class AsyncPrinter;
5355
typedef std::function<void(void*, AsyncPrinter*, uint8_t*, size_t)> ApDataHandler;
5456
typedef std::function<void(void*, AsyncPrinter*)> ApCloseHandler;
5557

58+
/////////////////////////////////////////////////////////
59+
5660
class AsyncPrinter: public Print
5761
{
5862
private:

0 commit comments

Comments
 (0)