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:

Code: Untitled.cpp Select all


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
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: ChatGPT-User, Qwantbot and 7 guests