Skip to content

Commit

Permalink
feat: support arduino uno r4 wifi
Browse files Browse the repository at this point in the history
  • Loading branch information
hideakitai committed Feb 7, 2024
1 parent dcba74c commit 5e7b577
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 29 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,40 @@ jobs:
- name: WiFi
verbose: true

build-wifis3:
name: "Build Test (WiFiS3): ${{matrix.board.arch}}:${{matrix.board.name}}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
board:
- vendor: arduino
arch: renesas_uno
name: unor4wifi
include:
- index: https://downloads.arduino.cc/packages/package_index.json
board:
vendor: arduino
steps:
- uses: actions/checkout@v4
- name: compile example sketchs
uses: arduino/compile-sketches@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fqbn: ${{matrix.board.vendor}}:${{matrix.board.arch}}:${{matrix.board.name}}
platforms: |
- name: ${{matrix.board.vendor}}:${{matrix.board.arch}}
source-url: ${{matrix.index}}
sketch-paths: |
- examples/arduino/OscWiFi
libraries: |
- source-path: ./
- name: ArxContainer
- name: ArxSmartPtr
- name: ArxTypeTraits
- name: DebugLog
verbose: true

build-wifinina:
name: 'Build Test (WiFiNINA): ${{matrix.board.arch}}:${{matrix.board.name}}'
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion ArduinoOSCWiFi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#if defined(ESP_PLATFORM) || defined(ESP8266) || defined(ARDUINO_AVR_UNO_WIFI_REV2) \
|| defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(ARDUINO_SAMD_MKR1000) \
|| defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
|| defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(ARDUINO_UNOR4_WIFI)
#define ARDUINOOSC_ENABLE_WIFI
#endif

Expand All @@ -23,6 +23,8 @@
#include <SPI.h>
#include <WiFi101.h>
#include <WiFiUdp.h>
#elif defined(ARDUINO_UNOR4_WIFI)
#include <WiFiS3.h>
#endif
#include "ArduinoOSC/ArduinoOSCCommon.h"
using OscWiFiManager = ArduinoOSC::Manager<WiFiUDP>;
Expand Down
45 changes: 18 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

OSC subscriber / publisher for Arduino


#### NOTE (>= v0.3.x) : BREAKING API CHANGES

- almost all apis has have changed and got much simpler
Expand All @@ -19,22 +18,21 @@ If you have already installed this library, please follow:
## Feature

- simple usage
- flexible callback registration with lambda
- directly binding osc packet to values
- osc packet sending in one-line
- publishing osc packet in one-line
- flexible callback registration with lambda
- directly binding osc packet to values
- osc packet sending in one-line
- publishing osc packet in one-line
- support basic OSC types based on [oscpkt](http://gruntthepeon.free.fr/oscpkt/html/)
- TF (`bool`: true, false)
- i (`int32_t`)
- h (`int64_t`)
- f (`float`)
- d (`double`)
- s (`string`)
- b (`bundle`)
- TF (`bool`: true, false)
- i (`int32_t`)
- h (`int64_t`)
- f (`float`)
- d (`double`)
- s (`string`)
- b (`bundle`)
- support pattern-matching (wildcards)
- does NOT support timestamp values.


## Usage

### Include ArduinoOSC
Expand Down Expand Up @@ -85,7 +83,7 @@ void loop() {

### Bind OSC to Lambda Arguments and One-Line Send

``` C++
```C++
void setup() {
// WiFi stuff
// ...
Expand All @@ -110,7 +108,7 @@ void loop() {

### Other Way to Subscribe

``` C++
```C++
// OscMessage as lambda argument
OscWiFi.subscribe(recv_port, "/lambda/msg",
[](const OscMessage& m) {
Expand Down Expand Up @@ -144,7 +142,6 @@ OscWiFi.subscribe(recv_port, "/need/reply", []() {
OscWiFi.subscribe(recv_port, "/callback", onOscReceived);
```


## Supported Platform

This library currently supports following platforms and interfaces.
Expand All @@ -155,6 +152,7 @@ Please feel free to send PR or request for more board support!
- ESP32
- ESP8266
- Raspberry Pi Pico W
- Arduino Uno R4 WiFi
- Arduino Uno WiFi Rev2
- Arduino MKR VIDOR 4000
- Arduino MKR WiFi 1010
Expand All @@ -165,7 +163,6 @@ Please feel free to send PR or request for more board support!

- Almost all platforms which has `Ethernet` (and `ETH`) library


## Limitation and Options for NO-STL Boards

STL is used to handle packet data by default, but for following boards/architectures, [ArxContainer](https://github.com/hideakitai/ArxContainer) is used to store the packet data because STL can not be used for such boards.
Expand All @@ -174,15 +171,14 @@ The storage size of such boards for packets, queue of packets, max packet binary
- AVR
- megaAVR


### Usage Recommendation for Arduino Uno (and other boards with tiny memory size)

For the boards which has tiny memory size (e.g. Arduino Uno), I reccomend not to use publisher and subscriber.
Though you can use them on such boards, such rich functions requires more memory.
The reccomended way is to use `send` and `parse` manually.
The example is shown in `examples/arduino/OscEtherUno`, so please consider to use it.

``` C++
```C++
#include <ArduinoOSCEther.h>
// #include <ArduinoOSC.h> // you can use this because Uno supports only Ethernet

Expand Down Expand Up @@ -219,14 +215,13 @@ void loop() {
}
```
### Memory Management (only for NO-STL Boards)
As mentioned above, for such boards like Arduino Uno, the storage sizes are limited.
And of course you can manage them by defining following macros.
But these default values are optimized for such boards, please be careful not to excess your boards storage/memory.
``` C++
```C++
#define ARDUINOOSC_MAX_MSG_ARGUMENT_SIZE 8
#define ARDUINOOSC_MAX_MSG_BYTE_SIZE 128
#define ARDUINOOSC_MAX_MSG_QUEUE_SIZE 1
Expand All @@ -241,22 +236,20 @@ OSC bundle option is disabled for such boards.
If you want to use that, please use this macro and handle packets manually.
`ArduinoOSC` does not use bundle by default.

``` C++
```C++
#define ARDUINOOSC_ENABLE_BUNDLE
#define ARDUINOOSC_MAX_MSG_BUNDLE_SIZE 128
```
### Enable Debug Logger
You can see the debug log when you insert following line before include `ArduinoOSC`.
``` C++
```C++
#define ARDUINOOSC_DEBUGLOG_ENABLE
#include <ArduinoOSC.h>
```


## Dependent Libraries

- [ArxTypeTraits](https://github.com/hideakitai/ArxTypeTraits)
Expand All @@ -268,12 +261,10 @@ You can see the debug log when you insert following line before include `Arduino

- [TeensyDirtySTLErrorSolution v0.1.0](https://github.com/hideakitai/TeensyDirtySTLErrorSolution)


## Special Thanks

- [ofxPubSubOsc](https://github.com/2bbb/ofxPubSubOsc)


## License

MIT
10 changes: 9 additions & 1 deletion examples/arduino/OscWiFi/OscWiFi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,18 @@ void setup() {
WiFi.mode(WIFI_STA);
#endif
WiFi.begin(ssid, pwd);
WiFi.config(ip, gateway, subnet);
WiFi.config(ip); // you can also set (ip, gateway, subnet)
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
#ifdef ARDUINO_UNOR4_WIFI
static int count = 0;
if (count++ > 20) {
Serial.println("WiFi connection timeout, retry");
WiFi.begin(ssid, pwd);
count = 0;
}
#endif
}
Serial.print("WiFi connected, IP = ");
Serial.println(WiFi.localIP());
Expand Down
5 changes: 5 additions & 0 deletions examples/arduino/OscWiFiAP/OscWiFiAP.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ void setup() {
delay(2000);

// WiFi AP Mode
#ifdef ARDUINO_UNOR4_WIFI
WiFi.config(ip);
WiFi.beginAP(ssid, pwd);
#else
WiFi.softAPConfig(ip, gateway, subnet);
WiFi.softAP(ssid, pwd);
#endif

Serial.print("WiFi AP IP = ");
Serial.println(WiFi.softAPIP());
Expand Down

0 comments on commit 5e7b577

Please sign in to comment.