Avoid WebsocketsServer loop blocking

array81
Posts: 3
Joined: Fri Oct 18, 2019 2:50 pm

Avoid WebsocketsServer loop blocking

Postby array81 » 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:
  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?

Who is online

Users browsing this forum: No registered users and 68 guests