ATmega32U4 code:
#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); }
AR9331 code:
opkg update opkg install php5-cli php5-mod-sockets php5-mod-json
nano mailbox.php
<?php require("/usr/lib/php/bridge/bridgeclient.class.php"); $client = new bridgeclient(); print("Sending mailbox message 'Hello world from PHP!'\n"); $client->mailbox("Hello world from PHP!"); ?>
/usr/bin/php-cli mailbox.php
Mailbox Read Message The Mailbox is checked every 10 seconds. The incoming messages will be shown below. Hello world from PHP! Waiting 10 seconds before checking the Mailbox again
Comments powered by CComment