Skip to content

added the MailboxReadMessage example for the Yun #2045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
Read Messages from the Mailbox

This example for the Arduino Yún sdemonstrate how to
read the messages queue, called Mailbox using the
Bridge library.
The messages can be sent to the queue through REST calls.
Appen the message in the URL after the keyword "/mailbox".
Example

"/mailbox/hello"

created 3 Feb 2014
by Federico Vanzati & Federico Fissore

This example code is in the public domain.

http://arduino.cc/en/Tutorial/MailboxReadMessage

*/

#include <Mailbox.h>

void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
// Initialize Bridge and Mailbox
Bridge.begin();
Mailbox.begin();
digitalWrite(13, HIGH);

// Initialize Serial
Serial.begin(9600);

// Wait until a Serial Monitor is connected.
while (!Serial);

Serial.println("Mailbox Read Message\n");
Serial.println("The Mailbox is checked every 10 seconds. The incoming messages will be shown below.\n");
}

void loop() {
String message;

// if there is a message in the Mailbox
if (Mailbox.messageAvailable())
{
// read all the messages present in the queue
while (Mailbox.messageAvailable())
{
Mailbox.readMessage(message);
Serial.println(message);
}

Serial.println("Waiting 10 seconds before checking the Mailbox again");
}

// wait 10 seconds
delay(10000);
}