Wemos OSCBundle crash

I have a Wemos D1 mini with one button on D5. If pressed it has to sent 2 OSC messages and when release it has to sent 2 messages again.
Using the code it will contact my Wifi. But I get a crash when one of the sent routines is called. Any thoughts?

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (3):
epc1=0x40100615 epc2=0x00000000 epc3=0x00000000 excvaddr=0x4002f521 depc=0x00000000

stack>>>

ctx: cont
sp: 3ffffda0 end: 3fffffd0 offset: 0150
3ffffef0: 000005c0 000000b8 3ffe85fc 401006ce
3fffff00: 000005c0 000000b8 3ffe85fc 3ffee660
3fffff10: 3ffef4c4 00000020 3ffef4ec 40100a1c
3fffff20: 3fffdad0 00000000 3ffef4c4 4020262c
3fffff30: 3fffdad0 00000020 3fffff50 4020218f
3fffff40: 3fffdad0 00000000 3ffee570 402012b8
3fffff50: 3ffef57c 00000002 00000000 00000000
3fffff60: 00000000 00000000 00000000 00000000
3fffff70: 3fffdad0 3ffef4ec 00000000 00000000
3fffff80: 00000000 00000000 3ffef73c 00000000
3fffff90: 00000010 40205f88 1001a8c0 3ffee660
3fffffa0: 3fffdad0 00001528 3ffee634 40201388
3fffffb0: 3fffdad0 00000000 3ffee634 40203318
3fffffc0: feefeffe feefeffe 3fffdab0 40100dc9
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3424, room 16
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8
tail 0
chksum 0x2b
csum 0x2b
v00043f30

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
//#include <OSCMessage.h>
#include <OSCBundle.h>
// #include <OSCData.h>

const int StatusLed = LED_BUILTIN;
const int SwitchButton = D5;
int LastState = HIGH;

char ssid[] = "WorstCase24";  // your network SSID (name)
char pass[] = "XXXXXX";   // your network password

WiFiUDP Udp;                             // A UDP instance to let us send and receive packets over UDP
const IPAddress outIp(192, 168, 1, 16);  // remote IP of your computer
const unsigned int outPort = 10024;      // remote port to receive OSC
const unsigned int localPort = 30000;    // local port to listen for OSC packets (actually not used for sending)

void setup() {
  Serial.begin(115200);
  delay(1000);
  pinMode(StatusLed, OUTPUT);
  digitalWrite(StatusLed, HIGH);
  pinMode(SwitchButton, INPUT);
  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, pass);

  while (WiFi.status() != WL_CONNECTED) {
    digitalWrite(StatusLed, LOW);
    delay(100);
    digitalWrite(StatusLed, HIGH);
    delay(400);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  digitalWrite(StatusLed, HIGH);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.println("Starting UDP");
  Udp.begin(localPort);
  Serial.print("Local port: ");
#ifdef ESP32
  Serial.println(localPort);
#else
  Serial.println(Udp.localPort());
#endif
  Serial.print("Mixer IP address: ");
  Serial.println(outIp);
  Serial.print("Mixer Port: ");
  Serial.println(outPort);
  delay(1000);
}

void loop() {
  bool sensorVal = digitalRead(SwitchButton);
  if (LastState != sensorVal) {
    LastState = sensorVal;
    if (sensorVal == HIGH) {
       SwitchOff();
    } else {
      SwitchOn();
    }
  }
  delay(100);
}

void SwitchOn() {
  digitalWrite(StatusLed, LOW);
  OSCBundle bundle;
  OSCMessage msg = bundle.add("/ch/07/mix/on");
  msg.add(0);
  bundle.add("/ch/08/mix/on");
  msg.add(1);
  Udp.beginPacket(outIp, outPort);
  bundle.send(Udp);
  Udp.endPacket();
  //msg.empty();
  Serial.println(F("MUTE ON"));
}

void SwitchOff() {
  digitalWrite(StatusLed, HIGH);
  OSCBundle bundle;
  OSCMessage msg = bundle.add("/ch/07/mix/on");
  msg.add(1);
  bundle.add("/ch/08/mix/on");
  msg.add(0);
  Udp.beginPacket(outIp, outPort);
  bundle.send(Udp);
  Udp.endPacket();
  //msg.empty();
  Serial.println(F("MUTE OFF"));
}

Debounce your button.

do not use delay().

Yeah. I know. but first I want to have the subroutines right and to know that it is functional working as it should do.
Changing the main loop was my next goal. But first I have to get rid of the crashes.

There is something wrong with OSCBundle.
This code functions, but ons has got one item.

void SwitchOn2() {
  //digitalWrite(StatusLed, HIGH);
  OSCMessage msg("/ch/07/mix/on");
  msg.add(1);
  Udp.beginPacket(outIp, outPort);
  msg.send(Udp);
  //delay(100);
  Udp.endPacket();
  Serial.println("MUTE OFF");
}

I changed the OSCBundle code. The output seems correct, but my X AIR mixer does not resond to it.

void SwitchOn() {
  OSCBundle bundle;
  //digitalWrite(StatusLed, HIGH);
  OSCMessage msg; 
  bundle.add("/ch/07/mix/on").add(1);
  bundle.add("/ch/08/mix/on").add(0);
  Udp.beginPacket(outIp, outPort);
  bundle.send(Udp);
  //delay(100);
  Udp.endPacket();
  Serial.println("MUTE OFF");
}

Does anybody has got a functional code with OSCBundle?

Finally I rewrote my code based on ESP8266-XR-Console-Remote

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.