Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Asynchronous SSL TCP Library for ESP32, ESP32_C3, ESP32_S2, ESP32_S3. This library is the base for future and more advanced Async SSL libraries, such as AsyncSSLWebServer, AsyncHTTPSRequest

License

NotificationsYou must be signed in to change notification settings

khoih-prog/AsyncTCP_SSL

Repository files navigation

arduino-library-badgeGitHub releasecontributions welcomeGitHub issues

Donate to my libraries using BuyMeACoffee



Table of contents



Important Note for ESP32_S3

Don't useESP32_S3 with core v2.0.4. Checkalready fixedESP32-S3 Powercycling right after uploading a sketch using Arduino IDE and Arduino Core 2.0.4 #7165

ESP32_S3 is OK now with core v2.0.5


Important Change from v1.2.0

Please have a look atHOWTO FixMultiple Definitions Linker Error


Why do we need thisAsyncTCP_SSL library

Features

This library is based on, modified from:

  1. Hristo Gochkov's AsyncTCP
  2. Maarten Fremouw's AsyncTCP.
  3. Thorsten von Eicken's AsyncTCP

to apply the better and fasterasynchronous feature of thepowerfulAsyncTCP Library with SSL, and will be the base for future and more advanced Async libraries for ESP32, such as AsyncSSLWebServer, AsyncHTTPSRequest, etc.

Why Async is better

  • Using asynchronous network means that you can handlemore than one connection at the same time
  • You are called once the request is ready and parsed
  • When you send the response, you areimmediately 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 handleany 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. ESP32 boards, such as ESP32_DEV, etc.
  2. ESP32_S2-based boards, such as ESP32S2_DEV, ESP32_S2 Saola, etc.
  3. ESP32_C3-based boards, such as ESP32C3_DEV, etc.
  4. ESP32_S3-based boards, such as ESP32S3_DEV, etc., using ESP32 corev2.0.3 orv2.0.5+


Prerequisites

  1. Arduino IDE 1.8.19+ for Arduino.GitHub release
  2. ESP32 Core 2.0.5+ for ESP32-based boards.Latest release for ESP32, ESP32_S2, ESP32_C3
  3. ESP32 Core 2.0.4 can't be used for ESP32_S3-based boards. Checkalready fixedESP32-S3 Powercycling right after uploading a sketch using Arduino IDE and Arduino Core 2.0.4 #7165


Installation

Use Arduino Library Manager

The best and easiest way is to useArduino Library Manager. Search forAsyncTCP_SSL, then select / install the latest version.You can also use this linkarduino-library-badge for more detailed instructions.

Manual Install

Another way to install is to:

  1. Navigate toAsyncTCP_SSL page.
  2. Download the latest releaseAsyncTCP_SSL-main.zip.
  3. Extract the zip file toAsyncTCP_SSL-main directory
  4. Copy wholeAsyncTCP_SSL-main folder to Arduino libraries' directory such as~/Arduino/libraries/.

VS Code & PlatformIO

  1. InstallVS Code
  2. InstallPlatformIO
  3. InstallAsyncTCP_SSL library by usingLibrary Manager. Search forAsyncTCP_SSL inPlatform.io Author's Libraries
  4. Use includedplatformio.ini file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples atProject Configuration File


Note for Platform IO using ESP32 LittleFS

In Platform IO, to fix the error when usingLittleFS_esp32 v1.0 for ESP32-based boards with ESP32 core v1.0.4- (ESP-IDF v3.2-), uncomment the following line

from

//#define CONFIG_LITTLEFS_FOR_IDF_3_2   /* For old IDF - like in release 1.0.4 */

to

#defineCONFIG_LITTLEFS_FOR_IDF_3_2/* For old IDF - like in release 1.0.4*/

It's advisable to use the latestLittleFS_esp32 v1.0.5+ to avoid the issue.

Thanks toRoshan to report the issue inError esp_littlefs.c 'utime_p'



HOWTO FixMultiple Definitions Linker Error

The current library implementation, usingxyz-Impl.h instead of standardxyz.cpp, possibly creates certainMultiple Definitions Linker error in certain use cases.

You can include this.hpp file

// Can be included as many times as necessary, without `Multiple Definitions` Linker Error#include"AsyncTCP_SSL.hpp"//https://github.com/khoih-prog/AsyncTCP_SSL

in many files. But be sure to use the following.h filein just 1.h,.cpp or.ino file, which mustnot be included in any other file, to avoidMultiple Definitions Linker Error

// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error#include"AsyncTCP_SSL.h"//https://github.com/khoih-prog/AsyncTCP_SSL

Check the newmultiFileProject example for aHOWTO demo.



Note for Platform IO using ESP32 LittleFS

In Platform IO, to fix the error when usingLittleFS_esp32 v1.0 for ESP32-based boards with ESP32 core v1.0.4- (ESP-IDF v3.2-), uncomment the following line

from

//#define CONFIG_LITTLEFS_FOR_IDF_3_2   /* For old IDF - like in release 1.0.4 */

to

#defineCONFIG_LITTLEFS_FOR_IDF_3_2/* For old IDF - like in release 1.0.4*/

It's advisable to use the latestLittleFS_esp32 v1.0.5+ to avoid the issue.

Thanks toRoshan to report the issue inError esp_littlefs.c 'utime_p'



HOWTO Use analogRead() with ESP32 running WiFi and/or BlueTooth (BT/BLE)

Please have a look atESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example to have more detailed description and solution of the issue.

1. ESP32 has 2 ADCs, named ADC1 and ADC2

2. ESP32 ADCs functions

  • ADC1 controls ADC function for pinsGPIO32-GPIO39
  • ADC2 controls ADC function for pinsGPIO0, 2, 4, 12-15, 25-27

3.. ESP32 WiFi uses ADC2 for WiFi functions

Look in fileadc_common.c

In ADC2, there're two locks used for different cases:

  1. lock shared with app and Wi-Fi:ESP32:When Wi-Fi using the ADC2, we assume it will never stop, so app checks the lock and returns immediately if failed.ESP32S2:The controller's control over the ADC is determined by the arbiter. There is no need to control by lock.

  2. lock shared between tasks:when several tasks sharing the ADC2, we want to guaranteeall the requests will be handled.Since conversions are short (about 31us), app returns the lock very soon,we use a spinlock to stand there waiting to do conversions one by one.

adc2_spinlock should be acquired first, then adc2_wifi_lock or rtc_spinlock.

  • In order to use ADC2 for other functions, we have toacquire complicated firmware locks and very difficult to do
  • So, it's not advisable to use ADC2 with WiFi/BlueTooth (BT/BLE).
  • Use ADC1, and pins GPIO32-GPIO39
  • If somehow it's a must to use those pins serviced by ADC2 (GPIO0, 2, 4, 12, 13, 14, 15, 25, 26 and 27), use thefix mentioned at the end ofESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example to work with ESP32 WiFi/BlueTooth (BT/BLE).


Original documentation

For ESP32, checkAsyncTCP Library

This is a fully asynchronous SSL TCP library, aimed at enabling trouble-free, multi-connection network environment for Espressif's ESP32 MCUs.

AsyncSSLClient

The base classes on which everything else is built. They expose all possible scenarios, but are really raw and require more skills to use.



Examples

  1. multiFileProject.New


Debug Terminal Output Samples

1. AsyncHTTPSRequest_ESP on ESP32_DEV

Following is the debug terminal when running exampleAsyncHTTPSRequest_ESP on ESP32_DEV to demonstrate the operation of SSL Async HTTPS request, usingAsyncTCP_SSL Library.

Starting AsyncHTTPSRequest_ESPusing ESP32_DEVAsyncTCP_SSL v1.3.1AsyncHTTPSRequest_Generic v2.1.2Connecting to WiFi SSID: HueNet1.......AsyncHTTPSRequest @ IP :192.168.2.133**************************************abbreviation: EDTclient_ip: aaa.bbb.ccc.ddddatetime:2022-09-18T01:35:32.451975-04:00day_of_week:0day_of_year:261dst:truedst_from:2022-03-13T07:00:00+00:00dst_offset:3600dst_until:2022-11-06T06:00:00+00:00raw_offset: -18000timezone: America/Torontounixtime:1663479332utc_datetime:2022-09-18T05:35:32.451975+00:00utc_offset: -04:00week_number:37**************************************HHHHHH**************************************abbreviation: EDTclient_ip: aaa.bbb.ccc.ddddatetime:2022-09-18T01:36:31.992595-04:00day_of_week:0day_of_year:261dst:truedst_from:2022-03-13T07:00:00+00:00dst_offset:3600dst_until:2022-11-06T06:00:00+00:00raw_offset: -18000timezone: America/Torontounixtime:1663479391utc_datetime:2022-09-18T05:36:31.992595+00:00utc_offset: -04:00week_number:37

2. AsyncHTTPSRequest_ESP on ESP32S2_DEV

Following is the debug terminal when running exampleAsyncHTTPSRequest_ESP on ESP32S2_DEV to demonstrate the operation of SSL Async HTTPS request, usingAsyncTCP_SSL Library.

Starting AsyncHTTPSRequest_ESPusing ESP32S2_DEVAsyncTCP_SSL v1.3.1AsyncHTTPSRequest_Generic v2.1.2Connecting to WiFi SSID: HueNet1.......AsyncHTTPSRequest @ IP :192.168.2.79[ATCP] _handle_async_event: LWIP_TCP_DNS =0x3FFE4E24[ATCP] _handle_async_event: LWIP_TCP_DNS, name = worldtimeapi.org , IP =213.188.196.246[ATCP] _handle_async_event: LWIP_TCP_CONNECTED =0x3FFE4E240x3FFE5024[ATCP] _handle_async_event: LWIP_TCP_CONNECTED =0[ATCP] _handle_async_event: LWIP_TCP_SENT =0x3FFE5024[ATCP] _sent: len =305[ATCP] _handle_async_event: LWIP_TCP_RECV =0x3FFE5024[ATCP] _recv: tot_len =1436[ATCP] _handle_async_event: LWIP_TCP_RECV =0x3FFE5024[ATCP] _recv: tot_len =1436[ATCP] _handle_async_event: LWIP_TCP_RECV =0x3FFE5024[ATCP] _recv: tot_len =1242[ATCP] _handle_async_event: LWIP_TCP_SENT =0x3FFE5024[ATCP] _sent: len =107[ATCP] _handle_async_event: LWIP_TCP_SENT =0x3FFE5024[ATCP] _sent: len =6[ATCP] _handle_async_event: LWIP_TCP_SENT =0x3FFE5024[ATCP] _sent: len =45[ATCP] _handle_async_event: LWIP_TCP_RECV =0x3FFE5024[ATCP] _recv: tot_len =51[ATCP] _handle_async_event: LWIP_TCP_SENT =0x3FFE5024[ATCP] _sent: len =106[ATCP] _handle_async_event: LWIP_TCP_RECV =0x3FFE5024[ATCP] _recv: tot_len =1016**************************************abbreviation: EDTclient_ip: aaa.bbb.ccc.ddddatetime:2022-09-18T01:46:31.858783-04:00day_of_week:0day_of_year:261dst:truedst_from:2022-03-13T07:00:00+00:00dst_offset:3600dst_until:2022-11-06T06:00:00+00:00raw_offset: -18000timezone: America/Torontounixtime:1663479991utc_datetime:2022-09-18T05:46:31.858783+00:00utc_offset: -04:00week_number:37**************************************

3. AsyncHTTPSRequest_ESP on ESP32C3_DEV

Following is the debug terminal when running exampleAsyncHTTPSRequest_ESP on ESP32C3_DEV to demonstrate the operation of SSL Async HTTPS request, usingAsyncTCP_SSL Library.

Starting AsyncHTTPSRequest_ESPusing ESP32C3_DEVAsyncTCP_SSL v1.3.1AsyncHTTPSRequest_Generic v2.1.2Connecting to WiFi SSID: HueNet1.........AsyncHTTPSRequest @ IP :192.168.2.80**************************************abbreviation: EDTclient_ip: aaa.bbb.ccc.ddddatetime:2022-09-18T01:35:32.451975-04:00day_of_week:0day_of_year:261dst:truedst_from:2022-03-13T07:00:00+00:00dst_offset:3600dst_until:2022-11-06T06:00:00+00:00raw_offset: -18000timezone: America/Torontounixtime:1663479332utc_datetime:2022-09-18T05:35:32.451975+00:00utc_offset: -04:00week_number:37**************************************

4. AsyncHTTPSRequest_ESP_WiFiManager on ESP32_DEV

Following is the debug terminal when running exampleAsyncHTTPSRequest_ESP_WiFiManager on ESP32_DEV to demonstrate the operation of SSL Async HTTPS request, usingAsyncTCP_SSL Library, andESPAsync_WiFiManager Library

Starting AsyncHTTPSRequest_ESP_WiFiManagerusing LittleFS on ESP32_DEVESPAsync_WiFiManager v1.14.1AsyncTCP_SSL v1.3.1AsyncHTTPSRequest_Generic v2.1.2Stored: SSID = HueNet1, Pass =12345678Got stored Credentials. Timeout 120sConnectMultiWiFi in setupAfter waiting11.38 secs more insetup(), connection result is connected. Local IP: 192.168.2.232H**************************************abbreviation: EDTclient_ip: aaa.bbb.ccc.ddddatetime: 2022-09-18T01:36:31.992595-04:00day_of_week: 0day_of_year: 261dst: truedst_from: 2022-03-13T07:00:00+00:00dst_offset: 3600dst_until: 2022-11-06T06:00:00+00:00raw_offset: -18000timezone: America/Torontounixtime: 1663479391utc_datetime: 2022-09-18T05:36:31.992595+00:00utc_offset: -04:00week_number: 37**************************************H

5. AsyncHTTPSRequest_ESP_Multi on ESP32S3_DEV

Following is the debug terminal when running exampleAsyncHTTPSRequest_ESP_Multi onESP32S3_DEV on ESP32 core v2.0.5 to demonstrate the operation of SSL Async HTTPS request, usingAsyncTCP_SSL Library

Starting AsyncHTTPSRequest_ESP_Multi on ESP32S3_DEVAsyncTCP_SSL v1.3.1AsyncHTTPSRequest_Generic v2.1.2Connecting to WiFi SSID: HueNet1...AsyncHTTPSRequest @ IP :192.168.2.187Sending request: https://worldtimeapi.org/api/timezone/Europe/Prague.txtSending request: https://www.myexternalip.com/raw[AHTTPS] _onError handler SSL error = OK[AHTTPS] _onError handler SSL error = OK**************************************[AHTTPS] Response Code =  HTTP OK**************************************aaa.bbb.ccc.ddd****************************************************************************[AHTTPS] Response Code =  HTTP OK**************************************abbreviation: CESTclient_ip: aaa.bbb.ccc.ddddatetime:2022-09-18T07:50:04.395849+02:00day_of_week:0day_of_year:261dst:truedst_from:2022-03-27T01:00:00+00:00dst_offset:3600dst_until:2022-10-30T01:00:00+00:00raw_offset:3600timezone: Europe/Pragueunixtime:1663480204utc_datetime:2022-09-18T05:50:04.395849+00:00utc_offset: +02:00week_number:37**************************************Sending request: https://worldtimeapi.org/api/timezone/America/Toronto.txt**************************************[AHTTPS] Response Code =  HTTP OK**************************************abbreviation: EDTclient_ip: aaa.bbb.ccc.ddddatetime:2022-09-18T01:50:05.382100-04:00day_of_week:0day_of_year:261dst:truedst_from:2022-03-13T07:00:00+00:00dst_offset:3600dst_until:2022-11-06T06:00:00+00:00raw_offset: -18000timezone: America/Torontounixtime:1663480205utc_datetime:2022-09-18T05:50:05.382100+00:00utc_offset: -04:00week_number:37**************************************H


Debug

Debug is enabled by default on Serial.

You can also change the debugging level_ASYNC_TCP_SSL_LOGLEVEL_ from 0 to 4 in the sketch

#define_ASYNC_TCP_SSL_LOGLEVEL_1

Troubleshooting

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.



Issues

Submit issues to:AsyncTCP_SSL issues


TO DO

  1. Search for bug and improvement.
  2. Similar Async SSL libraries for ESP8266, STM32, Portenta_H7 and many other boards
  3. Permit both HTTP and HTTPS

DONE

  1. Add support to ESP32 using SSL
  2. Add Table of Contents
  3. Add debug feature
  4. Fixmultiple-definitions linker error
  5. Add examples
  6. Remove hard-code if possible
  7. Improve debug messages by adding functions to displayerror/state messages instead ofcryptic error/state number
  8. Add support toESP32_S3, using ESP32 corev2.0.3 orv2.0.5+.Don't useESP32_S3 with core v2.0.4. Checkalready fixedESP32-S3 Powercycling right after uploading a sketch using Arduino IDE and Arduino Core 2.0.4 #7165
  9. IncreaseASYNC_QUEUE_LENGTH to default512 from 32 and make it user-configurable
  10. IncreaseASYNC_TCP_PRIORITY to default10 from 3, and make it user-configurable


Contributions and Thanks

Many thanks for everyone for bug reporting, new feature suggesting, testing and contributing to the development of this library.

Contributions and Thanks

  1. Based on and modified fromHristo Gochkov's AsyncTCP. Many thanks toHristo Gochkov for greatAsyncTCP Library
  2. Based onMaarten Fremouw's AsyncTCP Library.
  3. Based onThorsten von Eicken's AsyncTCP Library.
me-no-dev
⭐️⭐️ Hristo Gochkov

fremouw
Maarten Fremouw

tve
Thorsten von Eicken


Contributing

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

License

  • The library is licensed underLGPLv3

Copyright

  • Copyright (c) 2016- Hristo Gochkov
  • Copyright (c) 2019- Maarten Fremouw
  • Copyright (c) 2019- Thorsten von Eicken
  • Copyright (c) 2021- Khoi Hoang

About

Asynchronous SSL TCP Library for ESP32, ESP32_C3, ESP32_S2, ESP32_S3. This library is the base for future and more advanced Async SSL libraries, such as AsyncSSLWebServer, AsyncHTTPSRequest

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp