LiamBindle / MQTT-C

A portable MQTT C client for embedded systems and PCs alike.
https://liambindle.ca/MQTT-C
MIT License
766 stars 269 forks source link

FPU-Trap when calculating client->typical_response_time #152

Open fawkes851 opened 2 years ago

fawkes851 commented 2 years ago

I get a FPU error on a hardware device in line 868 of mqtt.c:

client->typical_response_time = 0.875 * (client->typical_response_time) + 0.125 * (double) (MQTT_PAL_TIME() - msg->time_sent)

When the response time is typically below 1 second, the difference (MQTT_PAL_TIME() - msg->time_sent) is zero and the product get smaller each time a response is received until it hits the minimum value of a double.

As MQTT_PAL_TIME() is meant to be in seconds, it's the question whether this calculation makes sense in low latency environments.