Created
July 11, 2013 19:56
-
-
Save tsileo/5978677 to your computer and use it in GitHub Desktop.
JSON serial echo serve, parse JSON object over serial, and resend it back.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
JSON serial echo server | |
Parse JSON object over serial, and resend it back. | |
*/ | |
#include <aJSON.h> | |
aJsonStream serial_stream(&Serial); | |
void setup() | |
{ | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
if (serial_stream.available()) { | |
serial_stream.skip(); | |
} | |
if (serial_stream.available()) { | |
// Parse the fhe serial object if any | |
aJsonObject *msg = aJson.parse(&serial_stream); | |
// Print it | |
aJson.print(msg, &serial_stream); | |
Serial.println(); | |
// Delete it | |
aJson.deleteItem(msg); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment