Closed dacattack closed 10 months ago
Do you have any kind of debug log output so we can see what's going on? I suspect some sort of concurrency/mutex-code blocking execution.
Indeed I believe is an issue realted with the semaphores used by the i2s driver and the mqtt library but I have no idea how to fix it. There's not much additional info coming from the debug. You can check this yourself using my code or your own code as long as you send i2s audio buffers. To be honest the problem also occurs using PubSubClient library. At this point is important to understand that it affects the execution time of the publish function not the i2s_read function. I hope we end up finding the issue. If I find any solution I'll post it here. Thanks
What is the exact behaviour you're seeing?
Does the publish function block? Or do you have a "delayed receipt".
Could you post the output of your Serial.print
statements?
You might want to delay()
in your mqtt task.
I don't have an i2s device. I can't do real-world testing.
void MqttLoopTask(){
for(;;){
mqttclient.loop();
}
}
writing a task function that never blocks is very poor application design. You run the task at 0's core with prio 3 and it makes other tasks on the same core starve, which is network WiFi stack on core 0.
You may consider adding a vTaskDelay(1 / portTICK_PERIOD_MS);
to you loop or add taskYIELD();
and run your task with lowest prio.
Is this issue still relevant? Any progress?
Closing due to inactivity. feel free to reopen if the issue is still relevant.
Do not use to discuss topics!
Describe the bug This library seems to have some kind of problem when working together with i2s driver. I've done many tests and the results are always the same. I'm sending audio files read by the inmp441 MEMS. You can get a few published messages withouth any problem, in fact, it only takes around 300 microseconds to publish a 14KB message(which is amazing) but eventually it will freeze and next message will take around 800-1200 ms and that is not acceptable at all. If I disable I2S then this won't happen. Well actually the sending time its very unestable and some messages might take a few miliseconds, but always within a reasonable amount of time.
Which platform, esp8266 or esp32? I'm using ESP32 Do you use TLS or not? I do use TLS. Do you use an IDE (Arduino, Platformio...)? PlatformIO Which version of the Arduino framework? 2.0.9 Please include any debug output and/or decoded stack trace if applicable.
Expected behaviour Estable sending time. I can expect messages to vary a bit, but not this huge amount of time.
To Reproduce Steps to reproduce the behaviour: Set up the mqtt library, objects,functions and get a valid SSL/TLS certificate for your broker. Then include library "/driver/i2s.h" and configure the microphone i2s communications( SR of 16KHz, 16 bit data width) and then send the audio files with a QoS 2. Measure with the function micros() the time the library spent delivering the message to de broker.
Example code
Additional context Add any other context about the problem here.