Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Provide feedback

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

Saved searches

Use saved searches to filter your results more quickly

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

A WebSocket Server and Client library for Arduino, based on RFC6455, for writing modern Websockets applications. Now support ESP8266, ESP32 (including ESP32-S2 Saola, AI-Thinker ESP-12K, WT32_ETH01, etc.), nRF52, SAMD21, SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, Teensy, RP2040-based, etc. boards, with WiFiNINA, Teensy 4.1 NativeEthernet/QNEthernet, …

License

NotificationsYou must be signed in to change notification settings

khoih-prog/WebSockets2_Generic

Repository files navigation

arduino-library-badgeGitHub releaseGitHubcontributions welcomeGitHub issues

Donate to my libraries using BuyMeACoffee



Table of Contents

Why do we need thisWebSockets2_Generic library

Features

Many Web services require WebSockets library, which is so far written only for ESP8266/ESP32 boards. The ESP boards so far rely on theMarkus Sattler's WebSockets Library to connect toAlexa viaSinric orSinricPro skills.

ThisWebSockets2_Generic library is based on and modified fromGil Maimon's ArduinoWebSockets Library to provide support to many more boards, such asWT32_ETH01 (ESP32 + LAN8720), Arduino SAMD21, Adafruit SAMD21/SAMD51, Seeeduino SAMD21/SAMD51, nRF52, STM32F/L/H/G/WB/MP1, Teensy, SAM DUE, Portenta_H7, etc. and enable those boards to use WebSockets services, including voice-controlled Alexa along with Blynk. Those supported boards can also runWebSockets Server. The WebSockets can be used withESP’s WiFi, WiFiNINA, WiFi101, W5x00/ENC28J60/LAN8742A Ethernet, Teensy 4.1 NativeEthernet/QNEthernet, ESP8266/ESP32-AT modules/shields, Portenta_H7 WiFi/Ethernet, RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, using WiFiNINA.

Please seethe TinyWebsockets wiki for roughly-accurate information about the API not covered here.

Supported features of RFC6455

  • text frame
  • binary frame
  • connection close
  • ping
  • pong
  • continuation frame

Supported features of RFC2616


Currently supported Boards

ThisWebSockets_Generic2 library currently supports these following boards:

  1. nRF52 boards, such asAdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.

  2. 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.
  • Seeeduino: 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. SAM DUE
  2. Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0)
  3. STM32F/L/H/G/WB/MP1 boards (with 32+K Flash)
  • Nucleo-144
  • Nucleo-64
  • Discovery
  • Generic STM32F0, STM32F1, STM32F2, STM32F3, STM32F4, STM32F7 (with 64+K Flash): x8 and up
  • STM32L0, STM32L1, STM32L4
  • STM32G0, STM32G4
  • STM32H7
  • STM32WB
  • STM32MP1
  • LoRa boards
  • 3-D printer boards
  • Generic Flight Controllers
  • Midatronics boards
  1. ESP32, using either WiFi or Ethernet

  2. ESP8266

  3. RP2040-based boards, such asRASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, usingArduino-mbed RP2040 core orEarle Philhower's arduino-pico core.

  4. WT32_ETH01 boards using ESP32-based boards and LAN8720 Ethernet

  5. Portenta_H7 using eitherMurata WiFi orVision-shield Ethernet

  6. RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, using WiFiNINA or Ethernet

  7. RP2040W boards, such as RASPBERRY_PI_PICO_W, using Cyw43439 WiFi or Ethernet


Currently supported WiFi shields/modules

  1. WiFiNINA usingWiFiNINA_Generic library
  2. WiFi101 usingWiFi101_Generic libraryNew
  3. U-Blox W101, W102 usingWiFiNINA_Generic library
  4. ESP32 and ESP8266 WiFi
  5. Portenta_H7 built-in Murata WiFi
  6. RP2040W built-in CYW43439 WiFi

Currently supported Ethernet shields/modules

  1. W5x00 usingEthernet_Generic library
  2. W5x00 usingEthernet,EthernetLarge,Ethernet2 orEthernet3 library
  3. ENC28J60 usingEthernetENC orUIPEthernet library
  4. LAN8720 Ethernet used inWT32_ETH01 boards
  5. LAN8742A or LAN8720 usingSTM32Ethernet andLwIP libraries.
  6. Teensy 4.1 built-in Ethernet usingNativeEthernet library
  7. Teensy 4.1 built-in Ethernet usingQNEthernet library
  8. Portenta_H7 using Ethernet fromPortenta Vision shields



Prerequisites

  1. Arduino IDE 1.8.19+ for Arduino.GitHub release

  2. Arduino AVR core 1.8.6+ for Arduino (Use Arduino Board Manager) AVR boards.GitHub release

  3. Teensy core v1.57+ for Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0) boards.GitHub release

  4. Arduino SAM DUE core v1.6.12+ for SAM DUE ARM Cortex-M3 boards.

  5. Arduino SAMD core 1.8.13+ for SAMD ARM Cortex-M0+ boards.GitHub release

  6. Adafruit SAMD core 1.7.11+ for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.).GitHub release

  7. Seeeduino SAMD core 1.8.3+ for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.).Latest release

  8. Adafruit nRF52 v1.3.0+ for nRF52 boards such as Adafruit NRF52840_FEATHER, NRF52832_FEATHER, NRF52840_FEATHER_SENSE, NRF52840_ITSYBITSY, NRF52840_CIRCUITPLAY, NRF52840_CLUE, NRF52840_METRO, NRF52840_PCA10056, PARTICLE_XENON,NINA_B302_ublox, etc.GitHub release

  9. ESP32 Core 2.0.5+ for ESP32-based boards.Latest release

  10. ESP8266 Core 3.0.2+ for ESP8266-based boards.Latest release. To use ESP8266 core 2.7.1+ for LittleFS.

  11. ArduinoCore-mbed mbed_rp2040, mbed_nano, mbed_portenta core 3.4.1+ for Arduino (Use Arduino Board Manager)Portenta_H7, RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO.GitHub release

  12. Earle Philhower's arduino-pico core v2.6.4+ for RP2040-based boards such asRASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, etc.GitHub release

  13. Arduino Core for STM32 v2.3.0+ for STM32F/L/H/G/WB/MP1 boards.GitHub release. Use STM32 corev2.2.0 for LAN8720 or compile error.

  14. Arduino AmebaD core 3.1.4+ for Realtek RTL8720DN, RTL8722DM and RTL8722CSM.GitHub release

  15. WiFiNINA_Generic library v1.8.15-1+ if for WiFiNINA. To install. checkarduino-library-badge.

  16. EthernetWebServer library v2.3.0+ if necessary to use Ethernet modules/shields. To install, checkarduino-library-badge

  17. EthernetWebServer_STM32 library v1.5.0+ if necessary to use Ethernet modules/shields. To install, checkarduino-library-badge

  18. WebServer_WT32_ETH01 library v1.5.1+ if necessary to use WT32_ETH01 boards. To install, checkarduino-library-badge

  19. Depending on which Ethernet card you're using:

  1. WiFiWebServer library v1.10.1+ if necessary to use certain WiFi/WiFiNINA features. To install, checkarduino-library-badge
  2. FlashStorage_SAMD library v1.3.2+ for SAMD21 and SAMD51 boards (ZERO, MKR, NANO_33_IOT, M0, M0 Pro, AdaFruit Itsy-Bitsy M4, etc.) if necessary to use certain features.GitHub release
  3. FlashStorage_STM32 library v1.2.0+ for STM32F/L/H/G/WB/MP1 boards.GitHub release if necessary to use certain features.
  4. DueFlashStorage library v1.0.0+ for SAM DUE if necessary to use certain features. To install, checkarduino-library-badge.
  5. Adafruit's LittleFS/InternalFS for nRF52. Already included if you already installed AdafruitnRF52 board package from Boards Manager.
  6. DoubleResetDetector_Generic v1.8.1+ if necessary to use some examples. To install. checkarduino-library-badge if necessary to use certain features.
  7. WiFi101_Generic Library v1.0.0+ to use SAMD MKR1000, etc. boards with WiFi101 to send large data. To install. checkarduino-library-badge.
  8. SinricPro_Generic v2.8.5+ if necessary to use some examples. To install. checkarduino-library-badge if necessary to use certain features.


Installation

Use Arduino Library Manager

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

Manual Install

Another way to install is to:

  1. Navigate toWebSockets2_Generic page.
  2. Download the latest releaseWebSockets2_Generic-master.zip.
  3. Extract the zip file toWebSockets2_Generic-master directory
  4. Copy wholeWebSockets2_Generic-master folder to Arduino libraries' directory such as~/Arduino/libraries/.

VS Code & PlatformIO

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


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 wholenRF52 Packages_Patches directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0).

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

  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/boards.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.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.zThese 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/cores/nRF5/Udp.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Print.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Print.cpp
  • ~/.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 files inPackages_Patches for Teensy directory into Teensy hardware directory (./arduino-1.8.19/hardware/teensy/avr/boards.txt).

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

  • ./arduino-1.8.19/hardware/teensy/avr/boards.txt
  • ./arduino-1.8.19/hardware/teensy/avr/cores/teensy/Stream.h
  • ./arduino-1.8.19/hardware/teensy/avr/cores/teensy3/Stream.h
  • ./arduino-1.8.19/hardware/teensy/avr/cores/teensy4/Stream.h

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

  • ./arduino-x.yy.zz/hardware/teensy/avr/boards.txt
  • ./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy/Stream.h
  • ./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy3/Stream.h
  • ./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy4/Stream.h

3. For Arduino SAM DUE boards

To be able to compile and run on SAM DUE boards, you have to copy the wholeSAM 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.zzThis 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, run and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards, you have to copy the wholeArduino SAMD Packages_Patches directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.13).

For core version v1.8.10+

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

  • ~/.arduino15/packages/arduino/hardware/samd/1.8.13/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 thenotorious Arduino SAMD compiler error. SeeImprove Arduino compatibility with the STL (min and max macro)

 ...\arm-none-eabi\include\c++\7.2.1\bits\stl_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 theArduino.h file anymore.

5. For Adafruit SAMD boards

To be able to compile, run and automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards, you have to copy the wholeAdafruit SAMD Packages_Patches directory into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.11).

Supposing the Adafruit SAMD core version is 1.7.11. These files must be copied into the directory:

  • ~/.arduino15/packages/adafruit/hardware/samd/1.7.11/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/samd/1.7.11/cores/arduino/Print.h
  • ~/.arduino15/packages/adafruit/hardware/samd/1.7.11/cores/arduino/Print.cpp

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

  • ~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/cores/arduino/Print.h
  • ~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/cores/arduino/Print.cpp

6. For Seeeduino SAMD boards

To be able to compile, run and automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards, you have to copy the wholeSeeeduino SAMD Packages_Patches directory into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3).

Supposing the Seeeduino SAMD core version is 1.8.3. These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/platform.txt
  • ~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Arduino.h
  • ~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Print.h
  • ~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Print.cpp

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

  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/platform.txt
  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Arduino.h
  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Print.h
  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Print.cpp

7. For STM32 boards

7.1 For STM32 boards to use LAN8720

ForGeneric STM32F4 series boards, such asSTM32F407VE, usingLAN8720, please use STM32 corev2.2.0 as breaking corev2.3.0 creates the compile error.


To use LAN8720 on some STM32 boards

  • Nucleo-144 (F429ZI, NUCLEO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG)
  • Discovery (DISCO_F746NG)
  • STM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)

you have to copy the filesstm32f4xx_hal_conf_default.h andstm32f7xx_hal_conf_default.h into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system) to overwrite the old files.

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

  • ~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h for STM32F4.
  • ~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h for Nucleo-144 STM32F7.

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

  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system/STM32F4xx/stm32f4xx_hal_conf_default.h
  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system/STM32F7xx/stm32f7xx_hal_conf_default.h

7.2 For STM32 boards to use Serial1

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 filesSTM32 variant.h into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.3.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 2.3.0. These files must be copied into the directory:

  • ~/.arduino15/packages/STM32/hardware/stm32/2.3.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/NUCLEO_F767ZI/variant.h for Nucleo-144 NUCLEO_F767ZI.
  • ~/.arduino15/packages/STM32/hardware/stm32/2.3.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/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,these files must be copied into the corresponding directory:

  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/NUCLEO_F767ZI/variant.h
  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/NUCLEO_L053R8/variant.h

8. For RP2040-based boards usingEarle Philhower arduino-pico core

8.1 To use BOARD_NAME

To be able to automatically detect and display BOARD_NAME on RP2040-based boards (RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, GENERIC_RP2040, etc) boards, you have to copy the fileRP2040 platform.txt into rp2040 directory (~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0).

Supposing the rp2040 core version is 1.4.0. This file must be copied into the directory:

  • ~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0/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.zzThis file must be copied into the directory:

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

With core after v1.5.0, this step is not necessary anymore thanks to the PRAdd -DBOARD_NAME="{build.board}" #136.

8.2 To avoid compile error relating to microsecondsToClockCycles

Some libraries, such asAdafruit DHT-sensor-library, require the definition of microsecondsToClockCycles().To be able to compile and run on RP2040-based boards, you have to copy the files inRP2040 Arduino.h into rp2040 directory (~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0).

Supposing the rp2040 core version is 1.4.0. This file must be copied to replace:

  • ~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0/cores/rp2040/Arduino.h

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

  • ~/.arduino15/packages/rp2040/hardware/rp2040/x.yy.zz/cores/rp2040/Arduino.h

With core after v1.5.0, this step is not necessary anymore thanks to the PRAdd defs for compatibility #142.

9. For Portenta_H7 boards using Arduino IDE in Linux

To be able to upload firmware to Portenta_H7 using Arduino IDE in Linux (Ubuntu, etc.), you have to copy the fileportenta_post_install.sh into mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/portenta_post_install.sh).

Then run the following command usingsudo

$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1$ chmod 755 portenta_post_install.sh$ sudo ./portenta_post_install.sh

This will create the file/etc/udev/rules.d/49-portenta_h7.rules as follows:

# Portenta H7 bootloader mode UDEV rulesSUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="035b", GROUP="plugdev", MODE="0666"

Supposing the ArduinoCore-mbed core version is 3.4.1. Now only one file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/portenta_post_install.sh

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

This file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/mbed_portenta/x.yy.zz/portenta_post_install.sh

10. For RTL8720DN boards using AmebaD core

To avoid compile error relating to PROGMEM, you have to copy the fileRealtek AmebaD core pgmspace.h into Realtek AmebaD directory (~/.arduino15/packages/realtek/hardware/AmebaD/3.1.4/cores/ambd/avr/pgmspace.h).

Supposing the Realtek AmebaD core version is 3.1.4. This file must be copied into the directory:

  • ~/.arduino15/packages/realtek/hardware/AmebaD/3.1.4/cores/ambd/avr/pgmspace.h

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

  • ~/.arduino15/packages/realtek/hardware/AmebaD/x.yy.zz/cores/ambd/avr/pgmspace.h

11. For SAMD21 and SAMD51 boards using ArduinoCore-fab-sam core

To avoid compile error relating to SAMD21/SAMD51, you have to copy the fileArduinoCore-fab-sam core pgmspace.h intoArduinoCore-fab-sam samd directory (~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/1.9.0/boards.txt).

Supposing theArduinoCore-fab-sam samd core version is 1.9.0. This file must be copied into the directory:

  • ~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/1.9.0/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.zzThis file must be copied into the directory:

  • ~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/x.yy.zz/boards.txt

12. For Seeeduino RP2040 boards

To be able to compile, run and automatically detect and display BOARD_NAME on Seeeduino RP2040 (XIAO RP2040, Wio RP2040 Mini) boards, you have to copy the wholeSeeeduino RP2040 Packages_Patches directory into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2).

Supposing the Seeeduino RP2040 core version is 2.7.2. These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2/boards.txt
  • ~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2/variants/Seeed_XIAO_RP2040/pins_arduino.h

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

  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/boards.txt
  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/variants/Seeed_XIAO_RP2040/pins_arduino.h

13. For Seeeduino nRF52840 boards

To be able to compile and run on Xiao nRF52840 boards, you have to copy the wholenRF52 1.0.0 directory into Seeeduino nRF52 directory (~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0).

Supposing the Seeeduino nRF52 version is 1.0.0. These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/platform.txt
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/cores/nRF5/Print.h
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/cores/nRF5/Print.cpp
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.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.zThese files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/platform.txt
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/cores/nRF5/Print.h
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/cores/nRF5/Print.cpp
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h


Libraries' Patches

1. For application requiring 2K+ HTML page

If your application requires 2K+ HTML page, the currentEthernet 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 fixEthernet library, just copy these following files into theEthernet library directory to overwrite the old files:

You can also use the forked and modified library atPatched Ethernet

3. For EthernetLarge library

To fixEthernetLarge library, just copy these following files into theEthernetLarge library directory to overwrite the old files:

You can also use the forked and modified library atPatched EthernetLarge

4. For Ethernet2 library

To fixEthernet2 library, just copy these following files into theEthernet2 library directory to overwrite the old files:

To add UDP Multicast support, necessary for theUPnP_Generic library:

You can also use the forked and modified library atPatched Ethernet2

5. For Ethernet3 library

  1. To fixEthernet3 library, just copy these following files into theEthernet3 library directory to overwrite the old files:

You can also use the forked and modified library atPatched Ethernet3

6. For UIPEthernet library

To be able to compile and run on nRF52 boards with ENC28J60 using UIPEthernet library, you have to copy these following files into the UIPEthernetutility directory to overwrite the old files:

7. For fixing ESP32 compile error

To fixESP32 compile error, just copy the following file into theESP32 cores/esp32 directory (e.g. ./arduino-1.8.13/hardware/espressif/cores/esp32) to overwrite the old file:

8. For fixing ESP8266 compile error

To fixESP8266 compile error such as

error:'class EthernetClass' has no member named'init'Ethernet.init (USE_THIS_SS_PIN);

just rename the following file in ./arduino-1.8.13/hardware/esp8266com/esp8266/libraries/Ethernet directory

  • FromEthernet.h toEthernet_ESP8266.h


Note for Platform IO using ESP32 LittleFS

Necessary only for esp32 core v1.0.6-

From esp32 core v1.0.6+,LittleFS_esp32 v1.0.6 has been included and this step is not necessary anymore.

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

from

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

to

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

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

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



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

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

1. ESP32 has 2 ADCs, named ADC1 and ADC2

2. ESP32 ADCs functions

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

3.. ESP32 WiFi uses ADC2 for WiFi functions

Look in fileadc_common.c

InADC2, there're two locks used for different cases:

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

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

adc2_spinlock should be acquired first, then adc2_wifi_lock or rtc_spinlock.

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


HOWTO use STM32F4 with LAN8720

1. Wiring

This is the Wiring for STM32F4 (BLACK_F407VE, etc.) using LAN8720

LAN8720 PHY<--->STM32F4
TX1<--->PB_13
TX_EN<--->PB_11
TX0<--->PB_12
RX0<--->PC_4
RX1<--->PC_5
nINT/RETCLK<--->PA_1
CRS<--->PA_7
MDIO<--->PA_2
MDC<--->PC_1
GND<--->GND
VCC<--->+3.3V

2. HOWTO program using STLink V-2 or V-3

Connect as follows. To program, useSTM32CubeProgrammer or Arduino IDE with

  • U(S)ART Support: "Enabled (generic Serial)"
  • Upload Method : "STM32CubeProgrammer (SWD)"
STLink<--->STM32F4
SWCLK<--->SWCLK
SWDIO<--->SWDIO
RST<--->NRST
GND<--->GND
5v<--->5V


3. HOWTO use Serial Port for Debugging

Connect FDTI (USB to Serial) as follows:

FDTI<--->STM32F4
RX<--->TX=PA_9
TX<--->RX=PA_10
GND<--->GND


Important Notes

  1. Code is restructured to provide flexibility to make it easy to support many moreWiFi/Ethernet modules/shields in the future. Please delete the *.cpp files, replaced by *.hpp files, in the src directory, if *.cpp files still exist after installing new version.

  2. ForAdafruit nRF52, use the SPI's pin as follows:

  • SS/CS = 10
  • SPI_MOSI = MO(SI)
  • SPI_MISO = MI(SO)
  • SPI_SCK = SCK
  1. ForAdafruit SAMD21/SAMD51, use the SPI's CS/SS pin as follows:
  • Itsy-Bitsy M0/M4, Feather M0 (Express), Hallowing M0 Express, Zero, Metro M0 => use CS = 16 = pin A2
  • Feather M4 (SAMD51) => use SS/CS = 9
  • Grand Central M4 => use SS/CS = 53
  • Hallowing M4 => use SS/CS = 10
  • Metro M4 AirLift => use SS/CS = 36

To know the default CS/SS pins of not listed boards, check the relatedvariant.h files in

~/.arduino15/packages/adafruit/hardware/samd/x.y.zz/variants/board_name/variant.h

  1. ForArduino SAM DUE, use the SPI's pin as follows:

  1. ForRP2040 usingArduino mbed_rp2040 core, use the SPI's pin as follows:
  • SS/CS = 5
  • SPI_MOSI = 3
  • SPI_MISO = 4
  • SPI_SCK = 2
  1. ForRP2040 usingEarle Philhower's arduino-pico core, use the SPI's pin as follows:
  • SS/CS = 17
  • SPI_MOSI = 19
  • SPI_MISO = 16
  • SPI_SCK = 18


Basic Usage

Client

Creating a client and connecting to a server:

WebsocketsClient client;client.connect("ws://your-server-ip:port/uri");

Sending a message:

client.send("Hello Server!");

Waiting for messages:

  1. Using Lambda function
// run callback when messages are receivedclient.onMessage([&](WebsocketsMessage message) {  Serial.print("Got Message:");  Serial.println(message.data());});
  1. Using normal callback function
// run callback when events are occurring  client.onMessage(onMessageCallback);

and

voidonMessageCallback(WebsocketsMessage message){//Doing something with received String message.data() type    Serial.print("Got Message:");  Serial.println(message.data());}

HOWTO keep receiving messages:

voidloop() {  client.poll();}

Server

Creating a server and listening for connections:

WebsocketsServer server;server.listen(8080);

Accepting connections:

WebsocketsClient client = server.accept();// handle client as described before :)// run callback when messages are receivedclient.onMessage([&](WebsocketsMessage message) {  Serial.print("Got Message:");  Serial.println(message.data());});

Reading WebSockets Client messages using non-blocking mode (new from v1.0.6):

Using this new feature to enable doing other tasks in the loop(), such asWebServer, control tasks, etc.Server, using library version beforev1.0.6, can only read Client messages in blocking mode. Therefore, the WebSocket Server can't hang, waiting for Client, and block all other tasks from running.

// You can do some other tasks here, such as WebServer, controlling tasks, etc.    WebsocketsClient client = SocketsServer.accept();if (client.available())  {    WebsocketsMessage msg = client.readNonBlocking();// log    Serial.print("Got Message:");    Serial.println(msg.data());// return echo    client.send("Echo:" + msg.data());// close the connection    client.close();  }

Please test using one of these following new examples withv1.0.6 andv1.0.5- to see the blocking effects. Please remember to change in loop() from

WebsocketsMessage msg = client.readNonBlocking();

to

WebsocketsMessage msg = client.readBlocking();

asclient.readNonBlocking() is a new function in v1.0.6+.

For ESP32/ESP8266
  1. Esp32-AdvancedWebServer using ESP32
  2. Esp8266-AdvancedWebServer using ESP8266
For WT32_ETH01
  1. WT32_ETH01_AdvancedWebServer using WT32_ETH01
For WiFiNINA
  1. SAMD-AdvancedWebServer using Nano-33-IoT
  2. nRF52-AdvancedWebServer using Adafruit nRF52 NRF52840_FEATHER_EXPRESS, NINA_B302_ublox and WiFiNINA W102 module.
  3. STM32-AdvancedWebServer using STM32 Nucleo-64 L053R8, STM32F4 and WiFiNINA W102 module.
For W5x00, ENC28J60 or LAN8742A Ethernet
  1. SAMDUE-Ethernet_AdvancedWebServer using SAM DUE and W5100 Ethernet
  2. STM32-Ethernet_AdvancedWebServer using STM32F7 Nucleo-144 F676ZI and built-in LAN8742A Ethernet.
  3. SAMD-Ethernet_AdvancedWebServer using Adafruit SAMD51 Itsy_Bitsy_M4, Seeeduino SAMD21 XIAO_M0 and W5500 Ethernet.
  4. nRF52-Ethernet_AdvancedWebServer using Adafruit nRF52 NRF52840_FEATHER_EXPRESS, NINA_B302_ublox and W5500 Ethernet.
  5. Teensy-Ethernet_AdvancedWebServer using Teensy and W5500 Ethernet.


HOWTO use WiFiNINA module/shield with WiFiNINA_Generic library

#defineWEBSOCKETS_USE_WIFININAtrue

For SAMD21/SAMD51, nRF52, SAM DUE, ESP32 using Ethernet W5x0 or ENC28J60

To use Ethernet W5x00 module/shield with Ethernetx library

1. To use EthernetW5x00 module/shield with one of the Ethernet libraries

#defineWEBSOCKETS_USE_ETHERNETtrue
  • To useW5x00 module/shield withEthernet library
#defineWEBSOCKETS_USE_ETHERNETtrue#defineUSE_ETHERNET_GENERICtrue#defineUSE_ETHERNET_ENCfalse#defineUSE_UIP_ETHERNETfalse

2. To use EthernetENC28J60 module/shield withUIPEthernet library

#defineWEBSOCKETS_USE_ETHERNETtrue#defineUSE_ETHERNET_GENERICfalse#defineUSE_ETHERNET_ENCfalse#defineUSE_UIP_ETHERNETtrue

3. To use EthernetENC28J60 module/shield with newEthernetENC library

#defineWEBSOCKETS_USE_ETHERNETtrue#defineUSE_ETHERNET_GENERICfalse#defineUSE_ETHERNET_ENCtrue#defineUSE_UIP_ETHERNETfalse

3. It's much easier just add to the sketch

#defineWEBSOCKETS_USE_ETHERNETtrue// Just select one to be true. If all is false, default is Ethernet.// If more than one are true, the priority is USE_ETHERNET_GENERIC, USE_ETHERNET2, USE_ETHERNET_ENC, USE_UIP_ETHERNET#defineUSE_ETHERNET_GENERICtrue#defineUSE_ETHERNET_ENCfalse#defineUSE_UIP_ETHERNETfalse#if USE_ETHERNET_GENERIC// Also default to Ethernet_Generic library  #include<Ethernet_Generic.h>  #defineETHERNET_TYPE"W5x00 and Ethernet_Generic Library"#elif USE_ETHERNET_ENC  #include<EthernetENC.h>  #defineETHERNET_TYPE"ENC28J60 and EthernetENC Library"  #elif USE_UIP_ETHERNET  #include<UIPEthernet.h>  #include<utility/logging.h>   #defineETHERNET_TYPE"ENC28J60 and UIPEthernet Library"#else// Default to Ethernet_Generic library  #include<Ethernet_Generic.h>  #defineETHERNET_TYPE"W5x00 and Ethernet_Generic Library"#endif#ifndef USE_THIS_SS_PIN  #defineUSE_THIS_SS_PIN10// For other boards#endif

For STM32F/L/H/G/WB/MP1 using Ethernet W5x0, ENC28J60 or LAN8742A

To use Ethernet W5x00 module/shield with Ethernetx library

1. To use EthernetW5x00 module/shield with Ethernet_Generic libraries

#defineWEBSOCKETS_USE_ETHERNETtrue
  • To useW5x00 module/shield withEthernet_Generic library
#defineWEBSOCKETS_USE_ETHERNETtrue#defineUSE_LAN8742A_ETHERNETfalse#defineUSING_LAN8720false#defineUSE_ETHERNET_GENERICtrue#defineUSE_ETHERNET_ENCfalse#defineUSE_UIP_ETHERNETfalse

2. To use EthernetENC28J60 module/shield withUIPEthernet library

#defineWEBSOCKETS_USE_ETHERNETtrue#defineUSE_LAN8742A_ETHERNETfalse#defineUSING_LAN8720false#defineUSE_ETHERNET_GENERICfalse#defineUSE_ETHERNET_ENCfalse#defineUSE_UIP_ETHERNETtrue

3. To use EthernetENC28J60 module/shield with newEthernetENC library

#defineWEBSOCKETS_USE_ETHERNETtrue#defineUSE_LAN8742A_ETHERNETfalse#defineUSING_LAN8720false#defineUSE_ETHERNET_GENERICfalse#defineUSE_ETHERNET_ENCtrue#defineUSE_UIP_ETHERNETfalse

4. To use EthernetLAN8742A built-in module/shield withSTM32Ethernet library

#defineWEBSOCKETS_USE_ETHERNETtrue#defineUSE_LAN8742A_ETHERNETtrue#defineUSING_LAN8720false#defineUSE_ETHERNET_GENERICfalse#defineUSE_ETHERNET_ENCfalse#defineUSE_UIP_ETHERNETfalse

5. To use EthernetLAN8720 module/shield withSTM32Ethernet library

#defineWEBSOCKETS_USE_ETHERNETtrue#defineUSE_LAN8742A_ETHERNETfalse#defineUSING_LAN8720true#defineUSE_ETHERNET_GENERICfalse#defineUSE_ETHERNET_ENCfalse#defineUSE_UIP_ETHERNETfalse

6. It's much easier just add to the sketch

#defineWEBSOCKETS_USE_ETHERNETtrue// Just select one to be true. If all is false, default is Ethernet.// If more than one are true, the priority is USE_LAN8742A_ETHERNET, USE_ETHERNET_GENERIC, USE_ETHERNET_ENC, USE_UIP_ETHERNET#defineUSING_LAN8720true#defineUSE_LAN8742A_ETHERNETfalse#defineUSE_ETHERNET_GENERICfalse#defineUSE_ETHERNET_ENCfalse#defineUSE_UIP_ETHERNETfalse#if ( USE_LAN8742A_ETHERNET  || USING_LAN8720 )  #defineUSE_BUILTIN_ETHERNETtrue  #include<LwIP.h>  #include<STM32Ethernet.h>  #if USING_LAN8720    #defineETHERNET_TYPE"LAN8720 and STM32Ethernet Library"  #else    #defineETHERNET_TYPE"LAN8742A and STM32Ethernet Library"  #endif#elif USE_ETHERNET_GENERIC// Also default to Ethernet_Generic library  #include<Ethernet_Generic.h>  #defineETHERNET_TYPE"W5x00 and Ethernet_Generic Library"#elif USE_ETHERNET_ENC  #include<EthernetENC.h>  #defineETHERNET_TYPE"ENC28J60 and EthernetENC Library"  #elif USE_UIP_ETHERNET  #include<UIPEthernet.h>  #include<utility/logging.h>   #defineETHERNET_TYPE"ENC28J60 and UIPEthernet Library" #else// Default to Ethernet_Generic library  #include<Ethernet_Generic.h>  #defineETHERNET_TYPE"W5x00 and Ethernet_Generic Library"#endif#ifndef USE_THIS_SS_PIN  #defineUSE_THIS_SS_PIN10// For other boards#endif

For Teensy 4.1, 4.0, 3.x using Ethernet W5x0, ENC28J60 or LAN8742A

To use Ethernet W5x00 module/shield with Ethernet_Generic library

1. To use EthernetW5x00 module/shield with one of the Ethernet libraries

#defineWEBSOCKETS_USE_ETHERNETtrue
  • To useW5x00 module/shield withEthernet_Generic library
#defineWEBSOCKETS_USE_ETHERNETtrue#defineUSE_ETHERNET_GENERICtrue#defineUSE_ETHERNET_ENCfalse#defineUSE_UIP_ETHERNETfalse#defineUSE_NATIVE_ETHERNETfalse

2. To use EthernetENC28J60 module/shield withUIPEthernet library

#defineWEBSOCKETS_USE_ETHERNETtrue#defineUSE_ETHERNET_GENERICfalse#defineUSE_ETHERNET_ENCfalse#defineUSE_UIP_ETHERNETtrue#defineUSE_NATIVE_ETHERNETfalse

3. To use EthernetENC28J60 module/shield with newEthernetENC library

#defineWEBSOCKETS_USE_ETHERNETtrue#defineUSE_ETHERNET_GENERICfalse#defineUSE_ETHERNET_ENCtrue#defineUSE_UIP_ETHERNETfalse#defineUSE_NATIVE_ETHERNETfalse

4. To use Teensy 4.1 NativeEthernet built-in module/shield withNativeEthernet library

#defineWEBSOCKETS_USE_ETHERNETtrue#defineUSE_ETHERNET_GENERICfalse#defineUSE_ETHERNET_ENCfalse#defineUSE_UIP_ETHERNETfalse#defineUSE_NATIVE_ETHERNETtrue

5. It's much easier just add to the sketch

#defineWEBSOCKETS_USE_ETHERNETtrue// Just select one to be true. If all is false, default is Ethernet.// If more than one are true, the priority is USE_NATIVE_ETHERNET, USE_ETHERNET_GENERIC, USE_ETHERNET_ENC, USE_UIP_ETHERNET#defineUSE_ETHERNET_GENERICtrue#defineUSE_ETHERNET_ENCfalse#defineUSE_UIP_ETHERNETfalse#defineUSE_NATIVE_ETHERNETfalse#if ( defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) && USE_NATIVE_ETHERNET )// Also default to Ethernet library  #include<NativeEthernet.h>  #defineETHERNET_TYPE"Teensy 4.1 NativeEthernet Library"#elif USE_ETHERNET_GENERIC// Also default to Ethernet_Generic library  #include<Ethernet_Generic.h>  #defineETHERNET_TYPE"W5x00 and Ethernet_Generic Library"#elif USE_ETHERNET_ENC  #include<EthernetENC.h>  #defineETHERNET_TYPE"ENC28J60 and EthernetENC Library"  #elif USE_UIP_ETHERNET  #include<UIPEthernet.h>  #include<utility/logging.h>   #defineETHERNET_TYPE"ENC28J60 and UIPEthernet Library" #else// Default to Ethernet_Generic library  #include<Ethernet_Generic.h>  #defineETHERNET_TYPE"W5x00 and Ethernet_Generic Library"#endif#ifndef USE_THIS_SS_PIN  #defineUSE_THIS_SS_PIN10// For other boards#endif


For Teensy 4.1 using NativeEthernet

Just as simple as:

#defineWEBSOCKETS_USE_ETHERNETtrue#defineUSE_NATIVE_ETHERNETtrue#defineUSE_QN_ETHERNETfalse


For Teensy 4.1 using QNEthernet

Just as simple as:

#defineWEBSOCKETS_USE_ETHERNETtrue#defineUSE_NATIVE_ETHERNETfalse#defineUSE_QN_ETHERNETtrue

To use ESP8266/ESP32 native WiFi

Default is usingESP8266/ESP32 native WiFi. You don't need to do anything special.


To use RP2040W built-in WiFi

#defineWEBSOCKETS_USE_RP2040Wtrue#defineUSE_RP2040W_WIFItrue#defineUSE_WIFI_NINAfalse


Examples

For ESP32 boards

  1. Esp32-Client
  2. Minimal-Esp32-Client
  3. Secured-Esp32-Client
  4. ESP32-Client_SINRIC
  5. Esp32-Server
  6. Esp32-RepeatingClient
  7. Esp32-AdvancedWebServer
  8. InSecured-Esp32-Client.New

For ESP8266 boards

  1. Esp8266-Client
  2. Minimal-Esp8266-Client
  3. Secured-Esp8266-Client
  4. SecuredTwoWay-Esp8266-Client
  5. ESP8266-Client_SINRIC
  6. Esp8266-Server
  7. Esp8266-RepeatingClient
  8. Esp8266-AdvancedWebServer
  9. InSecured-Esp8266-Client.New

For nRF52 boards using WiFiNINA

  1. nRF52-Client
  2. nRF52-Minimal-Client
  3. nRF52-Client_SINRIC
  4. nRF52-Server
  5. nRF52-RepeatingClient
  6. nRF52_ServerAllFunctionsDemo
  7. nRF52-AdvancedWebServer.

For SAMD21/SAMD51 boards using WiFiNINA

  1. SAMD-Client
  2. SAMD-Minimal-Client
  3. SAMD-Client_SINRIC
  4. SAMD-Server
  5. SAMD-RepeatingClient
  6. SAMD_ServerAllFunctionsDemo
  7. SAMD-AdvancedWebServer.

For SAMD21/SAMD51 boards using WiFi101

  1. SAMD_WiFi101-Client
  2. SAMD_WiFi101-Minimal-Client
  3. SAMD_WiFi101-Client_SINRIC
  4. SAMD_WiFi101-Server
  5. SAMD_WiFi101-RepeatingClient
  6. SAMD_WiFi101_ServerAllFunctionsDemo
  7. SAMD_WiFi101-AdvancedWebServer.

For STM32F/L/H/G/WB/MP1 boards using WiFiNINA

  1. STM32-Client
  2. STM32-Minimal-Client
  3. STM32-Client_SINRIC
  4. STM32-RepeatingClient
  5. STM32_ServerAllFunctionsDemo
  6. STM32-AdvancedWebServer.

For nRF52 boards using Ethernet (W5x00 or ENC28J60)

  1. nRF52-Ethernet-Client
  2. nRF52-Ethernet-Minimal-Client
  3. nRF52-Ethernet-Client_SINRIC
  4. nRF52-Ethernet-Server
  5. nRF52-Ethernet-RepeatingClient
  6. nRF52-Ethernet_ServerAllFunctionsDemo
  7. nRF52-Ethernet_AdvancedWebServer.

For SAMD21/SAMD51 boards using Ethernet (W5x00 or ENC28J60)

  1. SAMD-Ethernet-Client
  2. SAMD-Ethernet-Minimal-Client
  3. SAMD-Ethernet-Client_SINRIC
  4. SAMD-Ethernet-Server
  5. SAMD-Ethernet-RepeatingClient
  6. SAMD-Ethernet_ServerAllFunctionsDemo
  7. SAMD-Ethernet_AdvancedWebServer.

For SAM-DUE boards using Ethernet (W5x00 or ENC28J60)

  1. SAMDUE-Ethernet-Client
  2. SAMDUE-Ethernet-Minimal-Client
  3. SAMDUE-Ethernet-Client_SINRIC
  4. SAMDUE-Ethernet-Server
  5. SAMDUE-Ethernet-RepeatingClient
  6. SAMDUE-Ethernet_ServerAllFunctionsDemo
  7. SAMDUE-Ethernet_AdvancedWebServer.

For STM32F/L/H/G/WB/MP1 boards using Ethernet (W5x00, ENC28J60 or LAN8742A)

  1. STM32-Ethernet-Client
  2. STM32-Ethernet-Minimal-Client
  3. STM32-Ethernet-Client_SINRIC
  4. STM32-Ethernet-Server
  5. STM32-Ethernet-RepeatingClient
  6. STM32-Ethernet_ServerAllFunctionsDemo
  7. STM32-Ethernet_AdvancedWebServer.

For STM32F/L/H/G/WB/MP1 boards using Ethernet (LAN8720)

  1. STM32-Ethernet-Client_LAN8720
  2. STM32-Ethernet-Minimal-Client_LAN8720
  3. STM32-Ethernet-Client_SINRIC_LAN8720
  4. STM32-Ethernet-RepeatingClient_LAN8720

For Teensy boards using Ethernet (W5x00, ENC28J60 or LAN8742A). New in v1.1.0

  1. Teensy-Ethernet-Client
  2. Teensy-Ethernet-Minimal-Client
  3. Teensy-Ethernet-Client_SINRIC
  4. Teensy-Ethernet-Server
  5. Teensy-Ethernet-RepeatingClient
  6. Teensy-Ethernet_ServerAllFunctionsDemo
  7. Teensy-Ethernet_AdvancedWebServer.

For Teensy 4.1 boards using NativeEthernet (KSZ8081MNX/KSZ8081RNB). New in v1.1.0

  1. MultipleClients_Teensy41_Server
  2. SocketAndHttp_Teensy41_Server
  3. Teensy41_Client
  4. Teensy41_Server

For RP2040 boards using Ethernet (W5x00 or ENC28J60)

  1. RP2040-Ethernet-Client
  2. RP2040-Ethernet-Minimal-Client
  3. RP2040-Ethernet-Client_SINRIC
  4. RP2040-Ethernet-Server
  5. RP2040-Ethernet-RepeatingClient
  6. RP2040-Ethernet_ServerAllFunctionsDemo
  7. RP2040-Ethernet_AdvancedWebServer.

For WT32_ETH01 boards

  1. WT32_ETH01_AdvancedWebServer
  2. WT32_ETH01_Client
  3. WT32_ETH01_Client_SINRIC
  4. WT32_ETH01_InSecuredClient
  5. WT32_ETH01_MinimalClient
  6. WT32_ETH01_RepeatingClient
  7. WT32_ETH01_SecuredClient
  8. WT32_ETH01_Server.

For Teensy 4.1 boards using QNEthernet (KSZ8081MNX/KSZ8081RNB). New in v1.6.0

  1. MultipleClients_Teensy41_Server
  2. SocketAndHttp_Teensy41_Server
  3. Teensy41_Client
  4. Teensy41_Server

For Portenta_H7 boards using Vision-shield Ethernet. New in v1.7.0

  1. Portenta_H7_Ethernet_Client
  2. Portenta_H7_Ethernet_Server

For Portenta_H7 boards using Murata WiFi. New in v1.7.0

  1. Portenta_H7-AdvancedWebServer
  2. Portenta_H7-Client
  3. Portenta_H7-Client_SINRIC
  4. Portenta_H7-Minimal-Client
  5. Portenta_H7-RepeatingClient
  6. Portenta_H7-Server
  7. Portenta_H7_ServerAllFunctionsDemo

For RP2040 boards using WiFiNINA. New in v1.8.0

  1. RP2040-AdvancedWebServer
  2. RP2040-Client
  3. RP2040-Client_SINRIC
  4. RP2040-Minimal-Client
  5. RP2040-RepeatingClient
  6. RP2040-Server
  7. RP2040_ServerAllFunctionsDemo

For ESP32 boards using Ethernet. New in v1.11.0

  1. ESP32_Ethernet-Client
  2. ESP32_Ethernet-Minimal-Client
  3. ESP32_Ethernet-Client_SINRIC
  4. ESP32_Ethernet-Server
  5. ESP32_Ethernet-RepeatingClient
  6. ESP32_Ethernet_ServerAllFunctionsDemo
  7. ESP32_Ethernet_AdvancedWebServer.

For RP2040W boards using built-in WiFi. New in v1.13.0

  1. RP2040W-AdvancedWebServer
  2. RP2040W-Client
  3. RP2040W-Client_SINRIC
  4. RP2040W-Minimal-Client
  5. RP2040W-RepeatingClient
  6. RP2040W-Server
  7. RP2040W_ServerAllFunctionsDemo


Please take a look at other examples, as well.

#include"defines.h"
#defineDEBUG_LOCAL2
#include<WebSockets2_Generic.h>
#include<ArduinoJson.h>// https://arduinojson.org/ or install via Arduino library manager
usingnamespacewebsockets2_generic;
WebsocketsClient client;
#defineHEARTBEAT_INTERVAL300000// 5 Minutes
bool isConnected =false;
uint64_t heartbeatTimestamp =0;
uint64_t now =0;
//To increase no of devices as needed
voidturnOn(String deviceId)
{
if (deviceId == SINRIC_Device_ID_1)// Device ID of 1st device
{
#if (DEBUG_LOCAL > 1)
Serial.print("Turn on device id:");
Serial.println(deviceId);
#endif
digitalWrite(LED_PIN, HIGH);
}
else
{
#if (DEBUG_LOCAL > 1)
Serial.print("Turn on for unknown device id:");
Serial.println(deviceId);
#endif
}
}
//To increase no of devices as needed
voidturnOff(String deviceId)
{
if (deviceId == SINRIC_Device_ID_1)// Device ID of 1st device
{
#if (DEBUG_LOCAL > 1)
Serial.print("Turn off Device ID:");
Serial.println(deviceId);
#endif
digitalWrite(LED_PIN, LOW);
}
else
{
#if (DEBUG_LOCAL > 1)
Serial.print("Turn off for unknown device id:");
Serial.println(deviceId);
#endif
}
}
voidonEventsCallback(WebsocketsEvent event, String data)
{
(void) data;
if (event == WebsocketsEvent::ConnectionOpened)
{
if (!isConnected)
isConnected =true;
Serial.println("Connnection Opened");
}
elseif (event == WebsocketsEvent::ConnectionClosed)
{
if (isConnected)
isConnected =false;
Serial.println("Connnection Closed");
}
elseif (event == WebsocketsEvent::GotPing)
{
if (!isConnected)
isConnected =true;
Serial.println("Got a Ping!");
}
elseif (event == WebsocketsEvent::GotPong)
{
if (!isConnected)
isConnected =true;
Serial.println("Got a Pong!");
}
}
voidonMessagesCallback(WebsocketsMessage message)
{
String SINRIC_message = message.data();
Serial.print("Got Message:");
Serial.println(SINRIC_message/*message.data()*/);
// Example payloads
// For Switch or Light device types
// {"deviceId": xxxx, "action": "setPowerState", value: "ON"} // https://developer.amazon.com/docs/device-apis/alexa-powercontroller.html
// For Light device type
// Look at the light example in github
#if (ARDUINOJSON_VERSION_MAJOR >= 6)
DynamicJsonDocumentjson(1024);
//auto deserializeError = deserializeJson(json, (char*)message.data());
auto deserializeError =deserializeJson(json, SINRIC_message);
if ( deserializeError )
{
Serial.println("JSON parseObject() failed");
return;
}
//serializeJson(json, Serial);
#else
DynamicJsonBuffer jsonBuffer;
// Parse JSON string
JsonObject& json = jsonBuffer.parseObject(SINRIC_message);
// Test if parsing succeeds.
if (!json.success())
{
Serial.println("JSON parseObject() failed");
return;
}
#endif
String deviceId = json ["deviceId"];
String action = json ["action"];
if (action =="setPowerState")
{
// Switch or Light
String value = json ["value"];
if (value =="ON")
{
turnOn(deviceId);
}
else
{
turnOff(deviceId);
}
}
}
voidsetup()
{
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
Serial.begin(115200);
while (!Serial &&millis() <5000);
Serial.println("\nStarting SAMD-Client_SINRIC with WiFiNINA on" +String(BOARD_NAME));
Serial.println(WEBSOCKETS2_GENERIC_VERSION);
// check for the WiFi module:
if (WiFi.status() == WL_NO_MODULE)
{
Serial.println("Communication with WiFi module failed!");
// don't continue
return;
}
String fv = WiFi.firmwareVersion();
if (fv < WIFI_FIRMWARE_LATEST_VERSION)
{
Serial.println("Please upgrade the firmware");
}
Serial.print("Attempting to connect to SSID:");
Serial.println(ssid);
// Connect to wifi
WiFi.begin(ssid, password);
// Wait some time to connect to wifi
for (int i =0; i <10 && WiFi.status() != WL_CONNECTED; i++)
{
Serial.print(".");
delay(1000);
}
if (WiFi.status() == WL_CONNECTED)
{
Serial.print("Connected to Wifi, IP address:");
Serial.println(WiFi.localIP());
Serial.print("Connecting to WebSockets Server @");
Serial.println(websockets_server_host);
}
else
{
Serial.println("\nNo WiFi");
return;
}
// run callback when events are occuring
client.onMessage(onMessagesCallback);
// try to connect to Websockets server
client.addHeader("apikey", SINRIC_API_KEY);
client.setAuthorization("apikey", SINRIC_API_KEY);
bool connected = client.connect(websockets_server_host, websockets_server_port,"/");
if (connected)
{
Serial.println("Connected!");
}
else
{
Serial.println("Not Connected!");
}
}
voidloop()
{
// let the websockets client check for incoming messages
if (client.available())
{
client.poll();
now =millis();
// Send heartbeat in order to avoid disconnections during ISP resetting IPs over night. Thanks @MacSass
if ((now - heartbeatTimestamp) > HEARTBEAT_INTERVAL)
{
heartbeatTimestamp = now;
client.send("H");
}
}
}

2. Filedefines.h

#ifndefdefines_h
#definedefines_h
#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(WEBSOCKETS_WIFININA_USE_SAMD)
#undef WEBSOCKETS_WIFININA_USE_SAMD
#endif
#defineWEBSOCKETS_USE_WIFININA true
#defineWEBSOCKETS_WIFININA_USE_SAMD true
#else
#error This code is intended to run only on the SAMD boards ! Please check your Tools->Board setting.
#endif
#if defined(WEBSOCKETS_WIFININA_USE_SAMD)
#if defined(ARDUINO_SAMD_ZERO)
#defineBOARD_TYPE "SAMD Zero"
#elif defined(ARDUINO_SAMD_MKR1000)
#defineBOARD_TYPE "SAMD MKR1000"
#elif defined(ARDUINO_SAMD_MKRWIFI1010)
#defineBOARD_TYPE "SAMD MKRWIFI1010"
#elif defined(ARDUINO_SAMD_NANO_33_IOT)
#defineBOARD_TYPE "SAMD NANO_33_IOT"
#elif defined(ARDUINO_SAMD_MKRFox1200)
#defineBOARD_TYPE "SAMD MKRFox1200"
#elif ( defined(ARDUINO_SAMD_MKRWAN1300)|| defined(ARDUINO_SAMD_MKRWAN1310) )
#defineBOARD_TYPE "SAMD MKRWAN13X0"
#elif defined(ARDUINO_SAMD_MKRGSM1400)
#defineBOARD_TYPE "SAMD MKRGSM1400"
#elif defined(ARDUINO_SAMD_MKRNB1500)
#defineBOARD_TYPE "SAMD MKRNB1500"
#elif defined(ARDUINO_SAMD_MKRVIDOR4000)
#defineBOARD_TYPE "SAMD MKRVIDOR4000"
#elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS)
#defineBOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS"
#elif defined(ADAFRUIT_FEATHER_M0_EXPRESS)
#defineBOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS"
#elif defined(ADAFRUIT_METRO_M0_EXPRESS)
#defineBOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS"
#elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0)
#defineBOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0"
#elif defined(ADAFRUIT_GEMMA_M0)
#defineBOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0"
#elif defined(ADAFRUIT_TRINKET_M0)
#defineBOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0"
#elif defined(ADAFRUIT_ITSYBITSY_M0)
#defineBOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0"
#elif defined(ARDUINO_SAMD_HALLOWING_M0)
#defineBOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0"
#elif defined(ADAFRUIT_METRO_M4_EXPRESS)
#defineBOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS"
#elif defined(ADAFRUIT_GRAND_CENTRAL_M4)
#defineBOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4"
#elif defined(ADAFRUIT_FEATHER_M4_EXPRESS)
#defineBOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS"
#elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS)
#defineBOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS"
#elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS)
#defineBOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS"
#elif defined(ADAFRUIT_PYPORTAL)
#defineBOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL"
#elif defined(ADAFRUIT_PYPORTAL_M4_TITANO)
#defineBOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO"
#elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS)
#defineBOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS"
#elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE)
#defineBOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE"
#elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS)
#defineBOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS"
#elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS)
#defineBOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS"
#elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4)
#defineBOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4"
#elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
#defineBOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS"
#elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS)
#defineBOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS"
#elif defined(SEEED_WIO_TERMINAL)
#defineBOARD_TYPE "SAMD SEEED_WIO_TERMINAL"
#elif defined(SEEED_FEMTO_M0)
#defineBOARD_TYPE "SAMD SEEED_FEMTO_M0"
#elif defined(SEEED_XIAO_M0)
#defineBOARD_TYPE "SAMD SEEED_XIAO_M0"
#elif defined(Wio_Lite_MG126)
#defineBOARD_TYPE "SAMD SEEED Wio_Lite_MG126"
#elif defined(WIO_GPS_BOARD)
#defineBOARD_TYPE "SAMD SEEED WIO_GPS_BOARD"
#elif defined(SEEEDUINO_ZERO)
#defineBOARD_TYPE "SAMD SEEEDUINO_ZERO"
#elif defined(SEEEDUINO_LORAWAN)
#defineBOARD_TYPE "SAMD SEEEDUINO_LORAWAN"
#elif defined(SEEED_GROVE_UI_WIRELESS)
#defineBOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS"
#elif defined(__SAMD21E18A__)
#defineBOARD_TYPE "SAMD21E18A"
#elif defined(__SAMD21G18A__)
#defineBOARD_TYPE "SAMD21G18A"
#elif defined(__SAMD51G19A__)
#defineBOARD_TYPE "SAMD51G19A"
#elif defined(__SAMD51J19A__)
#defineBOARD_TYPE "SAMD51J19A"
#elif defined(__SAMD51J20A__)
#defineBOARD_TYPE "SAMD51J20A"
#elif defined(__SAM3X8E__)
#defineBOARD_TYPE "SAM3X8E"
#elif defined(__CPU_ARC__)
#defineBOARD_TYPE "CPU_ARC"
#elif defined(__SAMD51__)
#defineBOARD_TYPE "SAMD51"
#else
#defineBOARD_TYPE "SAMD Unknown"
#endif
#endif
#ifndefBOARD_NAME
#defineBOARD_NAME BOARD_TYPE
#endif
#include<WiFiNINA_Generic.h>
#defineDEBUG_WEBSOCKETS_PORT Serial
// Debug Level from 0 to 4
#define_WEBSOCKETS_LOGLEVEL_ 3
constchar*ssid="ssid";//Enter SSID
constchar*password="password";//Enter Password
#defineSINRIC_WEBSERVER "iot.sinric.com"
#defineSINRIC_WEBSERVER_PORT 80
#defineSINRIC_API_KEY "11111111-2222-3333-4444-555555555555"
#defineSINRIC_Device_ID_1 "012345678901234567890123" // Device ID, got from Sinric
constchar*websockets_server_host=SINRIC_WEBSERVER;//Enter server address
constuint16_twebsockets_server_port=SINRIC_WEBSERVER_PORT;// Enter server port
#ifdefLED_BUILTIN
#defineLED_PIN LED_BUILTIN
#else
#defineLED_PIN 13
#endif
#endif//defines_h


Using SINRIC Service

This is the terminal output when runningSAMD-Client_SINRIC example onNano-33 IoT:

Starting WebSockets2_Generic SAMD-Client_SINRIC with WiFiNINA on SAMD NANO_33_IOTWebSockets2_Generic v1.13.2WiFi-begin: return1 =3WiFi-begin: return2 =3Connected to Wifi, Connecting to WebSockets Server @iot.sinric.com[WS] WebsocketsClient::generateHandshake: base64Authorization = ***************[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host: iot.sinric.comSec-WebSocket-Key: *********apikey:11111111-2222-3333-4444-555555555555Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic ***************Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::generateHandshake: key = Server[WS] WebsocketsClient::generateHandshake: value = nginx/1.10.3 (Ubuntu)[WS] WebsocketsClient::generateHandshake: key = Date[WS] WebsocketsClient::generateHandshake: value = Tue,14 Jul202002:27:30 GMT[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = upgrade[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = *********Connected!Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"ON"}Turn on device id:012345678901234567890123Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"OFF"}Turn off Device ID:012345678901234567890123


Binary Data

For binary data it is recommended to usemsg.rawData() which returns astd::string, ormsg.c_str() which returns aconst char*.The reason is thatmsg.data() returns an ArduinoString, which is great for Serial printing and very basic memory handling but bad for most binary usages.

Seeissue #32 for further information.

SSL and WSS Support

No matter what board you are using, in order to use WSS (websockets over SSL) you need to use

client.connect("wss://your-secured-server-ip:port/uri");

The next sections describe board-specific code for using WSS with the library.

ESP8266

With the esp8266 there are multiple ways for using WSS. By default,ArduinoWebsockets does not validate the certificate chain. This can be set explicitly using:

client.setInsecure();

You can also use aSSL Fingerprint to validate the SSL connection, for example:

// To update SHA1 fingerprint, use Google Chrome to connect to https://www.websocket.org/echo.html// Then "View Site Information" => "Certificate Viewer" => Copy SHA1 fingerprint// KH, This SHA1 fingerprint was updated 15.04.2021,// Issued on Mar 15th 2021, expired on June 13th 2021constchar echo_org_ssl_fingerprint[] PROGMEM   ="34 A2 66 08 A1 4D 1E 83 1A 0E 49 3C 4A 84 45 9E 4A 0D 08 FE";client.setFingerprint(echo_org_ssl_fingerprint);

or you could use thesetKnownKey() method to specify the public key of a certificate in order to validate the server you are connecting to.

PublicKey *publicKey =new PublicKey(public_key);client.setKnownKey(publicKey);

or you can specify the Certificate Authority (CA) usingsetTrustAnchors method, as follows:

X509List *serverTrustedCA =new X509List(ca_cert);client.setTrustAnchors(serverTrustedCA);

For client-side certificate validation, you can use RSA or EC certificates, using the methodsetClientRSACert orsetClientECCert .

ESP32

With the ESP32 you could either provide the full certificate, or provide no certificate. An example for setting CA Certificate:

// KH, This certificate was updated 15.04.2021,// Issued on Mar 15th 2021, expired on June 13th 2021constchar echo_org_ssl_ca_cert[] PROGMEM = \"-----BEGIN CERTIFICATE-----\n" \"MIIEZTCCA02gAwIBAgIQQAF1BIMUpMghjISpDBbN3zANBgkqhkiG9w0BAQsFADA/\n" \"MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\n" \"DkRTVCBSb290IENBIFgzMB4XDTIwMTAwNzE5MjE0MFoXDTIxMDkyOTE5MjE0MFow\n" \"MjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUxldCdzIEVuY3J5cHQxCzAJBgNVBAMT\n" \"AlIzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuwIVKMz2oJTTDxLs\n" \"jVWSw/iC8ZmmekKIp10mqrUrucVMsa+Oa/l1yKPXD0eUFFU1V4yeqKI5GfWCPEKp\n" \"Tm71O8Mu243AsFzzWTjn7c9p8FoLG77AlCQlh/o3cbMT5xys4Zvv2+Q7RVJFlqnB\n" \"U840yFLuta7tj95gcOKlVKu2bQ6XpUA0ayvTvGbrZjR8+muLj1cpmfgwF126cm/7\n" \"gcWt0oZYPRfH5wm78Sv3htzB2nFd1EbjzK0lwYi8YGd1ZrPxGPeiXOZT/zqItkel\n" \"/xMY6pgJdz+dU/nPAeX1pnAXFK9jpP+Zs5Od3FOnBv5IhR2haa4ldbsTzFID9e1R\n" \"oYvbFQIDAQABo4IBaDCCAWQwEgYDVR0TAQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8E\n" \"BAMCAYYwSwYIKwYBBQUHAQEEPzA9MDsGCCsGAQUFBzAChi9odHRwOi8vYXBwcy5p\n" \"ZGVudHJ1c3QuY29tL3Jvb3RzL2RzdHJvb3RjYXgzLnA3YzAfBgNVHSMEGDAWgBTE\n" \"p7Gkeyxx+tvhS5B1/8QVYIWJEDBUBgNVHSAETTBLMAgGBmeBDAECATA/BgsrBgEE\n" \"AYLfEwEBATAwMC4GCCsGAQUFBwIBFiJodHRwOi8vY3BzLnJvb3QteDEubGV0c2Vu\n" \"Y3J5cHQub3JnMDwGA1UdHwQ1MDMwMaAvoC2GK2h0dHA6Ly9jcmwuaWRlbnRydXN0\n" \"LmNvbS9EU1RST09UQ0FYM0NSTC5jcmwwHQYDVR0OBBYEFBQusxe3WFbLrlAJQOYf\n" \"r52LFMLGMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjANBgkqhkiG9w0B\n" \"AQsFAAOCAQEA2UzgyfWEiDcx27sT4rP8i2tiEmxYt0l+PAK3qB8oYevO4C5z70kH\n" \"ejWEHx2taPDY/laBL21/WKZuNTYQHHPD5b1tXgHXbnL7KqC401dk5VvCadTQsvd8\n" \"S8MXjohyc9z9/G2948kLjmE6Flh9dDYrVYA9x2O+hEPGOaEOa1eePynBgPayvUfL\n" \"qjBstzLhWVQLGAkXXmNs+5ZnPBxzDJOLxhF2JIbeQAcH5H0tZrUlo5ZYyOqA7s9p\n" \"O5b85o3AM/OJ+CktFBQtfvBhcJVd9wvlwPsk+uyOy2HI7mNxKKgsBTt375teA2Tw\n" \"UdHkhVNcsAKX1H7GNNLOEADksd86wuoXvg==\n" \"-----END CERTIFICATE-----\n";client.setCACert(echo_org_ssl_ca_cert);

From v1.2.4, you can use InSecured mode which does not validate the certificate chain. This can be set explicitly using:

client.setInsecure();


Debug Terminal Output Samples

1.SAMD-Ethernet-Client_SINRIC on SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS using ENC28J60

This is terminal debug output when runningSAMD-Ethernet-Client_SINRIC on SAMD51ADAFRUIT_ITSYBITSY_M4_EXPRESS using ENC28J60 Ethernet module.

Starting WebSockets2_Generic SAMD-Ethernet-Client_SINRIC on SAMD ADAFRUIT_ITSYBITSY_M4_EXPRESSEthernetusing ENC28J60and UIPEthernet LibraryWebSockets2_Generic v1.13.2ENC28J60_CONTROL_CS =16SS =16SPI_MOSI =25SPI_MISO =23SPI_SCK =24WebSockets Client IP address:192.168.2.137Connecting to WebSockets Server @iot.sinric.com[WS] WebsocketsClient::generateHandshake: base64Authorization = ********[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host: iot.sinric.comSec-WebSocket-Key: ********apikey:11111111-2222-3333-4444-555555555555Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic ********Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = ********[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Switching Protocols[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::generateHandshake: key = Server[WS] WebsocketsClient::generateHandshake: value = nginx/1.10.3 (Ubuntu)[WS] WebsocketsClient::generateHandshake: key = Date[WS] WebsocketsClient::generateHandshake: value = Fri,17 Jul202000:04:17 GMT[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = upgrade[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = ********Connected!Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"ON"}Turn on device id:012345678901234567890123Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"OFF"}Turn off Device ID:012345678901234567890123

2.SAMDUE-Ethernet-Server on SAM-DUE with W5100 using Ethernet_Generic library

This is terminal debug output when runningSAMDUE-Ethernet-Server onSAM DUE board with Ethernet W5100 shield using Ethernet_Generic library, and receiving WebSockets connection from an ESP8266 board.

Starting WebSockets2_Generic SAMDUE-Ethernet-Server on SAM DUEEthernetusing W5x00and Ethernet_Generic LibraryWebSockets2_Generic v1.13.2[WS] =========== USE_ETHERNET_GENERIC ===========[WS] Default SPI pinout:[WS] MOSI:75[WS] MISO:74[WS] SCK:76[WS] SS:10[WS] =========================[WS] SAM DUE  setCsPin:10[WS] =========================[WS] Currently Used SPI pinout:[WS] MOSI:75[WS] MISO:74[WS] SCK:76[WS] SS:10[WS] =========================WebSockets Server Runningand Ready on SAM DUEIP address:192.168.2.153, Port:8080H[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.153[WS] WebsocketsServer::recvHandshakeRequest: value = ********[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericGot Message: Hello to Server from ESP8266[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.153[WS] WebsocketsServer::recvHandshakeRequest: value = ********[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericGot Message: Hello to Server from ESP8266HHHHHHHHH

3.nRF52-Ethernet-Server on Adafruit NRF52840_ITSYBITSY_EXPRESS with ENC28J60 using UIPEthernet library

This is terminal debug output when runningnRF52-Ethernet-Server onAdafruit NRF52840_ITSYBITSY_EXPRESS board with Ethernet ENC28J60 shield using UIPEthernet library, and receiving WebSockets connection from an ESP8266 board.

Starting WebSockets2_Generic nRF52-Ethernet-Server on NRF52840_ITSYBITSY_EXPRESSEthernetusing ENC28J60and UIPEthernet LibraryWebSockets2_Generic v1.13.2ENC28J60_CONTROL_CS =10SS =5SPI_MOSI =24SPI_MISO =23SPI_SCK =25WebSockets Server Runningand Ready on NRF52840_ITSYBITSY_EXPRESSIP address:192.168.2.95, Port:8080H[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.95[WS] WebsocketsServer::recvHandshakeRequest: value = ********[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericGot Message: Hello to Server from ESP8266[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.95[WS] WebsocketsServer::recvHandshakeRequest: value = ********[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericGot Message: Hello to Server from ESP8266HHHHHHHHH

4.STM32-Ethernet-Client_SINRIC on STM32F7 Nucleo-144 NUCLEO_F767ZI with built-in Ethernet LAN8742A using STMEthernet library

This is terminal debug output when runningSTM32-Ethernet-Client_SINRIC onSTM32F7 Nucleo-144 NUCLEO_F767ZI board with built-in Ethernet LAN8742A using STMEthernet library.

Starting WebSockets2_Generic STM32-Ethernet-Client_SINRIC on NUCLEO_F767ZIEthernetusing LAN8742Aand STM32Ethernet LibraryWebSockets2_Generic v1.13.2[WS] =========== USE_LAN8742A_ETHERNET ===========WebSockets Client IP address:192.168.2.135Connecting to WebSockets Server @iot.sinric.com[WS] WebsocketsClient::generateHandshake: base64Authorization = ********[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host: iot.sinric.comSec-WebSocket-Key: ********apikey:11111111-2222-3333-4444-555555555555Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic ********Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = ********[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Switching Protocols[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::generateHandshake: key = Server[WS] WebsocketsClient::generateHandshake: value = nginx/1.10.3 (Ubuntu)[WS] WebsocketsClient::generateHandshake: key = Date[WS] WebsocketsClient::generateHandshake: value = Sat,18 Jul202006:42:54 GMT[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = upgrade[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = ********Connected!Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"ON"}Turn on device id:012345678901234567890123Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"OFF"}Turn off Device ID:012345678901234567890123

5.SAMDUE-Ethernet_ServerAllFunctionsDemo example on SAM-DUE and W5100 Ethernet

This is the terminal debug output when runningSAMDUE-Ethernet_ServerAllFunctionsDemo example onSAM DUE and W5100 Ethernet. There are 3 WebSockets Clients connecting to the WebSockets Server:

Start Generic_WebSocketServerAllFunctionsDemo_W5500WebSockets2_Generic v1.13.2[WS] =========== USE_ETHERNET_GENERIC ===========[WS] Default SPI pinout:[WS] MOSI:75[WS] MISO:74[WS] SCK:76[WS] SS:10[WS] =========================[WS] SAM DUE  setCsPin:10[WS] =========================[WS] Currently Used SPI pinout:[WS] MOSI:75[WS] MISO:74[WS] SCK:76[WS] SS:10[WS] =========================WebSockets Server IP address:192.168.2.95WebSockets Server Runningand Ready on SAM DUEIP address:192.168.2.95, Port:8080[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.95[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericGot Message: Hello to Server from ESP8266[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.95[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericGot Message: Hello to Server from ESP8266[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.95[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericGot Message: Hello to Server from ESP32[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.95[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericGot Message: Hello to Server from NUCLEO_F767ZI[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.95[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericGot Message: Hello to Server from ESP32...

6.STM32-Ethernet-Client_SINRIC_LAN8720 on BLACK_F407VE using LAN8720 and STM32Ethernet Library

This is terminal debug output when runningSTM32-Ethernet-Client_SINRIC_LAN8720 onBLACK_F407VE using LAN8720 and STM32Ethernet Library.

Starting STM32-Ethernet-Client_SINRIC_LAN8720 on BLACK_F407VEEthernetusing LAN8720and STM32Ethernet LibraryWebSockets2_Generic v1.13.2[WS] =========== USE_LAN8720_ETHERNET ===========WebSockets Client IP address:192.168.2.160Connecting to WebSockets Server @iot.sinric.com[WS] WebsocketsClient::generateHandshake: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host: iot.sinric.comSec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==apikey:"11111111-2222-3333-4444-555555555555"Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Switching Protocols[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::generateHandshake: key = Server[WS] WebsocketsClient::generateHandshake: value = nginx/1.10.3 (Ubuntu)[WS] WebsocketsClient::generateHandshake: key = Date[WS] WebsocketsClient::generateHandshake: value = Fri,16 Apr202103:03:10 GMT[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = upgrade[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=Connected!Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"ON"}Turn on device id:012345678901234567890123Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"OFF"}Turn off Device ID:012345678901234567890123

7.ESP32-Client_SINRIC on ESP32S2_DEV

This is terminal debug output when runningESP32-Client_SINRIC onESP32S2_DEV

Starting ESP32-Client_SINRIC on ESP32S2_DEVWebSockets2_Generic v1.13.2....Connected to Wifi, Connecting to WebSockets Server @iot.sinric.com[WS] WebsocketsClient::generateHandshake: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host: iot.sinric.comSec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==apikey:"11111111-2222-3333-4444-555555555555"Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Switching Protocols[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::generateHandshake: key = Server[WS] WebsocketsClient::generateHandshake: value = nginx/1.10.3 (Ubuntu)[WS] WebsocketsClient::generateHandshake: key = Date[WS] WebsocketsClient::generateHandshake: value = Thu,15 Apr202122:44:28 GMT[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = upgrade[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=Connected!Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"ON"}Turn on device id:012345678901234567890123Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"OFF"}Turn off Device ID:012345678901234567890123

8.Secured-ESP32-Client on ESP32S2_DEV

This is terminal debug output when runningSecured-ESP32-Client onESP32S2_DEV

Starting WebSockets Secured-ESP32-Client on ESP32S2_DEVWebSockets2_Generic v1.13.2....Connected to Wifi, Connecting to WebSockets Server @wss://echo.websocket.org/[WS] WebsocketsClient::doestStartsWith: str = wss://echo.websocket.org/[WS] WebsocketsClient::doestStartsWith: prefix = wss://[WS] WebsocketsClient::generateHandshake: base64Authorization = [WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host: echo.websocket.orgSec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = [WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Web Socket Protocol Handshake[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Credentials[WS] WebsocketsClient::generateHandshake: value =true[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = content-type[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = authorization[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = x-websocket-extensions[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = x-websocket-version[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = x-websocket-protocol[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Origin[WS] WebsocketsClient::generateHandshake: value = https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = Upgrade[WS] WebsocketsClient::generateHandshake: key = Date[WS] WebsocketsClient::generateHandshake: value = Fri,16 Apr202119:34:42 GMT[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=[WS] WebsocketsClient::generateHandshake: key = Server[WS] WebsocketsClient::generateHandshake: value = Kaazing Gateway[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocketConnection OpenedConnected!Got Message: Hello to Server from ESP32S2_DEVGot a Pong!

9.InSecured-ESP32-Client on ESP32_DEV

This is terminal debug output when runningInSecured-ESP32-Client onESP32_DEV

Starting WebSockets InSecured-ESP32-Client on ESP32_DEVWebSockets2_Generic v1.13.2...Connected to Wifi, Connecting to WebSockets Server @wss://echo.websocket.org/[WS] WebsocketsClient::doestStartsWith: str = wss://echo.websocket.org/[WS] WebsocketsClient::doestStartsWith: prefix = wss://[WS] WebsocketsClient::generateHandshake: base64Authorization = [WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host: echo.websocket.orgSec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = [WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Web Socket Protocol Handshake[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Credentials[WS] WebsocketsClient::generateHandshake: value =true[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = content-type[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = authorization[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = x-websocket-extensions[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = x-websocket-version[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = x-websocket-protocol[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Origin[WS] WebsocketsClient::generateHandshake: value = https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = Upgrade[WS] WebsocketsClient::generateHandshake: key = Date[WS] WebsocketsClient::generateHandshake: value = Wed,05 May202117:09:23 GMT[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=[WS] WebsocketsClient::generateHandshake: key = Server[WS] WebsocketsClient::generateHandshake: value = Kaazing Gateway[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocketConnection OpenedConnected!Got Message: Hello to Server from ESP32_DEVGot a Pong!

10.ESP8266-Client_SINRIC on ESP8266_NODEMCU_ESP12E

This is terminal debug output when runningESP8266-Client_SINRIC onESP8266_NODEMCU_ESP12E

Starting ESP8266-Client_SINRIC on ESP8266_NODEMCU_ESP12EWebSockets2_Generic v1.13.2......Connected to Wifi, Connecting to WebSockets Server @iot.sinric.com[WS] WebsocketsClient::generateHandshake: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host: iot.sinric.comSec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==apikey: api_keyUpgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Switching Protocols[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::generateHandshake: key = Server[WS] WebsocketsClient::generateHandshake: value = nginx/1.10.3 (Ubuntu)[WS] WebsocketsClient::generateHandshake: key = Date[WS] WebsocketsClient::generateHandshake: value = Fri,21 May202104:06:49 GMT[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = upgrade[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=Connected!

11.RP2040-Ethernet-Client_SINRIC on RASPBERRY_PI_PICO

This is terminal debug output when runningRP2040-Ethernet-Client_SINRIC onRASPBERRY_PI_PICO usingEarle Philhower's arduino-pico core

Starting RP2040-Ethernet-Client_SINRIC on RASPBERRY_PI_PICOEthernetusing W5x00and Ethernet_Generic LibraryWebSockets2_Generic v1.13.2[WS] =========== USE_ETHERNET_GENERIC ===========[WS] Default SPI pinout:[WS] MOSI:19[WS] MISO:16[WS] SCK:18[WS] SS:17[WS] =========================[WS] RASPBERRY_PI_PICO setCsPin:17[WS] =========================[WS] Currently Used SPI pinout:[WS] MOSI:19[WS] MISO:16[WS] SCK:18[WS] SS:17[WS] =========================WebSockets Client IP address:192.168.2.152Connecting to WebSockets Server @iot.sinric.com[WS] WebsocketsClient::connect: step1[WS] WebsocketsClient::generateHandshake: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host: iot.sinric.comSec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==apikey:11111111-2222-3333-4444-555555555555Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==[WS] WebsocketsClient::connect: step2[WS] WebsocketsClient::connect: step3[WS] WebsocketsClient::connect: step4[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Switching Protocols[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::connect: step5[WS] WebsocketsClient::connect: step6[WS] WebsocketsClient::generateHandshake: key = Server[WS] WebsocketsClient::generateHandshake: value = nginx/1.10.3 (Ubuntu)[WS] WebsocketsClient::generateHandshake: key = Date[WS] WebsocketsClient::generateHandshake: value = Tue,25 May202104:51:41 GMT[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = upgrade[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=[WS] WebsocketsClient::connect: step7Connected!Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"ON"}Turn onfor unknown device id:012345678901234567890123Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"OFF"}Turn offfor unknown device id:012345678901234567890123

12.RP2040-Ethernet-Client_SINRIC on MBED RaspberryPi Pico

This is terminal debug output when runningRP2040-Ethernet-Client_SINRIC onMBED RaspberryPi Pico usingArduino-mbed RP2040 core.

Starting RP2040-Ethernet-Client_SINRIC on RaspberryPi PicoEthernetusing W5x00and Ethernet_Generic LibraryWebSockets2_Generic v1.13.2[WS] =========== USE_ETHERNET_GENERIC ===========[WS] Default SPI pinout:[WS] MOSI:19[WS] MISO:16[WS] SCK:18[WS] SS:17[WS] =========================[WS] MBED RASPBERRY_PI_PICO setCsPin:17[WS] =========================[WS] Currently Used SPI pinout:[WS] MOSI:19[WS] MISO:16[WS] SCK:18[WS] SS:17[WS] =========================WebSockets Client IP address:192.168.2.152Connecting to WebSockets Server @iot.sinric.com[WS] WebsocketsClient::connect: step1[WS] WebsocketsClient::generateHandshake: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host: iot.sinric.comSec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==apikey:11111111-2222-3333-4444-555555555555Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==[WS] WebsocketsClient::connect: step2[WS] WebsocketsClient::connect: step3[WS] WebsocketsClient::connect: step4[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Switching Protocols[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::connect: step5[WS] WebsocketsClient::connect: step6[WS] WebsocketsClient::generateHandshake: key = Server[WS] WebsocketsClient::generateHandshake: value = nginx/1.10.3 (Ubuntu)[WS] WebsocketsClient::generateHandshake: key = Date[WS] WebsocketsClient::generateHandshake: value = Tue,25 May202104:57:32 GMT[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = upgrade[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=[WS] WebsocketsClient::connect: step7Connected!Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"ON"}Turn on device id:012345678901234567890123Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"OFF"}Turn off Device ID:012345678901234567890123

13.WT32_ETH01_Client_SINRIC on WT32_ETH01 (ESP32 + LAN8720)

This is terminal debug output when runningWT32_ETH01_Client_SINRIC onWT32_ETH01 (ESP32 + LAN8720) board.

Starting WT32_ETH01_Client_SINRIC on ESP32_DEV with ETH_PHY_LAN8720WebServer_WT32_ETH01 v1.5.1WebSockets2_Generic v1.13.2ETH MAC: A8:03:2A:A1:61:73, IPv4:192.168.2.232, FULL_DUPLEX, 100MbpsConnected. Connecting to WebSockets Server @iot.sinric.com[WS] WebsocketsClient::generateHandshake: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host: iot.sinric.comSec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==apikey:11111111-2222-3333-4444-555555555555Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Switching Protocols[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::generateHandshake: key = Server[WS] WebsocketsClient::generateHandshake: value = nginx/1.10.3 (Ubuntu)[WS] WebsocketsClient::generateHandshake: key = Date[WS] WebsocketsClient::generateHandshake: value = Thu,08 Jul202118:13:14 GMT[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = upgrade[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=Connected!Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"ON"}Turn on device id:012345678901234567890123Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"OFF"}Turn off Device ID:012345678901234567890123

14.WT32_ETH01_SecuredClient on WT32_ETH01 (ESP32 + LAN8720)

This is terminal debug output when runningWT32_ETH01_SecuredClient onWT32_ETH01 (ESP32 + LAN8720) board.

Starting WT32_ETH01_SecuredClient on ESP32_DEV with ETH_PHY_LAN8720WebServer_WT32_ETH01 v1.5.1WebSockets2_Generic v1.13.2ETH MAC: A8:03:2A:A1:61:73, IPv4:192.168.2.232, FULL_DUPLEX, 100MbpsConnected. Connecting to WebSockets Server @wss://echo.websocket.org/[WS] WebsocketsClient::doestStartsWith: str = wss://echo.websocket.org/[WS] WebsocketsClient::doestStartsWith: prefix = wss://[WS] WebsocketsClient::generateHandshake: base64Authorization = [WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host: echo.websocket.orgSec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = [WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Web Socket Protocol Handshake[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Credentials[WS] WebsocketsClient::generateHandshake: value =true[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = content-type[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = authorization[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = x-websocket-extensions[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = x-websocket-version[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Headers[WS] WebsocketsClient::generateHandshake: value = x-websocket-protocol[WS] WebsocketsClient::generateHandshake: key = Access-Control-Allow-Origin[WS] WebsocketsClient::generateHandshake: value = https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = Upgrade[WS] WebsocketsClient::generateHandshake: key = Date[WS] WebsocketsClient::generateHandshake: value = Thu,08 Jul202118:31:34 GMT[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=[WS] WebsocketsClient::generateHandshake: key = Server[WS] WebsocketsClient::generateHandshake: value = Kaazing Gateway[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocketConnection OpenedConnected!Got Message: Hello to Server from ESP32_DEVGot a Pong!

15.WT32_ETH01_AdvancedWebServer on WT32_ETH01 (ESP32 + LAN8720)

This is terminal debug output when runningWT32_ETH01_AdvancedWebServer onWT32_ETH01 (ESP32 + LAN8720) board.

Starting WT32_ETH01_AdvancedWebServer on ESP32_DEV with ETH_PHY_LAN8720WebServer_WT32_ETH01 v1.5.1WebSockets2_Generic v1.13.2ETH MAC: A8:03:2A:A1:61:73, IPv4:192.168.2.95, FULL_DUPLEX, 100MbpsMDNS responder startedWebSockets Server Runningand Ready on WT32-ETH01IP address:192.168.2.95, Port:8080HTTP server started[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.95[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericGot Message: [WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.95[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericGot Message:

16.SocketAndHttp_Teensy41_Server on TEENSY 4.1 using QNEthernet

This is terminal debug output and screenshot when runningSocketAndHttp_Teensy41_Server onTEENSY 4.1 using QNEthernet.

Start SocketAndHttp_Teensy41_Server on TEENSY4.1using QNEthernetWebSockets2_Generic v1.13.2=========== USE_QN_ETHERNET ===========Initialize Ethernetusing DHCP => Connected! IP address:192.168.2.119Visit http://192.168.2.119 in the browser to connect.[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.119[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericAcceptednew websockets client at index0Got Message: Hello to Server from ESP32Http client connected!Http client connected!Connection closed[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.119[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericAcceptednew websockets client at index0Got Message: Hello to Server from ESP32

17.MultiClients_Teensy41_Server on TEENSY 4.1 using QNEthernet

This is terminal debug output when runningMultiClients_Teensy41_Server onTEENSY 4.1 using QNEthernet.

17.1 Server
Starting MultiClients_Teensy41_Server on TEENSY4.1using QNEthernetWebSockets2_Generic v1.13.2=========== USE_QN_ETHERNET ===========Initialize Ethernetusing DHCP => Connected! IP address:192.168.2.119Server available at ws://192.168.2.119:81[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.119[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericAcceptednew websockets client at index0Got Message: Hello to Server from ESP32Connection closed[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.119[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericAcceptednew websockets client at index0Got Message: Hello to Server from ESP32
17.2 Client
Starting ESP32-RepeatingClient on ESP32_DEVWebSockets2_Generic v1.13.2....Connected to Wifi, Connecting to WebSockets Server @192.168.2.119[WS] WebsocketsClient::generateHandshake: base64Authorization = [WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host:192.168.2.119Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = [WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Switching Protocols[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = Upgrade[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Version[WS] WebsocketsClient::generateHandshake: value =13[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=Connection OpenedConnected!Got Message: Hello from TeensyGot Message: Echo: Hello to Server from ESP32

18.Portenta_H7_Ethernet_Server on PORTENTA_H7_M7 Ethernet

This is terminal debug output when runningPortenta_H7_Ethernet_Server onPORTENTA_H7_M7 Ethernet using Portenta_Ethernet Library

Starting Portenta_H7_Ethernet_Server on PORTENTA_H7_M7 Ethernetusing Portenta_Ethernet LibraryWebSockets2_Generic v1.13.2WebSockets Client @ IP address:192.168.2.132Server available at ws://192.168.2.132:8080[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.132[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericClient connectedGot Message: Hello to Server from ESP8266Client closed[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.132[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericClient connectedGot Message: Hello to Server from ESP8266

19.Portenta_H7-Client_SINRIC using WiFi on PORTENTA_H7_M7

This is terminal debug output when runningPortenta_H7-Client_SINRIC onPORTENTA_H7_M7 usingMurata WiFi

Starting Portenta_H7-Client_SINRICusing WiFi on PORTENTA_H7_M7WebSockets2_Generic v1.13.2Connecting to SSID: HueNet1Connected to Wifi, IP address:192.168.2.130Connecting to WebSockets Server @iot.sinric.com[WS] WebsocketsClient::generateHandshake: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host: iot.sinric.comSec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==apikey:11111111-2222-3333-4444-555555555555Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Switching Protocols[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::generateHandshake: key = Server[WS] WebsocketsClient::generateHandshake: value = nginx/1.10.3 (Ubuntu)[WS] WebsocketsClient::generateHandshake: key = Date[WS] WebsocketsClient::generateHandshake: value = Sun,19 Sep202103:17:49 GMT[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = upgrade[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=Connected!Got Message: {"action":"test","sender":"web"}Got Message: {"action":"test","sender":"web"}Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"ON"}Turn on device id:012345678901234567890123Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"OFF"}Turn off Device ID:012345678901234567890123

20.RP2040-AdvancedWebServer using WiFiNINA on MBED NANO_RP2040_CONNECT

This is terminal debug output when runningPortenta_H7-Client_SINRIC onMBED NANO_RP2040_CONNECT using WiFiNINA

Starting RP2040-AdvancedWebServer with WiFiNINA on MBED NANO_RP2040_CONNECTWebSockets2_Generic v1.13.2Attempting to connect to SSID: HueNet1Connected to Wifi, IP address:192.168.2.96WebSockets Server Runningand Ready on MBED NANO_RP2040_CONNECTIP address:192.168.2.96, Port:8080[WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.96[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericGot Message: [WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.96[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericGot Message: [WS] WebsocketsServer::recvHandshakeRequest: value =192.168.2.96[WS] WebsocketsServer::recvHandshakeRequest: value = MDEyMzQ1Njc4OWFiY2RlZg==[WS] WebsocketsServer::recvHandshakeRequest: value = websocket[WS] WebsocketsServer::recvHandshakeRequest: value = Upgrade[WS] WebsocketsServer::recvHandshakeRequest: value =13[WS] WebsocketsServer::recvHandshakeRequest: value = TinyWebsockets Client[WS] WebsocketsServer::recvHandshakeRequest: value = Basic [WS] WebsocketsServer::recvHandshakeRequest: value = https://github.com/khoih-prog/Websockets2_GenericGot Message:

21.Teensy41_Client using QNEthernet on Teensy 4.1

This is terminal debug output when runningTeensy41_Client onTeensy 4.1 using QNEthernet

Starting Teensy41_Client on TEENSY4.1using QNEthernetWebSockets2_Generic v1.13.2=========== USE_QN_ETHERNET ===========Initialize Ethernetusingstatic IP => Connected! IP address:192.168.2.222[WS] WebsocketsClient::doestStartsWith: str = ws://192.168.2.30:8080[WS] WebsocketsClient::doestStartsWith: prefix = ws://[WS] WebsocketsClient::connect: step1[WS] QNEthernet::connect: ip =192.168.2.30 , port =8080[WS] WebsocketsClient::generateHandshake: base64Authorization = [WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host:192.168.2.30Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = [WS] WebsocketsClient::connect: step2[WS] WebsocketsClient::connect: step3[WS] WebsocketsClient::connect: step4[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Switching Protocols[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::connect: step5[WS] WebsocketsClient::connect: step6[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = Upgrade[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=[WS] WebsocketsClient::generateHandshake: key = Origin[WS] WebsocketsClient::generateHandshake: value = https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: step7Connected to server : ws://192.168.2.30:8080Got Message: Hello Server

22.ESP32_Ethernet-Client using W5x00 Ethernet on ESP32_DEV

This is terminal debug output when runningESP32_Ethernet-Client onESP32_DEV usingW5x00 Ethernet withEthernet_Generic Library

Starting ESP32_Ethernet-Client on ESP32_DEVEthernetusing W5x00and Ethernet_Generic LibraryWebSockets2_Generic v1.13.2[WS] Default SPI pinout:[WS] MOSI:23[WS] MISO:19[WS] SCK:18[WS] SS:5[WS] =========================[WS] ESP32 setCsPin:5[WS] =========================[WS] Currently Used SPI pinout:[WS] MOSI:23[WS] MISO:19[WS] SCK:18[WS] SS:5[WS] =========================Using mac index =1Connected! IP address:192.168.2.81WebSockets Client IP address:192.168.2.84Connecting to WebSockets Server @192.168.2.30[WS] WebsocketsClient::connect: step1[WS] WebsocketsClient::generateHandshake: base64Authorization = [WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host:192.168.2.30Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = [WS] WebsocketsClient::connect: step2[WS] WebsocketsClient::connect: step3[WS] WebsocketsClient::connect: step4[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Switching Protocols[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::connect: step5[WS] WebsocketsClient::connect: step6[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = Upgrade[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=[WS] WebsocketsClient::generateHandshake: key = Origin[WS] WebsocketsClient::generateHandshake: value = https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: step7Connection OpenedConnected!Got Message: Hello to Server from ESP32_DEV

23.ESP32_Ethernet-Client using ENC28J60 and EthernetENC Library on ESP32_DEV

This is terminal debug output when runningESP32_Ethernet-Client onESP32_DEV usingENC28J60 Ethernet withEthernetENC Library

Starting ESP32_Ethernet-Client on ESP32_DEVEthernetusing ENC28J60and EthernetENC LibraryWebSockets2_Generic v1.13.2[WS] Default SPI pinout:[WS] MOSI:23[WS] MISO:19[WS] SCK:18[WS] SS:5[WS] =========================[WS] ESP32 setCsPin:5Using mac index =7Connected! IP address:192.168.2.85WebSockets Client IP address:192.168.2.85Connecting to WebSockets Server @192.168.2.30[WS] WebsocketsClient::connect: step1[WS] WebsocketsClient::generateHandshake: base64Authorization = [WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host:192.168.2.30Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = [WS] WebsocketsClient::connect: step2[WS] WebsocketsClient::connect: step3[WS] WebsocketsClient::connect: step4[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Switching Protocols[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::connect: step5[WS] WebsocketsClient::connect: step6[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = Upgrade[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=[WS] WebsocketsClient::generateHandshake: key = Origin[WS] WebsocketsClient::generateHandshake: value = https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: step7Connection OpenedConnected!Got Message: Hello to Server from ESP32_DEVGot a Ping!Got a Ping!Got a Ping!

24.ESP32_Ethernet-Client using ENC28J60 and UIPEthernet Library on ESP32_DEV

This is terminal debug output when runningESP32_Ethernet-Client onESP32_DEV usingENC28J60 Ethernet withUIPEthernet Library

Starting ESP32_Ethernet-Client on ESP32_DEVEthernetusing ENC28J60and UIPEthernet LibraryWebSockets2_Generic v1.13.2[WS] Default SPI pinout:[WS] MOSI:23[WS] MISO:19[WS] SCK:18[WS] SS:5[WS] =========================[WS] ESP32 setCsPin:5Using mac index =7Connected! IP address:192.168.2.85WebSockets Client IP address:192.168.2.88Connecting to WebSockets Server @192.168.2.30[WS] WebsocketsClient::connect: step1[WS] WebsocketsClient::generateHandshake: base64Authorization = [WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host:192.168.2.30Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = [WS] WebsocketsClient::connect: step2[WS] WebsocketsClient::connect: step3[WS] WebsocketsClient::connect: step4[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1101 Switching Protocols[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1101[WS] WebsocketsClient::connect: step5[WS] WebsocketsClient::connect: step6[WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = Upgrade[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=[WS] WebsocketsClient::generateHandshake: key = Origin[WS] WebsocketsClient::generateHandshake: value = https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: step7Connection OpenedConnected!Got Message: Hello to Server from ESP32_DEVGot a Ping!Got a Ping!Got a Ping!

25.RP2040W-Client using built-in WiFi on RASPBERRY_PI_PICO_W

This is terminal debug output when runningRP2040W-Client onRASPBERRY_PI_PICO_W using built-inCYW43439 WiFi

Starting RP2040W-Client on RASPBERRY_PI_PICO_WWebSockets2_Generic v1.13.2Connecting to SSID: HueNet1SSID: HueNet1Local IP Address:192.168.2.77Connecting to WebSockets Server @192.168.2.30[WS] WebsocketsClient::generateHandshake: base64Authorization = [WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1Host:192.168.2.30Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==Upgrade: websocketConnection: UpgradeSec-WebSocket-Version:13User-Agent: TinyWebsockets ClientAuthorization: Basic Origin: https://github.com/khoih-prog/Websockets2_Generic[WS] WebsocketsClient::connect: base64Authorization = [WS] WebsocketsClient::generateHandshake: key = Upgrade[WS] WebsocketsClient::generateHandshake: value = websocket[WS] WebsocketsClient::generateHandshake: key = Connection[WS] WebsocketsClient::generateHandshake: value = Upgrade[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=[WS] WebsocketsClient::generateHandshake: key = Origin[WS] WebsocketsClient::generateHandshake: value = https://github.com/khoih-prog/Websockets2_GenericConnection OpenedConnected!Got Message: Hello to Server from RASPBERRY_PI_PICO_WGot a Ping!Got a Ping!


Screenshots

  1. This is the screenshot when runningSTM32-Ethernet_AdvancedWebServer example onSTM32F7 Nucleo-144 F767ZI and built-in LAN8742A Ethernet to demonstrate the new non-blocking feature of WebSockets Server enabling WebServer and WebSockets Server to run concurrently.

  1. This is the screenshot when runningSAMD-AdvancedWebServer example onArduino SAMD21 Nano-33-IoT and built-in WiFiNINA to demonstrate the new non-blocking feature of WebSockets Server enabling WebServer and WebSockets Server to run concurrently.

  1. This is the screenshot when runningEsp32-AdvancedWebServer example onESP32-S2 to demonstrate the new non-blocking feature of WebSockets Server enabling WebServer and WebSockets Server to run concurrently.

  1. This is the screenshot when runningWT32_ETH01_AdvancedWebServer onWT32_ETH01 (ESP32 + LAN8720) board to demonstrate the new non-blocking feature of WebSockets Server enabling WebServer and WebSockets Server to run concurrently.

  1. This is the screenshot when runningPortenta_H7-AdvancedWebServer onPortenta_H7 board, using WiFi, to demonstrate the new non-blocking feature of WebSockets Server enabling WebServer and WebSockets Server to run concurrently.

  1. This is the screenshot when runningRP2040-AdvancedWebServer onMBED NANO_RP2040_CONNECT using WiFiNINA, to demonstrate the new non-blocking feature of WebSockets Server enabling WebServer and WebSockets Server to run concurrently.

  1. This is the screenshot when runningRP2040W-AdvancedWebServer onRASPBERRY_PI_PICO_W using built-in WiFi, to demonstrate the new non-blocking feature of WebSockets Server enabling WebServer and WebSockets Server to run concurrently.



Debug

Debug is enabled by default onSerial. Debug Level from 0 to 4. To disable, change the_WEBSOCKETS_LOGLEVEL_ to 0

// Use this to output debug msgs to Serial#defineDEBUG_WEBSOCKETS_PORT     Serial// Use this to disable all output debug msgs//#define DEBUG_WEBSOCKETS_PORT// Debug Level from 0 to 4#define_WEBSOCKETS_LOGLEVEL_3

Troubleshooting

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



Issues

Submit issues to:WebSockets2_Generic issues



TO DO

  1. Support more boards
  2. Support ESP8266/ESP32-AT shields.
  3. Add SSL client support to Teensy, SAMD21/SAMD51 and nRF52 using WiFiNINA.
  4. Support more non-compatible Ethernet Libraries such as Ethernet_Shield_W5200, EtherCard, EtherSia
  5. Add mDNS features
  6. SupportESP8266 using newlwIP_w5500,lwIP_w5100 andlwIP_enc28j60 Ethernet libraries
  7. Add SSL server / client support to Ethernet (W5x00, ENC28J60, QNEthernet, etc.)

DONE

  1. Add support toArduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.)
  2. Add support toAdafruit SAMD21 (Itsy-Bitsy M0, Metro M0, Feather M0 Express, etc.).
  3. Add support toAdafruit SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.).
  4. Add support toAdafruit nRF52 ( Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc..
  5. Add support toWiFiNINA usingWiFiNINA_Generic library.
  6. Add support toSINRIC
  7. Split each example into several manageable files.
  8. Add support to SAM DUE.
  9. Add support toEthernet W5x00, using eitherEthernet,Ethernet2 orEthernetLarge library
  10. Add support toEthernet ENC28J60, usingUIPEthernet library (v2.0.8 and v2.0.9)
  11. Add support toSTM32F/L/H/G/WB/MP1.
  12. Add support toEthernet LAN8742A, usingSTM32Ethernet library andSTM32duino_LwIP library.
  13. Add support toSeeeduino SAMD21/SAMD51: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, Wio Terminal, Grove UI Wireless, etc.
  14. Addnon-blocking WebSockets Server feature to enable WS Server and WebServer runningconcurrently
  15. Add support toEthernet ENC28J60, usingEthernetENC library.
  16. Add support to Teensy using Ethernet libraries such asEthernet, Ethernet2, Ethernet3, EthernetLarge, EthernetENC, UIPEthernet.
  17. Add support to Teensy 4.1 using NativeEthernet libraries.
  18. Add support toEthernet LAN8720 usingSTM32Ethernet library, for boards such asNucleo-144 (F429ZI, NUCLEO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG), Discovery (DISCO_F746NG) andSTM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)
  19. Add support toESP32-S2
  20. Update to useLatest esp32 core v1.0.6.
  21. Add support toESP32-C3
  22. Add InSecure mode forESP32
  23. Add support to MKR1000 / MKR1010WiFi boards usingForked WiFi101 library
  24. Add support to RP2040-based boards, such asRASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, usingEarle Philhower's arduino-pico core v1.3.1+.
  25. Add support to RP2040-based boards, such asRASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, usingArduino-mbed RP2040 core.
  26. Add support toWT32_ETH01 boards using ESP32-based boards and LAN8720 Ethernet
  27. Add support to Teensy 4.1 built-in Ethernet usingQNEthernet library
  28. Add support toPortenta_H7, using eitherMurata WiFi orVision-shield Ethernet
  29. Add support toRP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, using WiFiNINA
  30. Auto detect ESP32 core to use for WT32_ETH01
  31. Fix bug in WT32_ETH01 examples to reduce connection time
  32. Reduce QNEthernet latency
  33. Fix bug when usingQNEthernet staticIP.
  34. Add staticIP option toNativeEthernet examples
  35. Use newEthernet_Generic library as default for W5x00.
  36. SupportSPI2 for ESP32
  37. Add support to SPI1 for RP2040 usingarduino-pico core
  38. Use newwaitForLink() function of QNEthernet
  39. Add support toESP32 using eitherW5x00 orENC28J60 Ethernet
  40. Add support to ENC28J60 usingEthernetENC orUIPEthernet Library for these supported boards:ESP32, nRF52, RP2040, SAM DUE, SAMD, STM32, Teensy
  41. Add support toRP2040W usingCYW43439 WiFi orEthernet witharduino-pico core
  42. Add astyle usingallman style. Restyle the library
  43. Using newWiFi101_Generic library for sending larger data


Contributions and Thanks

  1. Based on and modified fromGil Maimon's ArduinoWebsockets

  2. Thanks to good work ofMiguel Alexandre Wisintainer for initiating, inspriring, working with, developing, debugging and testing. Without that, support to nRF52, especiallyNINA_B302_ublox running as nRF52840 and NINA_B112_ublox running as nRF52832, has never been started and finished. Seeu-blox nina b

  3. Thanks to bug report and persistence ofJake to help identify and addnon-blocking WebSockets Server feature to v1.0.6 to enable WS Server and WebServer runningconcurrently. SeeSupport as Http server and the Websockets server on Arduino DUE andRunning Http and Websocket Servers concurrently.

  4. Thanks toarnoson code posted inArduinoWebsockets release 0.5.0 to provide support to Teensy 4.1 using NativeEthernet.

  5. ThanksLionel REICHERT for PRAdd setInsecure for esp32 #18 leading to v1.2.4.

  6. Thanks toJose A.Molina for the enhancement requestMKR1000 and WIFI problem and another problem #20, and help testing, leading to new version v1.3.0 to support WiFi101 and MKD1000 / MKR1010WiFi boards.

  7. Thanks toRobert Viens for posting the issueCompile error with Arduino Nano RP2040 #32, leading to v1.8.0.

  8. ThanksShawn Silverman,QNEthernet library author, for

  9. Thanks5b4wn for issue report and proposed fix inQNEthernet higher latency #38 leading to v1.10.1

gilmaimon
⭐️⭐️ Gil Maimon

tcpipchip
⭐️ Miguel Wisintainer

jakespeed1311
Jake

arnoson
arnoson

LioRei
Lionel REICHERT

Josua2012
Jose A. Molina

Sirpercal
Robert Viens

ssilverman
Shawn Silverman

5b4wn
5b4wn


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 and credits


Copyright

  1. Copyright (c) 2019- Gil Maimon
  2. Copyright (c) 2020- Khoi Hoang

About

A WebSocket Server and Client library for Arduino, based on RFC6455, for writing modern Websockets applications. Now support ESP8266, ESP32 (including ESP32-S2 Saola, AI-Thinker ESP-12K, WT32_ETH01, etc.), nRF52, SAMD21, SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, Teensy, RP2040-based, etc. boards, with WiFiNINA, Teensy 4.1 NativeEthernet/QNEthernet, …

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors5


[8]ページ先頭

©2009-2025 Movatter.jp