![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
FRDM-K64F, Avnet M14A2A, Grove Shield, to create smart home system. In use with AT&Ts M2x & Flow.
Dependencies: mbed FXOS8700CQ MODSERIAL
Diff: main.cpp
- Revision:
- 52:9dafcb7f320f
- Parent:
- 50:8ac42961458c
- Child:
- 53:dcccf2881fa0
--- a/main.cpp Sun Jul 24 21:56:14 2016 +0000 +++ b/main.cpp Sun Jul 24 22:10:12 2016 +0000 @@ -518,12 +518,17 @@ printf(YEL "Read back : %s" DEF "\r\n", &MySocketData[0]); char myJsonResponse[512]; char stringToCharBuf[BUF_SIZE_FOR_N_MAX_SOCKREAD*MAX_WNC_SOCKREAD_PAYLOAD+1]; // WNC can return max of 1500 (per sockread) - strcpy(stringToCharBuf, MySocketData.c_str()); - if (extract_JSON(stringToCharBuf, &myJsonResponse[0])) + if ((MySocketData.length() + 1) < sizeof(stringToCharBuf)) { - printf(GRN "JSON : %s" DEF "\n", &myJsonResponse[0]); - parse_JSON(&myJsonResponse[0]); + strcpy(stringToCharBuf, MySocketData.c_str()); + if (extract_JSON(stringToCharBuf, &myJsonResponse[0])) + { + printf(GRN "JSON : %s" DEF "\n", &myJsonResponse[0]); + parse_JSON(&myJsonResponse[0]); + } } + else + puts("BUFFER not big enough for sock data!\r\n"); } else {