AsyncTCP, AsyncUDP, AsyncWebServer and AsyncHTTPRequest for Portenta_H7, supporting both Ethernet and WiFi now

As requested in AsyncWebserver for Portenta H7 #6, I'm currently working on

  1. Portenta_H7_AsyncTCP. Done, waiting for final tests, touch, docs, and to be published
  2. Portenta_H7_AsyncWebServer. Done for Ethernet, waiting for final tests, touch, docs, and to be published. Next will be for Murata WiFi

Please comment if you have any suggestion and/or enhancement to be included.

Best Regards,


Test Results:

1. Async_AdvancedWebServer

Selection_049

2. MQTT_ThingStream on PORTENTA_H7_M7

Start MQTT_ThingStream on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library
Portenta_H7_AsyncTCP v1.0.0
Portenta_H7_AsyncWebServer v1.0.0
Using mac index = 17
Connected! IP address: 192.168.2.87
***************************************
STM32_Pub
***************************************
Attempting MQTT connection to broker.emqx.io
...connected
Published connection message successfully!
Subcribed to: STM32_Sub
MQTT Message Send : STM32_Pub => Hello from MQTT_ThingStream on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library
MQTT Message receive [STM32_Pub] Hello from MQTT_ThingStream on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library
MQTT Message Send : STM32_Pub => Hello from MQTT_ThingStream on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library
MQTT Message receive [STM32_Pub] Hello from MQTT_ThingStream on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library

The first Portenta_H7_AsyncTCP library of the Async series of libraries for Portenta_H7 has been published. Some more will follow shortly


arduino-library-badgeGitHub release

Features

This library is based on, modified from:

  1. Hristo Gochkov's ESPAsyncTCP
  2. Phil Bowles' STM32AsyncTCP

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

Why Async is better

  • 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

Currently supported Boards

  1. Portenta_H7 boards such as Portenta_H7 Rev2 ABX00042, etc., using ArduinoCore-mbed mbed_portenta core

Changelog

Initial Releases v1.0.0

  1. Initial coding to support Portenta_H7 boards such as Portenta_H7 Rev2 ABX00042, etc., using ArduinoCore-mbed mbed_portenta core and Vision-shield Ethernet
1 Like

arduino-library-badgeGitHub release

Features

This library is based on, modified from:

  1. Hristo Gochkov's ESPAsyncWebServer

to apply the better and faster asynchronous feature of the powerful ESPAsyncWebServer Library into Portenta_H7. Thus Portenta_H7_AsyncWebServer is part of a series of advanced Async libraries, such as AsyncTCP, AsyncUDP, AsyncWebSockets, AsyncHTTPRequest, AsyncHTTPSRequest, etc. to be written or modified to support Portenta_H7, using either Vision-shield Ethernet or Murata WiFi.

Why Async is better

  • 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

Currently supported Boards

  1. Portenta_H7 boards such as Portenta_H7 Rev2 ABX00042, etc., using ArduinoCore-mbed mbed_portenta core using Vision-shield Ethernet

Debug Terminal Output Samples

1. MQTT_ThingStream on PORTENTA_H7_M7 using Ethernet

Following is debug terminal output when running example MQTT_ThingStream on PORTENTA_H7_M7 using Ethernet and Portenta_Ethernet Library

Start MQTT_ThingStream on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library
Portenta_H7_AsyncTCP v1.0.0
Portenta_H7_AsyncWebServer v1.0.0
Using mac index = 17
Connected! IP address: 192.168.2.87
***************************************
STM32_Pub
***************************************
Attempting MQTT connection to broker.emqx.io
...connected
Published connection message successfully!
Subcribed to: STM32_Sub
MQTT Message Send : STM32_Pub => Hello from MQTT_ThingStream on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library
MQTT Message receive [STM32_Pub] Hello from MQTT_ThingStream on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library
MQTT Message Send : STM32_Pub => Hello from MQTT_ThingStream on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library
MQTT Message receive [STM32_Pub] Hello from MQTT_ThingStream on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library

2. Async_HTTPBasicAuth on PORTENTA_H7_M7 using Ethernet

Following is debug terminal output when running example Async_HTTPBasicAuth on PORTENTA_H7_M7 using Ethernet and Portenta_Ethernet Library

Start Async_HTTPBasicAuth on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library
Portenta_H7_AsyncTCP v1.0.0
Portenta_H7_AsyncWebServer v1.0.0
Using mac index = 16
Connected! IP address: 192.168.2.87
Async_HttpBasicAuth started @ IP : 192.168.2.87
Open http://192.168.2.87/ in your browser to see it working
Login using username = admin and password = ethernet
[AWS] getMD5: Success
[AWS] genRandomMD5: res =  795d0e2e77f0bd1ac56d88a223e30cc8
[AWS] getMD5: Success
[AWS] genRandomMD5: res =  0bc073c1bf61fa0ae678fa5892cfd2a6
[AWS] requestDigestAuthentication: header =  realm="asyncesp", qop="auth", nonce="795d0e2e77f0bd1ac56d88a223e30cc8", opaque="0bc073c1bf61fa0ae678fa5892cfd2a6"
[AWS] getMD5: Success
[AWS] stringMD5: res =  9384b554a02515c9481a13b3787821da
[AWS] getMD5: Success
[AWS] stringMD5: res =  71998c64aea37ae77020c49c00f73fa8
[AWS] getMD5: Success
[AWS] stringMD5: res =  5908212c923b4d99fd278772873a142f
[AWS] AUTH SUCCESS

Releases v1.1.0

  1. Add support to Portenta_H7 boards such as Portenta_H7 Rev2 ABX00042, etc., using ArduinoCore-mbed mbed_portenta core and Murata WiFi


Releases v1.1.0

  1. Add support to Portenta_H7 boards such as Portenta_H7 Rev2 ABX00042, etc., using ArduinoCore-mbed mbed_portenta core and Murata WiFi

Portenta_H7_AsyncUDP Library

arduino-library-badgeGitHub release


Initial Releases v1.0.0

  1. Initial coding to support Portenta_H7 boards such as Portenta_H7 Rev2 ABX00042, etc., using ArduinoCore-mbed mbed_portenta core and Vision-shield Ethernet

Debug Terminal Output Samples

1. AsyncUdpNTPClient on PORTENTA_H7_M7 using Ethernet

This is terminal debug output when running AsyncUdpNTPClient on PORTENTA_H7_M7 using Ethernet and Portenta_Ethernet Library. It connects to NTP Server 0.ca.pool.ntp.org (IP=208.81.1.244:123) using Portenta_H7_AsyncUDP library, and requests NTP time every 60s. The packet is then received and processed asynchronously to print current UTC/GMT time.

Start AsyncUdpNTPClient on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library
Portenta_H7_AsyncUDP v1.0.0
Using mac index = 5
Connected! IP address: 192.168.2.87
UDP connected
============= createNTPpacket =============
Sending UDP Packet
Sent UDP Packet
Received UDP Packet Type: Unicast
From: 208.81.1.244:123, To: 192.168.2.87:58997, Length: 48
Seconds since Jan 1 1900 = 3842738319
Epoch/Unix time = 1633749519
The UTC/GMT time is Sat 2021-10-09 03:18:39 GMT
============= createNTPpacket =============
Sending UDP Packet
Sent UDP Packet
Received UDP Packet Type: Unicast
From: 208.81.1.244:123, To: 192.168.2.87:58997, Length: 48
Seconds since Jan 1 1900 = 3842738378
Epoch/Unix time = 1633749578
The UTC/GMT time is Sat 2021-10-09 03:19:38 GMT

Portenta_H7_AsyncHTTPRequest Library


Features

  1. Asynchronous HTTP Request library for Portenta_H7 using Murata WiFi or Vision-shield Ethernet.
  2. Providing a subset of HTTP.
  3. Relying on on Khoi Hoang's Portenta_H7_AsyncTCP
  4. Methods similar in format and usage to XmlHTTPrequest in Javascript.

Supports

  1. GET, POST, PUT, PATCH, DELETE and HEAD
  2. Request and response headers
  3. Chunked response
  4. Single String response for short (<~5K) responses (heap permitting).
  5. Optional onData callback.
  6. Optional onReadyStatechange callback.

Principles of operation

This library adds a simple HTTP layer on top of the Portenta_H7_AsyncTCP library to facilitate REST communication from a Client to a Server. The paradigm is similar to the XMLHttpRequest in Javascript, employing the notion of a ready-state progression through the transaction request.

Synchronization can be accomplished using callbacks on ready-state change, a callback on data receipt, or simply polling for ready-state change. Data retrieval can be incremental as received, or bulk retrieved when the transaction completes provided there is enough heap to buffer the entire response.


Initial Releases v1.0.0

  1. Initial coding to support Portenta_H7 boards such as Portenta_H7 Rev2 ABX00042, etc., using ArduinoCore-mbed mbed_portenta core with Vision-shield Ethernet ot Murata WiFi

Debug Terminal Ouput Samples

AsyncWebClientRepeating running on PORTENTA_H7_M7 WiFi

Start AsyncWebClientRepeating on PORTENTA_H7_M7
Portenta_H7_AsyncTCP v1.2.0
Portenta_H7_AsyncHTTPRequest v1.0.0
Connecting to SSID: HueNet1
SSID: HueNet1
Local IP Address: 192.168.2.94
signal strength (RSSI):-26 dBm

**************************************

           `:;;;,`                      .:;;:.           
        .;;;;;;;;;;;`                :;;;;;;;;;;:     TM 
      `;;;;;;;;;;;;;;;`            :;;;;;;;;;;;;;;;      
     :;;;;;;;;;;;;;;;;;;         `;;;;;;;;;;;;;;;;;;     
    ;;;;;;;;;;;;;;;;;;;;;       .;;;;;;;;;;;;;;;;;;;;    
   ;;;;;;;;:`   `;;;;;;;;;     ,;;;;;;;;.`   .;;;;;;;;   
  .;;;;;;,         :;;;;;;;   .;;;;;;;          ;;;;;;;  
  ;;;;;;             ;;;;;;;  ;;;;;;,            ;;;;;;. 
 ,;;;;;               ;;;;;;.;;;;;;`              ;;;;;; 
 ;;;;;.                ;;;;;;;;;;;`      ```       ;;;;;`
 ;;;;;                  ;;;;;;;;;,       ;;;       .;;;;;
`;;;;:                  `;;;;;;;;        ;;;        ;;;;;
,;;;;`    `,,,,,,,,      ;;;;;;;      .,,;;;,,,     ;;;;;
:;;;;`    .;;;;;;;;       ;;;;;,      :;;;;;;;;     ;;;;;
:;;;;`    .;;;;;;;;      `;;;;;;      :;;;;;;;;     ;;;;;
.;;;;.                   ;;;;;;;.        ;;;        ;;;;;
 ;;;;;                  ;;;;;;;;;        ;;;        ;;;;;
 ;;;;;                 .;;;;;;;;;;       ;;;       ;;;;;,
 ;;;;;;               `;;;;;;;;;;;;                ;;;;; 
 `;;;;;,             .;;;;;; ;;;;;;;              ;;;;;; 
  ;;;;;;:           :;;;;;;.  ;;;;;;;            ;;;;;;  
   ;;;;;;;`       .;;;;;;;,    ;;;;;;;;        ;;;;;;;:  
    ;;;;;;;;;:,:;;;;;;;;;:      ;;;;;;;;;;:,;;;;;;;;;;   
    `;;;;;;;;;;;;;;;;;;;.        ;;;;;;;;;;;;;;;;;;;;    
      ;;;;;;;;;;;;;;;;;           :;;;;;;;;;;;;;;;;:     
       ,;;;;;;;;;;;;;,              ;;;;;;;;;;;;;;       
         .;;;;;;;;;`                  ,;;;;;;;;:         
                                                         
                                                         
                                                         
                                                         
    ;;;   ;;;;;`  ;;;;:  .;;  ;; ,;;;;;, ;;. `;,  ;;;;   
    ;;;   ;;:;;;  ;;;;;; .;;  ;; ,;;;;;: ;;; `;, ;;;:;;  
   ,;:;   ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;,`;, ;;  ;;  
   ;; ;:  ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;;`;, ;;  ;;. 
   ;: ;;  ;;;;;:  ;;  ;; .;;  ;;   ,;,   ;;`;;;, ;;  ;;` 
  ,;;;;;  ;;`;;   ;;  ;; .;;  ;;   ,;,   ;; ;;;, ;;  ;;  
  ;;  ,;, ;; .;;  ;;;;;:  ;;;;;: ,;;;;;: ;;  ;;, ;;;;;;  
  ;;   ;; ;;  ;;` ;;;;.   `;;;:  ,;;;;;, ;;  ;;,  ;;;;   

**************************************

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.