WebSocket2_Generic Lib supports Alexa/SINRIC For ESP32/WT32_ETH01

khoih-prog
Posts: 53
Joined: Sat Feb 22, 2020 8:16 pm

WebSocket2_Generic Lib supports Alexa/SINRIC For ESP32/WT32_ETH01

Postby khoih-prog » Fri Jul 17, 2020 7:36 pm

WebSockets2_Generic

How To Install Using Arduino Library Manager


Why do we need this WebSockets2_Generic

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 is based on and modified from Gil Maimon's ArduinoWebSockets Library to provide support to many more boards, such as Arduino SAMD21, Adafruit SAMD21/SAMD51, nRF52, STM32, Teensy, SAM DUE, etc. and enable those boards to use WebSockets services, including voice-control Alexa along with Blynk. Those supported boards can also run WebSockets Server. The WebSockets can be used with ESP’s WiFi, WiFiNINA, W5x00/ENC28J60/LAN8742A Ethernet, ESP8266/ESP32-AT modules/shields.


New in v1.0.2

1. Add support to Ethernet ENC28J60, using UIPEthernet library. for nRF52, SAMD21/SAMD51 and SAM DUE boards.

New in v1.0.1

1. Add support to SAM DUE boards.
2. Add support to Ethernet W5x00, using either Ethernet, EthernetLarge or Ethernet2 library.
3. Restructure code to provide flexibility 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.

New in v1.0.0

1. Add support to 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..
2. Add support to SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.).
3. Add support to SAMD21 (ZERO, MKR, NANO_33_IOT, M0, M0 Pro, AdaFruit CIRCUITPLAYGROUND_EXPRESS, etc.).
4. Add Alexa / SINRIC examples and supports to those boards as well as ESP8266/ESP32


Supported features of RFC6455

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

1. Example code ESP32-Client_SINRIC

2. This is the terminal output when running ESP832Client_SINRIC example on ESP32:

Code: Select all

Starting WebSockets2_Generic ESP32-Client_SINRIC on ESP32
.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::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 = Thu, 16 Jul 2020 21:42:29 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
Last edited by khoih-prog on Thu Jul 08, 2021 10:20 pm, edited 1 time in total.

khoih-prog
Posts: 53
Joined: Sat Feb 22, 2020 8:16 pm

Re: WebSocket2_Generic Lib supports Aexa/SINRIC For ESP32/WT32_ETH01

Postby khoih-prog » Thu Jul 08, 2021 10:06 pm

Major Release v1.5.0

1. Add support to WT32_ETH01 (ESP32 + LAN8720) boards
2. Add examples with new features

Sample Debug Terminal Output

This is terminal debug output when running WT32_ETH01_Client_SINRIC on WT32_ETH01 (ESP32 + LAN8720) board.

Code: Select all

Starting WT32_ETH01_Client_SINRIC on ESP32_DEV with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.1.0
WebSockets2_Generic v1.5.0
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

Who is online

Users browsing this forum: No registered users and 45 guests