{"id":19850470,"url":"https://github.com/hideakitai/arduinoosc","last_synced_at":"2025-04-04T06:08:51.845Z","repository":{"id":41067126,"uuid":"105229814","full_name":"hideakitai/ArduinoOSC","owner":"hideakitai","description":"OSC subscriber / publisher for Arduino","archived":false,"fork":false,"pushed_at":"2024-11-07T19:00:39.000Z","size":353,"stargazers_count":211,"open_issues_count":1,"forks_count":21,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-03-28T05:12:27.125Z","etag":null,"topics":["arduino","esp32","esp8266","esp8266-arduino","osc","serial"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hideakitai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-29T04:27:56.000Z","updated_at":"2025-03-21T03:30:48.000Z","dependencies_parsed_at":"2023-11-14T05:23:59.081Z","dependency_job_id":"51410041-5cb9-45e3-aa18-a376df24dcef","html_url":"https://github.com/hideakitai/ArduinoOSC","commit_stats":null,"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hideakitai%2FArduinoOSC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hideakitai%2FArduinoOSC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hideakitai%2FArduinoOSC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hideakitai%2FArduinoOSC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hideakitai","download_url":"https://codeload.github.com/hideakitai/ArduinoOSC/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247128751,"owners_count":20888235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","esp32","esp8266","esp8266-arduino","osc","serial"],"created_at":"2024-11-12T13:26:11.809Z","updated_at":"2025-04-04T06:08:51.830Z","avatar_url":"https://github.com/hideakitai.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ArduinoOSC\n\nOSC subscriber / publisher for Arduino\n\n#### NOTE (\u003e= v0.3.x) : BREAKING API CHANGES\n\n- almost all apis has have changed and got much simpler\n- dropped support for `OscSerial` (recommend to use [MsgPacketizer](https://github.com/hideakitai/MsgPacketizer) for much smaller packet size)\n\n#### NOTE (\u003e= v0.4.0) : DEPENDENT LIBRARIES REMOVED\n\nIf you have already installed this library, please follow:\n\n- Cloned from GitHub (manually): Please install dependent libraries manually\n- Installed from library manager: re-install this library from library manager\n  - Dependent libraries will be installed automatically\n\n## Feature\n\n- simple usage\n  - flexible callback registration with lambda\n  - directly binding osc packet to values\n  - osc packet sending in one-line\n  - publishing osc packet in one-line\n- support basic OSC types based on [oscpkt](http://gruntthepeon.free.fr/oscpkt/html/)\n  - TF (`bool`: true, false)\n  - i (`int32_t`)\n  - h (`int64_t`)\n  - f (`float`)\n  - d (`double`)\n  - s (`string`)\n  - b (`bundle`)\n- support pattern-matching (wildcards)\n\n## Usage\n\n### Include ArduinoOSC\n\nPlease include `#include \"ArduinoOSC.h` first.\n\nIf you use the board which has both `WiFi` and `Ethernet`, you can't use `#include \u003cArduinoOSC.h\u003e`. Please replace it with `#include \u003cArduinoOSCWiFi.h\u003e` or `#include \u003cArduinoOSCEther.h\u003e` depending on the interface you want to use.\n\n```C++\n// For the boards which can use ether WiFi or Ethernet\n#include \u003cArduinoOSC.h\u003e\n// OR use WiFi on the board which can use both WiFi and Ethernet\n#include \u003cArduinoOSCWiFi.h\u003e\n// OR use Ethenet on the board which can use both WiFi and Ethernet\n#include \u003cArduinoOSCEther.h\u003e\n```\n\nFollowing examples use `OscWiFi`.\nTo use with `Ethernet`, please change `OscWiFi` to `OscEther`.\n\n### One-Line Subscriber / Publisher\n\n```C++\n#include \u003cArduinoOSCWiFi.h\u003e\n// #include \u003cArduinoOSC.h\u003e // you can use this if your borad supports only WiFi or Ethernet\n\nint i; float f; String s;\n\nvoid setup() {\n    // WiFi stuff\n    WiFi.begin(ssid, pwd);\n    WiFi.config(ip, gateway, subnet);\n\n    // subscribe osc packet and directly bind to variable\n    OscWiFi.subscribe(bind_port, \"/bind/values\", i, f, s);\n\n    // publish osc packet in 30 times/sec (default)\n    OscWiFi.publish(host, publish_port, \"/publish/value\", i, f, s);\n    // function can also be published\n    OscWiFi.publish(host, publish_port, \"/publish/func\", \u0026millis, \u0026micros)\n        -\u003esetFrameRate(1); // and publish it once per second\n}\n\nvoid loop() {\n    OscWiFi.update(); // should be called to subscribe + publish osc\n}\n```\n\n### Bind OSC to Lambda Arguments and One-Line Send\n\n```C++\nvoid setup() {\n    // WiFi stuff\n    // ...\n\n    OscWiFi.subscribe(bind_port, \"/lambda/bind/args\",\n        [\u0026](int\u0026 i, float\u0026 f, String\u0026 s) {\n            Serial.print(\"/lambda/bind/args \");\n            Serial.print(i); Serial.print(\" \");\n            Serial.print(f); Serial.print(\" \");\n            Serial.print(s); Serial.println();\n\n            // One-Line Send Back\n            OscWiFi.send(host, send_port, \"/reply\", i, f, s);\n        }\n    );\n}\n\nvoid loop() {\n    OscWiFi.update(); // should be called\n}\n```\n\n### Other Way to Subscribe\n\n```C++\n// OscMessage as lambda argument\nOscWiFi.subscribe(recv_port, \"/lambda/msg\",\n    [](const OscMessage\u0026 m) {\n        Serial.print(m.remoteIP()); Serial.print(\" \");\n        Serial.print(m.remotePort()); Serial.print(\" \");\n        Serial.print(m.size()); Serial.print(\" \");\n        Serial.print(m.address()); Serial.print(\" \");\n        Serial.print(m.arg\u003cint\u003e(0)); Serial.print(\" \");\n        Serial.print(m.arg\u003cfloat\u003e(1)); Serial.print(\" \");\n        Serial.print(m.arg\u003cString\u003e(2)); Serial.println();\n    }\n);\n\n// wildcard address pattern matching\nOscWiFi.subscribe(recv_port, \"/wildcard/*/test\",\n    [](const OscMessage\u0026 m) {\n        Serial.print(m.remoteIP()); Serial.print(\" \");\n        Serial.print(m.remotePort()); Serial.print(\" \");\n        Serial.print(m.size()); Serial.print(\" \");\n        Serial.print(m.address()); Serial.print(\" \");\n        Serial.print(m.arg\u003cint\u003e(0)); Serial.println();\n    }\n);\n\n// no arguments\nOscWiFi.subscribe(recv_port, \"/need/reply\", []() {\n    OscWiFi.send(host, send_port, \"/reply\", i, f, s);\n});\n\n// pre-defined callback\nOscWiFi.subscribe(recv_port, \"/callback\", onOscReceived);\n```\n\n## Supported Platform\n\nThis library currently supports following platforms and interfaces.\nPlease feel free to send PR or request for more board support!\n\n#### WiFi\n\n- ESP32\n- ESP8266\n- Raspberry Pi Pico W\n- Arduino Uno R4 WiFi\n- Arduino Uno WiFi Rev2\n- Arduino MKR VIDOR 4000\n- Arduino MKR WiFi 1010\n- Arduino MKR WiFi 1000\n- Arduino Nano 33 IoT\n\n#### Ethernet\n\n- Almost all platforms which has `Ethernet` (and `ETH`) library\n\n## Limitation and Options for NO-STL Boards\n\nSTL 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.\nThe storage size of such boards for packets, queue of packets, max packet binary size, callbacks are limited.\n\n- AVR\n- megaAVR\n\n### Usage Recommendation for Arduino Uno (and other boards with tiny memory size)\n\nFor the boards which has tiny memory size (e.g. Arduino Uno), I reccomend not to use publisher and subscriber.\nThough you can use them on such boards, such rich functions requires more memory.\nThe reccomended way is to use `send` and `parse` manually.\nThe example is shown in `examples/arduino/OscEtherUno`, so please consider to use it.\n\n```C++\n#include \u003cArduinoOSCEther.h\u003e\n// #include \u003cArduinoOSC.h\u003e // you can use this because Uno supports only Ethernet\n\n// required to use manual packet parsing\nOscEtherServer server(recv_port);\nOscEtherClient client;\n// OscEtherClient client(local_port);  // set the local port of client manually (default: 9)\n\n\nvoid setup() {\n    Ethernet.begin(mac, ip);\n}\n\nvoid loop() {\n    // manual sending instead of publishers\n    static uint32_t prev_func_ms = millis();\n    if (millis() \u003e prev_func_ms + 500) {\n        client.send(host, publish_port, \"/publish/func\", millis(), micros());\n        prev_func_ms = millis();\n    }\n\n    // manual parsing instead of subscribers\n    if (server.parse()) {\n        const OscMessage* msg = server.message();\n\n        if (msg-\u003eaddress() == \"/need/reply\") {\n            Serial.println(\"/need/reply\");\n            int i = millis();\n            float f = (float)micros() / 1000.f;\n            String s = F(\"hello\");\n            client.send(host, send_port, \"/reply\", i, f, s);\n        }\n    }\n}\n```\n\n### Memory Management (only for NO-STL Boards)\n\nAs mentioned above, for such boards like Arduino Uno, the storage sizes are limited.\nAnd of course you can manage them by defining following macros.\nBut these default values are optimized for such boards, please be careful not to excess your boards storage/memory.\n\n```C++\n#define ARDUINOOSC_MAX_MSG_ARGUMENT_SIZE 8\n#define ARDUINOOSC_MAX_MSG_BYTE_SIZE 128\n#define ARDUINOOSC_MAX_MSG_QUEUE_SIZE 1\n#define ARDUINOOSC_MAX_PUBLISH_DESTINATION 4\n#define ARDUINOOSC_MAX_SUBSCRIBE_ADDRESS_PER_PORT 4\n#define ARDUINOOSC_MAX_SUBSCRIBE_PORTS 2\n```\n\n### Enable Bundle for NO-STL Boards\n\nOSC bundle option is disabled for such boards.\nIf you want to use that, please use this macro and handle packets manually.\n`ArduinoOSC` does not use bundle by default.\n\n```C++\n#define ARDUINOOSC_ENABLE_BUNDLE\n#define ARDUINOOSC_MAX_MSG_BUNDLE_SIZE 128\n```\n\n### Enable Debug Logger\n\nYou can see the debug log when you insert following line before include `ArduinoOSC`.\n\n```C++\n#define ARDUINOOSC_DEBUGLOG_ENABLE\n#include \u003cArduinoOSC.h\u003e\n```\n\n## Dependent Libraries\n\n- [ArxTypeTraits](https://github.com/hideakitai/ArxTypeTraits)\n- [ArxContainer](https://github.com/hideakitai/ArxContainer)\n- [ArxSmartPtr](https://github.com/hideakitai/ArxSmartPtr)\n- [DebugLog](https://github.com/hideakitai/DebugLog)\n\n## Embedded Libraries\n\n- [TeensyDirtySTLErrorSolution v0.1.0](https://github.com/hideakitai/TeensyDirtySTLErrorSolution)\n\n## Special Thanks\n\n- [ofxPubSubOsc](https://github.com/2bbb/ofxPubSubOsc)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhideakitai%2Farduinoosc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhideakitai%2Farduinoosc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhideakitai%2Farduinoosc/lists"}