hideakitai / ArduinoOSC

OSC subscriber / publisher for Arduino
MIT License
207 stars 20 forks source link

Timestamp support? #56

Closed jhurliman closed 2 months ago

jhurliman commented 3 months ago

I see the message in the README about timestamps being ignored. I’m looking to add time synchronization and receive scheduled OSC messages on a dozen ESP32s. I’m happy to submit a PR to add timestamp support, but wanted to check:

  1. Is this something you’d be interested in merging?
  2. Where should I look in the codebase to add timestamp support?
hideakitai commented 2 months ago

Hi, @jhurliman

Thank you very much for considering your contribution. Yes, I'm interested in it. For the current status,

...Huh? You could use it if you wanted to... maybe!

hideakitai commented 2 months ago

If you can confirm you can use TimeTag, we should fix the comment in the README

jhurliman commented 2 months ago

I don't see an example of how to send a manually constructed OscMessage, could you point me in the right direction?

OscMessage msg_out;
OscEncoder wr;

// Get the current time (ESP32)
const uint64_t now = esp_timer_get_time();

wr.init().begin_bundle(TimeTag(now));
wr.encode(msg_out.init(OSC_TIME_RESPONSE).push(now));
wr.end_bundle();
// no matching function for call to 'arduino::osc::Manager<WiFiUDP>::send(const String&, const uint16_t&, OscMessage&)'
OscWiFi.send(msg_in.remoteIP(), OSC_SEND_PORT, msg_out);
hideakitai commented 2 months ago

Supported (but not tested) sending with timetag in main branch https://github.com/hideakitai/ArduinoOSC/pull/57

Please try

    const uint64_t now = esp_timer_get_time();
    const auto tt = OscTimeTag(now);
    OscWiFi.send(host, send_port, tt, "/msg", 1, 2.2f, "hello");
hideakitai commented 2 months ago

Ah sorry, it was not a bundle

hideakitai commented 2 months ago

The bundle is now supported in the main branch. Can you try this example? @jhurliman

https://github.com/hideakitai/ArduinoOSC/blob/main/examples/arduino/OscWiFiBundle/OscWiFiBundle.ino

hideakitai commented 2 months ago

If you still need help, please reopen this issue.