Avoid WebsocketsServer loop blocking
Posted: Tue Nov 12, 2019 11:34 pm
I have a esp32-cam an I use a WebsocketsServer to send the video streaming.
This is my code:
The code works, the client receive the video, however the "other code" on loop is not execute.
"auto client = camserver.accept();" doesn't allow the execution of other code. For example I need check temperature from sensor every 5 seconds.
Any ideas about how avoid this?
This is my code:
- auto client = camserver.accept();
- while (client.available()) {
- client.poll();
- fb = esp_camera_fb_get();
- client.sendBinary((const char *)fb->buf, fb->len);
- esp_camera_fb_return(fb);
- fb = NULL;
- }
- // other code to check temperature from sensor
"auto client = camserver.accept();" doesn't allow the execution of other code. For example I need check temperature from sensor every 5 seconds.
Any ideas about how avoid this?