基于区块链的毕业设计Changelog – 变更日志

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计Changelog – 变更日志 是一篇很好的国外资料

EthernetWebServer_SSL

Changelog - 变更日志 Changelog - 变更日志 Changelog - 变更日志 Changelog - 变更日志 Changelog - 变更日志



Table of Contents

  • Why do we need this EthernetWebServer_SSL library

    • Features
    • Currently supported Boards
    • Currently supported Ethernet shields/modules
  • Changelog

    • Releases v1.3.1
    • Releases v1.3.0
    • Major Releases v1.2.0
    • Releases v1.1.2
    • Releases v1.1.1
    • Releases v1.1.0
  • Prerequisites

  • Installation

    • Use Arduino Library Manager
    • Manual Install
    • VS Code & PlatformIO
  • Packages’ Patches

    • 1. For Adafruit nRF52840 and nRF52832 boards
    • 2. For Teensy boards
    • 3. For Arduino SAM DUE boards
    • 4. For Arduino SAMD boards
      • For core version v1.8.10+
      • For core version v1.8.9-
    • 5. For Adafruit SAMD boards
    • 6. For Seeeduino SAMD boards
    • 7. For STM32 boards
  • Libraries’ Patches

    • 1. For application requiring 2K+ HTML page
    • 2. For Ethernet library
    • 3. For EthernetLarge library
    • 4. For Etherne2 library
    • 5. For Ethernet3 library
    • 6. For UIPEthernet library
    • 7. For fixing ESP32 compile error
  • HOWTO Use analogRead() with ESP32 running WiFi and/or BlueTooth (BT/BLE)

    • 1. ESP32 has 2 ADCs, named ADC1 and ADC2
    • 2. ESP32 ADCs functions
    • 3. ESP32 WiFi uses ADC2 for WiFi functions
  • Configuration Notes

    • 1. How to select which built-in Ethernet or shield to use *Important
    • 2. How to select another CS/SS pin to use
    • 3. How to use W5x00 with ESP8266
    • 4. How to increase W5x00 TX/RX buffer
    • 5. How to adjust sendContent_P() and send_P() buffer size
  • WebServer and non TLS/SSL WebClient Usage

    • Init the CS/SS pin if use EthernetWrapper
    • Class Constructor
    • Basic Operation
    • Advanced Options
    • Other Function Calls
  • TLS/SSL WebClient Usage

    • Overview
      • 1. Board and Network Peripheral Requirements
      • 2. How to use Trust Anchors TA
      • 3. Note
  • How It Works

  • Other Features

    • Logging
    • Errors
    • Write Buffering
    • Session Caching
    • mTLS
  • Implementation Notes

    • Seeding Random Data
    • Certificate Verification
    • Resources
    • Read Buffer Overflow
    • Cipher Support
    • Known Issues
  • Examples

    • WebServer, TLS/SSL Client Examples
      • 1. AdvancedWebServer
      • 2. HelloServer
      • 3. HelloServer2
      • 4. HttpBasicAuth
      • 5. MQTTClient_Auth
      • 6. MQTTClient_Basic
      • 7. MQTTClient_SSL
      • 8. MQTTClient_SSL_Auth
      • 9. MQTTClient_SSL_Complex
      • 10. PostServer
      • 11. SimpleAuthentication
      • 12. UdpNTPClient
      • 13. UdpSendReceive
      • 14. WebClient
      • 15. WebClientMulti_SSL
      • 16. WebClientRepeating
      • 17. WebClient_SSL
      • 18. WebServer
      • 19. MQTTS_ThingStream.
      • 20. MQTT_ThingStream.
      • 21. AdvancedWebServer_NativeEthernet.
      • 22. WebClientMulti_SSL_NativeEthernet.
    • HTTP and WebSocket Client New Examples
      • 1. BasicAuthGet
      • 2. CustomHeader
      • 3. DweetGet
      • 4. DweetPost
      • 5. HueBlink
      • 6. node_test_server
      • 7. PostWithHeaders
      • 8. SimpleDelete
      • 9. SimpleGet
      • 10. SimpleHTTPExample
      • 11. SimplePost
      • 12. SimplePut
      • 13. SimpleWebSocket
  • Example AdvancedWebServer

    • 1. File AdvancedWebServer.ino
    • 2. File defines.h
  • Debug Terminal Output Samples

    • 1. AdvancedWebServer on NRF52840_FEATHER_EXPRESS with ENC28J60 using EthernetENC Library
    • 2. ENC28J60_WM_Config on ESP32 with ENC28J60 using UIPEthernet Library
    • 3. WebClientMulti_SSL on SAM DUE with W5x00 using EthernetLarge Library
    • 4. WebClient_SSL on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library
    • 5. MQTTClient_SSL_Complex on SAM DUE with W5x00 using EthernetLarge Library
  • Debug

  • Troubleshooting

  • Releases

  • Issues

  • TO DO

  • DONE

  • Contributions and Thanks

  • Contributing

  • License

  • Copyright



Why do we need this EthernetWebServer_SSL library

Features

This EthernetWebServer_SSL library is a simple yet complete TLS/SSL WebClient and non-TLS/SSL WebServer library for Teensy, SAM DUE, Arduino SAMD21, Adafruit SAMD21/SAMD51, Adafruit nRF52, ESP32/ESP8266, STM32, etc. boards using Ethernet shields. The functions are similar and compatible to those of ESP32 WebServer and ESP8266WebServer libraries to make life much easier to port sketches from ESP8266/ESP32.

This EthernetWebServer_SSL library adds TLS 1.2 functionality to EthernetClient, using BearSSL as an underlying TLS engine.

This EthernetWebServer_SSL library, from v1.2.0, also provides high-level HTTP and WebSocket Client with the functions are similar and compatible to those of ArduinoHttpClient Library

The library provides these features:

  1. TCP Server and Client
  2. UDP Server and Client
  3. HTTP Server and HTTP/HTTPS Client
  4. HTTPS GET and POST requests, provides argument parsing, handles one client at a time.
  5. High-level HTTP (GET, POST, PUT, PATCH, DELETE) and WebSocket Client. From v1.2.0.

Library is based on and modified from:

  1. Ivan Grokhotkov’s ESP8266WebServer
  2. Ivan Grokhotkov’s ESP32 WebServer
  3. OPEnSLab-OSU’s SSLClient v1.6.9
  4. ArduinoHttpClient Library

The EthernetWebServer class, found in EthernetWebServer.h header, is a simple WebServer class, knowing how to handle HTTP requests such as GET and POST and can only support one one client at a time.

The EthernetSSLClient class, found in SSLClient.h header, is a simple WebClient class, knowing how to handle HTTP/HTTPS requests such as GET and POST and can only support one client at a time.

Currently supported Boards

This EthernetWebServer_SSL library currently supports these following boards:

  1. nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.. Currently SSL WebClient is not working.
  2. SAM DUE
  3. SAMD21
  • Arduino SAMD21: ZERO, MKRs, NANO_33_IOT, etc.
  • Adafruit SAMD21 (M0): ItsyBitsy M0, Feather M0, Feather M0 Express, Metro M0 Express, Circuit Playground Express, Trinket M0, PIRkey, Hallowing M0, Crickit M0, etc.
  • SeeedStudio: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, etc.
  1. SAMD51
  • Adafruit SAMD51 (M4): Metro M4, Grand Central M4, ItsyBitsy M4, Feather M4 Express, Trellis M4, Metro M4 AirLift Lite, MONSTER M4SK Express, Hallowing M4, etc.
  • Seeeduino: WIO Terminal, Grove UI Wireless
  1. Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0, LC)
  2. AVR Mega1280, 2560, ADK.. SSL WebClient not supported yet. Check Trivial sketch won’t compile using Arduino 1.8.13
  3. ESP32
  4. ESP8266. SSL WebClient not supported yet. Check HTTPS GET request – ESP8266 – ENC28j60

Currently supported Ethernet shields/modules

  1. W5x00 using Ethernet, EthernetLarge, Ethernet2 or Ethernet3 library
  2. ENC28J60 using EthernetENC or UIPEthernet library
  3. Teensy 4.1 built-in NativeEthernet using NativeEthernet Library


Changelog

Releases v1.3.1

  1. Clean-up all compiler warnings possible.
  2. Add Table of Contents

Releases v1.3.0

  1. Add support to NativeEthernet Library for Teensy 4.1

Major Releases v1.2.0

  1. Add high-level HTTP and WebSockets Client by merging ArduinoHttpClient Library
  2. Add many more examples for HTTP and WebSockets Client.
  3. Add Version String.

Releases v1.1.2

  1. Add SSL debug feature.
  2. Enhance examples.

Releases v1.1.1

  1. Permit sites with “Chain could not be linked to a trust anchor” such as mqtt.thingstream.io.
  2. Add example MQTTS_ThingStream to demonstrate new feature

Releases v1.1.0

  1. Initial coding for SAMD21/SAMD51, SAM DUE, Teensy to support Ethernet shields using SSL.
  2. Supporting W5x00 using Ethernet, EthernetLarge, Ethernet2 and Ethernet3 libraries
  3. Supporting ENC28J60 using EthernetENC and UIPEthernet libraries


Prerequisites

  1. Arduino IDE 1.8.13+ for Arduino
  2. Arduino AVR core 1.8.3+ for Arduino AVR boards. Use Arduino Board Manager to install.
  3. Teensy core v1.53+ for Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0) boards.
  4. Arduino SAM DUE core v1.6.12+ for SAM DUE ARM Cortex-M3 boards.
  5. Arduino SAMD core 1.8.11+ for SAMD ARM Cortex-M0+ boards (Nano 33 IoT, etc.).
  6. Adafruit SAMD core 1.6.4+ for SAMD ARM Cortex-M0+ and M4 boards (Itsy-Bitsy M4, etc.)
  7. Seeeduino SAMD core 1.8.1+ for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.)
  8. Adafruit nRF52 v0.21.0+ for nRF52 boards such as AdaFruit Feather nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.
  9. ESP32 core 1.0.4+ for ESP32 boards
  10. ESP8266 core 2.7.4+ for ESP8266 boards. To use ESP8266 core 2.7.1+ for LittleFS.
  11. Functional-VLPP library v1.0.1+ to use server’s lambda function. To install. check Changelog - 变更日志
  12. Depending on which Ethernet card you’re using:
  • Ethernet library v2.0.0+ for W5100, W5200 and W5500.
  • EthernetLarge library v2.0.0+ for W5100, W5200 and W5500.
  • Ethernet2 library v1.0.4+ for W5500.
  • Ethernet3 library v1.5.3+ for W5500/WIZ550io/WIZ850io/USR-ES1 with Wiznet W5500 chip.
  • EthernetENC library v2.0.0+ for ENC28J60. New and Better
  • UIPEthernet library v2.0.9+ for ENC28J60
  • NativeEthernet Library version stable111+ for Teensy 4.1 built-in NativeEthernet

Installation

Use Arduino Library Manager

The best and easiest way is to use Arduino Library Manager. Search for EthernetWebServer_SSL, then select / install the latest version. You can also use this link Changelog - 变更日志 for more detailed instructions.

Manual Install

  1. Navigate to EthernetWebServer_SSL page.
  2. Download the latest release EthernetWebServer_SSL-main.zip.
  3. Extract the zip file to EthernetWebServer_SSL-main directory
  4. Copy the whole EthernetWebServer_SSL-main folder to Arduino libraries’ directory such as ~/Arduino/libraries/.

VS Code & PlatformIO:

  1. Install VS Code
  2. Install PlatformIO
  3. Install EthernetWebServer_SSL library by using Library Manager. Search for EthernetWebServer_SSL in Platform.io Author’s Libraries
  4. 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


Packages’ Patches

1. For Adafruit nRF52840 and nRF52832 boards

To be able to compile, run and automatically detect and display BOARD_NAME on nRF52840/nRF52832 boards, you have to copy the whole nRF52 0.21.0 directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0).

Supposing the Adafruit nRF52 version is 0.21.0. These files must be copied into the directory:

  • ~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/boards.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/cores/nRF5/Udp.h

Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z These files must be copied into the directory:

  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/boards.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h

2. For Teensy boards

To be able to compile and run on Teensy boards, you have to copy the file Teensy boards.txt into Teensy hardware directory (./arduino-1.8.12/hardware/teensy/avr/boards.txt).

Supposing the Arduino version is 1.8.12. This file must be copied into the directory:

  • ./arduino-1.8.12/hardware/teensy/avr/boards.txt

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:

  • ./arduino-x.yy.zz/hardware/teensy/avr/boards.txt

3. For Arduino SAM DUE boards

To be able to compile and run on SAM DUE boards, you have to copy the whole SAM DUE directory into Arduino sam directory (~/.arduino15/packages/arduino/hardware/sam/1.6.12).

Supposing the Arduino SAM core version is 1.6.12. This file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/sam/1.6.12/platform.txt

Whenever a new version is installed, remember to copy this file 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/sam/x.yy.zz/platform.txt

4. For Arduino SAMD boards

To be able to compile without error and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards, you have to copy the whole Arduino SAMD cores 1.8.10 directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.10).

For core version v1.8.10+

Supposing the Arduino SAMD version is 1.8.11. Now only one file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/samd/1.8.11/platform.txt

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/samd/x.yy.zz/platform.txt

For core version v1.8.9-

Supposing the Arduino SAMD version is 1.8.9. These files must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/samd/1.8.9/platform.txt
  • ~/.arduino15/packages/arduino/hardware/samd/1.8.9/cores/arduino/Arduino.h

Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z

These files must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/samd/x.yy.z/platform.txt
  • ~/.arduino15/packages/arduino/hardware/samd/x.yy.z/cores/arduino/Arduino.h

This is mandatory to fix the notorious Arduino SAMD compiler error. See Improve Arduino compatibility with the STL (min and max macro)

 ...arm-none-eabiincludec++7.2.1bitsstl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2      min(const _Tp& __a, const _Tp& __b, _Compare __comp) 

Whenever the above-mentioned compiler error issue is fixed with the new Arduino SAMD release, you don’t need to copy the Arduino.h file anymore.

5. For Adafruit SAMD boards

To be able to automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards, you have to copy the file Adafruit SAMD platform.txt into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.6.4).

Supposing the Adafruit SAMD core version is 1.6.4. This file must be copied into the directory:

  • ~/.arduino15/packages/adafruit/hardware/samd/1.6.4/platform.txt

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:

  • ~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/platform.txt

6. For Seeeduino SAMD boards

To be able to automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards, you have to copy the file Seeeduino SAMD platform.txt into Adafruit samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.1).

Supposing the Seeeduino SAMD core version is 1.8.1. This file must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/samd/1.8.1/platform.txt

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/platform.txt

7. For STM32 boards

To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards, you have to copy the files STM32 variant.h into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/1.9.0). You have to modify the files corresponding to your boards, this is just an illustration how to do.

Supposing the STM32 stm32 core version is 1.9.0. These files must be copied into the directory:

  • ~/.arduino15/packages/STM32/hardware/stm32/1.9.0/variants/NUCLEO_F767ZI/variant.h for Nucleo-144 NUCLEO_F767ZI.
  • ~/.arduino15/packages/STM32/hardware/stm32/1.9.0/variants/NUCLEO_L053R8/variant.h for Nucleo-64 NUCLEO_L053R8.

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz, theses files must be copied into the corresponding directory:

  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/NUCLEO_F767ZI/variant.h
  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/NUCLEO_L053R8/variant.h

Libraries’ Patches

1. For application requiring 2K+ HTML page

If your application requires 2K+ HTML page, the current Ethernet library must be modified if you are using W5200/W5500 Ethernet shields. W5100 is not supported for 2K+ buffer. If you use boards requiring different CS/SS pin for W5x00 Ethernet shield, for example ESP32, ESP8266, nRF52, etc., you also have to modify the following libraries to be able to specify the CS/SS pin correctly.

2. For Ethernet library

To fix Ethernet library, just copy these following files into the Ethernet library directory to overwrite the old files:

  • Ethernet.h
  • Ethernet.cpp
  • EthernetServer.cpp
  • w5100.h
  • w5100.cpp

3. For EthernetLarge library

To fix EthernetLarge library, just copy these following files into the EthernetLarge library directory to overwrite the old files:

  • EthernetLarge.h
  • EthernetLarge.cpp
  • EthernetServer.cpp
  • w5100.h
  • w5100.cpp

4. For Ethernet2 library

To fix Ethernet2 library, just copy these following files into the Ethernet2 library directory to overwrite the old files:

  • Ethernet2.h
  • Ethernet2.cpp

To add UDP Multicast support, necessary for the UPnP_Generic library:

  • EthernetUdp2.h
  • EthernetUdp2.cpp

5. For Ethernet3 library

  1. To fix Ethernet3 library, just copy these following files into the Ethernet3 library directory to overwrite the old files:
  • Ethernet3.h
  • Ethernet3.cpp

6. For UIPEthernet library

  1. To be able to compile and run on nRF52 boards with ENC28J60 using UIPEthernet library, you have to copy these following files into the UIPEthernet utility directory to overwrite the old files:
  • UIPEthernet.h
  • UIPEthernet.cpp
  • Enc28J60Network.h
  • Enc28J60Network.cpp

4. For fixing ESP32 compile error

  1. To fix ESP32 compile error, just copy the following file into the ESP32 cores/esp32 directory (e.g. ./arduino-1.8.12/hardware/espressif/cores/esp32) to overwrite the old file:
  • Server.h


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

Please have a look at ESP_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 pins GPIO32-GPIO39
  • ADC2 controls ADC function for pins GPIO0, 2, 4, 12-15, 25-27

3.. ESP32 WiFi uses ADC2 for WiFi functions

Look in file adc_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 guarantee all 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 to acquire 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 the fix mentioned at the end of ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example to work with ESP32 WiFi/BlueTooth (BT/BLE).


Configuration Notes

1. How to select which built-in Ethernet or shield to use

The easiest way is to use

#define USE_ETHERNET_WRAPPER    true

then select one and only one Ethernet library to use as follows:

  • Standard W5x00 Ethernet library is used by default, in the sketch, just be sure to comment out or leave these #defines to be false :
#define USE_UIP_ETHERNET        false  // Only one if the following to be true #define USE_ETHERNET          true #define USE_ETHERNET2         false #define USE_ETHERNET3         false #define USE_ETHERNET_LARGE    false #define USE_ETHERNET_ESP8266  false  #define USE_ETHERNET_ENC      false #define USE_CUSTOM_ETHERNET   false

To use W5x00 Ethernet, for example using EthernetLarge library

#define USE_UIP_ETHERNET        false  // Only one if the following to be true #define USE_ETHERNET            false #define USE_ETHERNET2           false #define USE_ETHERNET3           false #define USE_ETHERNET_LARGE      true #define USE_ETHERNET_ESP8266    false #define USE_ETHERNET_ENC        false #define USE_CUSTOM_ETHERNET     false
  • To use ENC28J60 Ethernet, using EthernetENC library (NEW and Better)
#define USE_UIP_ETHERNET        false  // Only one if the following to be true #define USE_ETHERNET            false #define USE_ETHERNET2           false #define USE_ETHERNET3           false #define USE_ETHERNET_LARGE      false #define USE_ETHERNET_ESP8266    false #define USE_ETHERNET_ENC        true #define USE_CUSTOM_ETHERNET     false
  • To use ENC28J60 Ethernet, using UIPEthernet library:
#define USE_UIP_ETHERNET        true  // Only one if the following to be true #define USE_ETHERNET            false #define USE_ETHERNET2           false #define USE_ETHERNET3           false #define USE_ETHERNET_LARGE      false #define USE_ETHERNET_ESP8266    false #define USE_ETHERNET_ENC        false #define USE_CUSTOM_ETHERNET     false
  • To use any of the Ethernet libraries, such as Ethernet2, Ethernet3, EthernetLarge, EthernetENC:
#define USE_UIP_ETHERNET        false  // Only one if the following to be true #define USE_ETHERNET            false #define USE_ETHERNET2           false #define USE_ETHERNET3           true #define USE_ETHERNET_LARGE      false #define USE_ETHERNET_ESP8266    false #define USE_ETHERNET_ENC        false #define USE_CUSTOM_ETHERNET     false
  • To use another Ethernet library For example, Ethernet_XYZ library uses Ethernet_XYZ.h
#define USE_UIP_ETHERNET        false  // Only one if the following to be true #define USE_ETHERNET            false #define USE_ETHERNET2           false #define USE_ETHERNET3           false #define USE_ETHERNET_LARGE      false #define USE_ETHERNET_ESP8266    false #define USE_ETHERNET_ENC        false #define USE_CUSTOM_ETHERNET     true  //Must be placed before #include <EthernetWebServer.h> #include <Ethernet_XYZ.h> ...  #include <EthernetWebServer.h>
  • Only for Teensy 4.1, to use NativeEthernet library
#if defined(__IMXRT1062__)     // For Teensy 4.1/4.0     #if defined(ARDUINO_TEENSY41)       #define BOARD_TYPE      "TEENSY 4.1"       // Use true for NativeEthernet Library, false if using other Ethernet libraries       #define USE_NATIVE_ETHERNET     true     #elif defined(ARDUINO_TEENSY40)       #define BOARD_TYPE      "TEENSY 4.0"     #else       #define BOARD_TYPE      "TEENSY 4.x"     #endif         #elif defined(__MK66FX1M0__)   .... 
  • Only for Teensy 4.1, to use another Ethernet library, for example Ethernet3 library
#if defined(__IMXRT1062__)   // For Teensy 4.1/4.0   #if defined(ARDUINO_TEENSY41)     #define BOARD_TYPE      "TEENSY 4.1"     // Use true for NativeEthernet Library, false if using other Ethernet libraries     #define USE_NATIVE_ETHERNET     false   #elif defined(ARDUINO_TEENSY40)     #define BOARD_TYPE      "TEENSY 4.0"   #else     #define BOARD_TYPE      "TEENSY 4.x"   #endif       #elif defined(__MK66FX1M0__)   ....    #define USE_UIP_ETHERNET        false  // Only one if the following to be true #define USE_ETHERNET            false #define USE_ETHERNET2           false #define USE_ETHERNET3           true #define USE_ETHERNET_LARGE      false #define USE_ETHERNET_ESP8266    false #define USE_ETHERNET_ENC        false #define USE_CUSTOM_ETHERNET     false   

Important:

  • The Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported. Don’t use unless you know how to modify those libraries.
  • Requests to support for any future custom Ethernet library will be ignored. Use at your own risk.

2. How to select another CS/SS pin to use

The default CS/SS pin is GPIO4(D2) for ESP8266, GPIO22 for ESP32, 10 for all other boards.

If the default pin is not corect, the easiest way is to change is to use

#define USE_ETHERNET_WRAPPER    true

then select the CS/SS pin (e.g. 22) to use as follows:

// To override the default CS/SS pin. Don't use unless you know exactly which pin to use #define USE_THIS_SS_PIN   22

3. How to use W5x00 with ESP8266

To avoid using the default but not-working Ethernet library of ESP8266, rename the Ethernet.h/cpp to Ethernet_ESP8266.h/cpp to avoid library conflict if you’re using the Arduino Ethernet library. The Ethernet2, Ethernet3, EthernetLarge library can be used without conflict.

These pins are tested OK with ESP8266 and W5x00

  // For ESP8266   // Pin                D0(GPIO16)    D1(GPIO5)    D2(GPIO4)    D3(GPIO0)    D4(GPIO2)    D8   // Ethernet           0                 X            X            X            X        0   // Ethernet2          X                 X            X            X            X        0   // Ethernet3          X                 X            X            X            X        0   // EthernetLarge      X                 X            X            X            X        0   // Ethernet_ESP8266   0                 0            0            0            0        0   // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs   // Must use library patch for Ethernet, EthernetLarge libraries   //Ethernet.setCsPin (USE_THIS_SS_PIN);   Ethernet.init (USE_THIS_SS_PIN); 

4. How to increase W5x00 TX/RX buffer

  • For Ethernet3 library only, use as follows
  // Use  MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer   #ifndef ETHERNET3_MAX_SOCK_NUM     #define ETHERNET3_MAX_SOCK_NUM      4   #endif      Ethernet.setCsPin (USE_THIS_SS_PIN);   Ethernet.init (ETHERNET3_MAX_SOCK_NUM);

5. How to adjust sendContent_P() and send_P() buffer size

sendContent_P() and send_P() buffer size is set default at 4 Kbytes, and minimum is 256 bytes. If you need to change, just add a definition, e.g.:

#define SENDCONTENT_P_BUFFER_SZ     2048

Note that the buffer size must be larger than 256 bytes. See Sending GZIP HTML ~ 120kb+ (suggested enhancement).



WebServer and non TLS/SSL WebClient Usage

Init the CS/SS pin if use EthernetWrapper

EthernetInit();

Class Constructor

  EthernetWebServer server(80);

Creates the EthernetWebServer class object.

Parameters:

host port number: int port (default is the standard HTTP port 80)

Basic Operations

Starting the server

  void begin();

Handling incoming client requests

  void handleClient();

Disabling the server

  void close();   void stop();

Both methods function the same

Client request handlers

  void on();   void addHandler();   void onNotFound();   void onFileUpload();	

Example:

  server.on("/", handlerFunction);   server.onNotFound(handlerFunction);   // called when handler is not assigned   server.onFileUpload(handlerFunction); // handle file uploads

Sending responses to the client

  void send();   void send_P();

Parameters:

code – HTTP response code, can be 200 or 404, etc.

content_type – HTTP content type, like "text/plain" or "image/png", etc.

content – actual content body

Advanced Options

Getting information about request arguments

  const String & arg();   const String & argName();   int args();   bool hasArg();

Function usage:

arg – get request argument value, use arg("plain") to get POST body

argName – get request argument name

args – get arguments count

hasArg – check if argument exist

Getting information about request headers

  const String & header();   const String & headerName();   const String & hostHeader();   int headers();   bool hasHeader();

Function usage:

header – get request header value

headerName – get request header name

hostHeader – get request host header if available, else empty string

headers – get header count

hasHeader – check if header exist

Authentication

  bool authenticate();   void requestAuthentication();

Function usage:

authenticate – server authentication, returns true if client is authenticated else false

requestAuthentication – sends authentication failure response to the client

Example Usage:

  if(!server.authenticate(username, password)){     server.requestAuthentication();   }

Other Function Calls

  const String & uri(); // get the current uri   HTTPMethod  method(); // get the current method    WiFiClient client(); // get the current client   HTTPUpload & upload(); // get the current upload   void setContentLength(); // set content length   void sendHeader(); // send HTTP header   void sendContent(); // send content   void sendContent_P();    void collectHeaders(); // set the request headers to collect   void serveStatic();   size_t streamFile();

TLS/SSL WebClient Usage

Have a look at marvellous documentation in SSLClient for more information about the underlying EthernetSSLClient.

The following info is taken and modified from SSLClient README

Overview

Using EthernetSSLClient is similar to using any other Arduino-based Client class. There are a few extra things, however, that you will need to get started:

1. Board and Network Peripheral Requirements

Your board should have a lot of resources (>110kb flash and >7kb RAM), and your network peripheral should have a large internal buffer (>7kb).

2. How to use Trust Anchors TA

You will need a header containing array of trust anchors (trust_anchors), which are used to verify the SSL connection later on. This file must generated for every project if connecting to different TLS/SSL WebServers. Check out TrustAnchors.md on how to generate this file for your project, and for more information about what a trust anchor is.

Once all those are ready, you can create an SSLClient object like this:

// Initialize the SSL client library // Arguments: EthernetClient, our trust anchors EthernetClient    client; EthernetSSLClient sslClient(client, TAs, (size_t)TAs_NUM)

Where:

  • EthernetClient – The type of client
  • client – An instance of the EthernetClient class you are using for EthernetSSLClient. It is important that this instance be stored outside the EthernetSSLClient declaration.

For instance:

EthernetSSLClient(EthernetClient() ...) 

wouldn’t work.

  • TAs – The name of the trust anchor array created in step 2. If you generated a header using the tutorial this will probably be TAs.
  • TAs_NUM – The number of trust anchors in TAs. If you generated a header using the tutorial this will probably be TAs_NUM.

Given this client, simply use EthernetSSLClient as you would the base client class:

if (sslClient.connect(www.arduino.cc, 443)) {   // Make a HTTP request:   sslClient.println(GET /asciilogo.txt HTTP/1.1);   sslClient.println("User-Agent: SSLClientOverEthernet");   sslClient.print("Host: ");   sslClient.println(server);   sslClient.println("Connection: close");   sslClient.println();   sslClient.flush(); } else {   // if you didn't get a connection to the server:   Serial.println("connection failed"); }
3. Note

sslClient.connect("www.arduino.cc", 443) can take 5-15 seconds to finish. This an unavoidable consequence of the SSL protocol, and is detailed in Implementation Notes.

For more information on EthernetSSLClient, check out the examples, API documentation, or the rest of this README.


How It Works

EthernetSSLClient was created to integrate SSL seamlessly with the Arduino infrastructure, and so it does just that: implementing the brilliant BearSSL as a proxy in front of any Arduino socket library. BearSSL is designed with low flash footprint in mind, and as a result does little verification of improper programming, relying on the developer to ensure the code is correct. Since EthernetSSLClient is built specifically for the Arduino ecosystem, most of EthernetSSLClient‘s code adds those programming checks back in, making debugging a fast and simple process.

Other Features

Logging

EthernetSSLClient also allows for changing the debugging level by adding an additional parameter to the constructor:

EthernetClient    client; EthernetSSLClient sslClient(client, TAs, (size_t)TAs_NUM, 1, SSLClient::SSL_INFO);)

Logging is always outputted through the Arduino Serial interface, so you’ll need to setup Serial before you can view the SSL logs. Log levels are enumerated in ::DebugLevel. The log level is set to SSL_WARN by default.

Errors

When EthernetSSLClient encounters an error, it will attempt to terminate the SSL session gracefully if possible, and then close the socket. Simple error information can be found from EthernetSSLClient::getWriteError(), which will return a value from the ::Error enum. For more detailed diagnostics, you can look at the serial logs, which will be displayed if the log level is at SSL_ERROR or lower.

Write Buffering

As you may have noticed in the documentation for EthernetSSLClient::write, calling this function does not actually write to the network. Instead, you must call EthernetSSLClient::available or EthernetSSLClient::flush, which will detect that the buffer is ready and write to the network (see EthernetSSLClient::write for details).

This was implemented as a buffered function because examples in Arduino libraries will often write to the network like so:

EthernetClient client; // ... // connect to ardiuino.cc over ssl (port 443 for websites) client.connect("www.arduino.cc", 443); // ... // write an http request to the network client.write("GET /asciilogo.txt HTTP/1.1rn"); client.write("Host: arduino.ccrn"); client.write("Connection: closern"); // wait for response while (!client.available()) { /* ... */ } // ...

Notice that every single write() call immediately writes to the network, which is fine with most network clients. With SSL, however, if we are encrypting and writing to the network every write() call, this will result in a lot of small encryption tasks. Encryption takes a lot of time and code, so to reduce the overhead of an SSL connection, SSLClient::write implicitly buffers until the developer states that they are waiting for data to be received with EthernetSSLClient::available. A simple example can be found below:

// Initialize the SSL client library // Arguments: EthernetClient, our trust anchors EthernetClient    client; EthernetSSLClient sslClient(client, TAs, (size_t)TAs_NUM)  // ... // connect to arduino.cc over ssl (port 443 for websites) sslClient.connect("www.arduino.cc", 443); // ... // add http request to the buffer sslClient.write("GET /asciilogo.txt HTTP/1.1rn"); sslClient.write("Host: arduino.ccrn"); sslClient.write("Connection: closern");  // write the bytes to the network, then wait for response while (!sslClient.available()); // ...

If you would like to trigger a network write manually without using the EthernetSSLClient::available, you can also call EthernetSSLClient::flush, which will write all data and return when finished.

Session Caching

As detailed in the Resources section, SSL handshakes take an extended period (1-4sec) to negotiate. To remedy this problem, BearSSL is able to keep a SSL session cache of the clients it has connected to. If BearSSL successfully resumes an SSL session, it can reduce connection time to 100-500ms.

In order to use SSL session resumption:

  • The website you are connecting to must support it. Support is widespread, but you can verify easily using the SSLLabs tool.
  • You must reuse the same EthernetSSLClient object (SSL Sessions are stored in the object itself).
  • You must reconnect to the exact same server.

EthernetSSLClient automatically stores an IP address and hostname in each session, ensuring that if you call connect("www.google.com"), EthernetSSLClient will use the SSL session with that hostname. However, because some websites have multiple servers on a single IP address (github.com being an example), you may find that even if you are connecting to the same host the connection does not resume. This is a flaw in the SSL session protocol — though it has been resolved in TLS 1.3, the lack of widespread adoption of the new protocol prevents it from being used here. SSL sessions can also expire based on server criteria, which will result in a standard 4-10 second connection.

SSL sessions take a lot of memory to store, so by default EthernetSSLClient will only store one at a time. You can change this behavior by adding the following to your EthernetSSLClient declaration:

// Initialize the SSL client library // Arguments: EthernetClient, our trust anchors EthernetClient    client; EthernetSSLClient sslClient(client, TAs, (size_t)TAs_NUM, SomeNumber);

Where SomeNumber is the number of sessions you would like to store. For example this declaration can store 3 sessions:

EthernetClient    client; EthernetSSLClient sslClient(client, TAs, (size_t)TAs_NUM, 3);

Sessions are managed internally using the SSLSession::getSession function. This function will cycle through sessions in a rotating order, allowing the session cache to continually overwrite old sessions. In general, it is a good idea to use a SessionCache size equal to the number of domains you plan on connecting to.

If you need to clear a session, you can do so using the SSLSession::removeSession function.

mTLS

As of v1.6.0, EthernetSSLClient supports mutual TLS authentication. mTLS is a variant of TLS that verifies both the server and device identities before a connection, and is commonly used in IoT protocols as a secure layer (MQTT over TLS, HTTPS over TLS, etc.).

To use mTLS with SSLClient you will need to a client certificate and client private key associated with the server you are attempting to connect to.

Depending on your use case, you will either generate these yourself (ex. Mosquito MQTT setup), or have them generated for you (ex. AWS IoT Certificate Generation). Given this cryptographic information, you can modify the standard EthernetSSLClient connection sketch to enable mTLS authentication:

... /* Somewhere above setup() */  // The client certificate, can be PEM or DER format // DER format will be an array of raw bytes, and PEM format will be a string // PEM format is shown below const char my_cert[] =  "-----BEGIN CERTIFICATE-----n" "MIIDpDCCAowCCQC7mCk5Iu3YmDANBgkqhkiG9w0BAQUFADCBkzELMAkGA1UEBhMCn" ... "-----END CERTIFICATE-----n";  // The client private key, must be the same format as the client certificate // Both RSA and ECC are supported, ECC is shown below const char my_key[] =  "-----BEGIN EC PRIVATE KEY-----n" ... "-----END EC PRIVATE KEY-----n";  // This line will parse and store the above information so SSLClient can use it later // Replace `fromPEM` with `fromDER` if you are using DER formatted certificates. SSLClientParameters mTLS = SSLClientParameters::fromPEM(my_cert, sizeof(cert), my_key, sizeof(key)); EthernetSSLClient my_client(...); ... void setup() {     ...     /* Before SSLClient connects */      my_client.setMutualAuthParams(mTLS);     ... } ...

The client certificate must be formatted correctly (according to BearSSL’s specification) in order for mTLS to work. If the certificate is improperly formatted, SSLClient will attempt to make a regular TLS connection instead of an mTLS one, and fail to connect as a result. Because of this, if you are seeing errors similar to "peer did not send certificate chain" on your server, check that your certificate and key are formatted correctly (see MQTT SSL possible?). For more information on SSLClient’s mTLS functionality, please see the SSLClientParameters documentation.

Note that both the above client certificate information as well as the correct trust anchors associated with the server are needed for the connection to succeed. Trust anchors will typically be generated from the CA used to generate the server certificate. More information on generating trust anchors can be found in TrustAnchors.md.



Implementation Notes

Some ideas that didn’t quite fit in the API documentation.

Seeding Random Data

The SSL protocol requires that EthernetSSLClient generate some random bits before connecting with a server. BearSSL provides a random number generator but requires a some entropy for a seed. Normally this seed is generated by taking the microsecond time using the internal clock, however since most microcontrollers are not build with this feature another source must be found.

Certificate Verification

EthernetSSLClient uses BearSSL's minimal x509 verification engine to verify the certificate of an SSL connection. This engine requires the developer create a trust anchor array using values stored in trusted root certificates. Check out TrustAnchors document for more details on this component of EthernetSSLClient.

BearSSL also features a known certificate validation engine, which only allows for a single domain in exchange for a significantly reduced resource usage (flash and CPU time). This functionality is planned to be implemented in the future.

Resources

The SSL protocol recommends a device support many different encryption algorithms, as well as protocols for SSL itself. The complexity of both of those components results in many medium sized components forming an extremely large whole. Additionally, most embedded processors lack the sophisticated math hardware commonly found in a modern CPU, and as a result require more instructions to create the encryption algorithms SSL requires. This not only increases size but makes the algorithms slow and memory intensive.

If flash footprint is becoming a problem, there are numerous debugging strings (~3kb estimated) that can be removed from SSLClient.h and SSLClient.cpp.

Read Buffer Overflow

SSL is a buffered protocol, and since most microcontrollers have limited resources (see Resources), EthernetSSLClient is limited in the size of its buffers. A common problem encountered with SSL connections is buffer overflow, caused by the server sending too much data at once. This problem is caused by the microcontroller being unable to copy and decrypt data faster than it is being received, forcing some data to be discarded. This usually puts BearSSL in an unrecoverable state, forcing EthernetSSLClient to close the connection with a write error. If you are experiencing frequent timeout problems, this could be the reason why.

In order to remedy this problem, the device must be able to read the data faster than it is being received, or alternatively have a cache large enough to store the entire payload. Since SSL's encryption forces the device to read slowly, this means we must increase the cache size. Depending on your platform, there are a number of ways this can be done:

  • Sometimes your communication shield will have an internal buffer, which can be expanded through the driver code. This is the case with the Arduino Ethernet library (in the form of the MAX_SOCK_NUM and ETHERNET_LARGE_BUFFERS macros), however the library must be modified for the change to take effect.
  • EthernetSSLClient has an internal buffer EthernetSSLClient::m_iobuf, which can be expanded. BearSSL limits the amount of data that can be processed based on the stage in the SSL handshake, and so this will change will have limited usefulness.
  • In some cases, a website will send so much data that even with the above solutions, EthernetSSLClient will be unable to keep up (a website with a lot of HTML is an example). In these cases you will have to find another method of retrieving the data you need.
  • If none of the above are viable, it is possible to implement your own Client class which has an internal buffer much larger than both the driver and BearSSL. This would require in-depth knowledge of programming and the communication shield you are working with, as well as a microcontroller with a significant amount of RAM.

Cipher Support

By default, EthernetSSLClient supports only TLS1.2 and the ciphers listed in TLS12_only_profile.c under suites[], and the list is relatively small to keep the connection secure and the flash footprint down. These ciphers should work for most applications, however if for some reason you would like to use an older version of TLS or a different cipher, you can change the BearSSL profile being used by SSLClient to an alternate one with support for older protocols. To do this, edit EthernetSSLClient::EthernetSSLClient to change these lines:

br_client_init_TLS12_only(&m_sslctx, &m_x509ctx, m_trust_anchors, m_trust_anchors_num); // comment the above line and uncomment the line below if you're having trouble connecting over SSL // br_ssl_client_init_full(&m_sslctx, &m_x509ctx, m_trust_anchors, m_trust_anchors_num);

to this:

// br_client_init_TLS12_only(&m_sslctx, &m_x509ctx, m_trust_anchors, m_trust_anchors_num); // comment the above line and uncomment the line below if you're having trouble connecting over SSL br_ssl_client_init_full(&m_sslctx, &m_x509ctx, m_trust_anchors, m_trust_anchors_num);

If for some unfortunate reason you need SSL 3.0 or SSL 2.0, you will need to modify the BearSSL profile to enable support. Check out the BearSSL profiles documentation and I wish you the best of luck.

Known Issues

  • In some drivers (Ethernet), calls to Client::flush will hang if internet is available but there is no route to the destination. Unfortunately SSLClient cannot correct for this without modifying the driver itself, and as a result the recommended solution is ensuring you choose a driver with built-in timeouts to prevent freezing. Check Calls to stop before connected cause lockups..

  • When using PubSubClient on the ESP32, a stack overflow will occur if the user does not flush the buffer immediately after writing. The cause of this issue is under active investigation. More information in issue PubSubClient on ESP32 overflows the stack.



Examples:

WebServer, TLS/SSL Client Examples

  1. AdvancedWebServer
  2. HelloServer
  3. HelloServer2
  4. HttpBasicAuth
  5. MQTTClient_Auth
  6. MQTTClient_Basic
  7. MQTTClient_SSL
  8. MQTTClient_SSL_Auth
  9. MQTTClient_SSL_Complex
  10. PostServer
  11. SimpleAuthentication
  12. UdpNTPClient
  13. UdpSendReceive
  14. WebClient
  15. WebClientMulti_SSL
  16. WebClientRepeating
  17. WebClient_SSL
  18. WebServer
  19. MQTTS_ThingStream.
  20. MQTT_ThingStream.
  21. AdvancedWebServer_NativeEthernet. New.
  22. WebClientMulti_SSL_NativeEthernet. New.

HTTP and WebSocket Client New Examples

  1. BasicAuthGet
  2. CustomHeader
  3. DweetGet
  4. DweetPost
  5. HueBlink
  6. node_test_server
  7. PostWithHeaders
  8. SimpleDelete
  9. SimpleGet
  10. SimpleHTTPExample
  11. SimplePost
  12. SimplePut
  13. SimpleWebSocket


Example AdvancedWebServer

1. File AdvancedWebServer.ino

/*    The Arduino board communicates with the shield using the SPI bus. This is on digital pins 11, 12, and 13 on the Uno    and pins 50, 51, and 52 on the Mega. On both boards, pin 10 is used as SS. On the Mega, the hardware SS pin, 53,    is not used to select the Ethernet controller chip, but it must be kept as an output or the SPI interface won't work. */  #include "defines.h"  EthernetWebServer server(80);  int reqCount = 0;                // number of requests received  void handleRoot() { #define BUFFER_SIZE     400      char temp[BUFFER_SIZE];   int sec = millis() / 1000;   int min = sec / 60;   int hr = min / 60;   int day = hr / 24;    snprintf(temp, BUFFER_SIZE - 1,            "<html> <head> <meta http-equiv='refresh' content='5'/> <title>AdvancedWebServer %s</title> <style> body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; } </style> </head> <body> <h2>Hi from EthernetWebServer_SSL!</h2> <h3>on %s</h3> <p>Uptime: %d d %02d:%02d:%02d</p> <img src="/test.svg" /> </body> </html>", BOARD_NAME, BOARD_NAME, day, hr % 24, min % 60, sec % 60);    server.send(200, F("text/html"), temp); }  void handleNotFound() {   String message = F("File Not Foundnn");      message += F("URI: ");   message += server.uri();   message += F("nMethod: ");   message += (server.method() == HTTP_GET) ? F("GET") : F("POST");   message += F("nArguments: ");   message += server.args();   message += F("n");      for (uint8_t i = 0; i < server.args(); i++)   {     message += " " + server.argName(i) + ": " + server.arg(i) + "n";   }      server.send(404, F("text/plain"), message); }  void drawGraph() {   String out;   out.reserve(3000);   char temp[70];      out += F("<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="310" height="150">n");   out += F("<rect width="310" height="150" fill="rgb(250, 230, 210)" stroke-width="1" stroke="rgb(0, 0, 0)" />n");   out += F("<g stroke="black">n");   int y = rand() % 130;    for (int x = 10; x < 300; x += 10)   {     int y2 = rand() % 130;     sprintf(temp, "<line x1="%d" y1="%d" x2="%d" y2="%d" stroke-width="1" />n", x, 140 - y, x + 10, 140 - y2);     out += temp;     y = y2;   }   out += F("</g>n</svg>n");    server.send(200, F("image/svg+xml"), out); }  void setup(void) {   Serial.begin(115200);   while (!Serial);    Serial.print("nStarting AdvancedWebServer on " + String(BOARD_NAME));   Serial.println(" with " + String(SHIELD_TYPE));   Serial.println(ETHERNET_WEBSERVER_SSL_VERSION);  #if USE_ETHERNET_WRAPPER    EthernetInit();  #else  #if USE_NATIVE_ETHERNET   ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); #elif USE_ETHERNET   ET_LOGWARN(F("=========== USE_ETHERNET ===========")); #elif USE_ETHERNET2   ET_LOGWARN(F("=========== USE_ETHERNET2 ===========")); #elif USE_ETHERNET3   ET_LOGWARN(F("=========== USE_ETHERNET3 ===========")); #elif USE_ETHERNET_LARGE   ET_LOGWARN(F("=========== USE_ETHERNET_LARGE ===========")); #elif USE_ETHERNET_ESP8266   ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #elif USE_ETHERNET_ENC   ET_LOGWARN(F("=========== USE_ETHERNET_ENC ==========="));   #else   ET_LOGWARN(F("=========================")); #endif    ET_LOGWARN(F("Default SPI pinout:"));   ET_LOGWARN1(F("MOSI:"), MOSI);   ET_LOGWARN1(F("MISO:"), MISO);   ET_LOGWARN1(F("SCK:"),  SCK);   ET_LOGWARN1(F("SS:"),   SS);   ET_LOGWARN(F("========================="));  #if defined(ESP8266)   // For ESP8266, change for other boards if necessary   #ifndef USE_THIS_SS_PIN     #define USE_THIS_SS_PIN   D2    // For ESP8266   #endif    ET_LOGWARN1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN);    #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC )     // For ESP8266     // Pin                D0(GPIO16)    D1(GPIO5)    D2(GPIO4)    D3(GPIO0)    D4(GPIO2)    D8     // Ethernet           0                 X            X            X            X        0     // Ethernet2          X                 X            X            X            X        0     // Ethernet3          X                 X            X            X            X        0     // EthernetLarge      X                 X            X            X            X        0     // Ethernet_ESP8266   0                 0            0            0            0        0     // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs     // Must use library patch for Ethernet, EthernetLarge libraries     Ethernet.init (USE_THIS_SS_PIN);    #elif USE_ETHERNET3     // Use  MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer     #ifndef ETHERNET3_MAX_SOCK_NUM       #define ETHERNET3_MAX_SOCK_NUM      4     #endif        Ethernet.setCsPin (USE_THIS_SS_PIN);     Ethernet.init (ETHERNET3_MAX_SOCK_NUM);    #elif USE_CUSTOM_ETHERNET        // You have to add initialization for your Custom Ethernet here     // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough     Ethernet.init(USE_THIS_SS_PIN);      #endif  //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )  #elif defined(ESP32)    // You can use Ethernet.init(pin) to configure the CS pin   //Ethernet.init(10);  // Most Arduino shields   //Ethernet.init(5);   // MKR ETH shield   //Ethernet.init(0);   // Teensy 2.0   //Ethernet.init(20);  // Teensy++ 2.0   //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet   //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet    #ifndef USE_THIS_SS_PIN     #define USE_THIS_SS_PIN   22    // For ESP32   #endif    ET_LOGWARN1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN);    // For other boards, to change if necessary   #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC )     // Must use library patch for Ethernet, EthernetLarge libraries     // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge     // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3        //Ethernet.setCsPin (USE_THIS_SS_PIN);     Ethernet.init (USE_THIS_SS_PIN);      #elif USE_ETHERNET3     // Use  MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer     #ifndef ETHERNET3_MAX_SOCK_NUM       #define ETHERNET3_MAX_SOCK_NUM      4     #endif        Ethernet.setCsPin (USE_THIS_SS_PIN);     Ethernet.init (ETHERNET3_MAX_SOCK_NUM);    #elif USE_CUSTOM_ETHERNET        // You have to add initialization for your Custom Ethernet here     // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough     Ethernet.init(USE_THIS_SS_PIN);       #endif  //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )  #else   //defined(ESP8266)   // unknown board, do nothing, use default SS = 10   #ifndef USE_THIS_SS_PIN     #define USE_THIS_SS_PIN   10    // For other boards   #endif    #if defined(BOARD_NAME)     ET_LOGWARN3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN);   #else     ET_LOGWARN1(F("Unknown board setCsPin:"), USE_THIS_SS_PIN);   #endif    // For other boards, to change if necessary   #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2  || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET )     // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries        Ethernet.init (USE_THIS_SS_PIN);      #elif USE_ETHERNET3     // Use  MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer     #ifndef ETHERNET3_MAX_SOCK_NUM       #define ETHERNET3_MAX_SOCK_NUM      4     #endif        Ethernet.setCsPin (USE_THIS_SS_PIN);     Ethernet.init (ETHERNET3_MAX_SOCK_NUM);    #elif USE_CUSTOM_ETHERNET        // You have to add initialization for your Custom Ethernet here     // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough     Ethernet.init(USE_THIS_SS_PIN);        #endif  //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )  #endif    //defined(ESP8266)   #endif  //USE_ETHERNET_WRAPPER     // start the ethernet connection and the server:   // Use DHCP dynamic IP and random mac   uint16_t index = millis() % NUMBER_OF_MAC;   // Use Static IP   //Ethernet.begin(mac[index], ip);   Ethernet.begin(mac[index]);    // Just info to know how to connect correctly   Serial.println(F("========================="));   Serial.println(F("Currently Used SPI pinout:"));   Serial.print(F("MOSI:"));   Serial.println(MOSI);   Serial.print(F("MISO:"));   Serial.println(MISO);   Serial.print(F("SCK:"));   Serial.println(SCK);   Serial.print(F("SS:"));   Serial.println(SS); #if USE_ETHERNET3   Serial.print(F("SPI_CS:"));   Serial.println(SPI_CS); #endif   Serial.println(F("========================="));    Serial.print(F("Using mac index = "));   Serial.println(index);    Serial.print(F("Connected! IP address: "));   Serial.println(Ethernet.localIP());    server.on(F("/"), handleRoot);   server.on(F("/test.svg"), drawGraph);   server.on(F("/inline"), []()   {     server.send(200, F("text/plain"), F("This works as well"));   });    server.onNotFound(handleNotFound);   server.begin();    Serial.print(F("HTTP EthernetWebServer is @ IP : "));   Serial.println(Ethernet.localIP()); }  void heartBeatPrint(void) {   static int num = 1;    Serial.print(F("."));    if (num == 80)   {     Serial.println();     num = 1;   }   else if (num++ % 10 == 0)   {     Serial.print(F(" "));   } }  void check_status() {   static unsigned long checkstatus_timeout = 0;  #define STATUS_CHECK_INTERVAL     10000L    // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change.   if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0))   {     heartBeatPrint();     checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL;   } }  void loop(void) {   server.handleClient();   check_status(); }

2. File defines.h

#pragma once  #define DEBUG_ETHERNET_WEBSERVER_PORT       Serial  // Debug Level from 0 to 4 #define _ETHERNET_WEBSERVER_LOGLEVEL_       3  #if    ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010)        || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310)        || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__)        || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__)        || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) )   #if defined(ETHERNET_USE_SAMD)     #undef ETHERNET_USE_SAMD   #endif   #define ETHERNET_USE_SAMD      true   #endif  #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) ||          defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) ||          defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) )   #if defined(ETHERNET_USE_NRF528XX)     #undef ETHERNET_USE_NRF528XX   #endif   #define ETHERNET_USE_NRF528XX      true #endif  #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) )   #if defined(ETHERNET_USE_SAM_DUE)     #undef ETHERNET_USE_SAM_DUE   #endif   #define ETHERNET_USE_SAM_DUE      true #endif  #if defined(ETHERNET_USE_SAMD)   // For SAMD   // Default pin 10 to SS/CS   #define USE_THIS_SS_PIN       10      #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) )     #define BOARD_TYPE      "SAMD Zero"   #elif defined(ARDUINO_SAMD_MKR1000)     #define BOARD_TYPE      "SAMD MKR1000"   #elif defined(ARDUINO_SAMD_MKRWIFI1010)     #define BOARD_TYPE      "SAMD MKRWIFI1010"   #elif defined(ARDUINO_SAMD_NANO_33_IOT)     #define BOARD_TYPE      "SAMD NANO_33_IOT"   #elif defined(ARDUINO_SAMD_MKRFox1200)     #define BOARD_TYPE      "SAMD MKRFox1200"   #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) )     #define BOARD_TYPE      "SAMD MKRWAN13X0"   #elif defined(ARDUINO_SAMD_MKRGSM1400)     #define BOARD_TYPE      "SAMD MKRGSM1400"   #elif defined(ARDUINO_SAMD_MKRNB1500)     #define BOARD_TYPE      "SAMD MKRNB1500"   #elif defined(ARDUINO_SAMD_MKRVIDOR4000)     #define BOARD_TYPE      "SAMD MKRVIDOR4000"   #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS)     #define BOARD_TYPE      "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS"   #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS)     #define BOARD_TYPE      "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS"   #elif defined(ADAFRUIT_METRO_M0_EXPRESS)     #define BOARD_TYPE      "SAMD21 ADAFRUIT_METRO_M0_EXPRESS"   #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0)     #define BOARD_TYPE      "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0"   #elif defined(ADAFRUIT_GEMMA_M0)     #define BOARD_TYPE      "SAMD21 ADAFRUIT_GEMMA_M0"   #elif defined(ADAFRUIT_TRINKET_M0)     #define BOARD_TYPE      "SAMD21 ADAFRUIT_TRINKET_M0"   #elif defined(ADAFRUIT_ITSYBITSY_M0)     #define BOARD_TYPE      "SAMD21 ADAFRUIT_ITSYBITSY_M0"   #elif defined(ARDUINO_SAMD_HALLOWING_M0)     #define BOARD_TYPE      "SAMD21 ARDUINO_SAMD_HALLOWING_M0"   #elif defined(ADAFRUIT_METRO_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_METRO_M4_EXPRESS"   #elif defined(ADAFRUIT_GRAND_CENTRAL_M4)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4"   #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS"   #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS"     #define USE_THIS_SS_PIN       10   #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS"   #elif defined(ADAFRUIT_PYPORTAL)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_PYPORTAL"   #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO"   #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS"   #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE"   #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS"   #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS"   #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4"   #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS"   #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS"   #elif defined(SEEED_WIO_TERMINAL)     #define BOARD_TYPE      "SAMD SEEED_WIO_TERMINAL"   #elif defined(SEEED_FEMTO_M0)     #define BOARD_TYPE      "SAMD SEEED_FEMTO_M0"   #elif defined(SEEED_XIAO_M0)     #define BOARD_TYPE      "SAMD SEEED_XIAO_M0"     #ifdef USE_THIS_SS_PIN       #undef USE_THIS_SS_PIN     #endif     #define USE_THIS_SS_PIN       A1     #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1   #elif defined(Wio_Lite_MG126)     #define BOARD_TYPE      "SAMD SEEED Wio_Lite_MG126"   #elif defined(WIO_GPS_BOARD)     #define BOARD_TYPE      "SAMD SEEED WIO_GPS_BOARD"   #elif defined(SEEEDUINO_ZERO)     #define BOARD_TYPE      "SAMD SEEEDUINO_ZERO"   #elif defined(SEEEDUINO_LORAWAN)     #define BOARD_TYPE      "SAMD SEEEDUINO_LORAWAN"   #elif defined(SEEED_GROVE_UI_WIRELESS)     #define BOARD_TYPE      "SAMD SEEED_GROVE_UI_WIRELESS"   #elif defined(__SAMD21E18A__)     #define BOARD_TYPE      "SAMD21E18A"   #elif defined(__SAMD21G18A__)     #define BOARD_TYPE      "SAMD21G18A"   #elif defined(__SAMD51G19A__)     #define BOARD_TYPE      "SAMD51G19A"   #elif defined(__SAMD51J19A__)     #define BOARD_TYPE      "SAMD51J19A"   #elif defined(__SAMD51J20A__)     #define BOARD_TYPE      "SAMD51J20A"   #elif defined(__SAM3X8E__)     #define BOARD_TYPE      "SAM3X8E"   #elif defined(__CPU_ARC__)     #define BOARD_TYPE      "CPU_ARC"   #elif defined(__SAMD51__)     #define BOARD_TYPE      "SAMD51"   #else     #define BOARD_TYPE      "SAMD Unknown"   #endif  #elif (ETHERNET_USE_SAM_DUE)   // Default pin 10 to SS/CS   #define USE_THIS_SS_PIN       10   #define BOARD_TYPE      "SAM DUE"  #elif (ETHERNET_USE_NRF528XX)   // Default pin 10 to SS/CS   #define USE_THIS_SS_PIN       10    #if defined(NRF52840_FEATHER)     #define BOARD_TYPE      "NRF52840_FEATHER"   #elif defined(NRF52832_FEATHER)     #define BOARD_TYPE      "NRF52832_FEATHER"   #elif defined(NRF52840_FEATHER_SENSE)     #define BOARD_TYPE      "NRF52840_FEATHER_SENSE"   #elif defined(NRF52840_ITSYBITSY)     #define BOARD_TYPE      "NRF52840_ITSYBITSY"     #define USE_THIS_SS_PIN   10    // For other boards   #elif defined(NRF52840_CIRCUITPLAY)     #define BOARD_TYPE      "NRF52840_CIRCUITPLAY"   #elif defined(NRF52840_CLUE)     #define BOARD_TYPE      "NRF52840_CLUE"   #elif defined(NRF52840_METRO)     #define BOARD_TYPE      "NRF52840_METRO"   #elif defined(NRF52840_PCA10056)     #define BOARD_TYPE      "NRF52840_PCA10056"   #elif defined(NINA_B302_ublox)     #define BOARD_TYPE      "NINA_B302_ublox"   #elif defined(NINA_B112_ublox)     #define BOARD_TYPE      "NINA_B112_ublox"   #elif defined(PARTICLE_XENON)     #define BOARD_TYPE      "PARTICLE_XENON"   #elif defined(ARDUINO_NRF52_ADAFRUIT)     #define BOARD_TYPE      "ARDUINO_NRF52_ADAFRUIT"   #else     #define BOARD_TYPE      "nRF52 Unknown"   #endif  #elif ( defined(CORE_TEENSY) )   // Default pin 10 to SS/CS   #define USE_THIS_SS_PIN       10      #if defined(__IMXRT1062__)     // For Teensy 4.1/4.0     #if defined(ARDUINO_TEENSY41)       #define BOARD_TYPE      "TEENSY 4.1"       // Use true for NativeEthernet Library, false if using other Ethernet libraries       #define USE_NATIVE_ETHERNET     true     #elif defined(ARDUINO_TEENSY40)       #define BOARD_TYPE      "TEENSY 4.0"     #else       #define BOARD_TYPE      "TEENSY 4.x"     #endif         #elif defined(__MK66FX1M0__)     #define BOARD_TYPE "Teensy 3.6"   #elif defined(__MK64FX512__)     #define BOARD_TYPE "Teensy 3.5"   #elif defined(__MKL26Z64__)     #define BOARD_TYPE "Teensy LC"   #elif defined(__MK20DX256__)     #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete)   #elif defined(__MK20DX128__)     #define BOARD_TYPE "Teensy 3.0"   #elif defined(__AVR_AT90USB1286__)     #error Teensy 2.0++ not supported yet   #elif defined(__AVR_ATmega32U4__)     #error Teensy 2.0 not supported yet   #else     // For Other Boards     #define BOARD_TYPE      "Unknown Teensy Board"   #endif  #elif ( defined(ESP8266) )   // For ESP8266   #warning Use ESP8266 architecture   #include <ESP8266mDNS.h>   #define ETHERNET_USE_ESP8266   #define BOARD_TYPE      "ESP8266"  #elif ( defined(ESP32) )   // For ESP32   #warning Use ESP32 architecture   #define ETHERNET_USE_ESP32   #define BOARD_TYPE      "ESP32"      #define W5500_RST_PORT   21  #elif (__AVR__)   // For Mega   // Default pin 10 to SS/CS   #define USE_THIS_SS_PIN       10   #define BOARD_TYPE            "AVR"    #error Not supporting AVR Mega, Nano, UNO, etc. yet.   // Currently not OK. See https://github.com/mike-matera/ArduinoSTL/issues/56   // Hopefully will be fixed in Arduino IDE 1.8.14   #include "ArduinoSTL.h"                                   // https://github.com/mike-matera/ArduinoSTL  #else    // Default pin 10 to SS/CS   #define USE_THIS_SS_PIN       10   #define BOARD_TYPE            "Unknown"    //#error Not supporting yet.    #endif  #ifndef BOARD_NAME   #define BOARD_NAME    BOARD_TYPE #endif  #include <SPI.h>  //#define USE_ETHERNET_WRAPPER    true #define USE_ETHERNET_WRAPPER    false  // Use true  for ENC28J60 and UIPEthernet library (https://github.com/UIPEthernet/UIPEthernet) // Use false for W5x00 and Ethernetx library      (https://www.arduino.cc/en/Reference/Ethernet)  //#define USE_UIP_ETHERNET   true #define USE_UIP_ETHERNET   false  // Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp // In order to USE_ETHERNET_ESP8266 #if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET )    // To override the default CS/SS pin. Don't use unless you know exactly which pin to use   // You can define here or customize for each board at same place with BOARD_TYPE   // Check @ defined(SEEED_XIAO_M0)   //#define USE_THIS_SS_PIN   22  //21  //5 //4 //2 //15      // Only one if the following to be true   #define USE_ETHERNET          true   #define USE_ETHERNET2         false   #define USE_ETHERNET3         false   #define USE_ETHERNET_LARGE    false   #define USE_ETHERNET_ESP8266  false    #define USE_ETHERNET_ENC      false   #define USE_CUSTOM_ETHERNET   false      #if !USE_ETHERNET_WRAPPER        #if ( USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET )       #ifdef USE_CUSTOM_ETHERNET         #undef USE_CUSTOM_ETHERNET       #endif       #define USE_CUSTOM_ETHERNET   false     #endif      #if USE_NATIVE_ETHERNET       #include "NativeEthernet.h"       #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error       #define SHIELD_TYPE           "Custom Ethernet using Teensy 4.1 NativeEthernet Library"     #elif USE_ETHERNET3       #include "Ethernet3.h"       #warning Using Ethernet3 lib       #define SHIELD_TYPE           "W5x00 using Ethernet3 Library"     #elif USE_ETHERNET2       #include "Ethernet2.h"       #warning Using Ethernet2 lib       #define SHIELD_TYPE           "W5x00 using Ethernet2 Library"     #elif USE_ETHERNET_LARGE       #include "EthernetLarge.h"       #warning Using EthernetLarge lib       #define SHIELD_TYPE           "W5x00 using EthernetLarge Library"     #elif USE_ETHERNET_ESP8266       #include "Ethernet_ESP8266.h"       #warning Using Ethernet_ESP8266 lib        #define SHIELD_TYPE           "W5x00 using Ethernet_ESP8266 Library"      #elif USE_ETHERNET_ENC       #include "EthernetENC.h"       #warning Using EthernetENC lib       #define SHIELD_TYPE           "ENC28J60 using EthernetENC Library"     #elif USE_CUSTOM_ETHERNET       //#include "Ethernet_XYZ.h"       #include "EthernetENC.h"       #warning Using Custom Ethernet library. You must include a library and initialize.       #define SHIELD_TYPE           "Custom Ethernet using Ethernet_XYZ Library"     #else       #ifdef USE_ETHERNET         #undef USE_ETHERNET       #endif       #define USE_ETHERNET   true       #include "Ethernet.h"       #warning Using Ethernet lib       #define SHIELD_TYPE           "W5x00 using Ethernet Library"     #endif          // Ethernet_Shield_W5200, EtherCard, EtherSia not supported     // Select just 1 of the following #include if uncomment #define USE_CUSTOM_ETHERNET     // Otherwise, standard Ethernet library will be used for W5x00      #endif    //  USE_ETHERNET_WRAPPER #elif USE_UIP_ETHERNET     #include "UIPEthernet.h"     #warning Using UIPEthernet library     #define SHIELD_TYPE           "ENC28J60 using UIPEthernet Library" #endif      // #if !USE_UIP_ETHERNET  #include <EthernetWebServer_SSL.h>  #ifndef SHIELD_TYPE   #define SHIELD_TYPE     "Unknown Ethernet shield/library"  #endif  // Enter a MAC address and IP address for your controller below. #define NUMBER_OF_MAC      20  byte mac[][NUMBER_OF_MAC] = {   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, };  // Select the IP address according to your local network IPAddress ip(192, 168, 2, 222);  // Google DNS Server IP IPAddress myDns(8, 8, 8, 8); 


Debug Termimal Output Samples

1. AdvancedWebServer on NRF52840_FEATHER_EXPRESS with ENC28J60 using EthernetENC Library

The following are debug terminal output and screen shot when running example AdvancedWebServer on Adafruit NRF52840_FEATHER_EXPRESS with ENC28J60 using EthernetENC Library

Changelog - 变更日志

Starting AdvancedWebServer on NRF52840_FEATHER with ENC28J60 using EthernetENC Library EthernetWebServer_SSL v1.3.0 [ETHERNET_WEBSERVER] ========================= [ETHERNET_WEBSERVER] Default SPI pinout: [ETHERNET_WEBSERVER] MOSI: 25 [ETHERNET_WEBSERVER] MISO: 24 [ETHERNET_WEBSERVER] SCK: 26 [ETHERNET_WEBSERVER] SS: 5 [ETHERNET_WEBSERVER] ========================= [ETHERNET_WEBSERVER] Board : NRF52840_FEATHER , setCsPin: 10 ========================= Currently Used SPI pinout: MOSI:25 MISO:24 SCK:26 SS:5 ========================= Using mac index = 11 Connected! IP address: 192.168.2.96 HTTP EthernetWebServer is @ IP : 192.168.2.96 EthernetWebServer::handleClient: New Client method:  GET url:  / search: headerName: Host headerValue: 192.168.2.113 headerName: Connection headerValue: keep-alive headerName: DNT headerValue: 1 headerName: Upgrade-Insecure-Requests headerValue: 1 headerName: User-Agent headerValue: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36 headerName: Accept headerValue: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 headerName: Accept-Encoding headerValue: gzip, deflate headerName: Accept-Language headerValue: en-GB,en-US;q=0.9,en;q=0.8 args: args count:  0 args: args count:  0 Request: / Arguments:  Final list of key/value pairs: EthernetWebServer::_handleRequest handle EthernetWebServer::send1: len =  347 content =  <html><head><meta http-equiv='refresh' content='5'/><title>AdvancedWebServer NRF52840_FEATHER</title><style>body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }</style></head><body><h2>Hi from EthernetWebServer!</h2><h3>on NRF52840_FEATHER</h3><p>Uptime: 0 d 00:00:11</p><img src="/test.svg" /></body></html> EthernetWebServer::_prepareHeader sendHeader Conn close EthernetWebServer::send1: write header =  HTTP/1.1 200 OK Content-Type: text/html Content-Length: 347 Connection: close  EthernetWebServer::sendContent: Client.write content:  <html><head><meta http-equiv='refresh' content='5'/><title>AdvancedWebServer NRF52840_FEATHER</title><style>body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }</style></head><body><h2>Hi from EthernetWebServer_SSL!</h2><h3>on NRF52840_FEATHER</h3><p>Uptime: 0 d 00:00:11</p><img src="/test.svg" /></body></html> EthernetWebServer::_handleRequest OK EthernetWebServer::handleClient: Client disconnected EthernetWebServer::handleClient: Don't keepCurrentClient EthernetWebServer::handleClient: Client disconnected EthernetWebServer::handleClient: New Client method:  GET url:  /test.svg search: headerName: Host headerValue: 192.168.2.113 headerName: Connection headerValue: keep-alive headerName: User-Agent headerValue: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36 headerName: DNT headerValue: 1 headerName: Accept headerValue: image/webp,image/apng,image/*,*/*;q=0.8 headerName: Referer headerValue: http://192.168.2.113/ headerName: Accept-Encoding headerValue: gzip, deflate headerName: Accept-Language headerValue: en-GB,en-US;q=0.9,en;q=0.8 args: args count:  0 args: args count:  0 Request: /test.svg Arguments:  Final list of key/value pairs: EthernetWebServer::_handleRequest handle EthernetWebServer::send1: len =  1950 content =  <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="310" height="150"> <rect width="310" height="150" fill="rgb(250, 230, 210)" stroke-width="1" stroke="rgb(0, 0, 0)" /> <g stroke="black"> <line x1="10" y1="98" x2="20" y2="111" stroke-width="1" /> <line x1="20" y1="111" x2="30" y2="90" stroke-width="1" /> <line x1="30" y1="90" x2="40" y2="22" stroke-width="1" /> <line x1="40" y1="22" x2="50" y2="98" stroke-width="1" /> <line x1="50" y1="98" x2="60" y2="64" stroke-width="1" /> <line x1="60" y1="64" x2="70" y2="104" stroke-width="1" /> <line x1="70" y1="104" x2="80" y2="31" stroke-width="1" /> <line x1="80" y1="31" x2="90" y2="59" stroke-width="1" /> <line x1="90" y1="59" x2="100" y2="139" stroke-width="1" /> <line x1="100" y1="139" x2="110" y2="117" stroke-width="1" /> <line x1="110" y1="117" x2="120" y2="75" stroke-width="1" /> <line x1="120" y1="75" x2="130" y2="72" stroke-width="1" /> <line x1="130" y1="72" x2="140" y2="137" stroke-width="1" /> <line x1="140" y1="137" x2="150" y2="20" stroke-width="1" /> <line x1="150" y1="20" x2="160" y2="94" stroke-width="1" /> <line x1="160" y1="94" x2="170" y2="81" stroke-width="1" /> <line x1="170" y1="81" x2="180" y2="38" stroke-width="1" /> <line x1="180" y1="38" x2="190" y2="33" stroke-width="1" /> <line x1="190" y1="33" x2="200" y2="53" stroke-width="1" /> <line x1="200" y1="53" x2="210" y2="88" stroke-width="1" /> <line x1="210" y1="88" x2="220" y2="32" stroke-width="1" /> <line x1="220" y1="32" x2="230" y2="110" stroke-width="1" /> <line x1="230" y1="110" x2="240" y2="87" stroke-width="1" /> <line x1="240" y1="87" x2="250" y2="11" stroke-width="1" /> <line x1="250" y1="11" x2="260" y2="98" stroke-width="1" /> <line x1="260" y1="98" x2="270" y2="76" stroke-width="1" /> <line x1="270" y1="76" x2="280" y2="121" stroke-width="1" /> <line x1="280" y1="121" x2="290" y2="139" stroke-width="1" /> <line x1="290" y1="139" x2="300" y2="103" stroke-width="1" /> </g> </svg>  EthernetWebServer::_prepareHeader sendHeader Conn close EthernetWebServer::send1: write header =  HTTP/1.1 200 OK Content-Type: image/svg+xml Content-Length: 1950 Connection: close 

2. ENC28J60_WM_Config on ESP32 with ENC28J60 using UIPEthernet Library

The terminal output of ESP32 running a ENC28J60_WM_Config example of BlynkEthernet_WM Library

Start ENC28J60_WM_Config on ESP32 [38] EEPROMsz:1024 [38] CCSum=0x29f2,RCSum=0x29f2 [38] CrCCsum=0,CrRCsum=0 [38] Hdr=ENC28J60,BName=ESP32-ENC28J60-WM [38] Svr=account.duckdns.org,Tok=token [45] Svr1=account.ddns.net,Tok1=token1 [51] Prt=8080,SIP=blank [53] MAC:FE-80-D6-B4-FC-EE ENC28J60_CONTROL_CS =13 SS =5 SPI_MOSI =23 SPI_MISO =19 SPI_SCK =18 [5332] IP:192.168.2.103 [5332] bg:ECon.TryB [5332]      ___  __          __    / _ )/ /_ _____  / /__   / _  / / // / _ /  '_/  /____/_/_, /_//_/_/_         /___/ v0.6.1 on ESP32  [5343] BlynkArduinoClient.connect: Connecting to account.duckdns.org:8080 [6454] Ready (ping: 37ms). [6522] Connected to Blynk Server = account.duckdns.org, Token = token [6522] bg:EBCon Conn2Blynk: server = account.duckdns.org, port = 8080 Token = token, IP = 192.168.2.103 BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB

3. WebClientMulti_SSL on SAM DUE with W5x00 using EthernetLarge Library

The terminal output of SAM DUE with W5x00 using EthernetLarge Library running WebClientMulti_SSL example

Start WebClientMulti_SSL on SAM DUE with W5x00 using EthernetLarge Library EthernetWebServer_SSL v1.3.0 [ETHERNET_WEBSERVER] =========== USE_ETHERNET_LARGE =========== [ETHERNET_WEBSERVER] Default SPI pinout: [ETHERNET_WEBSERVER] MOSI: 75 [ETHERNET_WEBSERVER] MISO: 74 [ETHERNET_WEBSERVER] SCK: 76 [ETHERNET_WEBSERVER] SS: 10 [ETHERNET_WEBSERVER] ========================= [ETHERNET_WEBSERVER] Board : SAM DUE , setCsPin: 10 _pinCS = 0 W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 10 W5100::init: W5100, SSIZE =4096 ========================= Currently Used SPI pinout: MOSI:75 MISO:74 SCK:76 SS:10 ========================= Using mac index = 5 Connected! IP address: 192.168.2.81 Connecting to www.arduino.cc... Took: 2399 HTTP/1.1 200 OK Date: Tue, 10 Nov 2020 09:37:58 GMT Content-Type: text/plain Transfer-Encoding: chunked Connection: close Set-Cookie: __cfduid=d3528e024daf847cc558d2ba3205ee3d01605001078; expires=Thu, 10-Dec-20 09:37:58 GMT; path=/; domain=.arduino.cc; HttpOnly; SameSite=Lax Last-Modified: Wed, 02 Oct 2013 13:46:47 GMT Vary: Accept-Encoding Access-Control-Allow-Origin: https://www.arduino.cc Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS Access-Control-Allow-Headers: Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With Strict-Transport-Security: max-age=500; includeSubDomains X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block CF-Cache-Status: DYNAMIC cf-request-id: 06531dfd840000b65f100a1000000001 Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" Server: cloudflare CF-RAY: 5efecc42682cb65f-YWG  8d7             `:;;;,`                      .:;;:.                    .;;;;;;;;;;;`                :;;;;;;;;;;:     TM        `;;;;;;;;;;;;;;;`            :;;;;;;;;;;;;;;;            :;;;;;;;;;;;;;;;;;;         `;;;;;;;;;;;;;;;;;;          ;;;;;;;;;;;;;;;;;;;;;       .;;;;;;;;;;;;;;;;;;;;        ;;;;;;;;:`   `;;;;;;;;;     ,;;;;;;;;.`   .;;;;;;;;      .;;;;;;,         :;;;;;;;   .;;;;;;;          ;;;;;;;     ;;;;;;             ;;;;;;;  ;;;;;;,            ;;;;;;.   ,;;;;;               ;;;;;;.;;;;;;`              ;;;;;;   ;;;;;.                ;;;;;;;;;;;`      ```       ;;;;;`  ;;;;;                  ;;;;;;;;;,       ;;;       .;;;;; `;;;;:                  `;;;;;;;;        ;;;        ;;;;; ,;;;;`    `,,,,,,,,      ;;;;;;;      .,,;;;,,,     ;;;;; :;;;;`    .;;;;;;;;       ;;;;;,      :;;;;;;;;     ;;;;; :;;;;`    .;;;;;;;;      `;;;;;;      :;;;;;;;;     ;;;;; .;;;;.                   ;;;;;;;.        ;;;        ;;;;;  ;;;;;                  ;;;;;;;;;        ;;;        ;;;;;  ;;;;;                 .;;;;;;;;;;       ;;;       ;;;;;,  ;;;;;;               `;;;;;;;;;;;;                ;;;;;   `;;;;;,             .;;;;;; ;;;;;;;              ;;;;;;    ;;;;;;:           :;;;;;;.  ;;;;;;;            ;;;;;;      ;;;;;;;`       .;;;;;;;,    ;;;;;;;;        ;;;;;;;:       ;;;;;;;;;:,:;;;;;;;;;:      ;;;;;;;;;;:,;;;;;;;;;;        `;;;;;;;;;;;;;;;;;;;.        ;;;;;;;;;;;;;;;;;;;;           ;;;;;;;;;;;;;;;;;           :;;;;;;;;;;;;;;;;:             ,;;;;;;;;;;;;;,              ;;;;;;;;;;;;;;                 .;;;;;;;;;`                  ,;;;;;;;;:                                                                                                                                                                                                                                                      ;;;   ;;;;;`  ;;;;:  .;;  ;; ,;;;;;, ;;. `;,  ;;;;        ;;;   ;;:;;;  ;;;;;; .;;  ;; ,;;;;;: ;;; `;, ;;;:;;      ,;:;   ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;,`;, ;;  ;;      ;; ;:  ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;;`;, ;;  ;;.     ;: ;;  ;;;;;:  ;;  ;; .;;  ;;   ,;,   ;;`;;;, ;;  ;;`    ,;;;;;  ;;`;;   ;;  ;; .;;  ;;   ,;,   ;; ;;;, ;;  ;;     ;;  ,;, ;; .;;  ;;;;;:  ;;;;;: ,;;;;;: ;;  ;;, ;;;;;;     ;;   ;; ;;  ;;` ;;;;.   `;;;:  ,;;;;;, ;;  ;;,  ;;;;     0  (EthernetSSLClient)(SSL_WARN)(connected): Socket was dropped unexpectedly (this can be an alternative to closing the connection)  Disconnecting. Received 3324 bytes in 0.3154 s, rate = 10.54 kbytes/second Connecting to www.cloudflare.com... Took: 207 HTTP/1.1 200 OK Date: Tue, 10 Nov 2020 09:38:03 GMT Content-Type: text/plain Transfer-Encoding: chunked Connection: close Set-Cookie: __cfduid=dfa9b1dae33cb96315678c7c8c518f4c31605001083; expires=Thu, 10-Dec-20 09:38:03 GMT; path=/; domain=.www.cloudflare.com; HttpOnly; SameSite=Lax; Secure Access-Control-Allow-Origin: * Server: cloudflare CF-RAY: 5efecc66fb77b65f-YWG X-Frame-Options: SAMEORIGIN Expires: Thu, 01 Jan 1970 00:00:01 GMT Cache-Control: no-cache  bb fl=168f4 h=www.cloudflare.com ip=76.10.180.220 ts=1605001083.997 visit_scheme=https uag=SSLClientOverEthernet colo=YWG http=http/1.1 loc=CA tls=TLSv1.2 sni=plaintext warp=off gateway=off  0  (EthernetSSLClient)(SSL_WARN)(connected): Socket was dropped unexpectedly (this can be an alternative to closing the connection)  Disconnecting.  

4. WebClient_SSL on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library

The terminal output of SEEED_XIAO_M0 with W5x00 using Ethernet3 Library running WebClient_SSL example

Start WebClient_SSL on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library EthernetWebServer_SSL v1.3.0 [ETHERNET_WEBSERVER] =========== USE_ETHERNET3 =========== [ETHERNET_WEBSERVER] Default SPI pinout: [ETHERNET_WEBSERVER] MOSI: 10 [ETHERNET_WEBSERVER] MISO: 9 [ETHERNET_WEBSERVER] SCK: 8 [ETHERNET_WEBSERVER] SS: 4 [ETHERNET_WEBSERVER] ========================= [ETHERNET_WEBSERVER] Board : SEEED_XIAO_M0 , setCsPin: 1  Ethernet3 W5500 init, using SPI_CS = 1, number of sockets = 4 ========================= Currently Used SPI pinout: MOSI:10 MISO:9 SCK:8 SS:4 SPI_CS:1 ========================= Using mac index = 1 Connected! IP address: 192.168.2.102 Connecting to : www.arduino.cc, port : 443 Connected to www.arduino.cc Took: 3551 HTTP/1.1 200 OK Date: Tue, 10 Nov 2020 07:59:21 GMT Content-Type: text/plain Transfer-Encoding: chunked Connection: close Set-Cookie: __cfduid=dd7e2b24e26b05eb2d2e5793ac594c3611604995161; expires=Thu, 10-Dec-20 07:59:21 GMT; path=/; domain=.arduino.cc; HttpOnly; SameSite=Lax Last-Modified: Wed, 02 Oct 2013 13:46:47 GMT Vary: Accept-Encoding Access-Control-Allow-Origin: https://www.arduino.cc Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS Access-Control-Allow-Headers: Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With Strict-Transport-Security: max-age=500; includeSubDomains X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block CF-Cache-Status: DYNAMIC cf-request-id: 0652c3b5b60000f99d7e918000000001 Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" Server: cloudflare CF-RAY: 5efe3bcf881af99d-YYZ alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400  8d7             `:;;;,`                      .:;;:.                    .;;;;;;;;;;;`                :;;;;;;;;;;:     TM        `;;;;;;;;;;;;;;;`            :;;;;;;;;;;;;;;;            :;;;;;;;;;;;;;;;;;;         `;;;;;;;;;;;;;;;;;;          ;;;;;;;;;;;;;;;;;;;;;       .;;;;;;;;;;;;;;;;;;;;        ;;;;;;;;:`   `;;;;;;;;;     ,;;;;;;;;.`   .;;;;;;;;      .;;;;;;,         :;;;;;;;   .;;;;;;;          ;;;;;;;     ;;;;;;             ;;;;;;;  ;;;;;;,            ;;;;;;.   ,;;;;;               ;;;;;;.;;;;;;`              ;;;;;;   ;;;;;.                ;;;;;;;;;;;`      ```       ;;;;;`  ;;;;;                  ;;;;;;;;;,       ;;;       .;;;;; `;;;;:                  `;;;;;;;;        ;;;        ;;;;; ,;;;;`    `,,,,,,,,      ;;;;;;;      .,,;;;,,,     ;;;;; :;;;;`    .;;;;;;;;       ;;;;;,      :;;;;;;;;     ;;;;; :;;;;`    .;;;;;;;;      `;;;;;;      :;;;;;;;;     ;;;;; .;;;;.                   ;;;;;;;.        ;;;        ;;;;;  ;;;;;                  ;;;;;;;;;        ;;;        ;;;;;  ;;;;;                 .;;;;;;;;;;       ;;;       ;;;;;,  ;;;;;;               `;;;;;;;;;;;;                ;;;;;   `;;;;;,             .;;;;;; ;;;;;;;              ;;;;;;    ;;;;;;:           :;;;;;;.  ;;;;;;;            ;;;;;;      ;;;;;;;`       .;;;;;;;,    ;;;;;;;;        ;;;;;;;:       ;;;;;;;;;:,:;;;;;;;;;:      ;;;;;;;;;;:,;;;;;;;;;;        `;;;;;;;;;;;;;;;;;;;.        ;;;;;;;;;;;;;;;;;;;;           ;;;;;;;;;;;;;;;;;           :;;;;;;;;;;;;;;;;:             ,;;;;;;;;;;;;;,              ;;;;;;;;;;;;;;                 .;;;;;;;;;`                  ,;;;;;;;;:                                                                                                                                                                                                                                                      ;;;   ;;;;;`  ;;;;:  .;;  ;; ,;;;;;, ;;. `;,  ;;;;        ;;;   ;;:;;;  ;;;;;; .;;  ;; ,;;;;;: ;;; `;, ;;;:;;      ,;:;   ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;,`;, ;;  ;;      ;; ;:  ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;;`;, ;;  ;;.     ;: ;;  ;;;;;:  ;;  ;; .;;  ;;   ,;,   ;;`;;;, ;;  ;;`    ,;;;;;  ;;`;;   ;;  ;; .;;  ;;   ,;,   ;; ;;;, ;;  ;;     ;;  ,;, ;; .;;  ;;;;;:  ;;;;;: ,;;;;;: ;;  ;;, ;;;;;;     ;;   ;; ;;  ;;` ;;;;.   `;;;:  ,;;;;;, ;;  ;;,  ;;;;     0  (EthernetSSLClient)(SSL_WARN)(connected): Socket was dropped unexpectedly (this can be an alternative to closing the connection)  Disconnecting. Received 3405 bytes in 0.2072 s, rate = 16.43 kbytes/second  

5. MQTTClient_SSL_Complex on SAM DUE with W5x00 using EthernetLarge Library

  1. The terminal output of SAM DUE with W5x00 using EthernetLarge Library running MQTTClient_SSL_Complex example
Start MQTTClient_SSL_Complex on SAM DUE with W5x00 using EthernetLarge Library EthernetWebServer_SSL v1.3.0 [ETHERNET_WEBSERVER] =========== USE_ETHERNET_LARGE =========== [ETHERNET_WEBSERVER] Default SPI pinout: [ETHERNET_WEBSERVER] MOSI: 75 [ETHERNET_WEBSERVER] MISO: 74 [ETHERNET_WEBSERVER] SCK: 76 [ETHERNET_WEBSERVER] SS: 10 [ETHERNET_WEBSERVER] ========================= [ETHERNET_WEBSERVER] Board : SAM DUE , setCsPin: 10 _pinCS = 0 W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 10 W5100::init: W5100, SSIZE =4096 ========================= Currently Used SPI pinout: MOSI:75 MISO:74 SCK:76 SS:10 ========================= Using mac index = 6 Connected! IP address: 192.168.2.71 Attempting MQTT connection to broker.emqx.io...connected Message Send : MQTT_Pub => Hello from MQTTClient_SSL_Complex on SAM DUE, millis = 7694 Message arrived [MQTT_Pub] Hello from MQTTClient_SSL_Complex on SAM DUE, millis = 7694 Attempting MQTT connection to broker.emqx.io...connected Message Send : MQTT_Pub => Hello from MQTTClient_SSL_Complex on SAM DUE, millis = 15580 Message arrived [MQTT_Pub] Hello from MQTTClient_SSL_Complex on SAM DUE, millis = 15580 Attempting MQTT connection to broker.emqx.io...connected Message Send : MQTT_Pub => Hello from MQTTClient_SSL_Complex on SAM DUE, millis = 20587 Message arrived [MQTT_Pub] Hello from MQTTClient_SSL_Complex on SAM DUE, millis = 20587  

  1. The terminal output of SEEED_XIAO_M0 with W5x00 using Ethernet3 Library running MQTTS_ThingStream example
Start MQTTS_ThingStream on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library EthernetWebServer_SSL v1.3.0 [ETHERNET_WEBSERVER] Board : SEEED_XIAO_M0 , setCsPin: 1 [ETHERNET_WEBSERVER] Default SPI pinout: [ETHERNET_WEBSERVER] MOSI: 10 [ETHERNET_WEBSERVER] MISO: 9 [ETHERNET_WEBSERVER] SCK: 8 [ETHERNET_WEBSERVER] SS: 4 [ETHERNET_WEBSERVER] =========================  Ethernet3 W5500 init, using SPI_CS = 1, number of sockets = 4 You're connected to the network, IP = 192.168.2.102 *************************************** esp32-sniffer/12345678/ble *************************************** Attempting MQTT connection to mqtt.thingstream.io ...connected Published connection message successfully! Subcribed to: esp32-sniffer/12345678/ble MQTT Message Send : esp32-sniffer/12345678/ble => Hello from MQTTS_ThingStream on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library MQTT Message receive [esp32-sniffer/12345678/ble] Hello from MQTTS_ThingStream on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library MQTT Message Send : esp32-sniffer/12345678/ble => Hello from MQTTS_ThingStream on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library MQTT Message receive [esp32-sniffer/12345678/ble] Hello from MQTTS_ThingStream on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library MQTT Message Send : esp32-sniffer/12345678/ble => Hello from MQTTS_ThingStream on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library MQTT Message receive [esp32-sniffer/12345678/ble] Hello from MQTTS_ThingStream on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library 


Debug

Debug is enabled by default on Serial. Debug Level from 0 to 4. To disable, change the ETHERNET_WEBSERVER_LOGLEVEL to 0

// Use this to output debug msgs to Serial #define DEBUG_ETHERNET_WEBSERVER_PORT       Serial // Use this to disable all output debug msgs // Debug Level from 0 to 4 #define _ETHERNET_WEBSERVER_LOGLEVEL_       0

Troubleshooting

If you get compilation errors, more often than not, you may need to install a newer version of the board’s core, applying Libraries’ Patches, Packages’ Patches or this library latest version.



Releases

Release v1.3.1

  1. Clean-up all compiler warnings possible.
  2. Add Table of Contents

Release v1.3.0

  1. Add support to NativeEthernet Library for Teensy 4.1

Major Release v1.2.0

  1. Add high-level HTTP and WebSockets Client by merging ArduinoHttpClient Library
  2. Add many more examples for HTTP and WebSockets Client.
  3. Add Version String.

Release v1.1.2

  1. Add SSL debug feature.
  2. Enhance examples.

Release v1.1.1

  1. Permit sites with “Chain could not be linked to a trust anchor” such as mqtt.thingstream.io.
  2. Add example MQTTS_ThingStream to demonstrate new feature

Release v1.1.0

  1. Initial coding for SAMD21/SAMD51, SAM DUE, Teensy to support Ethernet shields using SSL.
  2. Supporting W5x00 using Ethernet, EthernetLarge, Ethernet2 and Ethernet3 libraries
  3. Supporting ENC28J60 using EthernetENC and UIPEthernet libraries


Currently supported Boards

This EthernetWebServer_SSL library currently supports these following boards:

  1. nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.. Currently SSL WebClient is not working.
  2. SAM DUE
  3. SAMD21
  • Arduino SAMD21: ZERO, MKRs, NANO_33_IOT, etc.
  • Adafruit SAMD21 (M0): ItsyBitsy M0, Feather M0, Feather M0 Express, Metro M0 Express, Circuit Playground Express, Trinket M0, PIRkey, Hallowing M0, Crickit M0, etc.
  • SeeedStudio: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, etc.
  1. SAMD51
  • Adafruit SAMD51 (M4): Metro M4, Grand Central M4, ItsyBitsy M4, Feather M4 Express, Trellis M4, Metro M4 AirLift Lite, MONSTER M4SK Express, Hallowing M4, etc.
  • Seeeduino: WIO Terminal, Grove UI Wireless
  1. Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0, LC)
  2. AVR Mega1280, 2560, ADK.. SSL WebClient not supported yet. Check Trivial sketch won’t compile using Arduino 1.8.13
  3. ESP32
  4. ESP8266. SSL WebClient not supported yet. Check HTTPS GET request – ESP8266 – ENC28j60

Supporting Ethernet shields/modules:

  1. W5x00 using Ethernet, EthernetLarge, Ethernet2 or Ethernet3 library
  2. ENC28J60 using EthernetENC or UIPEthernet library
  3. Teensy 4.1 built-in NativeEthernet using NativeEthernet Library

The library provides these features:

  1. TCP Server and Client
  2. UDP Server and Client
  3. HTTP Server and HTTP/HTTPS Client
  4. HTTPS GET and POST requests, provides argument parsing, handles one client at a time.
  5. High-level HTTP (GET, POST, PUT, PATCH, DELETE) and WebSocket Client. From v1.2.0.

Issues

Submit issues to: EthernetWebServer_SSL issues


TO DO

  1. Bug Searching and Killing
  2. Add TLS/SSL Server support
  3. Support more types of boards using Ethernet shields.
  4. Support more non-compatible Ethernet Libraries such as Ethernet_Shield_W5200, EtherCard, EtherSia
  5. Add mDNS features.

DONE

  1. Add support to Arduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.)
  2. Add support to Adafruit SAMD21 (Itsy-Bitsy M0, Metro M0, Feather M0 Express, etc.).
  3. Add support to Adafruit SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.).
  4. Add support to Adafruit nRF52 ( Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc. non-SSL EthernetServer.
  5. Add support to SAM DUE.
  6. Add support to Ethernet W5x00, using either Ethernet, Ethernet2, Ethernet3 or EthernetLarge library
  7. Add support to Ethernet ENC28J60, using UIPEthernet library
  8. Add support to ESP32 and ESP8266 non-SSL EthernetServer.
  9. Add support to Seeeduino SAMD21/SAMD51: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, Wio Terminal, Grove UI Wireless
  10. Add support to EthernetENC
  11. Add support to PROGMEM-related commands, such as sendContent_P() and send_P()
  12. Add TLS/SSL Client support to SAMD21/SAMD51, SAM DUE, Teensy, ESP32, etc.
  13. Add High-level HTTP (GET, POST, PUT, PATCH, DELETE) and WebSocket Client
  14. Add support to NativeEthernet Library for Teensy 4.1


Contributions and Thanks

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

  1. Based on and modified from the good Ivan Grokhotkov’s ESP8266WebServer and ESP32 WebServer libraries.
  2. OPEnSLab-OSU for OPEnSLab-OSU’s SSLClient
  3. Thanks to good work of Miguel Alexandre Wisintainer for initiating, inspriring, working with, developing, debugging and testing. Without that, support to nRF52, especially U-Blox B302 running as nRF52840 and U-Blox B112 running as nRF52832, has never been started and finished. Also see ESP32-based U-BLOX NINA W102 running ENC28J60.
  4. Adrian McEwen for HttpClient Library on which the ArduinoHttpClient Library and this EthernetWebServer library are relied.
  5. Thanks to jimmie11 to report and suggest a fix in Compile Error on Teensy 4.1 #14 leading to the new version v1.3.0 to provide support to Teensy 4.1 using NativeEthernet Library
Changelog - 变更日志
⭐️ Ivan Grokhotkov
Changelog - 变更日志
⭐️ OPEnSLab-OSU
Changelog - 变更日志
⭐️ Adrian McEwen
Changelog - 变更日志
Miguel Wisintainer
Changelog - 变更日志
jimmie11

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 under MIT

Copyright

Copyright 2020- Khoi Hoang

v1.3.1


EthernetWebServer_SSL

<Changelog><Changelog><Changelog><Changelog><Changelog><Changelog><Changelog>Changelog - 变更日志

我们为什么需要这个以太网络服务器的SSL库

变更日志

先决条件

安装

软件包的补丁

库的补丁

如何在运行ESP32的情况下使用analogRead()WiFi和/或蓝牙(BT/BLE)

配置说明

Web服务器和非TLS/SSL网络客户端使用情况

TLS/SSL网络客户端使用方式

其工作原理

其他功能

实施说明

示例

示例AdvancedWebServer

调试终端输出示例

故障排除

发布

问题

要做

完成

贡献并感谢

贡献

许可证

版权

此EthernetWebServeru SSL库是一个简单但完整的TLS/SSL WebClient和非TLS/SSL WebServer库,适用于Teensy、SAM DUE、Arduino SAMD21,Adafruit SAMD21/SAMD51、Adafruit nRF52、ESP32/ESP8266、STM32等使用以太网屏蔽的板。这些函数与ESP32 WebServer和ESP8266WebServer库的功能相似且兼容,使得从ESP8266/ESP32移植草图变得更加容易。

这个EthernetWebServer_SSL库将tls1.2功能添加到EthernetClient,使用BearSSL作为底层TLS引擎。

这个来自v1.2.0的EthernetWebServeru SSL库还提供了高级HTTP和WebSocket客户端,其功能与ArduinoHttpClient库相似并兼容。该库提供了以下功能:

库基于并修改自:

EthernetWebServer类,在EthernetWebServer.h头中找到的是一个简单的WebServer类,它知道如何处理诸如GET和POST之类的HTTP请求,并且一次只能支持一个客户端。

在SSLClient.h头中找到的EthernetSSLClient类是一个简单的WebClient类,它知道如何处理HTTP/HTTPS请求(如GET和POST),并且一次只能支持一个客户端。

此EthernetWebServeru SSL库目前支持以下板:

最好、最简单的方法是使用Arduino库管理器。搜索EthernetWebServer_SSL,然后选择/安装最新版本。您也可以使用此链接Changelog - 变更日志获取更多详细说明。

要编译、运行并自动检测和显示nRF52840/nRF52832板上的板名,必须将整个nRF52 0.21.0目录复制到Adafruit nRF52目录(~/.arduino15/packages/Adafruit/hardware/nRF52/0.21.0)。

假设Adafruit nRF52版本为0.21.0。必须将这些文件复制到目录:

每当安装新版本时,请记住将这些文件复制到新版本目录中。例如,新版本是x.yy.z这些文件必须复制到目录:

为了能够在Teensy板上编译和运行,您必须复制Teensy文件板.txt进入Teensy硬件目录(./arduino-1.8.12/hardware/Teensy/avr/boards.txt文件).

假设Arduino版本为1.8.12。此文件必须复制到目录中:

每当安装新版本时,请记住将此文件复制到新版本目录中。例如,新版本是x。yy.zz号此文件必须复制到目录:

为了能够在SAM到期板上编译和运行,您必须将整个SAM DUE目录复制到Arduino SAM目录(~/.arduino15/packages/Arduino/hardware/SAM/1.6.12)。

假设Arduino SAM核心版本为1.6.12。必须将此文件复制到目录:

每当安装新版本时,请记住将此文件复制到新版本目录中。例如,新版本是x。yy.zz号此文件必须复制到目录中:

以便能够无错误地编译,并在Arduino SAMD(Nano-33-IoT等)板上自动检测和显示板名,您必须将整个Arduino SAMD cores 1.8.10目录复制到Arduino SAMD目录(~/.arduino15/packages/Arduino/hardware/SAMD/1.8.10)。

假设Arduino SAMD版本为1.8.11。现在只需将一个文件复制到目录中:

每当安装新版本时,请记住将这些文件复制到新版本目录中。例如,新版本是x。yy.zz号

必须将此文件复制到目录:

假设Arduino SAMD版本为1.8.9。必须将这些文件复制到目录:

每当安装新版本时,请记住将这些文件复制到新版本目录中。例如,新版本是x.yy.z

这些文件必须复制到目录:

这是修复臭名昭著的Arduino SAMD编译器错误所必需的。请参阅改进Arduino与STL(最小和最大宏)的兼容性。

只要使用新的Arduino SAMD版本修复了上述编译器错误问题,就不需要再复制Arduino.h文件了。

为了能够自动检测和显示Adafruit SAMD(Itsy Bitsy M4等)板上的板名,您必须复制Adafruit SAMD文件平台.txt进入Adafruit samd目录(~/.arduino15/packages/Adafruit/hardware/samd/1.6.4)。

假设Adafruit SAMD核心版本是1.6.4。必须将此文件复制到目录:

每当安装新版本时,请记住将此文件复制到新版本目录中。例如,新版本是x。yy.zz号此文件必须复制到目录中:

为了能够自动检测并显示Seeeduino SAMD(XIAO M0、Wio Terminal等)板上的板名,您必须复制文件Seeeduino SAMD平台.txt进入Adafruit samd目录(~/.arduino15/packages/Seeeduino/hardware/samd/1.8.1)。

假设seeduino SAMD核心版本是1.8.1。必须将此文件复制到目录:

每当安装新版本时,请记住将此文件复制到新版本目录中。例如,新版本是x。yy.zz号此文件必须复制到目录:

要在某些没有Serial1定义的STM32板(nucleao-144 nuclear_F767ZI、nuclea-64 nucleao_L053R8等)板上使用Serial1,必须将文件STM32 variant.h复制到STM32 STM32目录(~/.arduino15/packages/STM32/hardware/STM32/1.9.0)。你必须修改与你的电路板相对应的文件,这只是一个例子。

假设STM32 STM32核心版本是1.9.0。请记住,只要安装了新版本的文件,就必须将这些文件复制到新的目录中。例如,新版本是x。yy.zz号,这些文件必须复制到相应的目录:

如果您的应用程序需要2K+HTML页面,则必须修改当前的以太网库(如果您使用的是W5200/W5500以太网屏蔽)。2K+缓冲区不支持W5100。例如,对于需要修改5XS/ESP52的线路板,您还需要正确地使用以下5XS/ESP52引脚库。

要修复Ethernet库,只需将以下文件复制到Ethernet库目录以覆盖旧文件:

要修复EthernetLarge库,只需将以下文件复制到EthernetLarge库目录以覆盖旧文件:

要修复Ethernet2库,只需将以下文件复制到覆盖旧文件的Ethernet2库目录:

要添加UDP多播支持,UPnP通用库必需:

请查看ESP_WiFiManager问题39:使用自动连接示例时无法读取模拟端口,以获得更详细的描述和问题解决方案。

查找文件adc_common.c

在ADC2中,有两个锁用于不同的情况:

与app和Wi-Fi共享的锁:ESP32:当Wi-Fi使用ADC2时,我们假设它永远不会停止,因此app会检查锁,如果失败则立即返回。ESP32S2:控制器对ADC的控制由仲裁器决定。不需要用锁控制。

任务间共享锁:当多个任务共享ADC2时,我们要保证所有请求都能得到处理。由于转换时间很短(大约31us),app很快就会返回锁,我们使用一个spinlock站在那里等待一个接一个的转换。

应首先获取adc2 U自旋锁,然后获取adc2 U wifi U锁或rtc U自旋锁。

最简单的方法是使用

然后选择一个且只能使用的以太网库,如下所示:

要使用W5x00以太网,例如使用EthernetLarge library

ESP8266的默认CS/SS管脚是GPIO4(D2),ESP32的默认CS/SS管脚是GPIO4(D2),ESP32的默认CS/SS管脚是10。

如果默认管脚不是corect,最简单的更改方法是使用

然后选择要使用的CS/SS管脚(例如22),如下所示:

以避免使用默认但不工作的ESP8266以太网库,如果使用的是Arduino以太网库,请将Ethernet.h/cpp重命名为Ethernet_ESP8266.h/cpp以避免库冲突。Ethernet2,Ethernet3,EthernetLarge库可以在没有冲突的情况下使用。

这些管脚在ESP8266和W5x00下测试正常。

sendContent_p()和send_p()缓冲区大小默认设置为4 KB,最小为256字节。如果需要更改,只需添加一个定义,例如:

请注意,缓冲区大小必须大于256个字节。请参阅发送GZIP HTML~120kb+(建议增强)。

创建EthernetWebServer类对象。

参数:

主机端口号:int port(默认为标准HTTP端口80)

启动服务器

处理传入的客户端请求

禁用服务器

两种方法的功能相同

客户端请求处理程序

示例:

向客户端发送响应

参数:

代码-HTTP响应代码,可以是200或404等。

内容类型-HTTP cont



Table of Contents

  • 我们为什么需要这个以太网络服务器的SSL库

    • Features
    • Currently supported Boards
    • Currently supported Ethernet shields/modules
  • 变更日志

    • Releases v1.3.1
    • Releases v1.3.0
    • Major Releases v1.2.0
    • Releases v1.1.2
    • Releases v1.1.1
    • Releases v1.1.0
  • 先决条件

  • 安装

    • Use Arduino Library Manager
    • Manual Install
    • VS Code & PlatformIO
  • 软件包的补丁

    • 1. For Adafruit nRF52840 and nRF52832 boards
    • 2. For Teensy boards
    • 3. For Arduino SAM DUE boards
    • 4. For Arduino SAMD boards
      • For core version v1.8.10+
      • For core version v1.8.9-
    • 5. For Adafruit SAMD boards
    • 6. For Seeeduino SAMD boards
    • 7. For STM32 boards
  • 库的补丁

    • 1. For application requiring 2K+ HTML page
    • 2. For Ethernet library
    • 3. For EthernetLarge library
    • 4. For Etherne2 library
    • 5. For Ethernet3 library
    • 6. For UIPEthernet library
    • 7. For fixing ESP32 compile error
  • 如何在运行ESP32的情况下使用analogRead()WiFi和/或蓝牙(BT/BLE)

    • 1. ESP32 has 2 ADCs, named ADC1 and ADC2
    • 2. ESP32 ADCs functions
    • 3. ESP32 WiFi uses ADC2 for WiFi functions
  • 配置说明

    • 1. How to select which built-in Ethernet or shield to use *Important
    • 2. How to select another CS/SS pin to use
    • 3. How to use W5x00 with ESP8266
    • 4. How to increase W5x00 TX/RX buffer
    • 5. How to adjust sendContent_P() and send_P() buffer size
  • Web服务器和非TLS/SSL网络客户端使用情况

    • Init the CS/SS pin if use EthernetWrapper
    • Class Constructor
    • Basic Operation
    • Advanced Options
    • Other Function Calls
  • TLS/SSL网络客户端使用方式

    • Overview
      • 1. Board and Network Peripheral Requirements
      • 2. How to use Trust Anchors TA
      • 3. Note
  • 其工作原理

  • 其他功能

    • Logging
    • Errors
    • Write Buffering
    • Session Caching
    • mTLS
  • 实施说明

    • Seeding Random Data
    • Certificate Verification
    • Resources
    • Read Buffer Overflow
    • Cipher Support
    • Known Issues
  • 示例

    • WebServer, TLS/SSL Client Examples
      • 1. AdvancedWebServer
      • 2. HelloServer
      • 3. HelloServer2
      • 4. HttpBasicAuth
      • 5. MQTTClient_Auth
      • 6. MQTTClient_Basic
      • 7. MQTTClient_SSL
      • 8. MQTTClient_SSL_Auth
      • 9. MQTTClient_SSL_Complex
      • 10. PostServer
      • 11. SimpleAuthentication
      • 12. UdpNTPClient
      • 13. UdpSendReceive
      • 14. WebClient
      • 15. WebClientMulti_SSL
      • 16. WebClientRepeating
      • 17. WebClient_SSL
      • 18. WebServer
      • 19. MQTTS_ThingStream.
      • 20. MQTT_ThingStream.
      • 21. AdvancedWebServer_NativeEthernet.
      • 22. WebClientMulti_SSL_NativeEthernet.
    • HTTP and WebSocket Client New Examples
      • 1. BasicAuthGet
      • 2. CustomHeader
      • 3. DweetGet
      • 4. DweetPost
      • 5. HueBlink
      • 6. node_test_server
      • 7. PostWithHeaders
      • 8. SimpleDelete
      • 9. SimpleGet
      • 10. SimpleHTTPExample
      • 11. SimplePost
      • 12. SimplePut
      • 13. SimpleWebSocket
  • 示例AdvancedWebServer

    • 1. File AdvancedWebServer.ino
    • 2. File defines.h
  • 调试终端输出示例

    • 1. AdvancedWebServer on NRF52840_FEATHER_EXPRESS with ENC28J60 using EthernetENC Library
    • 2. ENC28J60_WM_Config on ESP32 with ENC28J60 using UIPEthernet Library
    • 3. WebClientMulti_SSL on SAM DUE with W5x00 using EthernetLarge Library
    • 4. WebClient_SSL on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library
    • 5. MQTTClient_SSL_Complex on SAM DUE with W5x00 using EthernetLarge Library
  • 故障排除

  • 发布

  • 问题

  • 要做

  • 完成

  • 贡献并感谢

  • 贡献

  • 许可证

  • 版权

  • 此EthernetWebServeru SSL库是一个简单但完整的TLS/SSL WebClient和非TLS/SSL WebServer库,适用于Teensy、SAM DUE、Arduino SAMD21,Adafruit SAMD21/SAMD51、Adafruit nRF52、ESP32/ESP8266、STM32等使用以太网屏蔽的板。这些函数与ESP32 WebServer和ESP8266WebServer库的功能相似且兼容,使得从ESP8266/ESP32移植草图变得更加容易。



Why do we need this EthernetWebServer_SSL library

Features

这个EthernetWebServer_SSL库将tls1.2功能添加到EthernetClient,使用BearSSL作为底层TLS引擎。

这个来自v1.2.0的EthernetWebServeru SSL库还提供了高级HTTP和WebSocket客户端,其功能与ArduinoHttpClient库相似并兼容。该库提供了以下功能:

库基于并修改自:

EthernetWebServer类,在EthernetWebServer.h头中找到的是一个简单的WebServer类,它知道如何处理诸如GET和POST之类的HTTP请求,并且一次只能支持一个客户端。

  1. TCP Server and Client
  2. UDP Server and Client
  3. HTTP Server and HTTP/HTTPS Client
  4. HTTPS GET and POST requests, provides argument parsing, handles one client at a time.
  5. High-level HTTP (GET, POST, PUT, PATCH, DELETE) and WebSocket Client. From v1.2.0.

在SSLClient.h头中找到的EthernetSSLClient类是一个简单的WebClient类,它知道如何处理HTTP/HTTPS请求(如GET和POST),并且一次只能支持一个客户端。

  1. Ivan Grokhotkov’s ESP8266WebServer
  2. Ivan Grokhotkov’s ESP32 WebServer
  3. OPEnSLab-OSU’s SSLClient v1.6.9
  4. ArduinoHttpClient Library

此EthernetWebServeru SSL库目前支持以下板:

最好、最简单的方法是使用Arduino库管理器。搜索EthernetWebServer_SSL,然后选择/安装最新版本。您也可以使用此链接Changelog - 变更日志获取更多详细说明。

Currently supported Boards

要编译、运行并自动检测和显示nRF52840/nRF52832板上的板名,必须将整个nRF52 0.21.0目录复制到Adafruit nRF52目录(~/.arduino15/packages/Adafruit/hardware/nRF52/0.21.0)。

  1. nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.. Currently SSL WebClient is not working.
  2. SAM DUE
  3. SAMD21
  • Arduino SAMD21: ZERO, MKRs, NANO_33_IOT, etc.
  • Adafruit SAMD21 (M0): ItsyBitsy M0, Feather M0, Feather M0 Express, Metro M0 Express, Circuit Playground Express, Trinket M0, PIRkey, Hallowing M0, Crickit M0, etc.
  • SeeedStudio: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, etc.
  1. SAMD51
  • Adafruit SAMD51 (M4): Metro M4, Grand Central M4, ItsyBitsy M4, Feather M4 Express, Trellis M4, Metro M4 AirLift Lite, MONSTER M4SK Express, Hallowing M4, etc.
  • Seeeduino: WIO Terminal, Grove UI Wireless
  1. Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0, LC)
  2. AVR Mega1280, 2560, ADK.. SSL WebClient not supported yet. Check Trivial sketch won’t compile using Arduino 1.8.13
  3. ESP32
  4. ESP8266. SSL WebClient not supported yet. Check HTTPS GET request – ESP8266 – ENC28j60

Currently supported Ethernet shields/modules

  1. W5x00 using Ethernet, EthernetLarge, Ethernet2 or Ethernet3 library
  2. ENC28J60 using EthernetENC or UIPEthernet library
  3. Teensy 4.1 built-in NativeEthernet using NativeEthernet Library


Changelog

Releases v1.3.1

  1. Clean-up all compiler warnings possible.
  2. Add Table of Contents

Releases v1.3.0

  1. Add support to NativeEthernet Library for Teensy 4.1

Major Releases v1.2.0

  1. Add high-level HTTP and WebSockets Client by merging ArduinoHttpClient Library
  2. Add many more examples for HTTP and WebSockets Client.
  3. Add Version String.

Releases v1.1.2

  1. Add SSL debug feature.
  2. Enhance examples.

Releases v1.1.1

  1. Permit sites with “Chain could not be linked to a trust anchor” such as mqtt.thingstream.io.
  2. Add example MQTTS_ThingStream to demonstrate new feature

Releases v1.1.0

  1. Initial coding for SAMD21/SAMD51, SAM DUE, Teensy to support Ethernet shields using SSL.
  2. Supporting W5x00 using Ethernet, EthernetLarge, Ethernet2 and Ethernet3 libraries
  3. Supporting ENC28J60 using EthernetENC and UIPEthernet libraries


Prerequisites

  1. Arduino IDE 1.8.13+ for Arduino
  2. Arduino AVR core 1.8.3+ for Arduino AVR boards. Use Arduino Board Manager to install.
  3. Teensy core v1.53+ for Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0) boards.
  4. Arduino SAM DUE core v1.6.12+ for SAM DUE ARM Cortex-M3 boards.
  5. Arduino SAMD core 1.8.11+ for SAMD ARM Cortex-M0+ boards (Nano 33 IoT, etc.).
  6. Adafruit SAMD core 1.6.4+ for SAMD ARM Cortex-M0+ and M4 boards (Itsy-Bitsy M4, etc.)
  7. Seeeduino SAMD core 1.8.1+ for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.)
  8. Adafruit nRF52 v0.21.0+ for nRF52 boards such as AdaFruit Feather nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.
  9. ESP32 core 1.0.4+ for ESP32 boards
  10. ESP8266 core 2.7.4+ for ESP8266 boards. To use ESP8266 core 2.7.1+ for LittleFS.
  11. Functional-VLPP library v1.0.1+ to use server’s lambda function. To install. check Changelog - 变更日志
  12. Depending on which Ethernet card you’re using:
  • Ethernet library v2.0.0+ for W5100, W5200 and W5500.
  • EthernetLarge library v2.0.0+ for W5100, W5200 and W5500.
  • Ethernet2 library v1.0.4+ for W5500.
  • Ethernet3 library v1.5.3+ for W5500/WIZ550io/WIZ850io/USR-ES1 with Wiznet W5500 chip.
  • EthernetENC library v2.0.0+ for ENC28J60. New and Better
  • UIPEthernet library v2.0.9+ for ENC28J60
  • NativeEthernet Library version stable111+ for Teensy 4.1 built-in NativeEthernet

Installation

Use Arduino Library Manager

假设Adafruit nRF52版本为0.21.0。必须将这些文件复制到目录:

Manual Install

  1. Navigate to EthernetWebServer_SSL page.
  2. Download the latest release EthernetWebServer_SSL-main.zip.
  3. Extract the zip file to EthernetWebServer_SSL-main directory
  4. Copy the whole EthernetWebServer_SSL-main folder to Arduino libraries’ directory such as ~/Arduino/libraries/.

VS Code & PlatformIO:

  1. Install VS Code
  2. Install PlatformIO
  3. Install EthernetWebServer_SSL library by using Library Manager. Search for EthernetWebServer_SSL in Platform.io Author’s Libraries
  4. 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


Packages’ Patches

1. For Adafruit nRF52840 and nRF52832 boards

每当安装新版本时,请记住将这些文件复制到新版本目录中。例如,新版本是x.yy.z这些文件必须复制到目录:

为了能够在Teensy板上编译和运行,您必须复制Teensy文件板.txt进入Teensy硬件目录(./arduino-1.8.12/hardware/Teensy/avr/boards.txt文件).

  • ~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/boards.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/cores/nRF5/Udp.h

假设Arduino版本为1.8.12。此文件必须复制到目录中:

  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/boards.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h

2. For Teensy boards

每当安装新版本时,请记住将此文件复制到新版本目录中。例如,新版本是x。yy.zz号此文件必须复制到目录:

为了能够在SAM到期板上编译和运行,您必须将整个SAM DUE目录复制到Arduino SAM目录(~/.arduino15/packages/Arduino/hardware/SAM/1.6.12)。

  • ./arduino-1.8.12/hardware/teensy/avr/boards.txt

假设Arduino SAM核心版本为1.6.12。必须将此文件复制到目录:

  • ./arduino-x.yy.zz/hardware/teensy/avr/boards.txt

3. For Arduino SAM DUE boards

每当安装新版本时,请记住将此文件复制到新版本目录中。例如,新版本是x。yy.zz号此文件必须复制到目录中:

以便能够无错误地编译,并在Arduino SAMD(Nano-33-IoT等)板上自动检测和显示板名,您必须将整个Arduino SAMD cores 1.8.10目录复制到Arduino SAMD目录(~/.arduino15/packages/Arduino/hardware/SAMD/1.8.10)。

  • ~/.arduino15/packages/arduino/hardware/sam/1.6.12/platform.txt

假设Arduino SAMD版本为1.8.11。现在只需将一个文件复制到目录中:

  • ~/.arduino15/packages/arduino/hardware/sam/x.yy.zz/platform.txt

4. For Arduino SAMD boards

每当安装新版本时,请记住将这些文件复制到新版本目录中。例如,新版本是x。yy.zz号

For core version v1.8.10+

必须将此文件复制到目录:

  • ~/.arduino15/packages/arduino/hardware/samd/1.8.11/platform.txt

假设Arduino SAMD版本为1.8.9。必须将这些文件复制到目录:

每当安装新版本时,请记住将这些文件复制到新版本目录中。例如,新版本是x.yy.z

  • ~/.arduino15/packages/arduino/hardware/samd/x.yy.zz/platform.txt

For core version v1.8.9-

这些文件必须复制到目录:

  • ~/.arduino15/packages/arduino/hardware/samd/1.8.9/platform.txt
  • ~/.arduino15/packages/arduino/hardware/samd/1.8.9/cores/arduino/Arduino.h

这是修复臭名昭著的Arduino SAMD编译器错误所必需的。请参阅改进Arduino与STL(最小和最大宏)的兼容性。

只要使用新的Arduino SAMD版本修复了上述编译器错误问题,就不需要再复制Arduino.h文件了。

  • ~/.arduino15/packages/arduino/hardware/samd/x.yy.z/platform.txt
  • ~/.arduino15/packages/arduino/hardware/samd/x.yy.z/cores/arduino/Arduino.h

为了能够自动检测和显示Adafruit SAMD(Itsy Bitsy M4等)板上的板名,您必须复制Adafruit SAMD文件平台.txt进入Adafruit samd目录(~/.arduino15/packages/Adafruit/hardware/samd/1.6.4)。

 ...arm-none-eabiincludec++7.2.1bitsstl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2      min(const _Tp& __a, const _Tp& __b, _Compare __comp) 

假设Adafruit SAMD核心版本是1.6.4。必须将此文件复制到目录:

5. For Adafruit SAMD boards

每当安装新版本时,请记住将此文件复制到新版本目录中。例如,新版本是x。yy.zz号此文件必须复制到目录中:

为了能够自动检测并显示Seeeduino SAMD(XIAO M0、Wio Terminal等)板上的板名,您必须复制文件Seeeduino SAMD平台.txt进入Adafruit samd目录(~/.arduino15/packages/Seeeduino/hardware/samd/1.8.1)。

  • ~/.arduino15/packages/adafruit/hardware/samd/1.6.4/platform.txt

假设seeduino SAMD核心版本是1.8.1。必须将此文件复制到目录:

  • ~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/platform.txt

6. For Seeeduino SAMD boards

每当安装新版本时,请记住将此文件复制到新版本目录中。例如,新版本是x。yy.zz号此文件必须复制到目录:

要在某些没有Serial1定义的STM32板(nucleao-144 nuclear_F767ZI、nuclea-64 nucleao_L053R8等)板上使用Serial1,必须将文件STM32 variant.h复制到STM32 STM32目录(~/.arduino15/packages/STM32/hardware/STM32/1.9.0)。你必须修改与你的电路板相对应的文件,这只是一个例子。

  • ~/.arduino15/packages/Seeeduino/hardware/samd/1.8.1/platform.txt

假设STM32 STM32核心版本是1.9.0。请记住,只要安装了新版本的文件,就必须将这些文件复制到新的目录中。例如,新版本是x。yy.zz号,这些文件必须复制到相应的目录:

  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/platform.txt

7. For STM32 boards

如果您的应用程序需要2K+HTML页面,则必须修改当前的以太网库(如果您使用的是W5200/W5500以太网屏蔽)。2K+缓冲区不支持W5100。例如,对于需要修改5XS/ESP52的线路板,您还需要正确地使用以下5XS/ESP52引脚库。

要修复Ethernet库,只需将以下文件复制到Ethernet库目录以覆盖旧文件:

  • ~/.arduino15/packages/STM32/hardware/stm32/1.9.0/variants/NUCLEO_F767ZI/variant.h for Nucleo-144 NUCLEO_F767ZI.
  • ~/.arduino15/packages/STM32/hardware/stm32/1.9.0/variants/NUCLEO_L053R8/variant.h for Nucleo-64 NUCLEO_L053R8.

要修复EthernetLarge库,只需将以下文件复制到EthernetLarge库目录以覆盖旧文件:

  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/NUCLEO_F767ZI/variant.h
  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/NUCLEO_L053R8/variant.h

Libraries’ Patches

1. For application requiring 2K+ HTML page

要修复Ethernet2库,只需将以下文件复制到覆盖旧文件的Ethernet2库目录:

2. For Ethernet library

要添加UDP多播支持,UPnP通用库必需:

  • Ethernet.h
  • Ethernet.cpp
  • EthernetServer.cpp
  • w5100.h
  • w5100.cpp

3. For EthernetLarge library

请查看ESP_WiFiManager问题39:使用自动连接示例时无法读取模拟端口,以获得更详细的描述和问题解决方案。

  • EthernetLarge.h
  • EthernetLarge.cpp
  • EthernetServer.cpp
  • w5100.h
  • w5100.cpp

4. For Ethernet2 library

查找文件adc_common.c

  • Ethernet2.h
  • Ethernet2.cpp

在ADC2中,有两个锁用于不同的情况:

  • EthernetUdp2.h
  • EthernetUdp2.cpp

5. For Ethernet3 library

  1. To fix Ethernet3 library, just copy these following files into the Ethernet3 library directory to overwrite the old files:
  • Ethernet3.h
  • Ethernet3.cpp

6. For UIPEthernet library

  1. To be able to compile and run on nRF52 boards with ENC28J60 using UIPEthernet library, you have to copy these following files into the UIPEthernet utility directory to overwrite the old files:
  • UIPEthernet.h
  • UIPEthernet.cpp
  • Enc28J60Network.h
  • Enc28J60Network.cpp

4. For fixing ESP32 compile error

  1. To fix ESP32 compile error, just copy the following file into the ESP32 cores/esp32 directory (e.g. ./arduino-1.8.12/hardware/espressif/cores/esp32) to overwrite the old file:
  • Server.h


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

与app和Wi-Fi共享的锁:ESP32:当Wi-Fi使用ADC2时,我们假设它永远不会停止,因此app会检查锁,如果失败则立即返回。ESP32S2:控制器对ADC的控制由仲裁器决定。不需要用锁控制。

1. ESP32 has 2 ADCs, named ADC1 and ADC2

2. ESP32 ADCs functions

  • ADC1 controls ADC function for pins GPIO32-GPIO39
  • ADC2 controls ADC function for pins GPIO0, 2, 4, 12-15, 25-27

3.. ESP32 WiFi uses ADC2 for WiFi functions

任务间共享锁:当多个任务共享ADC2时,我们要保证所有请求都能得到处理。由于转换时间很短(大约31us),app很快就会返回锁,我们使用一个spinlock站在那里等待一个接一个的转换。

应首先获取adc2 U自旋锁,然后获取adc2 U wifi U锁或rtc U自旋锁。

  1. 最简单的方法是使用

  2. 然后选择一个且只能使用的以太网库,如下所示:

要使用W5x00以太网,例如使用EthernetLarge library

  • In order to use ADC2 for other functions, we have to acquire 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 the fix mentioned at the end of ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example to work with ESP32 WiFi/BlueTooth (BT/BLE).


Configuration Notes

1. How to select which built-in Ethernet or shield to use

ESP8266的默认CS/SS管脚是GPIO4(D2),ESP32的默认CS/SS管脚是GPIO4(D2),ESP32的默认CS/SS管脚是10。

#define USE_ETHERNET_WRAPPER    true

如果默认管脚不是corect,最简单的更改方法是使用

  • Standard W5x00 Ethernet library is used by default, in the sketch, just be sure to comment out or leave these #defines to be false :
#define USE_UIP_ETHERNET        false  // Only one if the following to be true #define USE_ETHERNET          true #define USE_ETHERNET2         false #define USE_ETHERNET3         false #define USE_ETHERNET_LARGE    false #define USE_ETHERNET_ESP8266  false  #define USE_ETHERNET_ENC      false #define USE_CUSTOM_ETHERNET   false

然后选择要使用的CS/SS管脚(例如22),如下所示:

#define USE_UIP_ETHERNET        false  // Only one if the following to be true #define USE_ETHERNET            false #define USE_ETHERNET2           false #define USE_ETHERNET3           false #define USE_ETHERNET_LARGE      true #define USE_ETHERNET_ESP8266    false #define USE_ETHERNET_ENC        false #define USE_CUSTOM_ETHERNET     false
  • To use ENC28J60 Ethernet, using EthernetENC library (NEW and Better)
#define USE_UIP_ETHERNET        false  // Only one if the following to be true #define USE_ETHERNET            false #define USE_ETHERNET2           false #define USE_ETHERNET3           false #define USE_ETHERNET_LARGE      false #define USE_ETHERNET_ESP8266    false #define USE_ETHERNET_ENC        true #define USE_CUSTOM_ETHERNET     false
  • To use ENC28J60 Ethernet, using UIPEthernet library:
#define USE_UIP_ETHERNET        true  // Only one if the following to be true #define USE_ETHERNET            false #define USE_ETHERNET2           false #define USE_ETHERNET3           false #define USE_ETHERNET_LARGE      false #define USE_ETHERNET_ESP8266    false #define USE_ETHERNET_ENC        false #define USE_CUSTOM_ETHERNET     false
  • To use any of the Ethernet libraries, such as Ethernet2, Ethernet3, EthernetLarge, EthernetENC:
#define USE_UIP_ETHERNET        false  // Only one if the following to be true #define USE_ETHERNET            false #define USE_ETHERNET2           false #define USE_ETHERNET3           true #define USE_ETHERNET_LARGE      false #define USE_ETHERNET_ESP8266    false #define USE_ETHERNET_ENC        false #define USE_CUSTOM_ETHERNET     false
  • To use another Ethernet library For example, Ethernet_XYZ library uses Ethernet_XYZ.h
#define USE_UIP_ETHERNET        false  // Only one if the following to be true #define USE_ETHERNET            false #define USE_ETHERNET2           false #define USE_ETHERNET3           false #define USE_ETHERNET_LARGE      false #define USE_ETHERNET_ESP8266    false #define USE_ETHERNET_ENC        false #define USE_CUSTOM_ETHERNET     true  //Must be placed before #include <EthernetWebServer.h> #include <Ethernet_XYZ.h> ...  #include <EthernetWebServer.h>
  • Only for Teensy 4.1, to use NativeEthernet library
#if defined(__IMXRT1062__)     // For Teensy 4.1/4.0     #if defined(ARDUINO_TEENSY41)       #define BOARD_TYPE      "TEENSY 4.1"       // Use true for NativeEthernet Library, false if using other Ethernet libraries       #define USE_NATIVE_ETHERNET     true     #elif defined(ARDUINO_TEENSY40)       #define BOARD_TYPE      "TEENSY 4.0"     #else       #define BOARD_TYPE      "TEENSY 4.x"     #endif         #elif defined(__MK66FX1M0__)   .... 
  • Only for Teensy 4.1, to use another Ethernet library, for example Ethernet3 library
#if defined(__IMXRT1062__)   // For Teensy 4.1/4.0   #if defined(ARDUINO_TEENSY41)     #define BOARD_TYPE      "TEENSY 4.1"     // Use true for NativeEthernet Library, false if using other Ethernet libraries     #define USE_NATIVE_ETHERNET     false   #elif defined(ARDUINO_TEENSY40)     #define BOARD_TYPE      "TEENSY 4.0"   #else     #define BOARD_TYPE      "TEENSY 4.x"   #endif       #elif defined(__MK66FX1M0__)   ....    #define USE_UIP_ETHERNET        false  // Only one if the following to be true #define USE_ETHERNET            false #define USE_ETHERNET2           false #define USE_ETHERNET3           true #define USE_ETHERNET_LARGE      false #define USE_ETHERNET_ESP8266    false #define USE_ETHERNET_ENC        false #define USE_CUSTOM_ETHERNET     false   

Important:

  • The Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported. Don’t use unless you know how to modify those libraries.
  • Requests to support for any future custom Ethernet library will be ignored. Use at your own risk.

2. How to select another CS/SS pin to use

以避免使用默认但不工作的ESP8266以太网库,如果使用的是Arduino以太网库,请将Ethernet.h/cpp重命名为Ethernet_ESP8266.h/cpp以避免库冲突。Ethernet2,Ethernet3,EthernetLarge库可以在没有冲突的情况下使用。

这些管脚在ESP8266和W5x00下测试正常。

#define USE_ETHERNET_WRAPPER    true

sendContent_p()和send_p()缓冲区大小默认设置为4 KB,最小为256字节。如果需要更改,只需添加一个定义,例如:

// To override the default CS/SS pin. Don't use unless you know exactly which pin to use #define USE_THIS_SS_PIN   22

3. How to use W5x00 with ESP8266

请注意,缓冲区大小必须大于256个字节。请参阅发送GZIP HTML~120kb+(建议增强)。

创建EthernetWebServer类对象。

  // For ESP8266   // Pin                D0(GPIO16)    D1(GPIO5)    D2(GPIO4)    D3(GPIO0)    D4(GPIO2)    D8   // Ethernet           0                 X            X            X            X        0   // Ethernet2          X                 X            X            X            X        0   // Ethernet3          X                 X            X            X            X        0   // EthernetLarge      X                 X            X            X            X        0   // Ethernet_ESP8266   0                 0            0            0            0        0   // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs   // Must use library patch for Ethernet, EthernetLarge libraries   //Ethernet.setCsPin (USE_THIS_SS_PIN);   Ethernet.init (USE_THIS_SS_PIN); 

4. How to increase W5x00 TX/RX buffer

  • For Ethernet3 library only, use as follows
  // Use  MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer   #ifndef ETHERNET3_MAX_SOCK_NUM     #define ETHERNET3_MAX_SOCK_NUM      4   #endif      Ethernet.setCsPin (USE_THIS_SS_PIN);   Ethernet.init (ETHERNET3_MAX_SOCK_NUM);

5. How to adjust sendContent_P() and send_P() buffer size

参数:

#define SENDCONTENT_P_BUFFER_SZ     2048

主机端口号:int port(默认为标准HTTP端口80)



WebServer and non TLS/SSL WebClient Usage

Init the CS/SS pin if use EthernetWrapper

EthernetInit();

Class Constructor

  EthernetWebServer server(80);

启动服务器

处理传入的客户端请求

禁用服务器

Basic Operations

两种方法的功能相同

  void begin();

客户端请求处理程序

  void handleClient();

示例:

  void close();   void stop();

向客户端发送响应

参数:

  void on();   void addHandler();   void onNotFound();   void onFileUpload();	

代码-HTTP响应代码,可以是200或404等。

  server.on("/", handlerFunction);   server.onNotFound(handlerFunction);   // called when handler is not assigned   server.onFileUpload(handlerFunction); // handle file uploads

内容类型-HTTP cont

  void send();   void send_P();

Parameters:

code – HTTP response code, can be 200 or 404, etc.

content_type – HTTP content type, like "text/plain" or "image/png", etc.

content – actual content body

Advanced Options

Getting information about request arguments

  const String & arg();   const String & argName();   int args();   bool hasArg();

Function usage:

arg – get request argument value, use arg("plain") to get POST body

argName – get request argument name

args – get arguments count

hasArg – check if argument exist

Getting information about request headers

  const String & header();   const String & headerName();   const String & hostHeader();   int headers();   bool hasHeader();

Function usage:

header – get request header value

headerName – get request header name

hostHeader – get request host header if available, else empty string

headers – get header count

hasHeader – check if header exist

Authentication

  bool authenticate();   void requestAuthentication();

Function usage:

authenticate – server authentication, returns true if client is authenticated else false

requestAuthentication – sends authentication failure response to the client

Example Usage:

  if(!server.authenticate(username, password)){     server.requestAuthentication();   }

Other Function Calls

  const String & uri(); // get the current uri   HTTPMethod  method(); // get the current method    WiFiClient client(); // get the current client   HTTPUpload & upload(); // get the current upload   void setContentLength(); // set content length   void sendHeader(); // send HTTP header   void sendContent(); // send content   void sendContent_P();    void collectHeaders(); // set the request headers to collect   void serveStatic();   size_t streamFile();

TLS/SSL WebClient Usage

Have a look at marvellous documentation in SSLClient for more information about the underlying EthernetSSLClient.

The following info is taken and modified from SSLClient README

Overview

Using EthernetSSLClient is similar to using any other Arduino-based Client class. There are a few extra things, however, that you will need to get started:

1. Board and Network Peripheral Requirements

Your board should have a lot of resources (>110kb flash and >7kb RAM), and your network peripheral should have a large internal buffer (>7kb).

2. How to use Trust Anchors TA

You will need a header containing array of trust anchors (trust_anchors), which are used to verify the SSL connection later on. This file must generated for every project if connecting to different TLS/SSL WebServers. Check out TrustAnchors.md on how to generate this file for your project, and for more information about what a trust anchor is.

Once all those are ready, you can create an SSLClient object like this:

// Initialize the SSL client library // Arguments: EthernetClient, our trust anchors EthernetClient    client; EthernetSSLClient sslClient(client, TAs, (size_t)TAs_NUM)

Where:

  • EthernetClient – The type of client
  • client – An instance of the EthernetClient class you are using for EthernetSSLClient. It is important that this instance be stored outside the EthernetSSLClient declaration.

For instance:

EthernetSSLClient(EthernetClient() ...) 

wouldn’t work.

  • TAs – The name of the trust anchor array created in step 2. If you generated a header using the tutorial this will probably be TAs.
  • TAs_NUM – The number of trust anchors in TAs. If you generated a header using the tutorial this will probably be TAs_NUM.

Given this client, simply use EthernetSSLClient as you would the base client class:

if (sslClient.connect(www.arduino.cc, 443)) {   // Make a HTTP request:   sslClient.println(GET /asciilogo.txt HTTP/1.1);   sslClient.println("User-Agent: SSLClientOverEthernet");   sslClient.print("Host: ");   sslClient.println(server);   sslClient.println("Connection: close");   sslClient.println();   sslClient.flush(); } else {   // if you didn't get a connection to the server:   Serial.println("connection failed"); }
3. Note

sslClient.connect("www.arduino.cc", 443) can take 5-15 seconds to finish. This an unavoidable consequence of the SSL protocol, and is detailed in Implementation Notes.

For more information on EthernetSSLClient, check out the examples, API documentation, or the rest of this README.


How It Works

EthernetSSLClient was created to integrate SSL seamlessly with the Arduino infrastructure, and so it does just that: implementing the brilliant BearSSL as a proxy in front of any Arduino socket library. BearSSL is designed with low flash footprint in mind, and as a result does little verification of improper programming, relying on the developer to ensure the code is correct. Since EthernetSSLClient is built specifically for the Arduino ecosystem, most of EthernetSSLClient‘s code adds those programming checks back in, making debugging a fast and simple process.

Other Features

Logging

EthernetSSLClient also allows for changing the debugging level by adding an additional parameter to the constructor:

EthernetClient    client; EthernetSSLClient sslClient(client, TAs, (size_t)TAs_NUM, 1, SSLClient::SSL_INFO);)

Logging is always outputted through the Arduino Serial interface, so you’ll need to setup Serial before you can view the SSL logs. Log levels are enumerated in ::DebugLevel. The log level is set to SSL_WARN by default.

Errors

When EthernetSSLClient encounters an error, it will attempt to terminate the SSL session gracefully if possible, and then close the socket. Simple error information can be found from EthernetSSLClient::getWriteError(), which will return a value from the ::Error enum. For more detailed diagnostics, you can look at the serial logs, which will be displayed if the log level is at SSL_ERROR or lower.

Write Buffering

As you may have noticed in the documentation for EthernetSSLClient::write, calling this function does not actually write to the network. Instead, you must call EthernetSSLClient::available or EthernetSSLClient::flush, which will detect that the buffer is ready and write to the network (see EthernetSSLClient::write for details).

This was implemented as a buffered function because examples in Arduino libraries will often write to the network like so:

EthernetClient client; // ... // connect to ardiuino.cc over ssl (port 443 for websites) client.connect("www.arduino.cc", 443); // ... // write an http request to the network client.write("GET /asciilogo.txt HTTP/1.1rn"); client.write("Host: arduino.ccrn"); client.write("Connection: closern"); // wait for response while (!client.available()) { /* ... */ } // ...

Notice that every single write() call immediately writes to the network, which is fine with most network clients. With SSL, however, if we are encrypting and writing to the network every write() call, this will result in a lot of small encryption tasks. Encryption takes a lot of time and code, so to reduce the overhead of an SSL connection, SSLClient::write implicitly buffers until the developer states that they are waiting for data to be received with EthernetSSLClient::available. A simple example can be found below:

// Initialize the SSL client library // Arguments: EthernetClient, our trust anchors EthernetClient    client; EthernetSSLClient sslClient(client, TAs, (size_t)TAs_NUM)  // ... // connect to arduino.cc over ssl (port 443 for websites) sslClient.connect("www.arduino.cc", 443); // ... // add http request to the buffer sslClient.write("GET /asciilogo.txt HTTP/1.1rn"); sslClient.write("Host: arduino.ccrn"); sslClient.write("Connection: closern");  // write the bytes to the network, then wait for response while (!sslClient.available()); // ...

If you would like to trigger a network write manually without using the EthernetSSLClient::available, you can also call EthernetSSLClient::flush, which will write all data and return when finished.

Session Caching

As detailed in the Resources section, SSL handshakes take an extended period (1-4sec) to negotiate. To remedy this problem, BearSSL is able to keep a SSL session cache of the clients it has connected to. If BearSSL successfully resumes an SSL session, it can reduce connection time to 100-500ms.

In order to use SSL session resumption:

  • The website you are connecting to must support it. Support is widespread, but you can verify easily using the SSLLabs tool.
  • You must reuse the same EthernetSSLClient object (SSL Sessions are stored in the object itself).
  • You must reconnect to the exact same server.

EthernetSSLClient automatically stores an IP address and hostname in each session, ensuring that if you call connect("www.google.com"), EthernetSSLClient will use the SSL session with that hostname. However, because some websites have multiple servers on a single IP address (github.com being an example), you may find that even if you are connecting to the same host the connection does not resume. This is a flaw in the SSL session protocol — though it has been resolved in TLS 1.3, the lack of widespread adoption of the new protocol prevents it from being used here. SSL sessions can also expire based on server criteria, which will result in a standard 4-10 second connection.

SSL sessions take a lot of memory to store, so by default EthernetSSLClient will only store one at a time. You can change this behavior by adding the following to your EthernetSSLClient declaration:

// Initialize the SSL client library // Arguments: EthernetClient, our trust anchors EthernetClient    client; EthernetSSLClient sslClient(client, TAs, (size_t)TAs_NUM, SomeNumber);

Where SomeNumber is the number of sessions you would like to store. For example this declaration can store 3 sessions:

EthernetClient    client; EthernetSSLClient sslClient(client, TAs, (size_t)TAs_NUM, 3);

Sessions are managed internally using the SSLSession::getSession function. This function will cycle through sessions in a rotating order, allowing the session cache to continually overwrite old sessions. In general, it is a good idea to use a SessionCache size equal to the number of domains you plan on connecting to.

If you need to clear a session, you can do so using the SSLSession::removeSession function.

mTLS

As of v1.6.0, EthernetSSLClient supports mutual TLS authentication. mTLS is a variant of TLS that verifies both the server and device identities before a connection, and is commonly used in IoT protocols as a secure layer (MQTT over TLS, HTTPS over TLS, etc.).

To use mTLS with SSLClient you will need to a client certificate and client private key associated with the server you are attempting to connect to.

Depending on your use case, you will either generate these yourself (ex. Mosquito MQTT setup), or have them generated for you (ex. AWS IoT Certificate Generation). Given this cryptographic information, you can modify the standard EthernetSSLClient connection sketch to enable mTLS authentication:

... /* Somewhere above setup() */  // The client certificate, can be PEM or DER format // DER format will be an array of raw bytes, and PEM format will be a string // PEM format is shown below const char my_cert[] =  "-----BEGIN CERTIFICATE-----n" "MIIDpDCCAowCCQC7mCk5Iu3YmDANBgkqhkiG9w0BAQUFADCBkzELMAkGA1UEBhMCn" ... "-----END CERTIFICATE-----n";  // The client private key, must be the same format as the client certificate // Both RSA and ECC are supported, ECC is shown below const char my_key[] =  "-----BEGIN EC PRIVATE KEY-----n" ... "-----END EC PRIVATE KEY-----n";  // This line will parse and store the above information so SSLClient can use it later // Replace `fromPEM` with `fromDER` if you are using DER formatted certificates. SSLClientParameters mTLS = SSLClientParameters::fromPEM(my_cert, sizeof(cert), my_key, sizeof(key)); EthernetSSLClient my_client(...); ... void setup() {     ...     /* Before SSLClient connects */      my_client.setMutualAuthParams(mTLS);     ... } ...

The client certificate must be formatted correctly (according to BearSSL’s specification) in order for mTLS to work. If the certificate is improperly formatted, SSLClient will attempt to make a regular TLS connection instead of an mTLS one, and fail to connect as a result. Because of this, if you are seeing errors similar to "peer did not send certificate chain" on your server, check that your certificate and key are formatted correctly (see MQTT SSL possible?). For more information on SSLClient’s mTLS functionality, please see the SSLClientParameters documentation.

Note that both the above client certificate information as well as the correct trust anchors associated with the server are needed for the connection to succeed. Trust anchors will typically be generated from the CA used to generate the server certificate. More information on generating trust anchors can be found in TrustAnchors.md.



Implementation Notes

Some ideas that didn’t quite fit in the API documentation.

Seeding Random Data

The SSL protocol requires that EthernetSSLClient generate some random bits before connecting with a server. BearSSL provides a random number generator but requires a some entropy for a seed. Normally this seed is generated by taking the microsecond time using the internal clock, however since most microcontrollers are not build with this feature another source must be found.

Certificate Verification

EthernetSSLClient uses BearSSL's minimal x509 verification engine to verify the certificate of an SSL connection. This engine requires the developer create a trust anchor array using values stored in trusted root certificates. Check out TrustAnchors document for more details on this component of EthernetSSLClient.

BearSSL also features a known certificate validation engine, which only allows for a single domain in exchange for a significantly reduced resource usage (flash and CPU time). This functionality is planned to be implemented in the future.

Resources

The SSL protocol recommends a device support many different encryption algorithms, as well as protocols for SSL itself. The complexity of both of those components results in many medium sized components forming an extremely large whole. Additionally, most embedded processors lack the sophisticated math hardware commonly found in a modern CPU, and as a result require more instructions to create the encryption algorithms SSL requires. This not only increases size but makes the algorithms slow and memory intensive.

If flash footprint is becoming a problem, there are numerous debugging strings (~3kb estimated) that can be removed from SSLClient.h and SSLClient.cpp.

Read Buffer Overflow

SSL is a buffered protocol, and since most microcontrollers have limited resources (see Resources), EthernetSSLClient is limited in the size of its buffers. A common problem encountered with SSL connections is buffer overflow, caused by the server sending too much data at once. This problem is caused by the microcontroller being unable to copy and decrypt data faster than it is being received, forcing some data to be discarded. This usually puts BearSSL in an unrecoverable state, forcing EthernetSSLClient to close the connection with a write error. If you are experiencing frequent timeout problems, this could be the reason why.

In order to remedy this problem, the device must be able to read the data faster than it is being received, or alternatively have a cache large enough to store the entire payload. Since SSL's encryption forces the device to read slowly, this means we must increase the cache size. Depending on your platform, there are a number of ways this can be done:

  • Sometimes your communication shield will have an internal buffer, which can be expanded through the driver code. This is the case with the Arduino Ethernet library (in the form of the MAX_SOCK_NUM and ETHERNET_LARGE_BUFFERS macros), however the library must be modified for the change to take effect.
  • EthernetSSLClient has an internal buffer EthernetSSLClient::m_iobuf, which can be expanded. BearSSL limits the amount of data that can be processed based on the stage in the SSL handshake, and so this will change will have limited usefulness.
  • In some cases, a website will send so much data that even with the above solutions, EthernetSSLClient will be unable to keep up (a website with a lot of HTML is an example). In these cases you will have to find another method of retrieving the data you need.
  • If none of the above are viable, it is possible to implement your own Client class which has an internal buffer much larger than both the driver and BearSSL. This would require in-depth knowledge of programming and the communication shield you are working with, as well as a microcontroller with a significant amount of RAM.

Cipher Support

By default, EthernetSSLClient supports only TLS1.2 and the ciphers listed in TLS12_only_profile.c under suites[], and the list is relatively small to keep the connection secure and the flash footprint down. These ciphers should work for most applications, however if for some reason you would like to use an older version of TLS or a different cipher, you can change the BearSSL profile being used by SSLClient to an alternate one with support for older protocols. To do this, edit EthernetSSLClient::EthernetSSLClient to change these lines:

br_client_init_TLS12_only(&m_sslctx, &m_x509ctx, m_trust_anchors, m_trust_anchors_num); // comment the above line and uncomment the line below if you're having trouble connecting over SSL // br_ssl_client_init_full(&m_sslctx, &m_x509ctx, m_trust_anchors, m_trust_anchors_num);

to this:

// br_client_init_TLS12_only(&m_sslctx, &m_x509ctx, m_trust_anchors, m_trust_anchors_num); // comment the above line and uncomment the line below if you're having trouble connecting over SSL br_ssl_client_init_full(&m_sslctx, &m_x509ctx, m_trust_anchors, m_trust_anchors_num);

If for some unfortunate reason you need SSL 3.0 or SSL 2.0, you will need to modify the BearSSL profile to enable support. Check out the BearSSL profiles documentation and I wish you the best of luck.

Known Issues

  • In some drivers (Ethernet), calls to Client::flush will hang if internet is available but there is no route to the destination. Unfortunately SSLClient cannot correct for this without modifying the driver itself, and as a result the recommended solution is ensuring you choose a driver with built-in timeouts to prevent freezing. Check Calls to stop before connected cause lockups..

  • When using PubSubClient on the ESP32, a stack overflow will occur if the user does not flush the buffer immediately after writing. The cause of this issue is under active investigation. More information in issue PubSubClient on ESP32 overflows the stack.



Examples:

WebServer, TLS/SSL Client Examples

  1. AdvancedWebServer
  2. HelloServer
  3. HelloServer2
  4. HttpBasicAuth
  5. MQTTClient_Auth
  6. MQTTClient_Basic
  7. MQTTClient_SSL
  8. MQTTClient_SSL_Auth
  9. MQTTClient_SSL_Complex
  10. PostServer
  11. SimpleAuthentication
  12. UdpNTPClient
  13. UdpSendReceive
  14. WebClient
  15. WebClientMulti_SSL
  16. WebClientRepeating
  17. WebClient_SSL
  18. WebServer
  19. MQTTS_ThingStream.
  20. MQTT_ThingStream.
  21. AdvancedWebServer_NativeEthernet. New.
  22. WebClientMulti_SSL_NativeEthernet. New.

HTTP and WebSocket Client New Examples

  1. BasicAuthGet
  2. CustomHeader
  3. DweetGet
  4. DweetPost
  5. HueBlink
  6. node_test_server
  7. PostWithHeaders
  8. SimpleDelete
  9. SimpleGet
  10. SimpleHTTPExample
  11. SimplePost
  12. SimplePut
  13. SimpleWebSocket


Example AdvancedWebServer

1. File AdvancedWebServer.ino

/*    The Arduino board communicates with the shield using the SPI bus. This is on digital pins 11, 12, and 13 on the Uno    and pins 50, 51, and 52 on the Mega. On both boards, pin 10 is used as SS. On the Mega, the hardware SS pin, 53,    is not used to select the Ethernet controller chip, but it must be kept as an output or the SPI interface won't work. */  #include "defines.h"  EthernetWebServer server(80);  int reqCount = 0;                // number of requests received  void handleRoot() { #define BUFFER_SIZE     400      char temp[BUFFER_SIZE];   int sec = millis() / 1000;   int min = sec / 60;   int hr = min / 60;   int day = hr / 24;    snprintf(temp, BUFFER_SIZE - 1,            "<html> <head> <meta http-equiv='refresh' content='5'/> <title>AdvancedWebServer %s</title> <style> body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; } </style> </head> <body> <h2>Hi from EthernetWebServer_SSL!</h2> <h3>on %s</h3> <p>Uptime: %d d %02d:%02d:%02d</p> <img src="/test.svg" /> </body> </html>", BOARD_NAME, BOARD_NAME, day, hr % 24, min % 60, sec % 60);    server.send(200, F("text/html"), temp); }  void handleNotFound() {   String message = F("File Not Foundnn");      message += F("URI: ");   message += server.uri();   message += F("nMethod: ");   message += (server.method() == HTTP_GET) ? F("GET") : F("POST");   message += F("nArguments: ");   message += server.args();   message += F("n");      for (uint8_t i = 0; i < server.args(); i++)   {     message += " " + server.argName(i) + ": " + server.arg(i) + "n";   }      server.send(404, F("text/plain"), message); }  void drawGraph() {   String out;   out.reserve(3000);   char temp[70];      out += F("<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="310" height="150">n");   out += F("<rect width="310" height="150" fill="rgb(250, 230, 210)" stroke-width="1" stroke="rgb(0, 0, 0)" />n");   out += F("<g stroke="black">n");   int y = rand() % 130;    for (int x = 10; x < 300; x += 10)   {     int y2 = rand() % 130;     sprintf(temp, "<line x1="%d" y1="%d" x2="%d" y2="%d" stroke-width="1" />n", x, 140 - y, x + 10, 140 - y2);     out += temp;     y = y2;   }   out += F("</g>n</svg>n");    server.send(200, F("image/svg+xml"), out); }  void setup(void) {   Serial.begin(115200);   while (!Serial);    Serial.print("nStarting AdvancedWebServer on " + String(BOARD_NAME));   Serial.println(" with " + String(SHIELD_TYPE));   Serial.println(ETHERNET_WEBSERVER_SSL_VERSION);  #if USE_ETHERNET_WRAPPER    EthernetInit();  #else  #if USE_NATIVE_ETHERNET   ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); #elif USE_ETHERNET   ET_LOGWARN(F("=========== USE_ETHERNET ===========")); #elif USE_ETHERNET2   ET_LOGWARN(F("=========== USE_ETHERNET2 ===========")); #elif USE_ETHERNET3   ET_LOGWARN(F("=========== USE_ETHERNET3 ===========")); #elif USE_ETHERNET_LARGE   ET_LOGWARN(F("=========== USE_ETHERNET_LARGE ===========")); #elif USE_ETHERNET_ESP8266   ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #elif USE_ETHERNET_ENC   ET_LOGWARN(F("=========== USE_ETHERNET_ENC ==========="));   #else   ET_LOGWARN(F("=========================")); #endif    ET_LOGWARN(F("Default SPI pinout:"));   ET_LOGWARN1(F("MOSI:"), MOSI);   ET_LOGWARN1(F("MISO:"), MISO);   ET_LOGWARN1(F("SCK:"),  SCK);   ET_LOGWARN1(F("SS:"),   SS);   ET_LOGWARN(F("========================="));  #if defined(ESP8266)   // For ESP8266, change for other boards if necessary   #ifndef USE_THIS_SS_PIN     #define USE_THIS_SS_PIN   D2    // For ESP8266   #endif    ET_LOGWARN1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN);    #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC )     // For ESP8266     // Pin                D0(GPIO16)    D1(GPIO5)    D2(GPIO4)    D3(GPIO0)    D4(GPIO2)    D8     // Ethernet           0                 X            X            X            X        0     // Ethernet2          X                 X            X            X            X        0     // Ethernet3          X                 X            X            X            X        0     // EthernetLarge      X                 X            X            X            X        0     // Ethernet_ESP8266   0                 0            0            0            0        0     // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs     // Must use library patch for Ethernet, EthernetLarge libraries     Ethernet.init (USE_THIS_SS_PIN);    #elif USE_ETHERNET3     // Use  MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer     #ifndef ETHERNET3_MAX_SOCK_NUM       #define ETHERNET3_MAX_SOCK_NUM      4     #endif        Ethernet.setCsPin (USE_THIS_SS_PIN);     Ethernet.init (ETHERNET3_MAX_SOCK_NUM);    #elif USE_CUSTOM_ETHERNET        // You have to add initialization for your Custom Ethernet here     // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough     Ethernet.init(USE_THIS_SS_PIN);      #endif  //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )  #elif defined(ESP32)    // You can use Ethernet.init(pin) to configure the CS pin   //Ethernet.init(10);  // Most Arduino shields   //Ethernet.init(5);   // MKR ETH shield   //Ethernet.init(0);   // Teensy 2.0   //Ethernet.init(20);  // Teensy++ 2.0   //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet   //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet    #ifndef USE_THIS_SS_PIN     #define USE_THIS_SS_PIN   22    // For ESP32   #endif    ET_LOGWARN1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN);    // For other boards, to change if necessary   #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC )     // Must use library patch for Ethernet, EthernetLarge libraries     // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge     // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3        //Ethernet.setCsPin (USE_THIS_SS_PIN);     Ethernet.init (USE_THIS_SS_PIN);      #elif USE_ETHERNET3     // Use  MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer     #ifndef ETHERNET3_MAX_SOCK_NUM       #define ETHERNET3_MAX_SOCK_NUM      4     #endif        Ethernet.setCsPin (USE_THIS_SS_PIN);     Ethernet.init (ETHERNET3_MAX_SOCK_NUM);    #elif USE_CUSTOM_ETHERNET        // You have to add initialization for your Custom Ethernet here     // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough     Ethernet.init(USE_THIS_SS_PIN);       #endif  //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )  #else   //defined(ESP8266)   // unknown board, do nothing, use default SS = 10   #ifndef USE_THIS_SS_PIN     #define USE_THIS_SS_PIN   10    // For other boards   #endif    #if defined(BOARD_NAME)     ET_LOGWARN3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN);   #else     ET_LOGWARN1(F("Unknown board setCsPin:"), USE_THIS_SS_PIN);   #endif    // For other boards, to change if necessary   #if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2  || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET )     // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries        Ethernet.init (USE_THIS_SS_PIN);      #elif USE_ETHERNET3     // Use  MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer     #ifndef ETHERNET3_MAX_SOCK_NUM       #define ETHERNET3_MAX_SOCK_NUM      4     #endif        Ethernet.setCsPin (USE_THIS_SS_PIN);     Ethernet.init (ETHERNET3_MAX_SOCK_NUM);    #elif USE_CUSTOM_ETHERNET        // You have to add initialization for your Custom Ethernet here     // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough     Ethernet.init(USE_THIS_SS_PIN);        #endif  //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )  #endif    //defined(ESP8266)   #endif  //USE_ETHERNET_WRAPPER     // start the ethernet connection and the server:   // Use DHCP dynamic IP and random mac   uint16_t index = millis() % NUMBER_OF_MAC;   // Use Static IP   //Ethernet.begin(mac[index], ip);   Ethernet.begin(mac[index]);    // Just info to know how to connect correctly   Serial.println(F("========================="));   Serial.println(F("Currently Used SPI pinout:"));   Serial.print(F("MOSI:"));   Serial.println(MOSI);   Serial.print(F("MISO:"));   Serial.println(MISO);   Serial.print(F("SCK:"));   Serial.println(SCK);   Serial.print(F("SS:"));   Serial.println(SS); #if USE_ETHERNET3   Serial.print(F("SPI_CS:"));   Serial.println(SPI_CS); #endif   Serial.println(F("========================="));    Serial.print(F("Using mac index = "));   Serial.println(index);    Serial.print(F("Connected! IP address: "));   Serial.println(Ethernet.localIP());    server.on(F("/"), handleRoot);   server.on(F("/test.svg"), drawGraph);   server.on(F("/inline"), []()   {     server.send(200, F("text/plain"), F("This works as well"));   });    server.onNotFound(handleNotFound);   server.begin();    Serial.print(F("HTTP EthernetWebServer is @ IP : "));   Serial.println(Ethernet.localIP()); }  void heartBeatPrint(void) {   static int num = 1;    Serial.print(F("."));    if (num == 80)   {     Serial.println();     num = 1;   }   else if (num++ % 10 == 0)   {     Serial.print(F(" "));   } }  void check_status() {   static unsigned long checkstatus_timeout = 0;  #define STATUS_CHECK_INTERVAL     10000L    // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change.   if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0))   {     heartBeatPrint();     checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL;   } }  void loop(void) {   server.handleClient();   check_status(); }

2. File defines.h

#pragma once  #define DEBUG_ETHERNET_WEBSERVER_PORT       Serial  // Debug Level from 0 to 4 #define _ETHERNET_WEBSERVER_LOGLEVEL_       3  #if    ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010)        || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310)        || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__)        || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__)        || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) )   #if defined(ETHERNET_USE_SAMD)     #undef ETHERNET_USE_SAMD   #endif   #define ETHERNET_USE_SAMD      true   #endif  #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) ||          defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) ||          defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) )   #if defined(ETHERNET_USE_NRF528XX)     #undef ETHERNET_USE_NRF528XX   #endif   #define ETHERNET_USE_NRF528XX      true #endif  #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) )   #if defined(ETHERNET_USE_SAM_DUE)     #undef ETHERNET_USE_SAM_DUE   #endif   #define ETHERNET_USE_SAM_DUE      true #endif  #if defined(ETHERNET_USE_SAMD)   // For SAMD   // Default pin 10 to SS/CS   #define USE_THIS_SS_PIN       10      #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) )     #define BOARD_TYPE      "SAMD Zero"   #elif defined(ARDUINO_SAMD_MKR1000)     #define BOARD_TYPE      "SAMD MKR1000"   #elif defined(ARDUINO_SAMD_MKRWIFI1010)     #define BOARD_TYPE      "SAMD MKRWIFI1010"   #elif defined(ARDUINO_SAMD_NANO_33_IOT)     #define BOARD_TYPE      "SAMD NANO_33_IOT"   #elif defined(ARDUINO_SAMD_MKRFox1200)     #define BOARD_TYPE      "SAMD MKRFox1200"   #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) )     #define BOARD_TYPE      "SAMD MKRWAN13X0"   #elif defined(ARDUINO_SAMD_MKRGSM1400)     #define BOARD_TYPE      "SAMD MKRGSM1400"   #elif defined(ARDUINO_SAMD_MKRNB1500)     #define BOARD_TYPE      "SAMD MKRNB1500"   #elif defined(ARDUINO_SAMD_MKRVIDOR4000)     #define BOARD_TYPE      "SAMD MKRVIDOR4000"   #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS)     #define BOARD_TYPE      "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS"   #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS)     #define BOARD_TYPE      "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS"   #elif defined(ADAFRUIT_METRO_M0_EXPRESS)     #define BOARD_TYPE      "SAMD21 ADAFRUIT_METRO_M0_EXPRESS"   #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0)     #define BOARD_TYPE      "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0"   #elif defined(ADAFRUIT_GEMMA_M0)     #define BOARD_TYPE      "SAMD21 ADAFRUIT_GEMMA_M0"   #elif defined(ADAFRUIT_TRINKET_M0)     #define BOARD_TYPE      "SAMD21 ADAFRUIT_TRINKET_M0"   #elif defined(ADAFRUIT_ITSYBITSY_M0)     #define BOARD_TYPE      "SAMD21 ADAFRUIT_ITSYBITSY_M0"   #elif defined(ARDUINO_SAMD_HALLOWING_M0)     #define BOARD_TYPE      "SAMD21 ARDUINO_SAMD_HALLOWING_M0"   #elif defined(ADAFRUIT_METRO_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_METRO_M4_EXPRESS"   #elif defined(ADAFRUIT_GRAND_CENTRAL_M4)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4"   #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS"   #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS"     #define USE_THIS_SS_PIN       10   #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS"   #elif defined(ADAFRUIT_PYPORTAL)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_PYPORTAL"   #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO"   #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS"   #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE"   #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS"   #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS"   #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4"   #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS"   #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS)     #define BOARD_TYPE      "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS"   #elif defined(SEEED_WIO_TERMINAL)     #define BOARD_TYPE      "SAMD SEEED_WIO_TERMINAL"   #elif defined(SEEED_FEMTO_M0)     #define BOARD_TYPE      "SAMD SEEED_FEMTO_M0"   #elif defined(SEEED_XIAO_M0)     #define BOARD_TYPE      "SAMD SEEED_XIAO_M0"     #ifdef USE_THIS_SS_PIN       #undef USE_THIS_SS_PIN     #endif     #define USE_THIS_SS_PIN       A1     #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1   #elif defined(Wio_Lite_MG126)     #define BOARD_TYPE      "SAMD SEEED Wio_Lite_MG126"   #elif defined(WIO_GPS_BOARD)     #define BOARD_TYPE      "SAMD SEEED WIO_GPS_BOARD"   #elif defined(SEEEDUINO_ZERO)     #define BOARD_TYPE      "SAMD SEEEDUINO_ZERO"   #elif defined(SEEEDUINO_LORAWAN)     #define BOARD_TYPE      "SAMD SEEEDUINO_LORAWAN"   #elif defined(SEEED_GROVE_UI_WIRELESS)     #define BOARD_TYPE      "SAMD SEEED_GROVE_UI_WIRELESS"   #elif defined(__SAMD21E18A__)     #define BOARD_TYPE      "SAMD21E18A"   #elif defined(__SAMD21G18A__)     #define BOARD_TYPE      "SAMD21G18A"   #elif defined(__SAMD51G19A__)     #define BOARD_TYPE      "SAMD51G19A"   #elif defined(__SAMD51J19A__)     #define BOARD_TYPE      "SAMD51J19A"   #elif defined(__SAMD51J20A__)     #define BOARD_TYPE      "SAMD51J20A"   #elif defined(__SAM3X8E__)     #define BOARD_TYPE      "SAM3X8E"   #elif defined(__CPU_ARC__)     #define BOARD_TYPE      "CPU_ARC"   #elif defined(__SAMD51__)     #define BOARD_TYPE      "SAMD51"   #else     #define BOARD_TYPE      "SAMD Unknown"   #endif  #elif (ETHERNET_USE_SAM_DUE)   // Default pin 10 to SS/CS   #define USE_THIS_SS_PIN       10   #define BOARD_TYPE      "SAM DUE"  #elif (ETHERNET_USE_NRF528XX)   // Default pin 10 to SS/CS   #define USE_THIS_SS_PIN       10    #if defined(NRF52840_FEATHER)     #define BOARD_TYPE      "NRF52840_FEATHER"   #elif defined(NRF52832_FEATHER)     #define BOARD_TYPE      "NRF52832_FEATHER"   #elif defined(NRF52840_FEATHER_SENSE)     #define BOARD_TYPE      "NRF52840_FEATHER_SENSE"   #elif defined(NRF52840_ITSYBITSY)     #define BOARD_TYPE      "NRF52840_ITSYBITSY"     #define USE_THIS_SS_PIN   10    // For other boards   #elif defined(NRF52840_CIRCUITPLAY)     #define BOARD_TYPE      "NRF52840_CIRCUITPLAY"   #elif defined(NRF52840_CLUE)     #define BOARD_TYPE      "NRF52840_CLUE"   #elif defined(NRF52840_METRO)     #define BOARD_TYPE      "NRF52840_METRO"   #elif defined(NRF52840_PCA10056)     #define BOARD_TYPE      "NRF52840_PCA10056"   #elif defined(NINA_B302_ublox)     #define BOARD_TYPE      "NINA_B302_ublox"   #elif defined(NINA_B112_ublox)     #define BOARD_TYPE      "NINA_B112_ublox"   #elif defined(PARTICLE_XENON)     #define BOARD_TYPE      "PARTICLE_XENON"   #elif defined(ARDUINO_NRF52_ADAFRUIT)     #define BOARD_TYPE      "ARDUINO_NRF52_ADAFRUIT"   #else     #define BOARD_TYPE      "nRF52 Unknown"   #endif  #elif ( defined(CORE_TEENSY) )   // Default pin 10 to SS/CS   #define USE_THIS_SS_PIN       10      #if defined(__IMXRT1062__)     // For Teensy 4.1/4.0     #if defined(ARDUINO_TEENSY41)       #define BOARD_TYPE      "TEENSY 4.1"       // Use true for NativeEthernet Library, false if using other Ethernet libraries       #define USE_NATIVE_ETHERNET     true     #elif defined(ARDUINO_TEENSY40)       #define BOARD_TYPE      "TEENSY 4.0"     #else       #define BOARD_TYPE      "TEENSY 4.x"     #endif         #elif defined(__MK66FX1M0__)     #define BOARD_TYPE "Teensy 3.6"   #elif defined(__MK64FX512__)     #define BOARD_TYPE "Teensy 3.5"   #elif defined(__MKL26Z64__)     #define BOARD_TYPE "Teensy LC"   #elif defined(__MK20DX256__)     #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete)   #elif defined(__MK20DX128__)     #define BOARD_TYPE "Teensy 3.0"   #elif defined(__AVR_AT90USB1286__)     #error Teensy 2.0++ not supported yet   #elif defined(__AVR_ATmega32U4__)     #error Teensy 2.0 not supported yet   #else     // For Other Boards     #define BOARD_TYPE      "Unknown Teensy Board"   #endif  #elif ( defined(ESP8266) )   // For ESP8266   #warning Use ESP8266 architecture   #include <ESP8266mDNS.h>   #define ETHERNET_USE_ESP8266   #define BOARD_TYPE      "ESP8266"  #elif ( defined(ESP32) )   // For ESP32   #warning Use ESP32 architecture   #define ETHERNET_USE_ESP32   #define BOARD_TYPE      "ESP32"      #define W5500_RST_PORT   21  #elif (__AVR__)   // For Mega   // Default pin 10 to SS/CS   #define USE_THIS_SS_PIN       10   #define BOARD_TYPE            "AVR"    #error Not supporting AVR Mega, Nano, UNO, etc. yet.   // Currently not OK. See https://github.com/mike-matera/ArduinoSTL/issues/56   // Hopefully will be fixed in Arduino IDE 1.8.14   #include "ArduinoSTL.h"                                   // https://github.com/mike-matera/ArduinoSTL  #else    // Default pin 10 to SS/CS   #define USE_THIS_SS_PIN       10   #define BOARD_TYPE            "Unknown"    //#error Not supporting yet.    #endif  #ifndef BOARD_NAME   #define BOARD_NAME    BOARD_TYPE #endif  #include <SPI.h>  //#define USE_ETHERNET_WRAPPER    true #define USE_ETHERNET_WRAPPER    false  // Use true  for ENC28J60 and UIPEthernet library (https://github.com/UIPEthernet/UIPEthernet) // Use false for W5x00 and Ethernetx library      (https://www.arduino.cc/en/Reference/Ethernet)  //#define USE_UIP_ETHERNET   true #define USE_UIP_ETHERNET   false  // Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp // In order to USE_ETHERNET_ESP8266 #if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET )    // To override the default CS/SS pin. Don't use unless you know exactly which pin to use   // You can define here or customize for each board at same place with BOARD_TYPE   // Check @ defined(SEEED_XIAO_M0)   //#define USE_THIS_SS_PIN   22  //21  //5 //4 //2 //15      // Only one if the following to be true   #define USE_ETHERNET          true   #define USE_ETHERNET2         false   #define USE_ETHERNET3         false   #define USE_ETHERNET_LARGE    false   #define USE_ETHERNET_ESP8266  false    #define USE_ETHERNET_ENC      false   #define USE_CUSTOM_ETHERNET   false      #if !USE_ETHERNET_WRAPPER        #if ( USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET )       #ifdef USE_CUSTOM_ETHERNET         #undef USE_CUSTOM_ETHERNET       #endif       #define USE_CUSTOM_ETHERNET   false     #endif      #if USE_NATIVE_ETHERNET       #include "NativeEthernet.h"       #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error       #define SHIELD_TYPE           "Custom Ethernet using Teensy 4.1 NativeEthernet Library"     #elif USE_ETHERNET3       #include "Ethernet3.h"       #warning Using Ethernet3 lib       #define SHIELD_TYPE           "W5x00 using Ethernet3 Library"     #elif USE_ETHERNET2       #include "Ethernet2.h"       #warning Using Ethernet2 lib       #define SHIELD_TYPE           "W5x00 using Ethernet2 Library"     #elif USE_ETHERNET_LARGE       #include "EthernetLarge.h"       #warning Using EthernetLarge lib       #define SHIELD_TYPE           "W5x00 using EthernetLarge Library"     #elif USE_ETHERNET_ESP8266       #include "Ethernet_ESP8266.h"       #warning Using Ethernet_ESP8266 lib        #define SHIELD_TYPE           "W5x00 using Ethernet_ESP8266 Library"      #elif USE_ETHERNET_ENC       #include "EthernetENC.h"       #warning Using EthernetENC lib       #define SHIELD_TYPE           "ENC28J60 using EthernetENC Library"     #elif USE_CUSTOM_ETHERNET       //#include "Ethernet_XYZ.h"       #include "EthernetENC.h"       #warning Using Custom Ethernet library. You must include a library and initialize.       #define SHIELD_TYPE           "Custom Ethernet using Ethernet_XYZ Library"     #else       #ifdef USE_ETHERNET         #undef USE_ETHERNET       #endif       #define USE_ETHERNET   true       #include "Ethernet.h"       #warning Using Ethernet lib       #define SHIELD_TYPE           "W5x00 using Ethernet Library"     #endif          // Ethernet_Shield_W5200, EtherCard, EtherSia not supported     // Select just 1 of the following #include if uncomment #define USE_CUSTOM_ETHERNET     // Otherwise, standard Ethernet library will be used for W5x00      #endif    //  USE_ETHERNET_WRAPPER #elif USE_UIP_ETHERNET     #include "UIPEthernet.h"     #warning Using UIPEthernet library     #define SHIELD_TYPE           "ENC28J60 using UIPEthernet Library" #endif      // #if !USE_UIP_ETHERNET  #include <EthernetWebServer_SSL.h>  #ifndef SHIELD_TYPE   #define SHIELD_TYPE     "Unknown Ethernet shield/library"  #endif  // Enter a MAC address and IP address for your controller below. #define NUMBER_OF_MAC      20  byte mac[][NUMBER_OF_MAC] = {   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 },   { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, };  // Select the IP address according to your local network IPAddress ip(192, 168, 2, 222);  // Google DNS Server IP IPAddress myDns(8, 8, 8, 8); 


Debug Termimal Output Samples

1. AdvancedWebServer on NRF52840_FEATHER_EXPRESS with ENC28J60 using EthernetENC Library

The following are debug terminal output and screen shot when running example AdvancedWebServer on Adafruit NRF52840_FEATHER_EXPRESS with ENC28J60 using EthernetENC Library

Changelog - 变更日志

Starting AdvancedWebServer on NRF52840_FEATHER with ENC28J60 using EthernetENC Library EthernetWebServer_SSL v1.3.0 [ETHERNET_WEBSERVER] ========================= [ETHERNET_WEBSERVER] Default SPI pinout: [ETHERNET_WEBSERVER] MOSI: 25 [ETHERNET_WEBSERVER] MISO: 24 [ETHERNET_WEBSERVER] SCK: 26 [ETHERNET_WEBSERVER] SS: 5 [ETHERNET_WEBSERVER] ========================= [ETHERNET_WEBSERVER] Board : NRF52840_FEATHER , setCsPin: 10 ========================= Currently Used SPI pinout: MOSI:25 MISO:24 SCK:26 SS:5 ========================= Using mac index = 11 Connected! IP address: 192.168.2.96 HTTP EthernetWebServer is @ IP : 192.168.2.96 EthernetWebServer::handleClient: New Client method:  GET url:  / search: headerName: Host headerValue: 192.168.2.113 headerName: Connection headerValue: keep-alive headerName: DNT headerValue: 1 headerName: Upgrade-Insecure-Requests headerValue: 1 headerName: User-Agent headerValue: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36 headerName: Accept headerValue: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 headerName: Accept-Encoding headerValue: gzip, deflate headerName: Accept-Language headerValue: en-GB,en-US;q=0.9,en;q=0.8 args: args count:  0 args: args count:  0 Request: / Arguments:  Final list of key/value pairs: EthernetWebServer::_handleRequest handle EthernetWebServer::send1: len =  347 content =  <html><head><meta http-equiv='refresh' content='5'/><title>AdvancedWebServer NRF52840_FEATHER</title><style>body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }</style></head><body><h2>Hi from EthernetWebServer!</h2><h3>on NRF52840_FEATHER</h3><p>Uptime: 0 d 00:00:11</p><img src="/test.svg" /></body></html> EthernetWebServer::_prepareHeader sendHeader Conn close EthernetWebServer::send1: write header =  HTTP/1.1 200 OK Content-Type: text/html Content-Length: 347 Connection: close  EthernetWebServer::sendContent: Client.write content:  <html><head><meta http-equiv='refresh' content='5'/><title>AdvancedWebServer NRF52840_FEATHER</title><style>body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }</style></head><body><h2>Hi from EthernetWebServer_SSL!</h2><h3>on NRF52840_FEATHER</h3><p>Uptime: 0 d 00:00:11</p><img src="/test.svg" /></body></html> EthernetWebServer::_handleRequest OK EthernetWebServer::handleClient: Client disconnected EthernetWebServer::handleClient: Don't keepCurrentClient EthernetWebServer::handleClient: Client disconnected EthernetWebServer::handleClient: New Client method:  GET url:  /test.svg search: headerName: Host headerValue: 192.168.2.113 headerName: Connection headerValue: keep-alive headerName: User-Agent headerValue: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36 headerName: DNT headerValue: 1 headerName: Accept headerValue: image/webp,image/apng,image/*,*/*;q=0.8 headerName: Referer headerValue: http://192.168.2.113/ headerName: Accept-Encoding headerValue: gzip, deflate headerName: Accept-Language headerValue: en-GB,en-US;q=0.9,en;q=0.8 args: args count:  0 args: args count:  0 Request: /test.svg Arguments:  Final list of key/value pairs: EthernetWebServer::_handleRequest handle EthernetWebServer::send1: len =  1950 content =  <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="310" height="150"> <rect width="310" height="150" fill="rgb(250, 230, 210)" stroke-width="1" stroke="rgb(0, 0, 0)" /> <g stroke="black"> <line x1="10" y1="98" x2="20" y2="111" stroke-width="1" /> <line x1="20" y1="111" x2="30" y2="90" stroke-width="1" /> <line x1="30" y1="90" x2="40" y2="22" stroke-width="1" /> <line x1="40" y1="22" x2="50" y2="98" stroke-width="1" /> <line x1="50" y1="98" x2="60" y2="64" stroke-width="1" /> <line x1="60" y1="64" x2="70" y2="104" stroke-width="1" /> <line x1="70" y1="104" x2="80" y2="31" stroke-width="1" /> <line x1="80" y1="31" x2="90" y2="59" stroke-width="1" /> <line x1="90" y1="59" x2="100" y2="139" stroke-width="1" /> <line x1="100" y1="139" x2="110" y2="117" stroke-width="1" /> <line x1="110" y1="117" x2="120" y2="75" stroke-width="1" /> <line x1="120" y1="75" x2="130" y2="72" stroke-width="1" /> <line x1="130" y1="72" x2="140" y2="137" stroke-width="1" /> <line x1="140" y1="137" x2="150" y2="20" stroke-width="1" /> <line x1="150" y1="20" x2="160" y2="94" stroke-width="1" /> <line x1="160" y1="94" x2="170" y2="81" stroke-width="1" /> <line x1="170" y1="81" x2="180" y2="38" stroke-width="1" /> <line x1="180" y1="38" x2="190" y2="33" stroke-width="1" /> <line x1="190" y1="33" x2="200" y2="53" stroke-width="1" /> <line x1="200" y1="53" x2="210" y2="88" stroke-width="1" /> <line x1="210" y1="88" x2="220" y2="32" stroke-width="1" /> <line x1="220" y1="32" x2="230" y2="110" stroke-width="1" /> <line x1="230" y1="110" x2="240" y2="87" stroke-width="1" /> <line x1="240" y1="87" x2="250" y2="11" stroke-width="1" /> <line x1="250" y1="11" x2="260" y2="98" stroke-width="1" /> <line x1="260" y1="98" x2="270" y2="76" stroke-width="1" /> <line x1="270" y1="76" x2="280" y2="121" stroke-width="1" /> <line x1="280" y1="121" x2="290" y2="139" stroke-width="1" /> <line x1="290" y1="139" x2="300" y2="103" stroke-width="1" /> </g> </svg>  EthernetWebServer::_prepareHeader sendHeader Conn close EthernetWebServer::send1: write header =  HTTP/1.1 200 OK Content-Type: image/svg+xml Content-Length: 1950 Connection: close 

2. ENC28J60_WM_Config on ESP32 with ENC28J60 using UIPEthernet Library

The terminal output of ESP32 running a ENC28J60_WM_Config example of BlynkEthernet_WM Library

Start ENC28J60_WM_Config on ESP32 [38] EEPROMsz:1024 [38] CCSum=0x29f2,RCSum=0x29f2 [38] CrCCsum=0,CrRCsum=0 [38] Hdr=ENC28J60,BName=ESP32-ENC28J60-WM [38] Svr=account.duckdns.org,Tok=token [45] Svr1=account.ddns.net,Tok1=token1 [51] Prt=8080,SIP=blank [53] MAC:FE-80-D6-B4-FC-EE ENC28J60_CONTROL_CS =13 SS =5 SPI_MOSI =23 SPI_MISO =19 SPI_SCK =18 [5332] IP:192.168.2.103 [5332] bg:ECon.TryB [5332]      ___  __          __    / _ )/ /_ _____  / /__   / _  / / // / _ /  '_/  /____/_/_, /_//_/_/_         /___/ v0.6.1 on ESP32  [5343] BlynkArduinoClient.connect: Connecting to account.duckdns.org:8080 [6454] Ready (ping: 37ms). [6522] Connected to Blynk Server = account.duckdns.org, Token = token [6522] bg:EBCon Conn2Blynk: server = account.duckdns.org, port = 8080 Token = token, IP = 192.168.2.103 BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB

3. WebClientMulti_SSL on SAM DUE with W5x00 using EthernetLarge Library

The terminal output of SAM DUE with W5x00 using EthernetLarge Library running WebClientMulti_SSL example

Start WebClientMulti_SSL on SAM DUE with W5x00 using EthernetLarge Library EthernetWebServer_SSL v1.3.0 [ETHERNET_WEBSERVER] =========== USE_ETHERNET_LARGE =========== [ETHERNET_WEBSERVER] Default SPI pinout: [ETHERNET_WEBSERVER] MOSI: 75 [ETHERNET_WEBSERVER] MISO: 74 [ETHERNET_WEBSERVER] SCK: 76 [ETHERNET_WEBSERVER] SS: 10 [ETHERNET_WEBSERVER] ========================= [ETHERNET_WEBSERVER] Board : SAM DUE , setCsPin: 10 _pinCS = 0 W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 10 W5100::init: W5100, SSIZE =4096 ========================= Currently Used SPI pinout: MOSI:75 MISO:74 SCK:76 SS:10 ========================= Using mac index = 5 Connected! IP address: 192.168.2.81 Connecting to www.arduino.cc... Took: 2399 HTTP/1.1 200 OK Date: Tue, 10 Nov 2020 09:37:58 GMT Content-Type: text/plain Transfer-Encoding: chunked Connection: close Set-Cookie: __cfduid=d3528e024daf847cc558d2ba3205ee3d01605001078; expires=Thu, 10-Dec-20 09:37:58 GMT; path=/; domain=.arduino.cc; HttpOnly; SameSite=Lax Last-Modified: Wed, 02 Oct 2013 13:46:47 GMT Vary: Accept-Encoding Access-Control-Allow-Origin: https://www.arduino.cc Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS Access-Control-Allow-Headers: Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With Strict-Transport-Security: max-age=500; includeSubDomains X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block CF-Cache-Status: DYNAMIC cf-request-id: 06531dfd840000b65f100a1000000001 Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" Server: cloudflare CF-RAY: 5efecc42682cb65f-YWG  8d7             `:;;;,`                      .:;;:.                    .;;;;;;;;;;;`                :;;;;;;;;;;:     TM        `;;;;;;;;;;;;;;;`            :;;;;;;;;;;;;;;;            :;;;;;;;;;;;;;;;;;;         `;;;;;;;;;;;;;;;;;;          ;;;;;;;;;;;;;;;;;;;;;       .;;;;;;;;;;;;;;;;;;;;        ;;;;;;;;:`   `;;;;;;;;;     ,;;;;;;;;.`   .;;;;;;;;      .;;;;;;,         :;;;;;;;   .;;;;;;;          ;;;;;;;     ;;;;;;             ;;;;;;;  ;;;;;;,            ;;;;;;.   ,;;;;;               ;;;;;;.;;;;;;`              ;;;;;;   ;;;;;.                ;;;;;;;;;;;`      ```       ;;;;;`  ;;;;;                  ;;;;;;;;;,       ;;;       .;;;;; `;;;;:                  `;;;;;;;;        ;;;        ;;;;; ,;;;;`    `,,,,,,,,      ;;;;;;;      .,,;;;,,,     ;;;;; :;;;;`    .;;;;;;;;       ;;;;;,      :;;;;;;;;     ;;;;; :;;;;`    .;;;;;;;;      `;;;;;;      :;;;;;;;;     ;;;;; .;;;;.                   ;;;;;;;.        ;;;        ;;;;;  ;;;;;                  ;;;;;;;;;        ;;;        ;;;;;  ;;;;;                 .;;;;;;;;;;       ;;;       ;;;;;,  ;;;;;;               `;;;;;;;;;;;;                ;;;;;   `;;;;;,             .;;;;;; ;;;;;;;              ;;;;;;    ;;;;;;:           :;;;;;;.  ;;;;;;;            ;;;;;;      ;;;;;;;`       .;;;;;;;,    ;;;;;;;;        ;;;;;;;:       ;;;;;;;;;:,:;;;;;;;;;:      ;;;;;;;;;;:,;;;;;;;;;;        `;;;;;;;;;;;;;;;;;;;.        ;;;;;;;;;;;;;;;;;;;;           ;;;;;;;;;;;;;;;;;           :;;;;;;;;;;;;;;;;:             ,;;;;;;;;;;;;;,              ;;;;;;;;;;;;;;                 .;;;;;;;;;`                  ,;;;;;;;;:                                                                                                                                                                                                                                                      ;;;   ;;;;;`  ;;;;:  .;;  ;; ,;;;;;, ;;. `;,  ;;;;        ;;;   ;;:;;;  ;;;;;; .;;  ;; ,;;;;;: ;;; `;, ;;;:;;      ,;:;   ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;,`;, ;;  ;;      ;; ;:  ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;;`;, ;;  ;;.     ;: ;;  ;;;;;:  ;;  ;; .;;  ;;   ,;,   ;;`;;;, ;;  ;;`    ,;;;;;  ;;`;;   ;;  ;; .;;  ;;   ,;,   ;; ;;;, ;;  ;;     ;;  ,;, ;; .;;  ;;;;;:  ;;;;;: ,;;;;;: ;;  ;;, ;;;;;;     ;;   ;; ;;  ;;` ;;;;.   `;;;:  ,;;;;;, ;;  ;;,  ;;;;     0  (EthernetSSLClient)(SSL_WARN)(connected): Socket was dropped unexpectedly (this can be an alternative to closing the connection)  Disconnecting. Received 3324 bytes in 0.3154 s, rate = 10.54 kbytes/second Connecting to www.cloudflare.com... Took: 207 HTTP/1.1 200 OK Date: Tue, 10 Nov 2020 09:38:03 GMT Content-Type: text/plain Transfer-Encoding: chunked Connection: close Set-Cookie: __cfduid=dfa9b1dae33cb96315678c7c8c518f4c31605001083; expires=Thu, 10-Dec-20 09:38:03 GMT; path=/; domain=.www.cloudflare.com; HttpOnly; SameSite=Lax; Secure Access-Control-Allow-Origin: * Server: cloudflare CF-RAY: 5efecc66fb77b65f-YWG X-Frame-Options: SAMEORIGIN Expires: Thu, 01 Jan 1970 00:00:01 GMT Cache-Control: no-cache  bb fl=168f4 h=www.cloudflare.com ip=76.10.180.220 ts=1605001083.997 visit_scheme=https uag=SSLClientOverEthernet colo=YWG http=http/1.1 loc=CA tls=TLSv1.2 sni=plaintext warp=off gateway=off  0  (EthernetSSLClient)(SSL_WARN)(connected): Socket was dropped unexpectedly (this can be an alternative to closing the connection)  Disconnecting.  

4. WebClient_SSL on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library

The terminal output of SEEED_XIAO_M0 with W5x00 using Ethernet3 Library running WebClient_SSL example

Start WebClient_SSL on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library EthernetWebServer_SSL v1.3.0 [ETHERNET_WEBSERVER] =========== USE_ETHERNET3 =========== [ETHERNET_WEBSERVER] Default SPI pinout: [ETHERNET_WEBSERVER] MOSI: 10 [ETHERNET_WEBSERVER] MISO: 9 [ETHERNET_WEBSERVER] SCK: 8 [ETHERNET_WEBSERVER] SS: 4 [ETHERNET_WEBSERVER] ========================= [ETHERNET_WEBSERVER] Board : SEEED_XIAO_M0 , setCsPin: 1  Ethernet3 W5500 init, using SPI_CS = 1, number of sockets = 4 ========================= Currently Used SPI pinout: MOSI:10 MISO:9 SCK:8 SS:4 SPI_CS:1 ========================= Using mac index = 1 Connected! IP address: 192.168.2.102 Connecting to : www.arduino.cc, port : 443 Connected to www.arduino.cc Took: 3551 HTTP/1.1 200 OK Date: Tue, 10 Nov 2020 07:59:21 GMT Content-Type: text/plain Transfer-Encoding: chunked Connection: close Set-Cookie: __cfduid=dd7e2b24e26b05eb2d2e5793ac594c3611604995161; expires=Thu, 10-Dec-20 07:59:21 GMT; path=/; domain=.arduino.cc; HttpOnly; SameSite=Lax Last-Modified: Wed, 02 Oct 2013 13:46:47 GMT Vary: Accept-Encoding Access-Control-Allow-Origin: https://www.arduino.cc Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS Access-Control-Allow-Headers: Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With Strict-Transport-Security: max-age=500; includeSubDomains X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block CF-Cache-Status: DYNAMIC cf-request-id: 0652c3b5b60000f99d7e918000000001 Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" Server: cloudflare CF-RAY: 5efe3bcf881af99d-YYZ alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400  8d7             `:;;;,`                      .:;;:.                    .;;;;;;;;;;;`                :;;;;;;;;;;:     TM        `;;;;;;;;;;;;;;;`            :;;;;;;;;;;;;;;;            :;;;;;;;;;;;;;;;;;;         `;;;;;;;;;;;;;;;;;;          ;;;;;;;;;;;;;;;;;;;;;       .;;;;;;;;;;;;;;;;;;;;        ;;;;;;;;:`   `;;;;;;;;;     ,;;;;;;;;.`   .;;;;;;;;      .;;;;;;,         :;;;;;;;   .;;;;;;;          ;;;;;;;     ;;;;;;             ;;;;;;;  ;;;;;;,            ;;;;;;.   ,;;;;;               ;;;;;;.;;;;;;`              ;;;;;;   ;;;;;.                ;;;;;;;;;;;`      ```       ;;;;;`  ;;;;;                  ;;;;;;;;;,       ;;;       .;;;;; `;;;;:                  `;;;;;;;;        ;;;        ;;;;; ,;;;;`    `,,,,,,,,      ;;;;;;;      .,,;;;,,,     ;;;;; :;;;;`    .;;;;;;;;       ;;;;;,      :;;;;;;;;     ;;;;; :;;;;`    .;;;;;;;;      `;;;;;;      :;;;;;;;;     ;;;;; .;;;;.                   ;;;;;;;.        ;;;        ;;;;;  ;;;;;                  ;;;;;;;;;        ;;;        ;;;;;  ;;;;;                 .;;;;;;;;;;       ;;;       ;;;;;,  ;;;;;;               `;;;;;;;;;;;;                ;;;;;   `;;;;;,             .;;;;;; ;;;;;;;              ;;;;;;    ;;;;;;:           :;;;;;;.  ;;;;;;;            ;;;;;;      ;;;;;;;`       .;;;;;;;,    ;;;;;;;;        ;;;;;;;:       ;;;;;;;;;:,:;;;;;;;;;:      ;;;;;;;;;;:,;;;;;;;;;;        `;;;;;;;;;;;;;;;;;;;.        ;;;;;;;;;;;;;;;;;;;;           ;;;;;;;;;;;;;;;;;           :;;;;;;;;;;;;;;;;:             ,;;;;;;;;;;;;;,              ;;;;;;;;;;;;;;                 .;;;;;;;;;`                  ,;;;;;;;;:                                                                                                                                                                                                                                                      ;;;   ;;;;;`  ;;;;:  .;;  ;; ,;;;;;, ;;. `;,  ;;;;        ;;;   ;;:;;;  ;;;;;; .;;  ;; ,;;;;;: ;;; `;, ;;;:;;      ,;:;   ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;,`;, ;;  ;;      ;; ;:  ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;;`;, ;;  ;;.     ;: ;;  ;;;;;:  ;;  ;; .;;  ;;   ,;,   ;;`;;;, ;;  ;;`    ,;;;;;  ;;`;;   ;;  ;; .;;  ;;   ,;,   ;; ;;;, ;;  ;;     ;;  ,;, ;; .;;  ;;;;;:  ;;;;;: ,;;;;;: ;;  ;;, ;;;;;;     ;;   ;; ;;  ;;` ;;;;.   `;;;:  ,;;;;;, ;;  ;;,  ;;;;     0  (EthernetSSLClient)(SSL_WARN)(connected): Socket was dropped unexpectedly (this can be an alternative to closing the connection)  Disconnecting. Received 3405 bytes in 0.2072 s, rate = 16.43 kbytes/second  

5. MQTTClient_SSL_Complex on SAM DUE with W5x00 using EthernetLarge Library

  1. The terminal output of SAM DUE with W5x00 using EthernetLarge Library running MQTTClient_SSL_Complex example
Start MQTTClient_SSL_Complex on SAM DUE with W5x00 using EthernetLarge Library EthernetWebServer_SSL v1.3.0 [ETHERNET_WEBSERVER] =========== USE_ETHERNET_LARGE =========== [ETHERNET_WEBSERVER] Default SPI pinout: [ETHERNET_WEBSERVER] MOSI: 75 [ETHERNET_WEBSERVER] MISO: 74 [ETHERNET_WEBSERVER] SCK: 76 [ETHERNET_WEBSERVER] SS: 10 [ETHERNET_WEBSERVER] ========================= [ETHERNET_WEBSERVER] Board : SAM DUE , setCsPin: 10 _pinCS = 0 W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 10 W5100::init: W5100, SSIZE =4096 ========================= Currently Used SPI pinout: MOSI:75 MISO:74 SCK:76 SS:10 ========================= Using mac index = 6 Connected! IP address: 192.168.2.71 Attempting MQTT connection to broker.emqx.io...connected Message Send : MQTT_Pub => Hello from MQTTClient_SSL_Complex on SAM DUE, millis = 7694 Message arrived [MQTT_Pub] Hello from MQTTClient_SSL_Complex on SAM DUE, millis = 7694 Attempting MQTT connection to broker.emqx.io...connected Message Send : MQTT_Pub => Hello from MQTTClient_SSL_Complex on SAM DUE, millis = 15580 Message arrived [MQTT_Pub] Hello from MQTTClient_SSL_Complex on SAM DUE, millis = 15580 Attempting MQTT connection to broker.emqx.io...connected Message Send : MQTT_Pub => Hello from MQTTClient_SSL_Complex on SAM DUE, millis = 20587 Message arrived [MQTT_Pub] Hello from MQTTClient_SSL_Complex on SAM DUE, millis = 20587  

  1. The terminal output of SEEED_XIAO_M0 with W5x00 using Ethernet3 Library running MQTTS_ThingStream example
Start MQTTS_ThingStream on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library EthernetWebServer_SSL v1.3.0 [ETHERNET_WEBSERVER] Board : SEEED_XIAO_M0 , setCsPin: 1 [ETHERNET_WEBSERVER] Default SPI pinout: [ETHERNET_WEBSERVER] MOSI: 10 [ETHERNET_WEBSERVER] MISO: 9 [ETHERNET_WEBSERVER] SCK: 8 [ETHERNET_WEBSERVER] SS: 4 [ETHERNET_WEBSERVER] =========================  Ethernet3 W5500 init, using SPI_CS = 1, number of sockets = 4 You're connected to the network, IP = 192.168.2.102 *************************************** esp32-sniffer/12345678/ble *************************************** Attempting MQTT connection to mqtt.thingstream.io ...connected Published connection message successfully! Subcribed to: esp32-sniffer/12345678/ble MQTT Message Send : esp32-sniffer/12345678/ble => Hello from MQTTS_ThingStream on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library MQTT Message receive [esp32-sniffer/12345678/ble] Hello from MQTTS_ThingStream on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library MQTT Message Send : esp32-sniffer/12345678/ble => Hello from MQTTS_ThingStream on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library MQTT Message receive [esp32-sniffer/12345678/ble] Hello from MQTTS_ThingStream on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library MQTT Message Send : esp32-sniffer/12345678/ble => Hello from MQTTS_ThingStream on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library MQTT Message receive [esp32-sniffer/12345678/ble] Hello from MQTTS_ThingStream on SEEED_XIAO_M0 with W5x00 using Ethernet3 Library 


Debug

Debug is enabled by default on Serial. Debug Level from 0 to 4. To disable, change the ETHERNET_WEBSERVER_LOGLEVEL to 0

// Use this to output debug msgs to Serial #define DEBUG_ETHERNET_WEBSERVER_PORT       Serial // Use this to disable all output debug msgs // Debug Level from 0 to 4 #define _ETHERNET_WEBSERVER_LOGLEVEL_       0

Troubleshooting

If you get compilation errors, more often than not, you may need to install a newer version of the board’s core, applying Libraries’ Patches, Packages’ Patches or this library latest version.



Releases

Release v1.3.1

  1. Clean-up all compiler warnings possible.
  2. Add Table of Contents

Release v1.3.0

  1. Add support to NativeEthernet Library for Teensy 4.1

Major Release v1.2.0

  1. Add high-level HTTP and WebSockets Client by merging ArduinoHttpClient Library
  2. Add many more examples for HTTP and WebSockets Client.
  3. Add Version String.

Release v1.1.2

  1. Add SSL debug feature.
  2. Enhance examples.

Release v1.1.1

  1. Permit sites with “Chain could not be linked to a trust anchor” such as mqtt.thingstream.io.
  2. Add example MQTTS_ThingStream to demonstrate new feature

Release v1.1.0

  1. Initial coding for SAMD21/SAMD51, SAM DUE, Teensy to support Ethernet shields using SSL.
  2. Supporting W5x00 using Ethernet, EthernetLarge, Ethernet2 and Ethernet3 libraries
  3. Supporting ENC28J60 using EthernetENC and UIPEthernet libraries


Currently supported Boards

This EthernetWebServer_SSL library currently supports these following boards:

  1. nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.. Currently SSL WebClient is not working.
  2. SAM DUE
  3. SAMD21
  • Arduino SAMD21: ZERO, MKRs, NANO_33_IOT, etc.
  • Adafruit SAMD21 (M0): ItsyBitsy M0, Feather M0, Feather M0 Express, Metro M0 Express, Circuit Playground Express, Trinket M0, PIRkey, Hallowing M0, Crickit M0, etc.
  • SeeedStudio: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, etc.
  1. SAMD51
  • Adafruit SAMD51 (M4): Metro M4, Grand Central M4, ItsyBitsy M4, Feather M4 Express, Trellis M4, Metro M4 AirLift Lite, MONSTER M4SK Express, Hallowing M4, etc.
  • Seeeduino: WIO Terminal, Grove UI Wireless
  1. Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0, LC)
  2. AVR Mega1280, 2560, ADK.. SSL WebClient not supported yet. Check Trivial sketch won’t compile using Arduino 1.8.13
  3. ESP32
  4. ESP8266. SSL WebClient not supported yet. Check HTTPS GET request – ESP8266 – ENC28j60

Supporting Ethernet shields/modules:

  1. W5x00 using Ethernet, EthernetLarge, Ethernet2 or Ethernet3 library
  2. ENC28J60 using EthernetENC or UIPEthernet library
  3. Teensy 4.1 built-in NativeEthernet using NativeEthernet Library

The library provides these features:

  1. TCP Server and Client
  2. UDP Server and Client
  3. HTTP Server and HTTP/HTTPS Client
  4. HTTPS GET and POST requests, provides argument parsing, handles one client at a time.
  5. High-level HTTP (GET, POST, PUT, PATCH, DELETE) and WebSocket Client. From v1.2.0.

Issues

Submit issues to: EthernetWebServer_SSL issues


TO DO

  1. Bug Searching and Killing
  2. Add TLS/SSL Server support
  3. Support more types of boards using Ethernet shields.
  4. Support more non-compatible Ethernet Libraries such as Ethernet_Shield_W5200, EtherCard, EtherSia
  5. Add mDNS features.

DONE

  1. Add support to Arduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.)
  2. Add support to Adafruit SAMD21 (Itsy-Bitsy M0, Metro M0, Feather M0 Express, etc.).
  3. Add support to Adafruit SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.).
  4. Add support to Adafruit nRF52 ( Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc. non-SSL EthernetServer.
  5. Add support to SAM DUE.
  6. Add support to Ethernet W5x00, using either Ethernet, Ethernet2, Ethernet3 or EthernetLarge library
  7. Add support to Ethernet ENC28J60, using UIPEthernet library
  8. Add support to ESP32 and ESP8266 non-SSL EthernetServer.
  9. Add support to Seeeduino SAMD21/SAMD51: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, Wio Terminal, Grove UI Wireless
  10. Add support to EthernetENC
  11. Add support to PROGMEM-related commands, such as sendContent_P() and send_P()
  12. Add TLS/SSL Client support to SAMD21/SAMD51, SAM DUE, Teensy, ESP32, etc.
  13. Add High-level HTTP (GET, POST, PUT, PATCH, DELETE) and WebSocket Client
  14. Add support to NativeEthernet Library for Teensy 4.1


Contributions and Thanks

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

  1. Based on and modified from the good Ivan Grokhotkov’s ESP8266WebServer and ESP32 WebServer libraries.
  2. OPEnSLab-OSU for OPEnSLab-OSU’s SSLClient
  3. Thanks to good work of Miguel Alexandre Wisintainer for initiating, inspriring, working with, developing, debugging and testing. Without that, support to nRF52, especially U-Blox B302 running as nRF52840 and U-Blox B112 running as nRF52832, has never been started and finished. Also see ESP32-based U-BLOX NINA W102 running ENC28J60.
  4. Adrian McEwen for HttpClient Library on which the ArduinoHttpClient Library and this EthernetWebServer library are relied.
  5. Thanks to jimmie11 to report and suggest a fix in Compile Error on Teensy 4.1 #14 leading to the new version v1.3.0 to provide support to Teensy 4.1 using NativeEthernet Library
Changelog - 变更日志
⭐️ Ivan Grokhotkov
Changelog - 变更日志
⭐️ OPEnSLab-OSU
Changelog - 变更日志
⭐️ Adrian McEwen
Changelog - 变更日志
Miguel Wisintainer
Changelog - 变更日志
jimmie11

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 under MIT

Copyright

Copyright 2020- Khoi Hoang

v1.3.1

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/19412.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计Changelog – 变更日志

提供最优质的资源集合

立即查看 了解详情