-
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 Arduino Nano 33 IoT, MKR WIFI 1010 (#898)
- Loading branch information
Showing
11 changed files
with
257 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: Arduino library compliance (Lint) | ||
on: [push, pull_request] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: arduino/arduino-lint-action@v1 | ||
with: | ||
library-manager: update |
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,54 @@ | ||
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] | ||
|
||
jobs: | ||
build: | ||
name: ${{ matrix.board.fqbn }} | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
SKETCHES_REPORTS_PATH: sketches-reports | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
matrix: | ||
board: | ||
- fqbn: arduino:samd:mkrwifi1010 | ||
platforms: | | ||
- name: arduino:samd | ||
artifact-name-suffix: arduino-samd-mkrwifi1010 | ||
libraries: | | ||
- name: WiFiNINA | ||
- fqbn: arduino:samd:nano_33_iot | ||
platforms: | | ||
- name: arduino:samd | ||
artifact-name-suffix: arduino-samd-nano_33_iot | ||
libraries: | | ||
- name: WiFiNINA | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Compile examples | ||
uses: arduino/compile-sketches@v1 | ||
with: | ||
fqbn: ${{ matrix.board.fqbn }} | ||
platforms: ${{ matrix.board.platforms }} | ||
libraries: | | ||
# Install the library from the local path. | ||
- source-path: ./ | ||
${{ matrix.board.libraries }} | ||
sketch-paths: | | ||
- examples/arduino_wifinina/arduino_wifinina.ino | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
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] | ||
|
||
jobs: | ||
build: | ||
name: ${{ matrix.board.fqbn }} | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
SKETCHES_REPORTS_PATH: sketches-reports | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
matrix: | ||
board: | ||
- fqbn: arduino:renesas_uno:unor4wifi | ||
platforms: | | ||
- name: arduino:renesas_uno | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Compile examples | ||
uses: arduino/compile-sketches@v1 | ||
with: | ||
fqbn: ${{ matrix.board.fqbn }} | ||
platforms: ${{ matrix.board.platforms }} | ||
libraries: | | ||
# Install the library from the local path. | ||
- source-path: ./ | ||
sketch-paths: | | ||
- examples/arduino_renesas/arduino_uno_r4_wifi | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#include <Arduino.h> | ||
#include <SPI.h> | ||
#include <WiFiNINA.h> | ||
#include <WebSocketsClient.h> | ||
|
||
#define WIFI_SSID "" | ||
#define WIFI_PASS "" | ||
|
||
int status = WL_IDLE_STATUS; | ||
WiFiClient client; | ||
WebSocketsClient webSocket; | ||
|
||
void webSocketEvent(WStype_t type, uint8_t *payload, size_t length) { | ||
|
||
switch (type) { | ||
case WStype_DISCONNECTED: | ||
Serial.println("[WSc] Disconnected!"); | ||
break; | ||
case WStype_CONNECTED: | ||
Serial.println("[WSc] Connected!"); | ||
|
||
// send message to server when Connected | ||
webSocket.sendTXT("Connected"); | ||
break; | ||
case WStype_TEXT: | ||
Serial.print("[WSc] get text:"); | ||
Serial.println((char *)payload); | ||
|
||
// send message to server | ||
// webSocket.sendTXT("message here"); | ||
break; | ||
case WStype_BIN: | ||
// 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_PING: | ||
case WStype_PONG: | ||
case WStype_FRAGMENT_FIN: | ||
break; | ||
} | ||
} | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
|
||
while (!Serial) { | ||
; // wait for serial port to connect. Needed for native USB port only | ||
} | ||
|
||
Serial.println(); | ||
Serial.println(); | ||
Serial.println(); | ||
|
||
// check for the WiFi module: | ||
if (WiFi.status() == WL_NO_MODULE) { | ||
Serial.println("Communication with WiFi module failed!"); | ||
// don't continue | ||
while (true); | ||
} | ||
|
||
String fv = WiFi.firmwareVersion(); | ||
if (fv < WIFI_FIRMWARE_LATEST_VERSION) { | ||
Serial.println("Please upgrade the firmware"); | ||
} | ||
|
||
// attempt to connect to WiFi network: | ||
while (status != WL_CONNECTED) { | ||
Serial.print("Attempting to connect to SSID: "); | ||
Serial.println(WIFI_SSID); | ||
// Connect to WPA/WPA2 network. Change this line if using open or WEP network: | ||
status = WiFi.begin(WIFI_SSID, WIFI_PASS); | ||
|
||
// wait 10 seconds for connection: | ||
delay(10000); | ||
} | ||
|
||
Serial.println("Connected to WiFi"); | ||
|
||
// print your board's IP address: | ||
IPAddress ip = WiFi.localIP(); | ||
Serial.print("IP Address: "); | ||
Serial.println(ip); | ||
|
||
// server address, port and URL | ||
webSocket.begin("192.168.0.123", 8011); | ||
|
||
// event handler | ||
webSocket.onEvent(webSocketEvent); | ||
|
||
// 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
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