Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Commit

Permalink
v1.13.0 to add support to RP2040W
Browse files Browse the repository at this point in the history
### Release v1.13.0

1. Add support to `RP2040W` using `CYW43439 WiFi` or `Ethernet` with `arduino-pico` core
  • Loading branch information
khoih-prog authored Oct 12, 2022
1 parent 905b4c2 commit 1a24076
Show file tree
Hide file tree
Showing 74 changed files with 804 additions and 212 deletions.
135 changes: 106 additions & 29 deletions README.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
## Table of Contents

* [Changelog](#changelog)
* [Release v1.13.0](#release-v1130)
* [Release v1.12.1](#release-v1121)
* [Release v1.12.0](#release-v1120)
* [Release v1.11.0](#release-v1110)
Expand Down Expand Up @@ -48,6 +49,10 @@

## Changelog

### Release v1.13.0

1. Add support to `RP2040W` using `CYW43439 WiFi` or `Ethernet` with `arduino-pico` core

### Release v1.12.1

1. Improve and fix bug in examples
Expand Down
6 changes: 3 additions & 3 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "WebSockets2_Generic",
"version": "1.12.1",
"description": "WebSocket Server and Client for Arduino based on RFC6455, originally designed for ESP8266/ESP32. Now supports ESP8266, ESP32 (including ESP32-C3; ESP32-S2 Saola, AI-Thinker ESP-12K, WT32_ETH01, etc.), nRF52, SAMD21, SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, Teensy, RP2040-based, Portenta_H7, etc. boards, with WiFiNINA, Teensy 4.1 NativeEthernet/QNEthernet, Ethernet W5x00/ENC28J60/LAN8742A/LAN8720, ESP8266/ESP32-AT modules/shields, Portenta_H7 WiFi/Ethernet, as well as SINRIC / Alexa / Google Home. With updated SSL CA Certs, Fingerprint and InSecure mode. Now supporting ENC28J60 using either UIPEthernet or EthernetENC library and ESP32 using Ethernet",
"keywords": "communication, wifinina, wt32-eth01, websocket, webserver, Sinric, Alexa, ethernet, QNEthernet, NativeEthernet, lan8742a, lan8720, esp32, esp8266, stm32, samd, nrf52, rp2040, ssl, Portenta-H7, wifi, wifi101, sam-due, rpi-pico, W5x00, W5500, ENC28J60",
"version": "1.13.0",
"description": "WebSocket Server and Client for Arduino based on RFC6455, originally designed for ESP8266/ESP32. Now supports ESP8266, ESP32 (including ESP32-C3; ESP32-S2 Saola, AI-Thinker ESP-12K, WT32_ETH01, etc.), nRF52, SAMD21, SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, Teensy, RP2040-based, Portenta_H7, etc. boards, with WiFiNINA, Teensy 4.1 NativeEthernet/QNEthernet, Ethernet W5x00/ENC28J60/LAN8742A/LAN8720, ESP8266/ESP32-AT modules/shields, Portenta_H7 WiFi/Ethernet, as well as SINRIC / Alexa / Google Home. With updated SSL CA Certs, Fingerprint and InSecure mode. Now supporting ENC28J60 using either UIPEthernet or EthernetENC library, ESP32 using Ethernet and RP2-4-W using CYW43439 WiFi",
"keywords": "communication, wifinina, wt32-eth01, websocket, webserver, Sinric, Alexa, ethernet, QNEthernet, NativeEthernet, lan8742a, lan8720, esp32, esp8266, stm32, samd, nrf52, rp2040, ssl, Portenta-H7, wifi, wifi101, sam-due, rpi-pico, W5x00, W5500, ENC28J60, rp2040w, pico-w",
"authors": [
{
"name": "Gil Maimon",
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=WebSockets2_Generic
version=1.12.1
version=1.13.0
author=Gil Maimon <[email protected]>, Khoi Hoang <[email protected]>
maintainer=Khoi Hoang <[email protected]>
sentence=A WebSocket Server and Client library for Arduino, based on RFC6455, for writing modern Websockets applications.
paragraph=Featuring modern callbacks (supports lambdas) and a minimal interface. Contains a websockets Client and Server. Supports all features of the RFC6455 (pings, pongs, binary and text data, error codes) and WSS (Websockets over SSL). Now support ESP8266, ESP32 (including ESP32-C3; ESP32-S2 Saola, AI-Thinker ESP-12K, WT32_ETH01, etc.), nRF52, SAMD21, SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, Teensy, RP2040-based, Portenta_H7, etc. boards, with WiFiNINA, Teensy 4.1 NativeEthernet/QNEthernet, Ethernet W5x00/ENC28J60/LAN8742A/LAN8720, ESP8266/ESP32-AT modules/shields, Portenta_H7 WiFi/Ethernet, as well as SINRIC / Alexa / Google Home. With updated SSL CA Certs, Fingerprint and InSecure mode. Now supporting ENC28J60 using either UIPEthernet or EthernetENC library and ESP32 using Ethernet
paragraph=Featuring modern callbacks (supports lambdas) and a minimal interface. Contains a websockets Client and Server. Supports all features of the RFC6455 (pings, pongs, binary and text data, error codes) and WSS (Websockets over SSL). Now support ESP8266, ESP32 (including ESP32-C3; ESP32-S2 Saola, AI-Thinker ESP-12K, WT32_ETH01, etc.), nRF52, SAMD21, SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, Teensy, RP2040-based, Portenta_H7, etc. boards, with WiFiNINA, Teensy 4.1 NativeEthernet/QNEthernet, Ethernet W5x00/ENC28J60/LAN8742A/LAN8720, ESP8266/ESP32-AT modules/shields, Portenta_H7 WiFi/Ethernet, as well as SINRIC / Alexa / Google Home. With updated SSL CA Certs, Fingerprint and InSecure mode. Now supporting ENC28J60 using either UIPEthernet or EthernetENC library, ESP32 using Ethernet and RP2-4-W using CYW43439 WiFi
category=Communication
url=https://github.com/khoih-prog/WebSockets2_Generic
license=GPLv3
Expand Down
78 changes: 55 additions & 23 deletions src/Tiny_Websockets_Generic/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
Licensed under MIT license
Version: 1.12.1
Version: 1.13.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -25,13 +25,16 @@
1.11.0 K Hoang 08/10/2022 Add support to ESP32 using W5x00 Ethernet
1.12.0 K Hoang 09/10/2022 Add support to ENC28J60 using EthernetENC or UIPEthernet for all supported boards
1.12.1 K Hoang 09/10/2022 Fix bug in examples
1.13.0 K Hoang 11/10/2022 Add support to RP2040W using CYW43439 WiFi
*****************************************************************************************************************************/

#ifndef _CLIENT_HPP_
#define _CLIENT_HPP_

#pragma once

/////////////////////////////////////////////////////

#include <Tiny_Websockets_Generic/network/tcp_client.hpp>
#include <Tiny_Websockets_Generic/internals/data_frame.hpp>
#include <Tiny_Websockets_Generic/internals/websockets_endpoint.hpp>
Expand All @@ -40,7 +43,8 @@
#include <functional>
#include <vector>

// KH, from v1.0.1
/////////////////////////////////////////////////////

#if (WEBSOCKETS_USE_ETHERNET || WEBSOCKETS_USE_PORTENTA_H7_ETHERNET)
#if USE_UIP_ETHERNET
// KH, from v1.0.2
Expand Down Expand Up @@ -74,22 +78,39 @@
#warning WEBSOCKETS_USE_ETHERNET in client.hpp
#include <Tiny_Websockets_Generic/internals/ws_common_Ethernet_W5x00.hpp>
#endif

/////////////////////////////////////////////////////

#elif WEBSOCKETS_USE_RP2040W
#warning WEBSOCKETS_USE_RP2040W in client.hpp
#include <Tiny_Websockets_Generic/internals/ws_common_RP2040W.hpp>

/////////////////////////////////////////////////////

#elif WEBSOCKETS_USE_WIFININA
#warning WEBSOCKETS_USE_WIFININA in client.hpp
#include <Tiny_Websockets_Generic/internals/ws_common_WiFiNINA.hpp>

/////////////////////////////////////////////////////

#elif WEBSOCKETS_USE_WIFI101
#warning WEBSOCKETS_USE_WIFI101 in client.hpp
#include <Tiny_Websockets_Generic/internals/ws_common_WiFi101.hpp>
#include <Tiny_Websockets_Generic/internals/ws_common_WiFi101.hpp>

/////////////////////////////////////////////////////

#elif WEBSOCKETS_USE_PORTENTA_H7_WIFI
#warning WEBSOCKETS_USE_PORTENTA_H7_WIFI in client.hpp
#include <Tiny_Websockets_Generic/internals/ws_common_WiFi_Portenta_H7.hpp>

/////////////////////////////////////////////////////

#else
#warning WEBSOCKETS_USE_ESP_WIFI in client.hpp
#include <Tiny_Websockets_Generic/internals/ws_common.hpp>
#endif
//////


/////////////////////////////////////////////////////

namespace websockets2_generic
{
Expand All @@ -99,14 +120,18 @@ namespace websockets2_generic
ConnectionClosed,
GotPing, GotPong
};

/////////////////////////////////////////////////////

class WebsocketsClient;
typedef std::function<void(WebsocketsClient&, WebsocketsMessage)> MessageCallback;
typedef std::function<void(WebsocketsMessage)> PartialMessageCallback;

typedef std::function<void(WebsocketsClient&, WebsocketsEvent, WSInterfaceString)> EventCallback;
typedef std::function<void(WebsocketsEvent, WSInterfaceString)> PartialEventCallback;


/////////////////////////////////////////////////////

class WebsocketsClient
{
public:
Expand Down Expand Up @@ -150,9 +175,7 @@ namespace websockets2_generic
void setFragmentsPolicy(const FragmentsPolicy newPolicy);
FragmentsPolicy getFragmentsPolicy() const;

// KH add in v1.0.6
WebsocketsMessage readNonBlocking();
//////

WebsocketsMessage readBlocking();

Expand All @@ -161,13 +184,18 @@ namespace websockets2_generic

void close(const CloseReason reason = CloseReason_NormalClosure);
CloseReason getCloseReason() const;


/////////////////////////////////////////////////////

void setUseMasking(bool useMasking)
{
_endpoint.setUseMasking(useMasking);
}


/////////////////////////////////////////////////////

void setInsecure();

#ifdef ESP8266
void setFingerprint(const char* fingerprint);
void setClientRSACert(const X509List *cert, const PrivateKey *sk);
Expand All @@ -184,43 +212,44 @@ namespace websockets2_generic

virtual ~WebsocketsClient();

// KH add
void setAuthorization(const char * user, const char * password);
WSString getAuthorization(void);
//////

private:
// KH add

WSString base64Authorization; ///< Base64 encoded Auth request
//////

std::shared_ptr<network2_generic::TcpClient> _client;
std::vector<std::pair<WSString, WSString>> _customHeaders;
internals2_generic::WebsocketsEndpoint _endpoint;
bool _connectionOpen;
MessageCallback _messagesCallback;
EventCallback _eventsCallback;

/////////////////////////////////////////////////////

enum SendMode
{
SendMode_Normal,
SendMode_Streaming
} _sendMode;


} _sendMode;

/////////////////////////////////////////////////////

#ifdef ESP8266
const char* _optional_ssl_fingerprint = nullptr;
const X509List* _optional_ssl_trust_anchors = nullptr;

// KH, New in v1.0.5 (sync with v0.4.18)
const PublicKey* _optional_ssl_known_key = nullptr;
const X509List* _optional_ssl_rsa_cert = nullptr;
const PublicKey* _optional_ssl_known_key = nullptr;
const X509List* _optional_ssl_rsa_cert = nullptr;
const PrivateKey* _optional_ssl_rsa_private_key = nullptr;
const X509List* _optional_ssl_ec_cert = nullptr;
const PrivateKey* _optional_ssl_ec_private_key = nullptr;
const X509List* _optional_ssl_ec_cert = nullptr;
const PrivateKey* _optional_ssl_ec_private_key = nullptr;
//////
#elif defined(ESP32)
const char* _optional_ssl_ca_cert = nullptr;
const char* _optional_ssl_client_ca = nullptr;
const char* _optional_ssl_ca_cert = nullptr;
const char* _optional_ssl_client_ca = nullptr;
const char* _optional_ssl_private_key = nullptr;
#endif

Expand All @@ -230,6 +259,9 @@ namespace websockets2_generic

void upgradeToSecuredConnection();
};

/////////////////////////////////////////////////////

} // namespace websockets2_generic

#endif // _CLIENT_HPP_
3 changes: 2 additions & 1 deletion src/Tiny_Websockets_Generic/internals/data_frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
Licensed under MIT license
Version: 1.12.1
Version: 1.13.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -25,6 +25,7 @@
1.11.0 K Hoang 08/10/2022 Add support to ESP32 using W5x00 Ethernet
1.12.0 K Hoang 09/10/2022 Add support to ENC28J60 using EthernetENC or UIPEthernet for all supported boards
1.12.1 K Hoang 09/10/2022 Fix bug in examples
1.13.0 K Hoang 11/10/2022 Add support to RP2040W using CYW43439 WiFi
*****************************************************************************************************************************/

#pragma once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
Licensed under MIT license
Version: 1.12.1
Version: 1.13.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -25,6 +25,7 @@
1.11.0 K Hoang 08/10/2022 Add support to ESP32 using W5x00 Ethernet
1.12.0 K Hoang 09/10/2022 Add support to ENC28J60 using EthernetENC or UIPEthernet for all supported boards
1.12.1 K Hoang 09/10/2022 Fix bug in examples
1.13.0 K Hoang 11/10/2022 Add support to RP2040W using CYW43439 WiFi
*****************************************************************************************************************************/

#pragma once
Expand Down
3 changes: 2 additions & 1 deletion src/Tiny_Websockets_Generic/internals/ws_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
Licensed under MIT license
Version: 1.12.1
Version: 1.13.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -25,6 +25,7 @@
1.11.0 K Hoang 08/10/2022 Add support to ESP32 using W5x00 Ethernet
1.12.0 K Hoang 09/10/2022 Add support to ENC28J60 using EthernetENC or UIPEthernet for all supported boards
1.12.1 K Hoang 09/10/2022 Fix bug in examples
1.13.0 K Hoang 11/10/2022 Add support to RP2040W using CYW43439 WiFi
*****************************************************************************************************************************/

#pragma once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
Licensed under MIT license
Version: 1.12.1
Version: 1.13.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -25,6 +25,7 @@
1.11.0 K Hoang 08/10/2022 Add support to ESP32 using W5x00 Ethernet
1.12.0 K Hoang 09/10/2022 Add support to ENC28J60 using EthernetENC or UIPEthernet for all supported boards
1.12.1 K Hoang 09/10/2022 Fix bug in examples
1.13.0 K Hoang 11/10/2022 Add support to RP2040W using CYW43439 WiFi
*****************************************************************************************************************************/

#pragma once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
Licensed under MIT license
Version: 1.12.1
Version: 1.13.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -25,6 +25,7 @@
1.11.0 K Hoang 08/10/2022 Add support to ESP32 using W5x00 Ethernet
1.12.0 K Hoang 09/10/2022 Add support to ENC28J60 using EthernetENC or UIPEthernet for all supported boards
1.12.1 K Hoang 09/10/2022 Fix bug in examples
1.13.0 K Hoang 11/10/2022 Add support to RP2040W using CYW43439 WiFi
*****************************************************************************************************************************/

#pragma once
Expand Down
Loading

0 comments on commit 1a24076

Please sign in to comment.