-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support Nano 33 IoT, MKR WIFI 1010, XIAO, Wio Terminal (#901)
- Loading branch information
Showing
14 changed files
with
286 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
examples/seeed-studio/xio-wio-terminal/WebSocketClient/WebSocketClient.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.