Hi,
I hope this is the right part of the forum for this question.
I'm running a websocket server on a Blackpill STM32F11 using Arduino code from websockets2_generic.
The websocket server part works fine but it blocks any other code from running at the point commented below
This is the code from the example. The " if (client.available())" statement results in it accepting only one message before closing the socket. Changing the `if` to `while` allows continual message traffic but still doesn't allow sensor updates due to the `while loop` additionally `client.readnonblocking` is still blocking anyway.
// You can do some other tasks here, such as WebServer, controlling tasks, etc.
WebsocketsClient client = SocketsServer.accept();
if (client.available())
{
WebsocketsMessage msg = client.readNonBlocking(); // the code always hangs here waiting for traffic despite claiming to be non blocking
// log
Serial.print("Got Message: ");
Serial.println(msg.data());
// return echo
client.send("Echo: " + msg.data());
// close the connection
client.close();
}
I've googled this to death but have yet to find a solution.
I need to be able to monitor other sensors and be able to send them to the client, but so far this has not been possible due to the blocking effect of client.readnonblocking statement.
Any pointer as to how I can fix this ?
Regards Tim