Comments (1)
osc.addCallback("/ard/aaa", &callback);
osc.addCallback("/ard", &callback);
These are the "callback" function, so if the OSC message comes and the address of OSC is "/ard/aaa" or "/ard", callback() will be called.
//create new osc message
OSCMessage msg;
//set destination ip address & port no
msg.beginMessage(host, send_port);
//set argument
msg.setOSCAddress(m.getOSCAddress());
msg.addArgInt32(m.getArgAsInt32(0));
msg.addArgFloat(m.getArgAsFloat(1));
msg.addArgString(m.getArgAsString(2));
//send osc message
osc.send(msg);
Serial.println("Sent OSC message");
And these are the sequence to send OSC message. You can make sendOSC() function like
void sendOSC()
{
//create new osc message
OSCMessage msg;
//set destination ip address & port no
msg.beginMessage(host, send_port);
//set argument
msg.setOSCAddress("/return");
msg.addArgInt32(1);
msg.addArgFloat(2.2);
msg.addArgString("return message");
//send osc message
osc.send(msg);
Serial.println("Sent OSC message");
}
and also you can set this function to callback function like
void callback(OSCMessage& m)
{
sendOSC();
}
then you can get
#include <ArduinoOSC.h>
void setup()
{
// various settings...
osc.addCallback("/ard/aaa", &sendTest1); // if "/ard/aaa XXX" has come, sendTest1() will be called
osc.addCallback("/ard", &sendTest2); // if "/ard XXX" has come, sendTest2() will be called
}
void loop()
{
osc.parse();
}
void sendTest1(OSCMessage& m)
{
//create new osc message
OSCMessage msg;
//set destination ip address & port no
msg.beginMessage(host, send_port);
//set argument
msg.setOSCAddress("/return");
msg.addArgInt32(1);
msg.addArgFloat(2.2);
msg.addArgString("test");
//send osc message
osc.send(msg);
Serial.println("Sent OSC message");
}
void sendTest2(OSCMessage& m)
{
//create new osc message
OSCMessage msg;
//set destination ip address & port no
msg.beginMessage(host, send_port);
//set argument
msg.setOSCAddress("/test");
msg.addArgInt32(3);
msg.addArgFloat(4.4);
msg.addArgString("test2");
//send osc message
osc.send(msg);
Serial.println("Sent OSC message");
}
or you can just send OSC message in one second
#include <ArduinoOSC.h>
void setup()
{
// various settings...
// no callback definition
// osc.addCallback("/ard/aaa", &callback);
// osc.addCallback("/ard", &callback);
}
void loop()
{
// just send current time in one second
delay(1000);
//create new osc message
OSCMessage msg;
//set destination ip address & port no
msg.beginMessage(host, send_port);
//set argument
msg.setOSCAddress("/test");
msg.addArgInt32(millis()); // millis
msg.addArgFloat((float)millis() / 1000.f); // second
msg.addArgString("second");
//send osc message
osc.send(msg);
Serial.println("Sent OSC message");
}
from arduinoosc.
Related Issues (20)
- errors compiling the OscEtherUno sketch HOT 1
- Improve sending/receiving bundle
- Compilation error when including ArduinoOSC.h in a C++ header HOT 5
- Event-driven approach to receiving OSC data rather than polling? HOT 4
- Is it possible to have a non-fixed IP ? HOT 3
- Unable to parse or post any OSC message on WiFi HOT 4
- ESP32 AP mode HOT 5
- run ArduinoOSCEther with OLIMEX ESP32 POE HOT 9
- Core Panic issue HOT 1
- support for RPI Pico W HOT 1
- Example with OSC over Serial using MsgPacketizer HOT 1
- Teensy 4.1 Native Ethernet support HOT 2
- Add support for multicast? HOT 1
- Add support for softAP HOT 1
- Add support for Raspberry Pi PICO W
- multiple clients HOT 1
- now the dependencies must be installed separately? HOT 5
- RP2040 not sending wifi when in station mode HOT 6
- gccのバージョンエラー HOT 3
- In OscWiFiAP example, no ip obtained. HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduinoosc.