Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support Nano 33 IoT, MKR WIFI 1010, XIAO, Wio Terminal #901

Merged
merged 46 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
7b84f07
feat: arduino uno r wifi r 4 support
kakopappa Jul 28, 2024
809b9a3
Merge branch 'master' of https://github.com/kakopappa/arduinoWebSockets
kakopappa Jul 28, 2024
6c69b58
Update library.json
kakopappa Jul 28, 2024
fa6435a
Update README.md
kakopappa Jul 28, 2024
59289b1
feat: read me updated. example fixed.
kakopappa Jul 28, 2024
633fb98
fix: broken link
kakopappa Jul 28, 2024
cbba76e
fix: logging
kakopappa Jul 28, 2024
01387c9
Update library.properties
kakopappa Jul 28, 2024
07c3b94
Update WebSocketsVersion.h
kakopappa Jul 28, 2024
3f7795c
Update WebSocketsVersion.h
kakopappa Jul 28, 2024
15a8053
feat: Arduino NINA support.
kakopappa Aug 8, 2024
daf2d38
feat: Support Arduino NINA
kakopappa Aug 8, 2024
4d373f0
feat: Support Arduino NINA
kakopappa Aug 8, 2024
0d34f7c
feat: Support Arduino NINA
kakopappa Aug 8, 2024
1b1dbe5
feat: remove Rev2
kakopappa Aug 8, 2024
8c59076
feat: Support Arduino NINA
kakopappa Aug 8, 2024
6bf4622
feat: Support Wio-Terminal
kakopappa Aug 10, 2024
debb30b
Create arduino-lint.yaml
kakopappa Aug 10, 2024
6e154a8
Create arduino-lint.yaml
kakopappa Aug 10, 2024
b44ea5c
Delete .github/workflows/.github/workflows directory
kakopappa Aug 10, 2024
aaae82c
Create compile-unor4wifi-examples.yaml
kakopappa Aug 10, 2024
716bc83
Create compile-arduino_wifinina-examples.yaml
kakopappa Aug 10, 2024
47986cb
fix: install WiFiNINA
kakopappa Aug 10, 2024
30da358
Update compile-unor4wifi-examples.yaml
kakopappa Aug 10, 2024
8f3f464
feat: workflow for wio terminal
kakopappa Aug 10, 2024
7e586b6
fix: comments
kakopappa Aug 12, 2024
53ddebc
fix: workflow name
kakopappa Aug 12, 2024
a29e0c1
fix: workflow path
kakopappa Aug 12, 2024
d01a3a7
feat: add seeed XIAO
kakopappa Aug 12, 2024
3a56020
fix: examples path
kakopappa Aug 12, 2024
940f047
feat: wio_terminal added
kakopappa Aug 12, 2024
ccc772d
fix: samd
kakopappa Aug 12, 2024
b8261af
Merge pull request #1 from kakopappa/wio-terminal
kakopappa Aug 12, 2024
c279673
SSL support for Uno 4 and bugfixes
kakopappa Aug 15, 2024
0037ebd
fix: SSL class
kakopappa Aug 15, 2024
1b368be
Merge pull request #2 from kakopappa/wio-terminal
kakopappa Aug 15, 2024
c5abae3
fix: make workflows tigger on relavent changes.
kakopappa Aug 15, 2024
d4c275e
chor: add links
kakopappa Aug 15, 2024
997c9c6
Merge branch 'master' into main
kakopappa Aug 15, 2024
ffe6d90
fix: pr comments
kakopappa Aug 24, 2024
11bd92a
Merge branch 'main' of https://github.com/kakopappa/arduinoWebSockets…
kakopappa Aug 24, 2024
865490d
fix: pr comments
kakopappa Aug 24, 2024
7ee5b45
fix: remove dup definition
kakopappa Aug 24, 2024
271ebe8
fix: pr comments
kakopappa Aug 24, 2024
12f1ad8
fix: compliation errors
kakopappa Aug 24, 2024
b32f3c2
fix: distructor
kakopappa Aug 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/compile-arduino_wifinina-examples.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
name: Compile Arduino WiFiNINA Examples

# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
on: [push, pull_request]
on:
push:
paths:
- ".github/workflows/compile-arduino_wifinina-examples.yaml"
- "examples/arduino_wifinina/**"
- "src/**"
pull_request:
paths:
- ".github/workflows/compile-arduino_wifinina-examples.yaml"
- "examples/arduino_wifinina/**"
- "src/**"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms).
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
build:
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/compile-seeed-studio-examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Compile SeedStudio Examples

# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/compile-seeed-studio-examples.yaml"
- "examples/seeed-studio/**"
- "src/**"
pull_request:
paths:
- ".github/workflows/compile-seeed-studio-examples.yaml"
- "examples/seeed-studio/**"
- "src/**"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms).
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
build:
name: ${{ matrix.board.fqbn }}
runs-on: ubuntu-latest

env:
SKETCHES_REPORTS_PATH: sketches-reports

strategy:
fail-fast: false

matrix:
board:
- fqbn: Seeeduino:samd:seeed_XIAO_m0:usbstack=arduino,debug=off
platforms: |
- name: Seeeduino:samd
source-url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json
libraries: |
- name: Seeed Arduino rpcWiFi
- name: Seeed Arduino rpcUnified
- name: Seeed_Arduino_mbedtls
- name: Seeed Arduino FS
- name: Seeed Arduino SFUD
artifact-name-suffix: seeeduino-xia0
- fqbn: Seeeduino:samd:seeed_wio_terminal
platforms: |
- name: Seeeduino:samd
source-url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json
libraries: |
- name: Seeed Arduino rpcWiFi
- name: Seeed Arduino rpcUnified
- name: Seeed_Arduino_mbedtls
- name: Seeed Arduino FS
- name: Seeed Arduino SFUD
artifact-name-suffix: seeeduino-wio_terminal

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Compile examples
uses: arduino/compile-sketches@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fqbn: ${{ matrix.board.fqbn }}
platforms: ${{ matrix.board.platforms }}
libraries: |
# Install the library from the local path.
- source-path: ./
${{ matrix.board.libraries }}
sketch-paths: |
- examples/seeed-studio/xio-wio-terminal/WebSocketClient
enable-deltas-report: true
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}

- name: Save sketches report as workflow artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
path: ${{ env.SKETCHES_REPORTS_PATH }}
name: sketches-report-${{ matrix.board.artifact-name-suffix }}
17 changes: 16 additions & 1 deletion .github/workflows/compile-unor4wifi-examples.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
name: Compile Arduino UNO R4 WiFi Examples

# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
on: [push, pull_request]
on:
push:
paths:
- ".github/workflows/compile-unor4wifi-examples.yaml"
- "examples/arduino_renesas/**"
- "src/**"
pull_request:
paths:
- ".github/workflows/compile-unor4wifi-examples.yaml"
- "examples/arduino_renesas/**"
- "src/**"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms).
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
build:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ a WebSocket Server and Client for Arduino based on RFC6455.
- ATmega2560 with Ethernet Shield (ATmega branch)
- ATmega2560 with enc28j60 (ATmega branch)
- Arduino UNO [R4 WiFi](https://github.com/arduino/ArduinoCore-renesas)
- Arduino Nano 33 IoT, MKR WIFI 1010
- Arduino Nano 33 IoT, MKR WIFI 1010 (requires [WiFiNINA](https://github.com/arduino-libraries/WiFiNINA/) library)
- Seeeduino XIAO, Seeeduino Wio Terminal (requires [rpcWiFi](https://github.com/Seeed-Studio/Seeed_Arduino_rpcWiFi) library)

###### Note: ######

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* WebSocketClient.ino
*
* Created on: 10.08.2024
*
*/

#include <Arduino.h>
#include <rpcWiFi.h>
#include <WiFiMulti.h>
#include <WebSocketsClient.h>

WebSocketsClient webSocket;
WiFiMulti wifiMulti;

#define USE_SERIAL Serial

void hexdump(const void *mem, uint32_t len, uint8_t cols = 16) {
const uint8_t* src = (const uint8_t*) mem;
USE_SERIAL.printf("\n[HEXDUMP] Address: 0x%08X len: 0x%X (%d)", (ptrdiff_t)src, len, len);
for(uint32_t i = 0; i < len; i++) {
if(i % cols == 0) {
USE_SERIAL.printf("\n[0x%08X] 0x%08X: ", (ptrdiff_t)src, i);
}
USE_SERIAL.printf("%02X ", *src);
src++;
}
USE_SERIAL.printf("\n");
}

void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {

switch(type) {
case WStype_DISCONNECTED:
USE_SERIAL.printf("[WSc] Disconnected!\n");
break;
case WStype_CONNECTED:
USE_SERIAL.printf("[WSc] Connected to url: %s\n", payload);

// send message to server when Connected
webSocket.sendTXT("Connected");
break;
case WStype_TEXT:
USE_SERIAL.printf("[WSc] get text: %s\n", payload);

// send message to server
// webSocket.sendTXT("message here");
break;
case WStype_BIN:
USE_SERIAL.printf("[WSc] get binary length: %u\n", length);
hexdump(payload, length);

// send data to server
// webSocket.sendBIN(payload, length);
break;
case WStype_ERROR:
case WStype_FRAGMENT_TEXT_START:
case WStype_FRAGMENT_BIN_START:
case WStype_FRAGMENT:
case WStype_PONG:
case WStype_PING:
case WStype_FRAGMENT_FIN:
break;
}

}

void setup() {
// USE_SERIAL.begin(921600);
USE_SERIAL.begin(115200);

USE_SERIAL.println();
USE_SERIAL.println();
USE_SERIAL.println();

for(uint8_t t = 4; t > 0; t--) {
USE_SERIAL.printf("[SETUP] BOOT WAIT %d...\n", t);
USE_SERIAL.flush();
delay(1000);
}

wifiMulti.addAP("SSID", "passpasspass");

//WiFi.disconnect();
while(wifiMulti.run() != WL_CONNECTED) {
delay(100);
}

// server address, port and URL
webSocket.begin("192.168.0.123", 81, "/");

// event handler
webSocket.onEvent(webSocketEvent);

// use HTTP Basic Authorization this is optional remove if not needed
webSocket.setAuthorization("user", "Password");

// try ever 5000 again if connection has failed
webSocket.setReconnectInterval(5000);

}

void loop() {
webSocket.loop();
}
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"keywords": "wifi, http, web, server, client, websocket",
"license": "LGPL-2.1",
"name": "WebSockets",
"platforms": "atmelavr, espressif8266, espressif32, raspberrypi, renesas_uno",
"platforms": "*",
"repository": {
"type": "git",
"url": "https://github.com/Links2004/arduinoWebSockets.git"
Expand Down
2 changes: 1 addition & 1 deletion src/SocketIOclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,4 @@ void SocketIOclient::handleCbEvent(WStype_t type, uint8_t * payload, size_t leng
case WStype_PONG:
break;
}
}
}
4 changes: 3 additions & 1 deletion src/SocketIOclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ class SocketIOclient : protected WebSocketsClient {
void beginSSL(String host, uint16_t port, String url = "/socket.io/?EIO=3", String protocol = "arduino", uint32_t pingInterval = 60 * 1000, uint32_t pongTimeout = 90 * 1000, uint8_t disconnectTimeoutCount = 5);
#ifndef SSL_AXTLS
void beginSSLWithCA(const char * host, uint16_t port, const char * url = "/socket.io/?EIO=3", const char * CA_cert = NULL, const char * protocol = "arduino", uint32_t pingInterval = 60 * 1000, uint32_t pongTimeout = 90 * 1000, uint8_t disconnectTimeoutCount = 5);
void beginSSLWithCA(const char * host, uint16_t port, const char * url = "/socket.io/?EIO=3", BearSSL::X509List * CA_cert = NULL, const char * protocol = "arduino", uint32_t pingInterval = 60 * 1000, uint32_t pongTimeout = 90 * 1000, uint8_t disconnectTimeoutCount = 5);
void setSSLClientCertKey(const char * clientCert = NULL, const char * clientPrivateKey = NULL);
kakopappa marked this conversation as resolved.
Show resolved Hide resolved
#if defined(SSL_BARESSL)
void beginSSLWithCA(const char * host, uint16_t port, const char * url = "/socket.io/?EIO=3", BearSSL::X509List * CA_cert = NULL, const char * protocol = "arduino", uint32_t pingInterval = 60 * 1000, uint32_t pongTimeout = 90 * 1000, uint8_t disconnectTimeoutCount = 5);
void setSSLClientCertKey(BearSSL::X509List * clientCert = NULL, BearSSL::PrivateKey * clientPrivateKey = NULL);
#endif
#endif
#endif
bool isConnected(void);
Expand Down
32 changes: 27 additions & 5 deletions src/WebSockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@
#define WEBSOCKETS_YIELD() yield()
#define WEBSOCKETS_YIELD_MORE() delay(1)

#elif defined(WIO_TERMINAL) || defined(SEEED_XIAO_M0)

#define WEBSOCKETS_MAX_DATA_SIZE (15 * 1024)
#define WEBSOCKETS_YIELD() yield()
#define WEBSOCKETS_YIELD_MORE() delay(1)

#else

// atmega328p has only 2KB ram!
Expand All @@ -128,7 +134,7 @@
#define NETWORK_RP2040 (6)
#define NETWORK_UNOWIFIR4 (7)
#define NETWORK_WIFI_NINA (8)

#define NETWORK_SAMD_SEED (9)

// max size of the WS Message Header
#define WEBSOCKETS_MAX_HEADER_SIZE (14)
Expand All @@ -153,6 +159,9 @@
#elif defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT)
#define WEBSOCKETS_NETWORK_TYPE NETWORK_WIFI_NINA

#elif defined(WIO_TERMINAL) || defined(SEEED_XIAO_M0)
#define WEBSOCKETS_NETWORK_TYPE NETWORK_SAMD_SEED

#else
#define WEBSOCKETS_NETWORK_TYPE NETWORK_W5100

Expand Down Expand Up @@ -248,10 +257,6 @@
#elif(WEBSOCKETS_NETWORK_TYPE == NETWORK_UNOWIFIR4)

#include <WiFiS3.h>

#define WEBSOCKETS_NETWORK_CLASS WiFiClient
#define WEBSOCKETS_NETWORK_SERVER_CLASS WiFiServer

#define WEBSOCKETS_NETWORK_CLASS WiFiClient
#define WEBSOCKETS_NETWORK_SERVER_CLASS WiFiServer

Expand All @@ -264,6 +269,23 @@

#define WEBSOCKETS_NETWORK_CLASS WiFiClient
#define WEBSOCKETS_NETWORK_SERVER_CLASS WiFiServer
#define WEBSOCKETS_NETWORK_SSL_CLASS WiFiSSLClient

#elif(WEBSOCKETS_NETWORK_TYPE == NETWORK_SAMD_SEED)
#if __has_include(<rpcWiFi.h>) && __has_include(<rpcWiFiClientSecure.h>)
#include <rpcWiFi.h>
#include <rpcWiFiClientSecure.h>
#else
#error "Please install rpcWiFi library!"
#endif

#define WEBSOCKETS_NETWORK_CLASS WiFiClient
#define WEBSOCKETS_NETWORK_SERVER_CLASS WiFiServer
#define WEBSOCKETS_NETWORK_SSL_CLASS WiFiClientSecure

#define WEBSOCKETS_NETWORK_CLASS WiFiClient
#define WEBSOCKETS_NETWORK_SERVER_CLASS WiFiServer

#else
#error "no network type selected!"
#endif
Expand Down
Loading
Loading