Skip to content

Instantly share code, notes, and snippets.

@tsileo
Created July 11, 2013 19:56
Show Gist options
  • Save tsileo/5978677 to your computer and use it in GitHub Desktop.
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.
/*
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