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

Commit

Permalink
v2.14.0 to optimize library
Browse files Browse the repository at this point in the history
### Release v2.14.0

1. Suppress unnecessary warnings.
2. Don't use `deprecated sha.h` for ESP32 core v1.0.6+. Check [warning sha.h is deprecated, use sha_parallel_engine.h #738](Links2004/arduinoWebSockets#738)
3. Optimize code by passing by `reference` instead of `value`
4. Modify nearly all examples
5. Update `Packages' Patches`
  • Loading branch information
khoih-prog authored Feb 18, 2022
1 parent 18f6e84 commit 483caf3
Show file tree
Hide file tree
Showing 15 changed files with 497 additions and 491 deletions.
108 changes: 58 additions & 50 deletions README.md

Large diffs are not rendered by default.

9 changes: 9 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 v2.14.0](#release-v2140)
* [Release v2.13.0](#release-v2130)
* [Major Release v2.12.0](#major-release-v2120)
* [Release v2.11.1](#release-v2111)
Expand Down Expand Up @@ -53,6 +54,14 @@

## Changelog

### Release v2.14.0

1. Suppress unnecessary warnings.
2. Don't use `deprecated sha.h` for ESP32 core v1.0.6+. Check [warning sha.h is deprecated, use sha_parallel_engine.h #738](https://github.com/Links2004/arduinoWebSockets/issues/738)
3. Optimize code by passing by `reference` instead of `value`
4. Modify nearly all examples
5. Update `Packages' Patches`

### Release v2.13.0

1. Add support to `ESP32_S3`.
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "WebSockets_Generic",
"version": "2.13.0",
"version": "2.14.0",
"description": "RFC6455-based WebSockets Server and Client for Arduino boards, such as nRF52, Portenta_H7, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, Teensy, SAM DUE, RP2040-based boards, besides ESP8266/ESP32 ESP32 (ESP32, ESP32_S2, ESP32_S3 and ESP32_C3) and WT32_ETH01. Ethernet shields W5100, W5200, W5500, ENC28J60, Teensy 4.1 NativeEthernet/QNEthernet or Portenta_H7 WiFi/Ethernet. Now supporting websocket only mode for Socket.IO",
"keywords": "wifi, WiFiNINA, websocket, websockets-server, websockets-client, Teensy, SAM DUE, SAMD, STM32, nRF52, QNEthernet, rp2040, Portenta-H7, ESP32, ESP8266, W5x00, Ethernet, Ethernet2, Ethernet3, EthernetLarge, EthernetENC, UIPEthernet, NativeEthernet, ENC28J60, rpi-pico, http, web, server, client, Mega",
"authors": [
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name=WebSockets_Generic
version=2.13.0
version=2.14.0
author=Markus Sattler, Khoi Hoang <[email protected]>
maintainer=Khoi Hoang <[email protected]>
sentence=RFC6455-based WebSockets Server and Client for Arduino boards, such as nRF52, Portenta_H7, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, Teensy, SAM DUE, RP2040-based boards, besides ESP8266/ESP32 (ESP32, ESP32_S2, ESP32_S3 and ESP32_C3) and WT32_ETH01. Ethernet shields W5100, W5200, W5500, ENC28J60, Teensy 4.1 NativeEthernet/QNEthernet or Portenta_H7 WiFi/Ethernet. Now supporting websocket only mode for Socket.IO
paragraph=Use v2.2.2+ for ESP, nRF52, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, Teensy, SAM DUE, RP2040-based boards, WT32_ETH01, Portenta_H7, etc.
category=Communication
url=https://github.com/khoih-prog/WebSockets_Generic
architectures=*
includes=WebSocketsClient_Generic.h, WebSocketsServer_Generic.h,SocketIOclient_Generic
depends=WiFiNINA_Generic, WiFiWebServer, EthernetWebServer, WebServer_WT32_ETH01, EthernetWebServer_STM32, DoubleResetDetector_Generic, SinricPro_Generic, FlashStorage_SAMD
includes=WebSocketsClient_Generic.h, WebSocketsServer_Generic.h,SocketIOclient_Generic
4 changes: 2 additions & 2 deletions platformio/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ lib_compat_mode = strict

lib_deps =
; PlatformIO 4.x
WiFiNINA_Generic@~1.8.14-1
WiFiNINA_Generic@~1.8.14-3
WiFiWebServer@~1.6.1
EthernetWebServer@~2.0.0
WebServer_WT32_ETH01@~1.4.1
Expand All @@ -60,7 +60,7 @@ lib_deps =
QNEthernet@~0.13.0
https://github.com/khoih-prog/WiFi101
; PlatformIO 5.x
; khoih-prog/WiFiNINA_Generic@~1.8.14-1
; khoih-prog/WiFiNINA_Generic@~1.8.14-3
; khoih-prog/WiFiWebServer@~1.6.1
; khoih-prog/EthernetWebServer@~2.0.0
; khoih-prog/WebServer_WT32_ETH01@~1.4.1
Expand Down
23 changes: 13 additions & 10 deletions src/SocketIOclient_Generic-Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Version: 2.13.0
Version: 2.14.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand Down Expand Up @@ -57,6 +57,7 @@
2.11.1 K Hoang 12/12/2021 Add option to use transport=websocket with sticky-session SIO server
2.12.0 K Hoang 28/01/2022 Supporting SSL for ESP32-based WT32_ETH01 boards
2.13.0 K Hoang 14/02/2022 Add support to ESP32_S3. Add PING and PONG SocketIO events
2.14.0 K Hoang 17/02/2022 Suppress unnecessary warnings. Optimize code by passing by reference instead of value
*****************************************************************************************************************************/

#pragma once
Expand All @@ -74,51 +75,53 @@ SocketIOclient::~SocketIOclient()
{
}

void SocketIOclient::begin(const char * host, uint16_t port, const char * url, const char * protocol)
void SocketIOclient::begin(const char * host, const uint16_t& port, const char * url, const char * protocol)
{
WebSocketsClient::beginSocketIO(host, port, url, protocol);
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
initClient();
}

void SocketIOclient::begin(String host, uint16_t port, String url, String protocol)
void SocketIOclient::begin(const String& host, const uint16_t& port, const String& url, const String& protocol)
{
WebSocketsClient::beginSocketIO(host, port, url, protocol);
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
initClient();
}

void SocketIOclient::begin(IPAddress host, uint16_t port, String url, String protocol)
void SocketIOclient::begin(const IPAddress& host, const uint16_t& port, const String& url, const String& protocol)
{
WebSocketsClient::beginSocketIO(host, port, url, protocol);
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
initClient();
}

#if defined(HAS_SSL)
void SocketIOclient::beginSSL(const char * host, uint16_t port, const char * url, const char * protocol)
void SocketIOclient::beginSSL(const char * host, const uint16_t& port, const char * url, const char * protocol)
{
WebSocketsClient::beginSocketIOSSL(host, port, url, protocol);
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
initClient();
}

void SocketIOclient::beginSSL(String host, uint16_t port, String url, String protocol)
void SocketIOclient::beginSSL(const String& host, const uint16_t& port, const String& url, const String& protocol)
{
WebSocketsClient::beginSocketIOSSL(host, port, url, protocol);
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
initClient();
}

#if defined(SSL_BARESSL)
void SocketIOclient::beginSSLWithCA(const char * host, uint16_t port, const char * url, const char * CA_cert, const char * protocol)
void SocketIOclient::beginSSLWithCA(const char * host, const uint16_t& port, const char * url,
const char * CA_cert, const char * protocol)
{
WebSocketsClient::beginSocketIOSSLWithCA(host, port, url, CA_cert, protocol);
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
initClient();
}

void SocketIOclient::beginSSLWithCA(const char * host, uint16_t port, const char * url, BearSSL::X509List * CA_cert, const char * protocol)
void SocketIOclient::beginSSLWithCA(const char * host, const uint16_t& port, const char * url,
BearSSL::X509List * CA_cert, const char * protocol)
{
WebSocketsClient::beginSocketIOSSLWithCA(host, port, url, CA_cert, protocol);
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
Expand Down Expand Up @@ -229,7 +232,7 @@ bool SocketIOclient::send(socketIOmessageType_t type, const char * payload, size
return send(type, (uint8_t *)payload, length);
}

bool SocketIOclient::send(socketIOmessageType_t type, String & payload)
bool SocketIOclient::send(socketIOmessageType_t type, const String& payload)
{
return send(type, (uint8_t *)payload.c_str(), payload.length());
}
Expand Down Expand Up @@ -262,7 +265,7 @@ bool SocketIOclient::sendEVENT(const char * payload, size_t length)
return sendEVENT((uint8_t *)payload, length);
}

bool SocketIOclient::sendEVENT(String & payload)
bool SocketIOclient::sendEVENT(const String& payload)
{
return sendEVENT((uint8_t *)payload.c_str(), payload.length());
}
Expand Down
35 changes: 24 additions & 11 deletions src/SocketIOclient_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Version: 2.13.0
Version: 2.14.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand Down Expand Up @@ -57,6 +57,7 @@
2.11.1 K Hoang 12/12/2021 Add option to use transport=websocket with sticky-session SIO server
2.12.0 K Hoang 28/01/2022 Supporting SSL for ESP32-based WT32_ETH01 boards
2.13.0 K Hoang 14/02/2022 Add support to ESP32_S3. Add PING and PONG SocketIO events
2.14.0 K Hoang 17/02/2022 Suppress unnecessary warnings. Optimize code by passing by reference instead of value
*****************************************************************************************************************************/

#pragma once
Expand Down Expand Up @@ -112,18 +113,30 @@ class SocketIOclient : protected WebSocketsClient
virtual ~SocketIOclient();

// KH, change to default EIO=4. v2.5.1
void begin(const char * host, uint16_t port, const char * url = "/socket.io/?EIO=4", const char * protocol = "arduino");
void begin(String host, uint16_t port, String url = "/socket.io/?EIO=4", String protocol = "arduino");
void begin(const char * host, const uint16_t& port, const char * url = "/socket.io/?EIO=4",
const char * protocol = "arduino");

void begin(const String& host, const uint16_t& port, const String& url = "/socket.io/?EIO=4",
const String& protocol = "arduino");
// KH
void begin(IPAddress host, uint16_t port, String url = "/socket.io/?EIO=4", String protocol = "arduino");
void begin(const IPAddress& host, const uint16_t& port, const String& url = "/socket.io/?EIO=4",
const String& protocol = "arduino");

#ifdef HAS_SSL
void beginSSL(const char * host, uint16_t port, const char * url = "/socket.io/?EIO=4", const char * protocol = "arduino");
void beginSSL(String host, uint16_t port, String url = "/socket.io/?EIO=4", String protocol = "arduino");
void beginSSL(const char * host, const uint16_t& port, const char * url = "/socket.io/?EIO=4",
const char * protocol = "arduino");

void beginSSL(const String& host, const uint16_t& port, const String& url = "/socket.io/?EIO=4",
const String& protocol = "arduino");
#ifndef SSL_AXTLS
void beginSSLWithCA(const char * host, uint16_t port, const char * url = "/socket.io/?EIO=4", const char * CA_cert = NULL, const char * protocol = "arduino");
void beginSSLWithCA(const char * host, uint16_t port, const char * url = "/socket.io/?EIO=4", BearSSL::X509List * CA_cert = NULL, const char * protocol = "arduino");
void beginSSLWithCA(const char * host, const uint16_t& port, const char * url = "/socket.io/?EIO=4",
const char * CA_cert = NULL, const char * protocol = "arduino");

void beginSSLWithCA(const char * host, const uint16_t& port, const char * url = "/socket.io/?EIO=4",
BearSSL::X509List * CA_cert = NULL, const char * protocol = "arduino");

void setSSLClientCertKey(const char * clientCert = NULL, const char * clientPrivateKey = NULL);

void setSSLClientCertKey(BearSSL::X509List * clientCert = NULL, BearSSL::PrivateKey * clientPrivateKey = NULL);
#endif
#endif
Expand All @@ -136,20 +149,20 @@ class SocketIOclient : protected WebSocketsClient
bool sendEVENT(const uint8_t * payload, size_t length = 0);
bool sendEVENT(char * payload, size_t length = 0, bool headerToPayload = false);
bool sendEVENT(const char * payload, size_t length = 0);
bool sendEVENT(String & payload);
bool sendEVENT(const String& payload);

bool send(socketIOmessageType_t type, uint8_t * payload, size_t length = 0, bool headerToPayload = false);
bool send(socketIOmessageType_t type, const uint8_t * payload, size_t length = 0);
bool send(socketIOmessageType_t type, char * payload, size_t length = 0, bool headerToPayload = false);
bool send(socketIOmessageType_t type, const char * payload, size_t length = 0);
bool send(socketIOmessageType_t type, String & payload);
bool send(socketIOmessageType_t type, const String& payload);

void loop();

void configureEIOping(bool disableHeartbeat = false);

// KH, add v2.5.1
void setReconnectInterval(unsigned long time)
void setReconnectInterval(const unsigned long& time)
{
_reconnectInterval = time;
}
Expand Down
6 changes: 4 additions & 2 deletions src/WebSockets4WebServer_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Version: 2.13.0
Version: 2.14.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand Down Expand Up @@ -57,6 +57,7 @@
2.11.1 K Hoang 12/12/2021 Add option to use transport=websocket with sticky-session SIO server
2.12.0 K Hoang 28/01/2022 Supporting SSL for ESP32-based WT32_ETH01 boards
2.13.0 K Hoang 14/02/2022 Add support to ESP32_S3. Add PING and PONG SocketIO events
2.14.0 K Hoang 17/02/2022 Suppress unnecessary warnings. Optimize code by passing by reference instead of value
*****************************************************************************************************************************/

#pragma once
Expand All @@ -82,7 +83,8 @@ class WebSockets4WebServer : public WebSocketsServerCore
{
onEvent(event);

return [&, wsRootDir](const String & method, const String & url, WiFiClient * tcpClient, ESP8266WebServer::ContentTypeFunction contentType)
return [&, wsRootDir](const String & method, const String & url, WiFiClient * tcpClient,
ESP8266WebServer::ContentTypeFunction contentType)
{
(void)contentType;

Expand Down
Loading

0 comments on commit 483caf3

Please sign in to comment.