- Why do we need this WebSockets2_Generic library
- Changelog
- Prerequisites
- Installation
- Packages' Patches
- 1. For Adafruit nRF52840 and nRF52832 boards
- 2. For Teensy boards
- 3. For Arduino SAM DUE boards
- 4. For Arduino SAMD boards
- 5. For Adafruit SAMD boards
- 6. For Seeeduino SAMD boards
- 7. For STM32 boards
- 8. For RP2040-based boards using Earle Philhower arduino-pico core
- 9. For Portenta_H7 boards using Arduino IDE in Linux
- Libraries' Patches
- Note for Platform IO using ESP32 LittleFS
- HOWTO Use analogRead() with ESP32 running WiFi and/or BlueTooth (BT/BLE)
- HOWTO use STM32F4 with LAN8720
- Important Notes
- Basic Usage
- HOWTO use WiFiNINA module/shield with WiFiNINA_Generic library
- For SAMD21/SAMD51, nRF52, SAM DUE using Ethernet W5x0 or ENC28J60
- For STM32F/L/H/G/WB/MP1 using Ethernet W5x0, ENC28J60, LAN8720 or LAN8742A
- For Teensy 4.1, 4.0, 3.x using Ethernet W5x0, ENC28J60 or LAN8742A
- For Teensy 4.1 using NativeEthernet
- For Teensy 4.1 using QNEthernet
- To use ESP8266/ESP32 native WiFi
- Examples
- For ESP32 boards
- For ESP8266 boards
- For nRF52 boards using WiFiNINA
- For SAMD21/SAMD51 boards using WiFiNINA
- For SAMD21/SAMD51 boards using WiFi101
- For STM32F/L/H/G/WB/MP1 boards using WiFiNINA
- For nRF52 boards using Ethernet (W5x00 or ENC28J60)
- For SAMD21/SAMD51 boards using Ethernet (W5x00 or ENC28J60)
- For SAM-DUE boards using Ethernet (W5x00 or ENC28J60)
- For STM32F/L/H/G/WB/MP1 boards using Ethernet (W5x00, ENC28J60 or LAN8742A)
- For STM32F/L/H/G/WB/MP1 boards using Ethernet (LAN8720)
- For Teensy boards using Ethernet (W5x00, ENC28J60 or LAN8742A). New in v1.1.0
- For Teensy 4.1 boards using NativeEthernet (KSZ8081MNX/KSZ8081RNB). New in v1.1.0
- For RP2040 boards using Ethernet (W5x00 or ENC28J60).
- For WT32_ETH01 boards. New
- For Teensy 4.1 boards using QNEthernet (KSZ8081MNX/KSZ8081RNB). New in v1.6.0 New
- For Portenta_H7 boards using Vision-shield Ethernet. New in v1.7.0 New
- For Portenta_H7 boards using Murata WiFi. New in v1.7.0 New
- For RP2040 boards using WiFiNINA. New in v1.8.0 New
- Example SAMD-Client_SINRIC
- Using SINRIC Service
- Binary Data
- SSL and WSS Support
- Debug Terminal Output Samples
- Screenshots
- Debug
- Troubleshooting
- Issues
- TO DO
- DONE
- Contributions and Thanks
- Contributing
- License and credits
- Copyright
Why do we need this WebSockets2_Generic library
Many Web services require WebSockets library, which is so far written only for ESP8266/ESP32 boards. The ESP boards so far rely on the Markus Sattler's WebSockets Library to connect to Alexa via Sinric or SinricPro skills.
This WebSockets2_Generic library is based on and modified from Gil Maimon's ArduinoWebSockets Library to provide support to many more boards, such as WT32_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 run WebSockets Server. The WebSockets can be used with ESP’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 see the TinyWebsockets wiki for roughly-accurate information about the API not covered here.
- text frame
- binary frame
- connection close
- ping
- pong
- continuation frame
This WebSockets_Generic2 library currently supports these following boards:
-
nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.
-
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.
- 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
- SAM DUE
- Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0)
- 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
-
ESP32
-
ESP8266
-
RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core or Earle Philhower's arduino-pico core.
-
WT32_ETH01 boards using ESP32-based boards and LAN8720 Ethernet
-
Portenta_H7 using either
Murata WiFi
orVision-shield Ethernet
-
RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, using WiFiNINA
- WiFiNINA using
WiFiNINA_Generic library
- WiFi101 using
Modified WiFi101 library
- U-Blox W101, W102 using
WiFiNINA_Generic library
- ESP32 and ESP8266 WiFi
- Portenta_H7 built-in Murata WiFi
- W5x00 using
Ethernet
,EthernetLarge
,Ethernet2
orEthernet3
library - ENC28J60 using
EthernetENC
orUIPEthernet
library - LAN8720 Ethernet used in WT32_ETH01 boards
- Teensy 4.1 built-in Ethernet using
NativeEthernet
library - Teensy 4.1 built-in Ethernet using
QNEthernet
library - Portenta_H7 using Ethernet from Portenta Vision shields
-
Arduino AVR core 1.8.3+
for Arduino (Use Arduino Board Manager) AVR boards. -
Teensy core v1.55+
for Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0) boards. -
Arduino SAM DUE core v1.6.12+
for SAM DUE ARM Cortex-M3 boards. -
Arduino SAMD core 1.8.11+
for SAMD ARM Cortex-M0+ boards. -
Adafruit SAMD core 1.7.5+
for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). -
Seeeduino SAMD core 1.8.2+
for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.). -
Adafruit nRF52 v1.1.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. -
ESP32 Core 2.0.0+
for ESP32-based boards. -
ESP8266 Core 3.0.2+
for ESP8266-based boards. . To use ESP8266 core 2.7.1+ for LittleFS. -
ArduinoCore-mbed mbed_rp2040, mbed_nano, mbed_portenta core 2.5.2+
for Arduino (Use Arduino Board Manager) Portenta_H7, RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO. -
Earle Philhower's arduino-pico core v1.9.5+
for RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, etc. -
Arduino Core for STM32 v2.1.0+
for STM32F/L/H/G/WB/MP1 boards. -
Blynk library 0.6.1+
. to use with Blynk examples. Never use the Blynkbeta
library versions. -
WiFiNINA_Generic library v1.8.13+
if for WiFiNINA. To install. check . -
EthernetWebServer library v1.7.1+
if necessary to use Ethernet modules/shields. To install, check -
EthernetWebServer_STM32 library v1.2.1+
if necessary to use Ethernet modules/shields. To install, check -
WebServer_WT32_ETH01 library v1.2.0+
if necessary to use WT32_ETH01 boards. To install, check -
Depending on which Ethernet card you're using:
Ethernet library v2.0.0+
for W5100, W5200 and W5500.EthernetLarge library v2.0.0+
for W5100, W5200 and W5500.Ethernet2 library v1.0.4+
for W5500.Ethernet3 library v1.5.5+
for W5500/WIZ550io/WIZ850io/USR-ES1 with Wiznet W5500 chip.EthernetENC library v2.0.1+
for ENC28J60. . New and BetterUIPEthernet library v2.0.10+
for ENC28J60.STM32Ethernet library v1.2.0+
for built-in LAN8742A Ethernet on (Nucleo-144, Discovery). . To be used withLwIP library v2.1.2+
. .NativeEthernet Library version stable111+
for Teensy 4.1 built-in Ethernet.QNEthernet Library version v0.8.0+
for Teensy 4.1 built-in Ethernet. New
WiFiWebServer library v1.4.1+
if necessary to use certain WiFi/WiFiNINA features. To install, checkFlashStorage_SAMD library v1.2.1+
for SAMD21 and SAMD51 boards (ZERO, MKR, NANO_33_IOT, M0, M0 Pro, AdaFruit Itsy-Bitsy M4, etc.) if necessary to use certain features.FlashStorage_STM32 library v1.1.0+
for STM32F/L/H/G/WB/MP1 boards. if necessary to use certain features.DueFlashStorage library v1.0.0+
for SAM DUE if necessary to use certain features. To install, check .Adafruit's LittleFS/InternalFS
for nRF52. Already included if you already installed Adafruit nRF52 board package from Boards Manager.DoubleResetDetector_Generic v1.7.3+
if necessary to use some examples. To install. check if necessary to use certain features.Modified WiFi101 Library v0.16.1+
to use SAMD MKR1000, etc. boards with WiFi101.
The best and easiest way is to use Arduino Library Manager
. Search for WebSockets2_Generic, then select / install the latest version.
You can also use this link for more detailed instructions.
Another way to install is to:
- Navigate to WebSockets2_Generic page.
- Download the latest release
WebSockets2_Generic-master.zip
. - Extract the zip file to
WebSockets2_Generic-master
directory - Copy whole
WebSockets2_Generic-master
folder to Arduino libraries' directory such as~/Arduino/libraries/
.
- Install VS Code
- Install PlatformIO
- Install WebSockets2_Generic library by using Library Manager. Search for WebSockets2_Generic in Platform.io Author's Libraries
- Use included platformio.ini file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at Project Configuration File
To be able to compile, run and automatically detect and display BOARD_NAME on nRF52840/nRF52832 boards, you have to copy the whole nRF52 Packages_Patches directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/1.1.0).
Supposing the Adafruit nRF52 version is 1.1.0. These files must be copied into the directory:
~/.arduino15/packages/adafruit/hardware/nrf52/1.1.0/platform.txt
~/.arduino15/packages/adafruit/hardware/nrf52/1.1.0/boards.txt
~/.arduino15/packages/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Udp.h
~/.arduino15/packages/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.h
~/.arduino15/packages/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Print.cpp
~/.arduino15/packages/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.h
~/.arduino15/packages/adafruit/hardware/nrf52/1.1.0/variants/NINA_B302_ublox/variant.cpp
~/.arduino15/packages/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.h
~/.arduino15/packages/adafruit/hardware/nrf52/1.1.0/variants/NINA_B112_ublox/variant.cpp
~/.arduino15/packages/adafruit/hardware/nrf52/1.1.0/cores/nRF5/Udp.h
Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z These files must be copied into the directory:
~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/platform.txt
~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/boards.txt
~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/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
To be able to compile and run on Teensy boards, you have to copy the files in Packages_Patches for Teensy directory into Teensy hardware directory (./arduino-1.8.15/hardware/teensy/avr/boards.txt).
Supposing the Arduino version is 1.8.15. These files must be copied into the directory:
./arduino-1.8.15/hardware/teensy/avr/boards.txt
./arduino-1.8.15/hardware/teensy/avr/cores/teensy/Stream.h
./arduino-1.8.15/hardware/teensy/avr/cores/teensy3/Stream.h
./arduino-1.8.15/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.zz These 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
To be able to compile and run on SAM DUE boards, you have to copy the whole SAM DUE directory into Arduino sam directory (~/.arduino15/packages/arduino/hardware/sam/1.6.12).
Supposing the Arduino SAM core version is 1.6.12. This file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/sam/1.6.12/platform.txt
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/sam/x.yy.zz/platform.txt
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 whole Arduino SAMD Packages_Patches directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.11).
Supposing the Arduino SAMD version is 1.8.11. Now only one file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/samd/1.8.11/platform.txt
Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz
This file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/samd/x.yy.zz/platform.txt
Supposing the Arduino SAMD version is 1.8.9. These files must be copied into the directory:
~/.arduino15/packages/arduino/hardware/samd/1.8.9/platform.txt
~/.arduino15/packages/arduino/hardware/samd/1.8.9/cores/arduino/Arduino.h
Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z
These files must be copied into the directory:
~/.arduino15/packages/arduino/hardware/samd/x.yy.z/platform.txt
~/.arduino15/packages/arduino/hardware/samd/x.yy.z/cores/arduino/Arduino.h
This is mandatory to fix the notorious Arduino SAMD compiler error. See Improve Arduino compatibility with the STL (min and max macro)
...\arm-none-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 the Arduino.h
file anymore.
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 whole Adafruit SAMD Packages_Patches directory into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.5).
Supposing the Adafruit SAMD core version is 1.7.5. This file must be copied into the directory:
~/.arduino15/packages/adafruit/hardware/samd/1.7.5/platform.txt
~/.arduino15/packages/adafruit/hardware/samd/1.7.5/cores/arduino/Print.h
~/.arduino15/packages/adafruit/hardware/samd/1.7.5/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.zz This file 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
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 whole Seeeduino SAMD Packages_Patches directory into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2).
Supposing the Seeeduino SAMD core version is 1.8.2. This file must be copied into the directory:
~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/platform.txt
~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/cores/arduino/Arduino.h
~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/cores/arduino/Print.h
~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/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.zz This file 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
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 files stm32f4xx_hal_conf_default.h and stm32f7xx_hal_conf_default.h into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.1.0/system) to overwrite the old files.
Supposing the STM32 stm32 core version is 2.1.0. These files must be copied into the directory:
~/.arduino15/packages/STM32/hardware/stm32/2.1.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h
for STM32F4.~/.arduino15/packages/STM32/hardware/stm32/2.1.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, theses 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
To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards, you have to copy the files STM32 variant.h into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.1.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.1.0. These files must be copied into the directory:
~/.arduino15/packages/STM32/hardware/stm32/2.1.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.1.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, theses 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 using Earle Philhower arduino-pico core
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 file RP2040 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.zz This 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 PR Add -DBOARD_NAME="{build.board}" #136.
Some libraries, such as Adafruit 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 in RP2040 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.zz This 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 PR Add defs for compatibility #142.
To be able to upload firmware to Portenta_H7 using Arduino IDE in Linux (Ubuntu, etc.), you have to copy the file portenta_post_install.sh into mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/2.5.2/portenta_post_install.sh).
Then run the following command using sudo
$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/2.5.2
$ 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 rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="035b", GROUP="plugdev", MODE="0666"
Supposing the ArduinoCore-mbed core version is 2.5.2. Now only one file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/mbed_portenta/2.5.2/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
If your application requires 2K+ HTML page, the current Ethernet library
must be modified if you are using W5200/W5500 Ethernet shields. W5100 is not supported for 2K+ buffer. If you use boards requiring different CS/SS pin for W5x00 Ethernet shield, for example ESP32, ESP8266, nRF52, etc., you also have to modify the following libraries to be able to specify the CS/SS pin correctly.
To fix Ethernet library
, just copy these following files into the Ethernet library
directory to overwrite the old files:
To fix EthernetLarge library
, just copy these following files into the EthernetLarge library
directory to overwrite the old files:
To fix Ethernet2 library
, just copy these following files into the Ethernet2 library
directory to overwrite the old files:
To add UDP Multicast support, necessary for the UPnP_Generic library:
To fix Ethernet3 library
, just copy these following files into the Ethernet3 library
directory to overwrite the old files:
To be able to compile and run on nRF52 boards with ENC28J60 using UIPEthernet library, you have to copy these following files into the UIPEthernet utility
directory to overwrite the old files:
Check if you need to install the UIPthernet patch new STM32 core F3/F4 compatibility to avoid errors #include HardwareSPI.h
on some STM32 boards (Nucleo-32 F303K8, etc.)
To fix ESP32 compile error
, just copy the following file into the ESP32
cores/esp32 directory (e.g. ./arduino-1.8.13/hardware/espressif/cores/esp32) to overwrite the old file:
To fix ESP8266 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
- From
Ethernet.h
toEthernet_ESP8266.h
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 using LittleFS_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
#define CONFIG_LITTLEFS_FOR_IDF_3_2 /* For old IDF - like in release 1.0.4 */
It's advisable to use the latest LittleFS_esp32 v1.0.5+
to avoid the issue.
Thanks to Roshan to report the issue in Error esp_littlefs.c 'utime_p'
Please have a look at ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example to have more detailed description and solution of the issue.
- ADC1 controls ADC function for pins GPIO32-GPIO39
- ADC2 controls ADC function for pins GPIO0, 2, 4, 12-15, 25-27
Look in file adc_common.c
In ADC2, there're two locks used for different cases:
lock shared with app and Wi-Fi: ESP32: When Wi-Fi using the ADC2, we assume it will never stop, so app checks the lock and returns immediately if failed. ESP32S2: The controller's control over the ADC is determined by the arbiter. There is no need to control by lock.
lock shared between tasks: when several tasks sharing the ADC2, we want to guarantee all the requests will be handled. Since conversions are short (about 31us), app returns the lock very soon, we use a spinlock to stand there waiting to do conversions one by one.
adc2_spinlock should be acquired first, then adc2_wifi_lock or rtc_spinlock.
- In order to use ADC2 for other functions, we have to acquire complicated firmware locks and very difficult to do
- So, it's not advisable to use ADC2 with WiFi/BlueTooth (BT/BLE).
- Use ADC1, and pins GPIO32-GPIO39
- If somehow it's a must to use those pins serviced by ADC2 (GPIO0, 2, 4, 12, 13, 14, 15, 25, 26 and 27), use the fix mentioned at the end of ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example to work with ESP32 WiFi/BlueTooth (BT/BLE).
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 |
Connect as follows. To program, use STM32CubeProgrammer 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 |
Connect FDTI (USB to Serial) as follows:
FDTI | <---> | STM32F4 |
---|---|---|
RX | <---> | TX=PA_9 |
TX | <---> | RX=PA_10 |
GND | <---> | GND |
-
Code is restructured to provide flexibility to make it easy to support many more WiFi/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.
-
For Adafruit nRF52, use the SPI's pin as follows:
- SS/CS = 10
- SPI_MOSI = MO(SI)
- SPI_MISO = MI(SO)
- SPI_SCK = SCK
- For Adafruit 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 related variant.h
files in
~/.arduino15/packages/adafruit/hardware/samd/x.y.zz/variants/board_name/variant.h
- For Arduino SAM DUE, use the SPI's pin as follows:
- SS/CS = 10
- SPI_MOSI = 75 ( pin 4 @ ICSP connector )
- SPI_MISO = 74 ( pin 1 @ ICSP connector )
- SPI_SCK = 76 ( pin 3 @ ICSP connector )
- For RP2040 using
Arduino mbed_rp2040 core
, use the SPI's pin as follows:
- SS/CS = 5
- SPI_MOSI = 3
- SPI_MISO = 4
- SPI_SCK = 2
- For RP2040 using
Earle Philhower's arduino-pico core
, use the SPI's pin as follows:
- SS/CS = 17
- SPI_MOSI = 19
- SPI_MISO = 16
- SPI_SCK = 18
WebsocketsClient client;
client.connect("ws://your-server-ip:port/uri");
client.send("Hello Server!");
- Using Lambda function
// run callback when messages are received
client.onMessage([&](WebsocketsMessage message)
{
Serial.print("Got Message: ");
Serial.println(message.data());
});
- Using normal calback function
// run callback when events are occuring
client.onMessage(onMessageCallback);
and
void onMessageCallback(WebsocketsMessage message)
{
//Doing something with received String message.data() type
Serial.print("Got Message: ");
Serial.println(message.data());
}
void loop()
{
client.poll();
}
WebsocketsServer server;
server.listen(8080);
WebsocketsClient client = server.accept();
// handle client as described before :)
// run callback when messages are received
client.onMessage([&](WebsocketsMessage message)
{
Serial.print("Got Message: ");
Serial.println(message.data());
});
Using this new feature to enable doing other tasks in the loop(), such as WebServer, control tasks, etc. Server, using library version before v1.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 with v1.0.6 and v1.0.5- to see the blocking effects. Please remember to change in loop() from
WebsocketsMessage msg = client.readNonBlocking();
to
WebsocketsMessage msg = client.readBlocking();
as client.readNonBlocking() is a new function in v1.0.6+.
- Esp32-AdvancedWebServer using ESP32
- Esp8266-AdvancedWebServer using ESP8266
- WT32_ETH01_AdvancedWebServer using WT32_ETH01
- SAMD-AdvancedWebServer using Nano-33-IoT
- nRF52-AdvancedWebServer using Adafruit nRF52 NRF52840_FEATHER_EXPRESS, NINA_B302_ublox and WiFiNINA W102 module.
- STM32-AdvancedWebServer using STM32 Nucleo-64 L053R8, STM32F4 and WiFiNINA W102 module.
- SAMDUE-Ethernet_AdvancedWebServer using SAM DUE and W5100 Ethernet
- STM32-Ethernet_AdvancedWebServer using STM32F7 Nucleo-144 F676ZI and built-in LAN8742A Ethernet.
- SAMD-Ethernet_AdvancedWebServer using Adafruit SAMD51 Itsy_Bitsy_M4, Seeeduino SAMD21 XIAO_M0 and W5500 Ethernet.
- nRF52-Ethernet_AdvancedWebServer using Adafruit nRF52 NRF52840_FEATHER_EXPRESS, NINA_B302_ublox and W5500 Ethernet.
- Teensy-Ethernet_AdvancedWebServer using Teensy and W5500 Ethernet.
#define WEBSOCKETS_USE_WIFININA true
#define WEBSOCKETS_USE_ETHERNET true
#define USE_UIP_ETHERNET false
- To use
W5x00
module/shield withEthernet
library
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET true
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC false
#define USE_UIP_ETHERNET false
- To use
W5x00
module/shield withEthernet2
library
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 true
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC false
#define USE_UIP_ETHERNET false
- To use
W5x00
module/shield withEthernetLarge
library
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE true
#define USE_ETHERNET_ENC false
#define USE_UIP_ETHERNET false
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC false
#define USE_UIP_ETHERNET true
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC true
#define USE_UIP_ETHERNET false
#define WEBSOCKETS_USE_ETHERNET true
// Just select one to be true. If all is false, default is Ethernet.
// If more than one are true, the priority is USE_ETHERNET, USE_ETHERNET2, USE_ETHERNET_LARGE, USE_UIP_ETHERNET
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE true
#define USE_ETHERNET_ENC false
#define USE_UIP_ETHERNET false
#if USE_ETHERNET
// Also default to Ethernet library
#include <Ethernet.h>
#define ETHERNET_TYPE "W5x00 and Ethernet Library"
#elif USE_ETHERNET2
#include <Ethernet2.h>
#define ETHERNET_TYPE "W5x00 and Ethernet2 Library"
#elif USE_ETHERNET_LARGE
#include <EthernetLarge.h>
#define ETHERNET_TYPE "W5x00 and EthernetLarge Library"
#elif USE_ETHERNET_ENC
#include <EthernetENC.h>
#define ETHERNET_TYPE "ENC28J60 and EthernetENC Library"
#elif USE_UIP_ETHERNET
#include <UIPEthernet.h>
#include <utility/logging.h>
#define ETHERNET_TYPE "ENC28J60 and UIPEthernet Library"
#else
// Default to Ethernet library
#include <Ethernet.h>
#define ETHERNET_TYPE "W5x00 and Ethernet Library"
#endif
#ifndef USE_THIS_SS_PIN
#define USE_THIS_SS_PIN 10 // For other boards
#endif
#define WEBSOCKETS_USE_ETHERNET true
#define USE_UIP_ETHERNET false
#define USE_LAN8742A_ETHERNET false
- To use
W5x00
module/shield withEthernet
library
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET true
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC false
#define USE_UIP_ETHERNET false
#define USING_LAN8720 false
#define USE_LAN8742A_ETHERNET false
- To use
W5x00
module/shield withEthernet2
library
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 true
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC false
#define USE_UIP_ETHERNET false
#define USING_LAN8720 false
#define USE_LAN8742A_ETHERNET false
- To use
W5x00
module/shield withEthernetLarge
library
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE true
#define USE_ETHERNET_ENC false
#define USE_UIP_ETHERNET false
#define USING_LAN8720 false
#define USE_LAN8742A_ETHERNET false
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC false
#define USE_UIP_ETHERNET true
#define USING_LAN8720 false
#define USE_LAN8742A_ETHERNET false
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC true
#define USE_UIP_ETHERNET false
#define USING_LAN8720 false
#define USE_LAN8742A_ETHERNET false
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC false
#define USE_UIP_ETHERNET false
#define USING_LAN8720 false
#define USE_LAN8742A_ETHERNET true
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC false
#define USE_UIP_ETHERNET false
#define USING_LAN8720 true
#define USE_LAN8742A_ETHERNET true
#define WEBSOCKETS_USE_ETHERNET true
// Just select one to be true. If all is false, default is Ethernet.
// If more than one are true, the priority is USE_ETHERNET, USE_ETHERNET2, USE_ETHERNET_LARGE, USE_UIP_ETHERNET
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE true
#define USE_ETHERNET_ENC false
#define USE_UIP_ETHERNET false
#define USE_LAN8742A_ETHERNET false
#if USE_ETHERNET
// Also default to Ethernet library
#include <Ethernet.h>
#define ETHERNET_TYPE "W5x00 and Ethernet Library"
#elif USE_ETHERNET2
#include <Ethernet2.h>
#define ETHERNET_TYPE "W5x00 and Ethernet2 Library"
#elif USE_ETHERNET_LARGE
#include <EthernetLarge.h>
#define ETHERNET_TYPE "W5x00 and EthernetLarge Library"
#elif USE_ETHERNET_ENC
#include <EthernetENC.h>
#define ETHERNET_TYPE "ENC28J60 and EthernetENC Library"
#elif USE_UIP_ETHERNET
#include <UIPEthernet.h>
#include <utility/logging.h>
#define ETHERNET_TYPE "ENC28J60 and UIPEthernet Library"
#elif USE_LAN8742A_ETHERNET
#define USE_BUILTIN_ETHERNET true
#include <LwIP.h>
#include <STM32Ethernet.h>
#define ETHERNET_TYPE "LAN8742A and STM32Ethernet Library"
#else
// Default to Ethernet library
#include <Ethernet.h>
#define ETHERNET_TYPE "W5x00 and Ethernet Library"
#endif
#ifndef USE_THIS_SS_PIN
#define USE_THIS_SS_PIN 10 // For other boards
#endif
#define WEBSOCKETS_USE_ETHERNET true
#define USE_UIP_ETHERNET false
- To use
W5x00
module/shield withEthernet
library
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET true
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC false
#define USE_NATIVE_ETHERNET false
#define USE_UIP_ETHERNET false
- To use
W5x00
module/shield withEthernet2
library
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 true
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC false
#define USE_NATIVE_ETHERNET false
#define USE_UIP_ETHERNET false
- To use
W5x00
module/shield withEthernetLarge
library
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE true
#define USE_ETHERNET_ENC false
#define USE_NATIVE_ETHERNET false
#define USE_UIP_ETHERNET false
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC false
#define USE_NATIVE_ETHERNET false
#define USE_UIP_ETHERNET true
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC true
#define USE_NATIVE_ETHERNET false
#define USE_UIP_ETHERNET false
#define WEBSOCKETS_USE_ETHERNET true
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC true
#define USE_UIP_ETHERNET false
#define WEBSOCKETS_USE_ETHERNET true
// Just select one to be true. If all is false, default is Ethernet.
// If more than one are true, the priority is USE_ETHERNET, USE_ETHERNET2, USE_ETHERNET_LARGE, USE_UIP_ETHERNET
#define USE_ETHERNET false
#define USE_ETHERNET2 true
#define USE_ETHERNET_LARGE false
#define USE_ETHERNET_ENC false
#define USE_NATIVE_ETHERNET false
#define USE_UIP_ETHERNET false
#if ( defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) && USE_NATIVE_ETHERNET )
// Also default to Ethernet library
#include <NativeEthernet.h>
#define ETHERNET_TYPE "Teensy 4.1 NativeEthernet Library"
#elif USE_ETHERNET
// Also default to Ethernet library
#include <Ethernet.h>
#define ETHERNET_TYPE "W5x00 and Ethernet Library"
#elif USE_ETHERNET2
#include <Ethernet2.h>
#define ETHERNET_TYPE "W5x00 and Ethernet2 Library"
#elif USE_ETHERNET_LARGE
#include <EthernetLarge.h>
#define ETHERNET_TYPE "W5x00 and EthernetLarge Library"
#elif USE_ETHERNET_ENC
#include <EthernetENC.h>
#define ETHERNET_TYPE "ENC28J60 and EthernetENC Library"
#elif USE_UIP_ETHERNET
#include <UIPEthernet.h>
#include <utility/logging.h>
#define ETHERNET_TYPE "ENC28J60 and UIPEthernet Library"
#else
// Default to Ethernet library
#include <Ethernet.h>
#define ETHERNET_TYPE "W5x00 and Ethernet Library"
#endif
#ifndef USE_THIS_SS_PIN
#define USE_THIS_SS_PIN 10 // For other boards
#endif
Just as simple as:
#define WEBSOCKETS_USE_ETHERNET true
#define USE_NATIVE_ETHERNET true
#define USE_QN_ETHERNET false
Just as simple as:
#define WEBSOCKETS_USE_ETHERNET true
#define USE_NATIVE_ETHERNET false
#define USE_QN_ETHERNET true
Default is using ESP8266/ESP32 native WiFi
. You don't need to do anything special.
- Esp32-Client
- Minimal-Esp32-Client
- Secured-Esp32-Client
- ESP32-Client_SINRIC
- Esp32-Server
- Esp32-RepeatingClient
- Esp32-AdvancedWebServer
- InSecured-Esp32-Client. New
- Esp8266-Client
- Minimal-Esp8266-Client
- Secured-Esp8266-Client
- SecuredTwoWay-Esp8266-Client
- ESP8266-Client_SINRIC
- Esp8266-Server
- Esp8266-RepeatingClient
- Esp8266-AdvancedWebServer
- InSecured-Esp8266-Client. New
- nRF52-Client
- nRF52-Minimal-Client
- nRF52-Client_SINRIC
- nRF52-Server
- nRF52-RepeatingClient
- nRF52_ServerAllFunctionsDemo
- nRF52-AdvancedWebServer.
- SAMD-Client
- SAMD-Minimal-Client
- SAMD-Client_SINRIC
- SAMD-Server
- SAMD-RepeatingClient
- SAMD_ServerAllFunctionsDemo
- SAMD-AdvancedWebServer.
- SAMD_WiFi101-Client
- SAMD_WiFi101-Minimal-Client
- SAMD_WiFi101-Client_SINRIC
- SAMD_WiFi101-Server
- SAMD_WiFi101-RepeatingClient
- SAMD_WiFi101_ServerAllFunctionsDemo
- SAMD_WiFi101-AdvancedWebServer.
- STM32-Client
- STM32-Minimal-Client
- STM32-Client_SINRIC
- STM32-RepeatingClient
- STM32_ServerAllFunctionsDemo
- STM32-AdvancedWebServer.
- nRF52-Ethernet-Client
- nRF52-Ethernet-Minimal-Client
- nRF52-Ethernet-Client_SINRIC
- nRF52-Ethernet-Server
- nRF52-Ethernet-RepeatingClient
- nRF52-Ethernet_ServerAllFunctionsDemo
- nRF52-Ethernet_AdvancedWebServer.
- SAMD-Ethernet-Client
- SAMD-Ethernet-Minimal-Client
- SAMD-Ethernet-Client_SINRIC
- SAMD-Ethernet-Server
- SAMD-Ethernet-RepeatingClient
- SAMD-Ethernet_ServerAllFunctionsDemo
- SAMD-Ethernet_AdvancedWebServer.
- SAMDUE-Ethernet-Client
- SAMDUE-Ethernet-Minimal-Client
- SAMDUE-Ethernet-Client_SINRIC
- SAMDUE-Ethernet-Server
- SAMDUE-Ethernet-RepeatingClient
- SAMDUE-Ethernet_ServerAllFunctionsDemo
- SAMDUE-Ethernet_AdvancedWebServer.
- STM32-Ethernet-Client
- STM32-Ethernet-Minimal-Client
- STM32-Ethernet-Client_SINRIC
- STM32-Ethernet-Server
- STM32-Ethernet-RepeatingClient
- STM32-Ethernet_ServerAllFunctionsDemo
- STM32-Ethernet_AdvancedWebServer.
- STM32-Ethernet-Client_LAN8720
- STM32-Ethernet-Minimal-Client_LAN8720
- STM32-Ethernet-Client_SINRIC_LAN8720
- STM32-Ethernet-RepeatingClient_LAN8720
- Teensy-Ethernet-Client
- Teensy-Ethernet-Minimal-Client
- Teensy-Ethernet-Client_SINRIC
- Teensy-Ethernet-Server
- Teensy-Ethernet-RepeatingClient
- Teensy-Ethernet_ServerAllFunctionsDemo
- Teensy-Ethernet_AdvancedWebServer.
- RP2040-Ethernet-Client
- RP2040-Ethernet-Minimal-Client
- RP2040-Ethernet-Client_SINRIC
- RP2040-Ethernet-Server
- RP2040-Ethernet-RepeatingClient
- RP2040-Ethernet_ServerAllFunctionsDemo
- RP2040-Ethernet_AdvancedWebServer.
- WT32_ETH01_AdvancedWebServer
- WT32_ETH01_Client
- WT32_ETH01_Client_SINRIC
- WT32_ETH01_InSecuredClient
- WT32_ETH01_MinimalClient
- WT32_ETH01_RepeatingClient
- WT32_ETH01_SecuredClient
- WT32_ETH01_Server.
- Portenta_H7-AdvancedWebServer
- Portenta_H7-Client
- Portenta_H7-Client_SINRIC
- Portenta_H7-Minimal-Client
- Portenta_H7-RepeatingClient
- Portenta_H7-Server
- Portenta_H7_ServerAllFunctionsDemo
- RP2040-AdvancedWebServer
- RP2040-Client
- RP2040-Client_SINRIC
- RP2040-Minimal-Client
- RP2040-RepeatingClient
- RP2040-Server
- RP2040_ServerAllFunctionsDemo
Example SAMD-Client_SINRIC
Please take a look at other examples, as well.
1. File SAMD-Client_SINRIC.ino
#include "defines.h"
#define DEBUG_LOCAL 2
#include <WebSockets2_Generic.h>
#include <ArduinoJson.h> // https://arduinojson.org/ or install via Arduino library manager
using namespace websockets2_generic;
WebsocketsClient client;
#define HEARTBEAT_INTERVAL 300000 // 5 Minutes
bool isConnected = false;
uint64_t heartbeatTimestamp = 0;
uint64_t now = 0;
//To increase no of devices as needed
void turnOn(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
void turnOff(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
}
}
void onEventsCallback(WebsocketsEvent event, String data)
{
if (event == WebsocketsEvent::ConnectionOpened)
{
if (!isConnected)
isConnected = true;
Serial.println("Connnection Opened");
}
else if (event == WebsocketsEvent::ConnectionClosed)
{
if (isConnected)
isConnected = false;
Serial.println("Connnection Closed");
}
else if (event == WebsocketsEvent::GotPing)
{
if (!isConnected)
isConnected = true;
Serial.println("Got a Ping!");
}
else if (event == WebsocketsEvent::GotPong)
{
if (!isConnected)
isConnected = true;
Serial.println("Got a Pong!");
}
}
void onMessagesCallback(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)
DynamicJsonDocument json(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);
}
}
}
void setup()
{
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
Serial.begin(115200);
while (!Serial);
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!");
}
}
void loop()
{
// 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. File defines.h
#ifndef defines_h
#define defines_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
#define WEBSOCKETS_USE_WIFININA true
#define WEBSOCKETS_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)
#define BOARD_TYPE "SAMD Zero"
#elif defined(ARDUINO_SAMD_MKR1000)
#define BOARD_TYPE "SAMD MKR1000"
#elif defined(ARDUINO_SAMD_MKRWIFI1010)
#define BOARD_TYPE "SAMD MKRWIFI1010"
#elif defined(ARDUINO_SAMD_NANO_33_IOT)
#define BOARD_TYPE "SAMD NANO_33_IOT"
#elif defined(ARDUINO_SAMD_MKRFox1200)
#define BOARD_TYPE "SAMD MKRFox1200"
#elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) )
#define BOARD_TYPE "SAMD MKRWAN13X0"
#elif defined(ARDUINO_SAMD_MKRGSM1400)
#define BOARD_TYPE "SAMD MKRGSM1400"
#elif defined(ARDUINO_SAMD_MKRNB1500)
#define BOARD_TYPE "SAMD MKRNB1500"
#elif defined(ARDUINO_SAMD_MKRVIDOR4000)
#define BOARD_TYPE "SAMD MKRVIDOR4000"
#elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS)
#define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS"
#elif defined(ADAFRUIT_FEATHER_M0_EXPRESS)
#define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS"
#elif defined(ADAFRUIT_METRO_M0_EXPRESS)
#define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS"
#elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0)
#define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0"
#elif defined(ADAFRUIT_GEMMA_M0)
#define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0"
#elif defined(ADAFRUIT_TRINKET_M0)
#define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0"
#elif defined(ADAFRUIT_ITSYBITSY_M0)
#define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0"
#elif defined(ARDUINO_SAMD_HALLOWING_M0)
#define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0"
#elif defined(ADAFRUIT_METRO_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS"
#elif defined(ADAFRUIT_GRAND_CENTRAL_M4)
#define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4"
#elif defined(ADAFRUIT_FEATHER_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS"
#elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS"
#elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS"
#elif defined(ADAFRUIT_PYPORTAL)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL"
#elif defined(ADAFRUIT_PYPORTAL_M4_TITANO)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO"
#elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS"
#elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE)
#define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE"
#elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS"
#elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS"
#elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4"
#elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS"
#elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS"
#elif defined(SEEED_WIO_TERMINAL)
#define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL"
#elif defined(SEEED_FEMTO_M0)
#define BOARD_TYPE "SAMD SEEED_FEMTO_M0"
#elif defined(SEEED_XIAO_M0)
#define BOARD_TYPE "SAMD SEEED_XIAO_M0"
#elif defined(Wio_Lite_MG126)
#define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126"
#elif defined(WIO_GPS_BOARD)
#define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD"
#elif defined(SEEEDUINO_ZERO)
#define BOARD_TYPE "SAMD SEEEDUINO_ZERO"
#elif defined(SEEEDUINO_LORAWAN)
#define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN"
#elif defined(SEEED_GROVE_UI_WIRELESS)
#define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS"
#elif defined(__SAMD21E18A__)
#define BOARD_TYPE "SAMD21E18A"
#elif defined(__SAMD21G18A__)
#define BOARD_TYPE "SAMD21G18A"
#elif defined(__SAMD51G19A__)
#define BOARD_TYPE "SAMD51G19A"
#elif defined(__SAMD51J19A__)
#define BOARD_TYPE "SAMD51J19A"
#elif defined(__SAMD51J20A__)
#define BOARD_TYPE "SAMD51J20A"
#elif defined(__SAM3X8E__)
#define BOARD_TYPE "SAM3X8E"
#elif defined(__CPU_ARC__)
#define BOARD_TYPE "CPU_ARC"
#elif defined(__SAMD51__)
#define BOARD_TYPE "SAMD51"
#else
#define BOARD_TYPE "SAMD Unknown"
#endif
#endif
#ifndef BOARD_NAME
#define BOARD_NAME BOARD_TYPE
#endif
#include <WiFiNINA_Generic.h>
#define DEBUG_WEBSOCKETS_PORT Serial
// Debug Level from 0 to 4
#define _WEBSOCKETS_LOGLEVEL_ 3
const char* ssid = "ssid"; //Enter SSID
const char* password = "password"; //Enter Password
#define SINRIC_WEBSERVER "iot.sinric.com"
#define SINRIC_WEBSERVER_PORT 80
#define SINRIC_API_KEY "11111111-2222-3333-4444-555555555555"
#define SINRIC_Device_ID_1 "012345678901234567890123" // Device ID, got from Sinric
const char* websockets_server_host = SINRIC_WEBSERVER; //Enter server address
const uint16_t websockets_server_port = SINRIC_WEBSERVER_PORT; // Enter server port
#ifdef LED_BUILTIN
#define LED_PIN LED_BUILTIN
#else
#define LED_PIN 13
#endif
#endif //defines_h
This is the terminal output when running SAMD-Client_SINRIC example on Nano-33 IoT:
Starting WebSockets2_Generic SAMD-Client_SINRIC with WiFiNINA on SAMD NANO_33_IOT
WebSockets2_Generic v1.8.1
WiFi-begin: return1 = 3
WiFi-begin: return2 = 3
Connected to Wifi, Connecting to WebSockets Server @iot.sinric.com
[WS] WebsocketsClient::generateHandshake: base64Authorization = ***************
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: iot.sinric.com
Sec-WebSocket-Key: *********
apikey: 11111111-2222-3333-4444-555555555555
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: 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 Jul 2020 02: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: 012345678901234567890123
Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"OFF"}
Turn off Device ID: 012345678901234567890123
For binary data it is recommended to use msg.rawData()
which returns a std::string
, or msg.c_str()
which returns a const char*
.
The reason is that msg.data()
returns an Arduino String
, which is great for Serial printing and very basic memory handling but bad for most binary usages.
See issue #32 for further information.
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.
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 a SSL 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 2021
const char 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 the setKnownKey()
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) using setTrustAnchors
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 method setClientRSACert
or setClientECCert
.
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 2021
const char 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();
1. SAMD-Ethernet-Client_SINRIC on SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS using ENC28J60
This is terminal debug output when running SAMD-Ethernet-Client_SINRIC on SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS using ENC28J60 Ethernet module.
Starting WebSockets2_Generic SAMD-Ethernet-Client_SINRIC on SAMD ADAFRUIT_ITSYBITSY_M4_EXPRESS
Ethernet using ENC28J60 and UIPEthernet Library
WebSockets2_Generic v1.8.1
ENC28J60_CONTROL_CS =16
SS =16
SPI_MOSI =25
SPI_MISO =23
SPI_SCK =24
WebSockets Client IP address: 192.168.2.137
Connecting to WebSockets Server @iot.sinric.com
[WS] WebsocketsClient::generateHandshake: base64Authorization = ********
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: iot.sinric.com
Sec-WebSocket-Key: ********
apikey: 11111111-2222-3333-4444-555555555555
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic ********
Origin: https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: base64Authorization = ********
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Switching Protocols
[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[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 Jul 2020 00: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: 012345678901234567890123
Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"OFF"}
Turn off Device ID: 012345678901234567890123
2. SAMDUE-Ethernet-Server on SAM-DUE with W5100 using EthernetLarge library
This is terminal debug output when running SAMDUE-Ethernet-Server on SAM DUE board with Ethernet W5100 shield using EthernetLarge library, and receiving WebSockets connection from an ESP8266 board.
Starting WebSockets2_Generic SAMDUE-Ethernet-Server on SAM DUE
Ethernet using W5x00 and EthernetLarge Library
WebSockets2_Generic v1.8.1
W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 10
W5100::init: W5100, SSIZE =4096
WebSockets Server Running and Ready on SAM DUE
IP address: 192.168.2.153, Port: 8080
H[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_Generic
Got 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_Generic
Got Message: Hello to Server from ESP8266
HHHHHHHHH
3. nRF52-Ethernet-Server on Adafruit NRF52840_ITSYBITSY_EXPRESS with ENC28J60 using UIPEthernet library
This is terminal debug output when running nRF52-Ethernet-Server on Adafruit 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_EXPRESS
Ethernet using ENC28J60 and UIPEthernet Library
WebSockets2_Generic v1.8.1
ENC28J60_CONTROL_CS =10
SS =5
SPI_MOSI =24
SPI_MISO =23
SPI_SCK =25
WebSockets Server Running and Ready on NRF52840_ITSYBITSY_EXPRESS
IP address: 192.168.2.95, Port: 8080
H[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_Generic
Got 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_Generic
Got Message: Hello to Server from ESP8266
HHHHHHHHH
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 running STM32-Ethernet-Client_SINRIC on STM32F7 Nucleo-144 NUCLEO_F767ZI board with built-in Ethernet LAN8742A using STMEthernet library.
Starting WebSockets2_Generic STM32-Ethernet-Client_SINRIC on NUCLEO_F767ZI
Ethernet using LAN8742A and STM32Ethernet Library
WebSockets2_Generic v1.8.1
WebSockets Client IP address: 192.168.2.135
Connecting to WebSockets Server @iot.sinric.com
[WS] WebsocketsClient::generateHandshake: base64Authorization = ********
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: iot.sinric.com
Sec-WebSocket-Key: ********
apikey: 11111111-2222-3333-4444-555555555555
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic ********
Origin: https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: base64Authorization = ********
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Switching Protocols
[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[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 Jul 2020 06: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: 012345678901234567890123
Got 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 running SAMDUE-Ethernet_ServerAllFunctionsDemo example on SAM DUE and W5100 Ethernet. There are 3 WebSockets Clients connecting to the WebSockets Server:
- ESP32 running Esp32-RepeatingClient
- ESP8266 running Esp8266-RepeatingClient
- STM32 Nucleo-144 NUCLEO_F767ZI running STM32-Ethernet-RepeatingClient
Start Generic_WebSocketServerAllFunctionsDemo_W5500
WebSockets2_Generic v1.8.1
W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 10
W5100::init: W5100, SSIZE =4096
WebSockets Server IP address: 192.168.2.95
WebSockets Server Running and Ready on SAM DUE
IP 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_Generic
Got 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_Generic
Got 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_Generic
Got 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_Generic
Got 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_Generic
Got 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 running STM32-Ethernet-Client_SINRIC_LAN8720 on BLACK_F407VE using LAN8720 and STM32Ethernet Library.
Starting STM32-Ethernet-Client_SINRIC_LAN8720 on BLACK_F407VE
Ethernet using LAN8720 and STM32Ethernet Library
WebSockets2_Generic v1.8.1
WebSockets Client IP address: 192.168.2.160
Connecting to WebSockets Server @iot.sinric.com
[WS] WebsocketsClient::generateHandshake: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: iot.sinric.com
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
apikey: "11111111-2222-3333-4444-555555555555"
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
Origin: https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Switching Protocols
[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[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 Apr 2021 03: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: 012345678901234567890123
Got 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 running ESP32-Client_SINRIC on ESP32S2_DEV
Starting ESP32-Client_SINRIC on ESP32S2_DEV
WebSockets2_Generic v1.8.1
....Connected to Wifi, Connecting to WebSockets Server @iot.sinric.com
[WS] WebsocketsClient::generateHandshake: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: iot.sinric.com
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
apikey: "11111111-2222-3333-4444-555555555555"
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
Origin: https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Switching Protocols
[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[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 Apr 2021 22: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: 012345678901234567890123
Got 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 running Secured-ESP32-Client on ESP32S2_DEV
Starting WebSockets Secured-ESP32-Client on ESP32S2_DEV
WebSockets2_Generic v1.8.1
....
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.1
Host: echo.websocket.org
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic
Origin: https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: base64Authorization =
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Web Socket Protocol Handshake
[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[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 Apr 2021 19: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 = websocket
Connnection Opened
Connected!
Got Message: Hello to Server from ESP32S2_DEV
Got a Pong!
9. InSecured-ESP32-Client on ESP32_DEV
This is terminal debug output when running InSecured-ESP32-Client on ESP32_DEV
Starting WebSockets InSecured-ESP32-Client on ESP32_DEV
WebSockets2_Generic v1.8.1
...
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.1
Host: echo.websocket.org
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic
Origin: https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: base64Authorization =
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Web Socket Protocol Handshake
[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[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 May 2021 17: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 = websocket
Connnection Opened
Connected!
Got Message: Hello to Server from ESP32_DEV
Got a Pong!
10. ESP8266-Client_SINRIC on ESP8266_NODEMCU_ESP12E
This is terminal debug output when running ESP8266-Client_SINRIC on ESP8266_NODEMCU_ESP12E
Starting ESP8266-Client_SINRIC on ESP8266_NODEMCU_ESP12E
WebSockets2_Generic v1.8.1
......Connected to Wifi, Connecting to WebSockets Server @iot.sinric.com
[WS] WebsocketsClient::generateHandshake: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: iot.sinric.com
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
apikey: api_key
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
Origin: https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Switching Protocols
[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[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 May 2021 04: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 running RP2040-Ethernet-Client_SINRIC on RASPBERRY_PI_PICO using Earle Philhower's arduino-pico core
Starting RP2040-Ethernet-Client_SINRIC on RASPBERRY_PI_PICO
Ethernet using W5x00 and EthernetLarge Library
WebSockets2_Generic v1.8.1
_pinCS = 0
W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 17
W5100::init: W5500, SSIZE =8192
WebSockets Client IP address: 192.168.2.152
Connecting to WebSockets Server @iot.sinric.com
[WS] WebsocketsClient::connect: step 1
[WS] WebsocketsClient::generateHandshake: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: iot.sinric.com
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
apikey: 11111111-2222-3333-4444-555555555555
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
Origin: https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
[WS] WebsocketsClient::connect: step 2
[WS] WebsocketsClient::connect: step 3
[WS] WebsocketsClient::connect: step 4
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Switching Protocols
[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[WS] WebsocketsClient::connect: step 5
[WS] WebsocketsClient::connect: step 6
[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 May 2021 04: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: step 7
Connected!
Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"ON"}
Turn on for unknown device id: 012345678901234567890123
Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"OFF"}
Turn off for unknown device id: 012345678901234567890123
12. RP2040-Ethernet-Client_SINRIC on MBED RaspberryPi Pico
This is terminal debug output when running RP2040-Ethernet-Client_SINRIC on MBED RaspberryPi Pico using Arduino-mbed RP2040 core.
Starting RP2040-Ethernet-Client_SINRIC on RaspberryPi Pico
Ethernet using W5x00 and EthernetLarge Library
WebSockets2_Generic v1.8.1
_pinCS = 0
W5100 init, using SS_PIN_DEFAULT = 5, new ss_pin = 10, W5100Class::ss_pin = 5
W5100::init: W5500, SSIZE =8192
WebSockets Client IP address: 192.168.2.152
Connecting to WebSockets Server @iot.sinric.com
[WS] WebsocketsClient::connect: step 1
[WS] WebsocketsClient::generateHandshake: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: iot.sinric.com
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
apikey: 11111111-2222-3333-4444-555555555555
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
Origin: https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
[WS] WebsocketsClient::connect: step 2
[WS] WebsocketsClient::connect: step 3
[WS] WebsocketsClient::connect: step 4
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Switching Protocols
[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[WS] WebsocketsClient::connect: step 5
[WS] WebsocketsClient::connect: step 6
[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 May 2021 04: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: step 7
Connected!
Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"ON"}
Turn on device id: 012345678901234567890123
Got 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 running WT32_ETH01_Client_SINRIC on WT32_ETH01 (ESP32 + LAN8720) board.
Starting WT32_ETH01_Client_SINRIC on ESP32_DEV with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.1.0
WebSockets2_Generic v1.8.1
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.232, FULL_DUPLEX, 100Mbps
Connected. Connecting to WebSockets Server @iot.sinric.com
[WS] WebsocketsClient::generateHandshake: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: iot.sinric.com
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
apikey: 11111111-2222-3333-4444-555555555555
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
Origin: https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Switching Protocols
[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[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 Jul 2021 18: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: 012345678901234567890123
Got 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 running WT32_ETH01_SecuredClient on WT32_ETH01 (ESP32 + LAN8720) board.
Starting WT32_ETH01_SecuredClient on ESP32_DEV with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.1.0
WebSockets2_Generic v1.8.1
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.232, FULL_DUPLEX, 100Mbps
Connected. 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.1
Host: echo.websocket.org
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic
Origin: https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: base64Authorization =
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Web Socket Protocol Handshake
[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[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 Jul 2021 18: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 = websocket
Connnection Opened
Connected!
Got Message: Hello to Server from ESP32_DEV
Got a Pong!
15. WT32_ETH01_AdvancedWebServer on WT32_ETH01 (ESP32 + LAN8720)
This is terminal debug output when running WT32_ETH01_AdvancedWebServer on WT32_ETH01 (ESP32 + LAN8720) board.
Starting WT32_ETH01_AdvancedWebServer on ESP32_DEV with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.1.0
WebSockets2_Generic v1.8.1
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.95, FULL_DUPLEX, 100Mbps
MDNS responder started
WebSockets Server Running and Ready on WT32-ETH01
IP address: 192.168.2.95, Port: 8080
HTTP 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_Generic
Got 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_Generic
Got Message:
16. SocketAndHttp_Teensy41_Server on TEENSY 4.1 using QNEthernet
This is terminal debug output and screenshot when running SocketAndHttp_Teensy41_Server on TEENSY 4.1 using QNEthernet.
Start SocketAndHttp_Teensy41_Server on TEENSY 4.1 using QNEthernet
WebSockets2_Generic v1.8.1
=========== USE_QN_ETHERNET ===========
Initialize Ethernet using DHCP => Connected! IP address:192.168.2.119
Visit 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_Generic
Accepted new websockets client at index 0
Got Message: Hello to Server from ESP32
Http 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_Generic
Accepted new websockets client at index 0
Got Message: Hello to Server from ESP32
17. MultiClients_Teensy41_Server on TEENSY 4.1 using QNEthernet
This is terminal debug output when running MultiClients_Teensy41_Server on TEENSY 4.1 using QNEthernet.
Starting MultiClients_Teensy41_Server on TEENSY 4.1 using QNEthernet
WebSockets2_Generic v1.8.1
=========== USE_QN_ETHERNET ===========
Initialize Ethernet using DHCP => Connected! IP address:192.168.2.119
Server 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_Generic
Accepted new websockets client at index 0
Got Message: Hello to Server from ESP32
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_Generic
Accepted new websockets client at index 0
Got Message: Hello to Server from ESP32
Starting ESP32-RepeatingClient on ESP32_DEV
WebSockets2_Generic v1.8.1
....Connected to Wifi, Connecting to WebSockets Server @192.168.2.119
[WS] WebsocketsClient::generateHandshake: base64Authorization =
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: 192.168.2.119
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic
Origin: https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: base64Authorization =
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Switching Protocols
[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[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=
Connnection Opened
Connected!
Got Message: Hello from Teensy
Got Message: Echo: Hello to Server from ESP32
18. Portenta_H7_Ethernet_Server on PORTENTA_H7_M7 Ethernet
This is terminal debug output when running Portenta_H7_Ethernet_Server on PORTENTA_H7_M7 Ethernet using Portenta_Ethernet Library
Starting Portenta_H7_Ethernet_Server on PORTENTA_H7_M7 Ethernet using Portenta_Ethernet Library
WebSockets2_Generic v1.8.1
WebSockets Client @ IP address: 192.168.2.132
Server 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_Generic
Client connected
Got Message: Hello to Server from ESP8266
Client 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_Generic
Client connected
Got Message: Hello to Server from ESP8266
19. Portenta_H7-Client_SINRIC using WiFi on PORTENTA_H7_M7
This is terminal debug output when running Portenta_H7-Client_SINRIC on PORTENTA_H7_M7 using Murata
WiFi
Starting Portenta_H7-Client_SINRIC using WiFi on PORTENTA_H7_M7
WebSockets2_Generic v1.8.1
Connecting to SSID: HueNet1
Connected to Wifi, IP address: 192.168.2.130
Connecting to WebSockets Server @iot.sinric.com
[WS] WebsocketsClient::generateHandshake: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: iot.sinric.com
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
apikey: 11111111-2222-3333-4444-555555555555
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
Origin: https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: base64Authorization = YXBpa2V5OjkxMjdkNDc4LTExNjAtNDE4OC04MDQ4LTQ3OWJhNWM2OTExNA==
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Switching Protocols
[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[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 Sep 2021 03: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: 012345678901234567890123
Got Message: {"deviceId":"012345678901234567890123","action":"setPowerState","value":"OFF"}
Turn off Device ID: 012345678901234567890123
20. RP2040-AdvancedWebServer using WiFiNINA on on MBED NANO_RP2040_CONNECT
This is terminal debug output when running Portenta_H7-Client_SINRIC on MBED NANO_RP2040_CONNECT using WiFiNINA
Starting RP2040-AdvancedWebServer with WiFiNINA on MBED NANO_RP2040_CONNECT
WebSockets2_Generic v1.8.1
Attempting to connect to SSID: HueNet1
Connected to Wifi, IP address: 192.168.2.96
WebSockets Server Running and Ready on MBED NANO_RP2040_CONNECT
IP 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_Generic
Got 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_Generic
Got 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_Generic
Got Message:
- This is the screenshot when running STM32-Ethernet_AdvancedWebServer example on STM32F7 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.
- This is the screenshot when running SAMD-AdvancedWebServer example on Arduino 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.
- This is the screenshot when running Esp32-AdvancedWebServer example on ESP32-S2 to demonstrate the new non-blocking feature of WebSockets Server enabling WebServer and WebSockets Server to run concurrently.
- This is the screenshot when running WT32_ETH01_AdvancedWebServer on WT32_ETH01 (ESP32 + LAN8720) board to demonstrate the new non-blocking feature of WebSockets Server enabling WebServer and WebSockets Server to run concurrently.
- This is the screenshot when running Portenta_H7-AdvancedWebServer on Portenta_H7 board, using WiFi, to demonstrate the new non-blocking feature of WebSockets Server enabling WebServer and WebSockets Server to run concurrently.
- This is the screenshot when running RP2040-AdvancedWebServer on MBED NANO_RP2040_CONNECT using WiFiNINA, to demonstrate the new non-blocking feature of WebSockets Server enabling WebServer and WebSockets Server to run concurrently.
Debug is enabled by default on Serial. Debug Level from 0 to 4. To disable, change the WEBSOCKETS_LOGLEVEL to 0
// Use this to output debug msgs to Serial
#define DEBUG_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
If you get compilation errors, more often than not, you may need to install a newer version of the board's core, applying Libraries' Patches, Packages' Patches or this library latest version.
Submit issues to: WebSockets2_Generic issues
- Support more boards (Teensy, etc.)
- Support ESP8266/ESP32-AT shields.
- Add SSL support to SAMD21/SAMD51 and nRF52 using WiFiNINA.
- Support more non-compatible Ethernet Libraries such as Ethernet_Shield_W5200, EtherCard, EtherSia
- Add mDNS features.
- Add support to Arduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.)
- Add support to Adafruit SAMD21 (Itsy-Bitsy M0, Metro M0, Feather M0 Express, etc.).
- Add support to Adafruit SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.).
- Add support to Adafruit nRF52 ( Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc..
- Add support to WiFiNINA using
WiFiNINA_Generic library
. - Add support to
SINRIC
- Split each example into several manageable files.
- Add support to SAM DUE.
- Add support to Ethernet W5x00, using either
Ethernet
,Ethernet2
orEthernetLarge
library - Add support to Ethernet ENC28J60, using
UIPEthernet
library (v2.0.8 and v2.0.9) - Add support to STM32F/L/H/G/WB/MP1.
- Add support to Ethernet LAN8742A, using
STM32Ethernet library
andSTM32duino_LwIP library
. - Add support to Seeeduino SAMD21/SAMD51: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, Wio Terminal, Grove UI Wireless, etc.
- Add non-blocking WebSockets Server feature to enable WS Server and WebServer running concurrently
- Add support to Ethernet ENC28J60, using
EthernetENC
library. - Add support to Teensy using Ethernet libraries such as Ethernet, Ethernet2, Ethernet3, EthernetLarge, EthernetENC, UIPEthernet.
- Add support to Teensy 4.1 using NativeEthernet libraries.
- Add support to Ethernet LAN8720 using STM32Ethernet library, for boards such as Nucleo-144 (F429ZI, NUCLEO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG), Discovery (DISCO_F746NG) and STM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)
- Add support to ESP32-S2
- Update to use Latest esp32 core v1.0.6.
- Add support to ESP32-C3
- Add InSecure mode for ESP32
- Add support to MKR1000 / MKR1010WiFi boards using Forked WiFi101 library
- Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Earle Philhower's arduino-pico core v1.3.1+.
- Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core.
- Add support to WT32_ETH01 boards using ESP32-based boards and LAN8720 Ethernet
- Add support to Teensy 4.1 built-in Ethernet using
QNEthernet
library - Add support to Portenta_H7, using either
Murata WiFi
orVision-shield Ethernet
- Add support to RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, using WiFiNINA
- Based on and modified from Gil Maimon's ArduinoWebsockets
- Thanks to good work of Miguel Alexandre Wisintainer for initiating, inspriring, working with, developing, debugging and testing. Without that, support to nRF52, especially NINA_B302_ublox running as nRF52840 and NINA_B112_ublox running as nRF52832, has never been started and finished. See u-blox nina b
- Thanks to bug report and persistence of Jake to help identify and add non-blocking WebSockets Server feature to v1.0.6 to enable WS Server and WebServer running concurrently. See Support as Http server and the Websockets server on Arduino DUE and Running Http and Websocket Servers concurrently.
- Thanks to arnoson code posted in ArduinoWebsockets release 0.5.0 to provide support to Teensy 4.1 using NativeEthernet.
- Thanks Lionel REICHERT for PR Add setInsecure for esp32 #18 leading to v1.2.4.
- Thanks to Jose A.Molina for the enhancement request MKR1000 and WIFI problem and another problem #20, and help testing, leading to new version v1.3.0 to support WiFi101 and MKD1000 / MKR1010WiFi boards.
- Thanks to Robert Viens for posting the issue Compile error with Arduino Nano RP2040 #32, leading to v1.8.0.
⭐️⭐️ Gil Maimon |
⭐️ Miguel Wisintainer |
Jake |
arnoson |
Lionel REICHERT |
Jose A. Molina |
Robert Viens |
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
-
Most of the credits go to original author Gil Maimon as well as contributors in original library ArduinoWebsockets Contributors
-
The library is licensed under GPLv3.0
-
base64
written by René Nyffenegger.
- Copyright (c) 2019- Gil Maimon
- Copyright (c) 2020- Khoi Hoang