- Table of contents
- Why do we need this AsyncTCP_RP2040W library
- Changelog
- Prerequisites
- Installation
- Original documentation
- Examples
- Example AsyncTCP_Client
- Debug Terminal Output Samples
- Debug
- Troubleshooting
- Issues
- TO DO
- DONE
- Contributions and Thanks
- Contributing
- License
- Copyright
Why do we need this AsyncTCP_RP2040W library
This library is based on, modified from:
to apply the better and faster asynchronous feature of the powerful ESPAsyncTCP Library 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
- Using asynchronous network means that you can handle more than one connection at the same time
- You are called once the request is ready and parsed
- When you send the response, you are immediately ready to handle other connections while the server is taking care of sending the response in the background
- Speed is OMG
- Easy to use API, HTTP Basic and Digest MD5 Authentication (default), ChunkedResponse
- Easily extensible to handle any type of content
- Supports Continue 100
- Async WebSocket plugin offering different locations without extra servers or ports
- Async EventSource (Server-Sent Events) plugin to send events to the browser
- URL Rewrite plugin for conditional and permanent url rewrites
- ServeStatic plugin that supports cache, Last-Modified, default index and more
- Simple template processing engine to handle templates
- RASPBERRY_PI_PICO_W with CYW43439 WiFi using arduino-pico core
Arduino IDE 1.8.19+
for Arduino.Earle Philhower's arduino-pico core v2.7.1+
for RASPBERRY_PI_PICO_W with CYW43439 WiFi, etc.
The best and easiest way is to use Arduino Library Manager
. Search for AsyncTCP_RP2040W, then select / install the latest version.
You can also use this link for more detailed instructions.
Another way to install is to:
- Navigate to AsyncTCP_RP2040W page.
- Download the latest release
AsyncTCP_RP2040W-main.zip
. - Extract the zip file to
AsyncTCP_RP2040W-main
directory - Copy whole
AsyncTCP_RP2040W-main
folder to Arduino libraries' directory such as~/Arduino/libraries/
.
- Install VS Code
- Install PlatformIO
- Install AsyncTCP_RP2040W library by using Library Manager. Search for AsyncTCP_RP2040W in Platform.io Author's Libraries
- Use included platformio.ini file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at Project Configuration File
Check AsyncTCP Library
The base classes on which everything else is built. They expose all possible scenarios, but are really raw and require more skills to use.
This class can be used to send data like any other Print
interface (Serial
for example).
The object then can be used outside of the Async callbacks (the loop) and receive asynchronously data using onData
. The object can be checked if the underlying AsyncClient
is connected, or hook to the onDisconnect
callback.
This class is really similar to the AsyncPrinter
, but it can buffer some of the incoming data.
It is exactly what it sounds like. This is a standard, synchronous blocking TCP Client you're used to.
Example AsyncTCP_Client
Please take a look at other examples, as well.
1. AsyncTCP_Server on RASPBERRY_PI_PICO_W with CYW43439 WiFi
Start AsyncTCP_Server on RASPBERRY_PI_PICO_W with RP2040W CYW43439 WiFi
AsyncTCP_RP2040W v1.2.0
Connecting to SSID: HueNet
SSID: HueNet
Local IP Address: 192.168.2.128
AsyncTCPServer is @ IP: 192.168.2.128, port: 5698
New client has been connected to server, IP: 192.168.2.118
Data received from client 192.168.2.118
This is from AsyncTCPClient @ 192.168.2.118
2. AsyncTCP_Client on RASPBERRY_PI_PICO_W with CYW43439 WiFi
Following is debug terminal output when running example AsyncTCP_Client on RASPBERRY_PI_PICO_W using CYW43439 WiFi
, to demo the AsyncTCP_Client
auto-reconnects to AsyncTCP_Server
if connection is lost (network, power-recycle, etc.)
Start AsyncTCP_Client on RASPBERRY_PI_PICO_W with RP2040W CYW43439 WiFi
AsyncTCP_RP2040W v1.2.0
Connecting to SSID: HueNet
SSID: HueNet
Local IP Address: 192.168.2.118
AsyncTCPClient has been connected to Server 192.168.2.128, port 5698
********************
New replyToServer
Data received from 192.168.2.128
You've connected to AsyncTCPServer @ 192.168.2.128
********************
New replyToServer
Data received from 192.168.2.128
You've connected to AsyncTCPServer @ 192.168.2.128
********************
New replyToServer
Data received from 192.168.2.128
You've connected to AsyncTCPServer @ 192.168.2.128
********************
New replyToServer
Reconnecting to Server 192.168.2.128, port 5698
AsyncTCPClient has been disconnected from Server 192.168.2.128, port 5698
Reconnecting to Server 192.168.2.128, port 5698
Reconnecting to Server 192.168.2.128, port 5698
Reconnecting to Server 192.168.2.128, port 5698
AsyncTCPClient has been connected to Server 192.168.2.128, port 5698
********************
New replyToServer
Data received from 192.168.2.128
You've connected to AsyncTCPServer @ 192.168.2.128
********************
New replyToServer
Data received from 192.168.2.128
You've connected to AsyncTCPServer @ 192.168.2.128
Debug is enabled by default on Serial.
You can also change the debugging level _ASYNCTCP_RP2040W_LOGLEVEL_
from 0 to 4 in the library cpp
files
#define _ASYNCTCP_RP2040W_LOGLEVEL_ 1
If you get compilation errors, more often than not, you may need to install a newer version of the core for Arduino boards.
Sometimes, the library will only work if you update the board core to the latest version because I am using newly added functions.
Submit issues to: AsyncTCP_RP2040W issues
- Search for bug and improvement.
- RASPBERRY_PI_PICO_W with CYW43439 WiFi
- Add astyle using
allman
style. Restyle the library - Add complex auto-reconnect
AsyncTCPClient
andAsyncTCP_Server
examples - Improve
README.md
so that links can be used in other sites, such asPIO
Many thanks for everyone for bug reporting, new feature suggesting, testing and contributing to the development of this library.
- Based on and modified from Hristo Gochkov's ESPAsyncTCP. Many thanks to Hristo Gochkov for great ESPAsyncTCP Library
⭐️⭐️ Hristo Gochkov |
If you want to contribute to this project:
- Report bugs and errors
- Ask for enhancements
- Create issues and pull requests
- Tell other people about this library
- The library is licensed under GPLv3
- Copyright (c) 2016- Hristo Gochkov
- Copyright (c) 2022- Khoi Hoang