- Table of contents
- Why do we need this Portenta_H7_AsyncTCP library
- Changelog
- Prerequisites
- Installation
- Packages' Patches
- Original documentation
- Libraries currently depend on this library
- Debug Terminal Output Samples
- Debug
- Troubleshooting
- Releases
- Issues
- TO DO
- DONE
- Contributions and Thanks
- Contributing
- License
- Copyright
Why do we need this Portenta_H7_AsyncTCP library
This library is based on, modified from:
to apply the better and faster asynchronous feature of the powerful ESPAsyncTCP Library into Portenta_H7 boards, and will be the base for future and more advanced Async libraries for Portenta_H7, such as Portenta_H7_AsyncWebServer, Portenta_H7_AsyncHTTPRequest, Portenta_H7_AsyncHTTPSRequest
- 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
- Portenta_H7 boards such as
Portenta_H7 Rev2 ABX00042
, etc., using ArduinoCore-mbed mbed_portenta core usingVision-shield Ethernet
orMurata WiFi
Arduino IDE 1.8.19+
for Arduino.ArduinoCore-mbed mbed_portenta core 3.4.1+
for Arduino Portenta_H7 boards, such as Portenta_H7 Rev2 ABX00042, etc..
The best and easiest way is to use Arduino Library Manager
. Search for Portenta_H7_AsyncTCP, then select / install the latest version.
You can also use this link for more detailed instructions.
Another way to install is to:
- Navigate to Portenta_H7_AsyncTCP page.
- Download the latest release
Portenta_H7_AsyncTCP-main.zip
. - Extract the zip file to
Portenta_H7_AsyncTCP-main
directory - Copy whole
Portenta_H7_AsyncTCP-main
folder to Arduino libraries' directory such as~/Arduino/libraries/
.
- Install VS Code
- Install PlatformIO
- Install Portenta_H7_AsyncTCP library by using Library Manager. Search for Portenta_H7_AsyncTCP 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
To be able to upload firmware to Portenta_H7 using Arduino IDE in Linux (Ubuntu, etc.), you have to copy the file portenta_post_install.sh into mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/portenta_post_install.sh).
Then run the following command using sudo
$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1
$ chmod 755 portenta_post_install.sh
$ sudo ./portenta_post_install.sh
This will create the file /etc/udev/rules.d/49-portenta_h7.rules
as follows:
# Portenta H7 bootloader mode UDEV rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="035b", GROUP="plugdev", MODE="0666"
Supposing the ArduinoCore-mbed core version is 3.4.1. Now only one file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/portenta_post_install.sh
Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz
This file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/mbed_portenta/x.yy.zz/portenta_post_install.sh
To be able to compile, run on Portenta_H7 boards, you have to copy the whole mbed_portenta Packages_Patches directory into Arduino mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/2.5.2).
Supposing the Arduino mbed_portenta version is 2.5.2. These file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/mbed_portenta/2.5.2/libraries/SocketWrapper/src/MbedUdp.h
~/.arduino15/packages/arduino/hardware/mbed_portenta/2.5.2/libraries/SocketWrapper/src/MbedUdp.cpp
~/.arduino15/packages/arduino/hardware/mbed_portenta/2.5.2/cores/arduino/mbed/connectivity/lwipstack/include/lwipstack/lwipopts.h
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.
Following is the debug terminal and screen shot when running example Async_AdvancedWebServer on Portenta_H7 Ethernet to demonstrate the operation of Portenta_H7_AsyncWebServer, based on this Portenta_H7_AsyncTCP Library.
Start Async_AdvancedWebServer on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library
Portenta_H7_AsyncTCP v1.4.0
Portenta_H7_AsyncWebServer v1.4.2
Using mac index = 4
Connected! IP address: 192.168.2.87
HTTP EthernetWebServer is @ IP : 192.168.2.87
....
You can access the Async Advanced WebServers at the displayed server IP, e.g. 192.168.2.87
Following is the debug terminal and screen shot when running example Async_AdvancedWebServer on Portenta_H7 WiFi to demonstrate the operation of Portenta_H7_AsyncWebServer, based on this Portenta_H7_AsyncTCP Library.
Start Async_AdvancedWebServer on PORTENTA_H7_M7 with Portenta_H7 WiFi
Portenta_H7_AsyncTCP v1.4.0
Portenta_H7_AsyncWebServer v1.4.2
Connecting to SSID: HueNet1
SSID: HueNet1
Local IP Address: 192.168.2.94
signal strength (RSSI):-31 dBm
HTTP EthernetWebServer is @ IP : 192.168.2.94
..........
You can access the Async Advanced WebServers at the displayed server IP, e.g. 192.168.2.94
Following is the debug terminal when running example AsyncHTTPRequest on Portenta_H7 WiFi to demonstrate the operation of Portenta_H7_AsyncHTTPRequest, based on this Portenta_H7_AsyncTCP Library.
Start AsyncHTTPRequest on PORTENTA_H7_M7
Portenta_H7_AsyncTCP v1.4.0
Portenta_H7_AsyncHTTPRequest v1.4.2
Connecting to SSID: HueNet1
SSID: HueNet1
Local IP Address: 192.168.2.94
signal strength (RSSI):-27 dBm
Request sent
**************************************
abbreviation: EDT
client_ip: 104.247.246.186
datetime: 2021-10-14T21:35:10.868467-04:00
day_of_week: 4
day_of_year: 287
dst: true
dst_from: 2021-03-14T07:00:00+00:00
dst_offset: 3600
dst_until: 2021-11-07T06:00:00+00:00
raw_offset: -18000
timezone: America/Toronto
unixtime: 1634261710
utc_datetime: 2021-10-15T01:35:10.868467+00:00
utc_offset: -04:00
week_number: 41
**************************************
Following is the debug terminal when running example AsyncHTTPRequest on Portenta_H7 Ethernet to demonstrate the operation of Portenta_H7_AsyncHTTPRequest, based on this Portenta_H7_AsyncTCP Library.
Start AsyncHTTPRequest on PORTENTA_H7_M7
Portenta_H7_AsyncTCP v1.4.0
Portenta_H7_AsyncHTTPRequest v1.4.2
Using mac index = 6
Connected! IP address: 192.168.2.87
Request sent
**************************************
abbreviation: EDT
client_ip: 104.247.246.186
datetime: 2021-10-14T21:18:14.913322-04:00
day_of_week: 4
day_of_year: 287
dst: true
dst_from: 2021-03-14T07:00:00+00:00
dst_offset: 3600
dst_until: 2021-11-07T06:00:00+00:00
raw_offset: -18000
timezone: America/Toronto
unixtime: 1634260694
utc_datetime: 2021-10-15T01:18:14.913322+00:00
utc_offset: -04:00
week_number: 41
**************************************
Request sent
**************************************
abbreviation: EDT
client_ip: 104.247.246.186
datetime: 2021-10-14T21:19:14.649325-04:00
day_of_week: 4
day_of_year: 287
dst: true
dst_from: 2021-03-14T07:00:00+00:00
dst_offset: 3600
dst_until: 2021-11-07T06:00:00+00:00
raw_offset: -18000
timezone: America/Toronto
unixtime: 1634260754
utc_datetime: 2021-10-15T01:19:14.649325+00:00
utc_offset: -04:00
week_number: 41
**************************************
Debug is enabled by default on Serial.
You can also change the debugging level _PORTENTA_H7_ATCP_LOGLEVEL_
from 0 to 4 in the library cpp
files
#define _PORTENTA_H7_ATCP_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: Portenta_H7_AsyncTCP issues
- Search for bug and improvement.
- Add support to Portenta_H7
Vision-shield Ethernet
- Add Table of Contents
- Add support to Portenta_H7
Murata WiFi
- Fix issue with slow browsers or network
- Remove hard-code if possible
- Improve debug messages by adding functions to display
error/state messages
instead ofcryptic error/state number
- Use
allman
astyle
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
- Based on PhilBowles' STM32 AsyncTCP Library.
- Thanks to rusty-bit to initiate the Discussion in AsyncWebserver for Portenta H7 #6 leading to these Portenta_H7_AsyncTCP and Portenta_H7_AsyncWebServer libraries
- Thanks to Jeremy Ellis to test and report the compile error issue with mbed_portenta core v2.6.1, leading to v1.3.0
- Thanks to Maximilian Gerhardt for PR Fix platform value for Portenta #1, leading to v1.3.2
⭐️⭐️ Hristo Gochkov |
⭐️ Phil Bowles |
rusty-bit |
Jeremy Ellis |
Maximilian Gerhardt |
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) 2021- Khoi Hoang