Skip to content

It is hoped that a public function can be added to OSCMessage to obtain the binary array of OSCMessage, so that OSC messages can be sent in more ways. #142

@ChinaBurn

Description

@ChinaBurn

It is hoped that a public function can be added to OSCMessage to obtain the binary array of OSCMessage, so that OSC messages can be sent in more ways. Especially on other MCUs, such as esp32, stm32.
Below is a sample code snippet of mine on eps32, which can accurately receive osc messages, but the sent osc messages are subpackaged by UDP, resulting in incomplete data.

The hardware is esp32+Lan8720 sending and receiving through Ethernet, using "AsyncUDP":

void InitAsyncUDP() {
  if (AsyncUdp.listen(UDPLocalPort)) {
    Serial.printf("AsyncUDP Listening on Port: %d\n", UDPLocalPort);
    AsyncUdp.onPacket(UDPReceiver);
  }
}

void UDPReceiver(AsyncUDPPacket packet) {
  OSCBundle bundleIN;
  bundleIN.fill(packet.data(), packet.length());
  if (!bundleIN.hasError()) {
    bundleIN.route("/TableLight", routeTone);
  } else {
    Serial.printf("OSCReceiveError\n");
  }
  // Serial.printf("Received Udp Packet Lenght:%d\n", packet.length());
}

void Task_SendOSC() {
  int AccelerationOSC = round(Acceleration * 100.00);
  OSCMessage msg("/BianMaQi");
  msg.add(AccelerationOSC);
  AsyncUdp.connect(RemooteOSCIP, RemooteOSCPort);
  msg.send(AsyncUdp);
  AsyncUdp.close();
  msg.empty();
}

In the above code, receiving osc messages works fine, but the sent osc messages are divided into multiple udp data packets, but the data length is correct. Because of this, when another device receives the osc message, a parsing error will occur.

In esp32, AsyncUdp has methods for sending data, such as:

size_t writeTo(const uint8_t *data, size_t len, const IPAddress addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX);

If I can obtain the binary data of this message after constructing the OSC message, I can send it out in this way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions