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

Commit 2011e39

Browse files
authored
v1.0.6
### New in v1.0.6 1. Add ***non-blocking WebSockets Server*** feature to enable WS Server and WebServer running ***concurently***. See [***Support as Http server and the Websockets server on Arduino DUE***](khoih-prog/WebSockets_Generic#1) and [***Running Http and Websocket Servers concurrently***](#1). Thanks to bug report and persistence of [Jake](https://github.com/jakespeed1311). 2. Add non-blocking WebSockets Server and WebServer examples. 3. Add Ethernet Library Patches 4. Add Arduino SAMD Packages_Patches to fix compiler errors when using [Standard Template Library STL](https://en.wikipedia.org/wiki/Standard_Template_Library)
1 parent 7d24223 commit 2011e39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+414
-99
lines changed

Diff for: README.md

+141-19
Large diffs are not rendered by default.

Diff for: keywords.txt

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ streamBinary KEYWORD2
6060
end KEYWORD2
6161
setFragmentsPolicy KEYWORD2
6262
getFragmentsPolicy KEYWORD2
63+
readNonBlocking KEYWORD2
6364
readBlocking KEYWORD2
6465
ping KEYWORD2
6566
pong KEYWORD2

Diff for: library.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "WebSockets2_Generic",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "WebSocket Server and Client for Arduino based on RFC6455, originally designed for ESP8266/ESP32, now modified and ported to run on nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, etc. boards, with WiFiNINA, Ethernet W5x00/ENC28J60/LAN8742A, ESP8266/ESP32-AT modules/shields, as well as SINRIC / Alexa / Google Home",
55
"keywords": "wifi, http, web, server, client, websocket, ethernet, Sinric, Alexa",
66
"authors": [

Diff for: library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=WebSockets2_Generic
2-
version=1.0.5
2+
version=1.0.6
33
author=Gil Maimon <mail.gilmaimon@gmail.com>, Khoi Hoang <khoih.prog@gmail.com>
44
maintainer=Khoi Hoang <khoih.prog@gmail.com>
55
sentence=A library for writing modern Websockets applications with Arduino. Now support ESP8266, ESP32, nRF52, SAMD21, SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, etc. boards, with WiFiNINA, Ethernet W5x00/ENC28J60/LAN8742A, ESP8266/ESP32-AT modules/shields, as well as SINRIC / Alexa / Google Home

Diff for: src/Tiny_Websockets_Generic/client.hpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#ifndef _CLIENT_HPP_
@@ -119,6 +120,10 @@ namespace websockets2_generic
119120
void setFragmentsPolicy(const FragmentsPolicy newPolicy);
120121
FragmentsPolicy getFragmentsPolicy() const;
121122

123+
// KH add in v1.0.6
124+
WebsocketsMessage readNonBlocking();
125+
//////
126+
122127
WebsocketsMessage readBlocking();
123128

124129
bool ping(const WSInterfaceString data = "");

Diff for: src/Tiny_Websockets_Generic/internals/data_frame.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#pragma once

Diff for: src/Tiny_Websockets_Generic/internals/websockets_endpoint.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#pragma once

Diff for: src/Tiny_Websockets_Generic/internals/ws_common.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#pragma once

Diff for: src/Tiny_Websockets_Generic/internals/ws_common_Ethernet_W5x00.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#pragma once

Diff for: src/Tiny_Websockets_Generic/internals/ws_common_LAN8742AEthernet.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#pragma once

Diff for: src/Tiny_Websockets_Generic/internals/ws_common_UIPEthernet.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#pragma once

Diff for: src/Tiny_Websockets_Generic/internals/ws_common_WiFiNINA.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#pragma once

Diff for: src/Tiny_Websockets_Generic/internals/wscrypto/crypto.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#pragma once

Diff for: src/Tiny_Websockets_Generic/internals/wscrypto/sha1.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#pragma once

Diff for: src/Tiny_Websockets_Generic/message.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#ifndef _MESSAGE_HPP_

Diff for: src/Tiny_Websockets_Generic/network/DUE_Ethernet_W5x00/DUE_Ethernet_W5x00_tcp.hpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#pragma once
@@ -122,15 +123,24 @@ namespace websockets2_generic
122123
}
123124

124125
TcpClient* accept() override
125-
{
126+
{
126127
while (available())
127128
{
128129
yield();
129130
auto client = server.available();
130131

131-
if (client)
132+
if (client)
133+
{
132134
return new EthernetTcpClient{client};
135+
}
136+
// KH, from v1.0.6, add to enable non-blocking when no WS Client
137+
else
138+
{
139+
// Return NULL Client. Remember to test for NULL and process correctly
140+
return NULL;
141+
}
133142
}
143+
134144
return new EthernetTcpClient;
135145
}
136146

Diff for: src/Tiny_Websockets_Generic/network/DUE_UIPEthernet/DUE_UIPEthernet_tcp.hpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#pragma once
@@ -118,15 +119,24 @@ namespace websockets2_generic
118119
}
119120

120121
TcpClient* accept() override
121-
{
122+
{
122123
while (available())
123124
{
124125
yield();
125126
auto client = server.available();
126127

127-
if (client)
128+
if (client)
129+
{
128130
return new EthernetTcpClient{client};
131+
}
132+
// KH, from v1.0.6, add to enable non-blocking when no WS Client
133+
else
134+
{
135+
// Return NULL Client. Remember to test for NULL and process correctly
136+
return NULL;
137+
}
129138
}
139+
130140
return new EthernetTcpClient;
131141
}
132142

Diff for: src/Tiny_Websockets_Generic/network/SAMD_Ethernet_W5x00/SAMD_Ethernet_W5x00_tcp.hpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#pragma once
@@ -126,15 +127,24 @@ namespace websockets2_generic
126127
}
127128

128129
TcpClient* accept() override
129-
{
130+
{
130131
while (available())
131132
{
132133
yield();
133134
auto client = server.available();
134135

135-
if (client)
136+
if (client)
137+
{
136138
return new EthernetTcpClient{client};
139+
}
140+
// KH, from v1.0.6, add to enable non-blocking when no WS Client
141+
else
142+
{
143+
// Return NULL Client. Remember to test for NULL and process correctly
144+
return NULL;
145+
}
137146
}
147+
138148
return new EthernetTcpClient;
139149
}
140150

Diff for: src/Tiny_Websockets_Generic/network/SAMD_UIPEthernet/SAMD_UIPEthernet_tcp.hpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
1212
Licensed under MIT license
13-
Version: 1.0.5
13+
Version: 1.0.6
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,6 +21,7 @@
2121
1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using
2222
Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches.
2323
1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug.
24+
1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples.
2425
*****************************************************************************************************************************/
2526

2627
#pragma once
@@ -122,15 +123,24 @@ namespace websockets2_generic
122123
}
123124

124125
TcpClient* accept() override
125-
{
126+
{
126127
while (available())
127128
{
128129
yield();
129130
auto client = server.available();
130131

131-
if (client)
132+
if (client)
133+
{
132134
return new EthernetTcpClient{client};
135+
}
136+
// KH, from v1.0.6, add to enable non-blocking when no WS Client
137+
else
138+
{
139+
// Return NULL Client. Remember to test for NULL and process correctly
140+
return NULL;
141+
}
133142
}
143+
134144
return new EthernetTcpClient;
135145
}
136146

0 commit comments

Comments
 (0)