Fixed: missing os_sprintf %s

pull/196/head
cskarai 8 years ago
parent 491931b7d2
commit 1cd8363834
  1. 14
      web-server/web-server.c

@ -392,10 +392,16 @@ static int ICACHE_FLASH_ATTR WEB_handleMCUResponse(HttpdConnData *connData, CmdR
float f; float f;
os_memcpy( &f, value, 4); os_memcpy( &f, value, 4);
char intbuf[20]; // os_sprintf doesn't support %f
os_sprintf(intbuf, "%f", f); int intPart = f;
os_strcpy(jsonBuf + jsonPtr, intbuf); int fracPart = (f - intPart) * 1000; // use 3 digit precision
jsonPtr += os_strlen(intbuf); if( fracPart < 0 ) // for negative numbers
fracPart = -fracPart;
char floatBuf[20];
os_sprintf(floatBuf, "%d.%03d", intPart, fracPart);
os_strcpy(jsonBuf + jsonPtr, floatBuf);
jsonPtr += os_strlen(floatBuf);
} }
break; break;
case WEB_STRING: case WEB_STRING:

Loading…
Cancel
Save