Fix invalid JSON

Fix invalid JSON floating point result from nan into null (#4147)
This commit is contained in:
Theo Arends 2018-10-25 10:44:59 +02:00
parent 048de4c7fa
commit 51ee22273b
2 changed files with 13 additions and 6 deletions

View File

@ -1,6 +1,7 @@
/* 6.2.1.19 20181023
* Fix header file execution order by renaming user_config.h to my_user_config.h
*
* Fix invalid JSON floating point result from nan into null (#4147)
*
* 6.2.1.18 20181019
* Add more API callbacks and document API.md
* Add support for La Crosse TX20 Anemometer (#2654, #3146)

View File

@ -196,7 +196,12 @@ int TextToInt(char *str)
char* dtostrfd(double number, unsigned char prec, char *s)
{
return dtostrf(number, 1, prec, s);
if (isnan(number)) {
strcpy(s, "null");
return s;
} else {
return dtostrf(number, 1, prec, s);
}
}
char* Unescape(char* buffer, uint16_t* size)
@ -630,10 +635,6 @@ boolean GetUsedInModule(byte val, uint8_t *arr)
if (GPIO_I2C_SCL == val) { return true; }
if (GPIO_I2C_SDA == val) { return true; }
#endif
#ifndef USE_SR04
if (GPIO_SR04_TRIG == val) { return true; }
if (GPIO_SR04_ECHO == val) { return true; }
#endif
#ifndef USE_WS2812
if (GPIO_WS2812 == val) { return true; }
#endif
@ -706,6 +707,11 @@ boolean GetUsedInModule(byte val, uint8_t *arr)
if (GPIO_HX711_SCK == val) { return true; }
if (GPIO_HX711_DAT == val) { return true; }
#endif
#ifndef USE_TX20_WIND_SENSOR
if (GPIO_TX20_TXD_BLACK == val) { return true; }
#endif
if ((val >= GPIO_REL1) && (val < GPIO_REL1 + MAX_RELAYS)) {
offset = (GPIO_REL1_INV - GPIO_REL1);
}