From 56f60f5ce34b8fd3c2e178a7f93b78ca994c454b Mon Sep 17 00:00:00 2001 From: Andrew Yong Date: Sun, 25 Sep 2016 21:02:30 +0800 Subject: [PATCH] Prevent publishing "NaN" literally --- Adafruit_MQTT.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Adafruit_MQTT.cpp b/Adafruit_MQTT.cpp index f08ec05..7b775dd 100644 --- a/Adafruit_MQTT.cpp +++ b/Adafruit_MQTT.cpp @@ -788,6 +788,8 @@ bool Adafruit_MQTT_Publish::publish(uint32_t i) { } bool Adafruit_MQTT_Publish::publish(double f, uint8_t precision) { + if (isnan(f)) + return false; char payload[41]; // Need to technically hold float max, 39 digits and minus sign. dtostrf(f, 0, precision, payload); return mqtt->publish(topic, payload, qos);