Skip to content

Commit f55e788

Browse files
authored
Fix bl602 crashing trying to publish NaN (#1925)
* Fix bl602 crashing trying to publish NaN * Fix bl602 crashing trying to publish NaN
1 parent 7a547c9 commit f55e788

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/mqtt/new_mqtt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "../driver/drv_deviceclock.h"
1717
#include "../driver/drv_tuyaMCU.h"
1818
#include "../hal/hal_ota.h"
19+
#include <math.h>
1920
#ifndef WINDOWS
2021
#include <lwip/dns.h>
2122
#endif
@@ -1443,6 +1444,9 @@ OBK_Publish_Result MQTT_PublishMain_StringInt(const char* sChannel, int iv, int
14431444
OBK_Publish_Result MQTT_PublishMain_StringFloat(const char* sChannel, float f, int maxDecimalPlaces, int flags)
14441445
{
14451446
char valueStr[16];
1447+
if (isnan(f)) {
1448+
f = 0;
1449+
}
14461450

14471451
sprintf(valueStr, "%f", f);
14481452
// fix decimal places

0 commit comments

Comments
 (0)