Hi there,
I have been following this tutorial for receiving messages using MQTT https://www.seeedstudio.com/blog/2021/02/19/build-an-mqtt-intercom-with-wio-terminal-with-code/
but I’m using the RESpeaker shield for playing sound and record audio.
I have an issue that after I receive a message and play a sound clip, the WIO terminal is no longer responsive.
This function in Wirelesscomm.h, is listening for new messages and calls alarm()
void callback(char* topic, byte* payload, unsigned int length) {
String response, identity;
if (payload && strcmp(topic,PUBTOPIC) != 0) {
for (int i = 0; i < length; i++) {
response += (char)payload[i];
}
for (int i = 0; i < (strlen(topic)-9) ; i++) {
identity += (char)topic[i];
}
fadetxt("Message from: " + identity, FSS9, 40, 250, 240, TC_DATUM);
fadetxt(response, FSS9, 40, 280, 240, TC_DATUM);
alarm();
}
}
This function in Audio.h, plays the sound.
void alarm() {
if (playSdWav1.isPlaying() == false) {
Serial.println("Start playing");
playSdWav1.play("flute.wav");
delay(10); // wait for library to parse WAV info'
}
}
If I remove playSdWav1.play(“flute.wav”); the code keeps receiving messages and printing Start playing in the serial console. Which tells me that I’m not handling something correctly while the sound is playing.
I can’t seem to be able to upload files as I’m a new user, if full code is necessary I can maybe upload a link in dropbox.