Page 1 of 1

New AsyncHTTPSRequest_Generic Library for ESSP32, WT32_ETH01

Posted: Sat Oct 23, 2021 3:54 am
by khoih-prog
AsyncHTTPSRequest_Generic Library

How To Install Using Arduino Library Manager


Why do we need this Async AsyncHTTPSRequest_Generic Library

Features

1. Asynchronous HTTPS Request library for ESP32, ESP32_S2, ESP32_C3 using built-in WiFi.
2. Providing a subset of HTTPS.
3. Relying on on AsyncTCP_SSL for ESP32 using built-in WiFi
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 HTTPS layer on top of the [/url]/AsyncTCP_SSL 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.

The underlying buffering uses a new xbuf class. It handles both character and binary data. Class xbuf uses a chain of small (64 byte) segments that are allocated and added to the tail as data is added and deallocated from the head as data is read, achieving the same result as a dynamic circular buffer limited only by the size of heap. The xbuf implements indexOf and readUntil functions.

For short transactions, buffer space should not be an issue. In fact, it can be more economical than other methods that use larger fixed length buffers. Data is acked when retrieved by the caller, so there is some limited flow control to limit heap usage for larger transfers.

Request and response headers are handled in the typical fashion.

Chunked responses are recognized and handled transparently.

This library is based on, modified from:

1. Bob Lemaire's asyncHTTPrequest Library
2. Khoi Hoang's AsyncHTTPRequest_Generic Library

Releases v1.1.0

1. Add support to ESP32-based WT32_ETH01 using LAN8720 using either ESP32 core v1.0.6- or core v2.0.0+
2. Add example for WT32_ETH01

Initial Releases v1.0.0

1. Initial coding to support Async HTTPS to ESP32, ESP32_S2 and ESP32_C3 using built-in WiFi

Currently Supported Boards

1. ESP32 including ESP32_S2 and ESP32_C3


Debug Termimal Output Samples

1. This is terminal debug output when running AsyncHTTPSRequest_ESP example on ESP32_DEV using built-in WiFi.

Code: Select all

Starting AsyncHTTPSRequest_ESP using ESP32_DEV
AsyncTCP_SSL v1.1.0
AsyncHTTPSRequest_Generic v1.0.0
Connecting to WiFi SSID: HueNet1
.......
AsyncHTTPSRequest @ IP : 192.168.2.78

**************************************
abbreviation: EDT
client_ip: aaa.bbb.ccc.ddd
datetime: 2021-10-21T16:05:03.170256-04:00
day_of_week: 4
day_of_year: 294
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: 1634846703
utc_datetime: 2021-10-21T20:05:03.170256+00:00
utc_offset: -04:00
week_number: 42
**************************************
HHHHHH
**************************************
abbreviation: EDT
client_ip: aaa.bbb.ccc.ddd
datetime: 2021-10-21T16:06:00.828056-04:00
day_of_week: 4
day_of_year: 294
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: 1634846760
utc_datetime: 2021-10-21T20:06:00.828056+00:00
utc_offset: -04:00
week_number: 42
**************************************

Re: New AsyncHTTPSRequest_Generic Library for ESSP32, WT32_ETH01

Posted: Sun Feb 27, 2022 6:52 am
by khoih-prog
Releases v2.0.0

1. Breaking change to permit coexisting with AsyncHTTPRequest library to send and receive both HTTP and HTTPS.
1. Add example AsyncHTTP_HTTPSRequest_ESP to demonstrate how to send HTTP and HTTPS requests to multiple addresses and receive responses from them.

Releases v1.4.1

1. Add example AsyncHTTPSRequest_ESP_Multi to demonstrate how to send requests to multiple addresses and receive responses from them.

Releases v1.4.0

1. Add support to new ESP32-S3
2. Add LittleFS support to ESP32-C3
3. Use ESP32-core's LittleFS library instead of Lorol's LITTLEFS library for v2.0.0+
4. Add complex example AsyncHTTPSRequest_ESP_WiFiManager

Releases v1.3.0

1. Reduce the breaking effect of v1.2.0 by enabling compatibility with old code to include only AsyncHTTPSRequest_Generic.h
2. Modify to be compatible with AsyncTCP_SSL releases v1.2.0
3. Add example multiFileProject to demo for multiple-file project.

Releases v1.2.0

1. Fix multiple-definitions linker error and weird bug related to `src_cpp`.
2. Optimize library code by using `reference-passing` instead of `value-passing`
3. Update all examples

Releases v1.1.1

Warning: Releases v1.1.1+ can be used and autodetect ESP32 core v2.0.0+ or v1.0.6- for WT32_ETH01

1. Auto detect ESP32 core to use for WT32_ETH01
2. Fix bug in WT32_ETH01 examples to reduce connection time


Debug Termimal Output Samples

1. This is terminal debug output when running AsyncHTTP_HTTPSRequest_ESP example on ESP32_DEV to demonstrate how to send HTTP and HTTPS requests to multiple addresses and receive responses from them.

Code: Select all

Starting AsyncHTTP_HTTPSRequest_ESP on ESP32_DEV
AsyncTCP_SSL v1.2.0
AsyncHTTPSRequest_Generic v2.0.0
AsyncHTTPRequest_Generic v1.7.1
Connecting to WiFi SSID: HueNet1
.......
AsyncHTTPSRequest @ IP : 192.168.2.88

Sending HTTPS request: https://worldtimeapi.org/api/timezone/Europe/Prague.txt

Sending HTTP request: http://worldtimeapi.org/api/timezone/America/Vancouver.txt

**************************************
abbreviation: PST
client_ip: aaa.bbb.ccc.ddd
datetime: 2022-02-26T21:22:16.988348-08:00
day_of_week: 6
day_of_year: 57
dst: false
dst_from: 
dst_offset: 0
dst_until: 
raw_offset: -28800
timezone: America/Vancouver
unixtime: 1645939336
utc_datetime: 2022-02-27T05:22:16.988348+00:00
utc_offset: -08:00
week_number: 8
**************************************

**************************************
abbreviation: CET
client_ip: aaa.bbb.ccc.ddd
datetime: 2022-02-27T06:22:17.007202+01:00
day_of_week: 0
day_of_year: 58
dst: false
dst_from: 
dst_offset: 0
dst_until: 
raw_offset: 3600
timezone: Europe/Prague
unixtime: 1645939337
utc_datetime: 2022-02-27T05:22:17.007202+00:00
utc_offset: +01:00
week_number: 8
**************************************

Sending HTTP request: http://www.myexternalip.com/raw

**************************************
aaa.bbb.ccc.ddd
**************************************

Sending HTTPS request: https://worldtimeapi.org/api/timezone/America/Toronto.txt

**************************************
abbreviation: EST
client_ip: aaa.bbb.ccc.ddd
datetime: 2022-02-27T00:22:17.185617-05:00
day_of_week: 0
day_of_year: 58
dst: false
dst_from: 
dst_offset: 0
dst_until: 
raw_offset: -18000
timezone: America/Toronto
unixtime: 1645939337
utc_datetime: 2022-02-27T05:22:17.185617+00:00
utc_offset: -05:00
week_number: 8
**************************************

Sending HTTP request: http://worldtimeapi.org/api/timezone/Europe/London.txt

**************************************
abbreviation: GMT
client_ip: aaa.bbb.ccc.ddd
datetime: 2022-02-27T05:22:17.290540+00:00
day_of_week: 0
day_of_year: 58
dst: false
dst_from: 
dst_offset: 0
dst_until: 
raw_offset: 0
timezone: Europe/London
unixtime: 1645939337
utc_datetime: 2022-02-27T05:22:17.290540+00:00
utc_offset: +00:00
week_number: 8
**************************************
H