Page 1 of 1

Avoid WebsocketsServer loop blocking

Posted: Tue Nov 12, 2019 11:34 pm
by array81
I have a esp32-cam an I use a WebsocketsServer to send the video streaming.
This is my code:
  1. auto client = camserver.accept();
  2.  
  3. while (client.available()) {
  4.   client.poll();
  5.   fb = esp_camera_fb_get();
  6.   client.sendBinary((const char *)fb->buf, fb->len);
  7.   esp_camera_fb_return(fb);
  8.   fb = NULL;
  9. }
  10.  
  11. // other code to check temperature from sensor
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?