diff options
Diffstat (limited to 'libraries/Bridge/examples')
-rw-r--r-- | libraries/Bridge/examples/Bridge/Bridge.ino | 32 | ||||
-rw-r--r-- | libraries/Bridge/examples/FileTest/FileTest.ino | 50 | ||||
-rw-r--r-- | libraries/Bridge/examples/HttpClient/HttpClient.ino | 23 | ||||
-rw-r--r-- | libraries/Bridge/examples/Process/Process.ino | 24 |
4 files changed, 129 insertions, 0 deletions
diff --git a/libraries/Bridge/examples/Bridge/Bridge.ino b/libraries/Bridge/examples/Bridge/Bridge.ino new file mode 100644 index 0000000..848cc4e --- /dev/null +++ b/libraries/Bridge/examples/Bridge/Bridge.ino @@ -0,0 +1,32 @@ + +#include <Bridge.h> + +void brk() { + Bridge.print((char)3); +} + +void setup() { + pinMode(13,OUTPUT); + digitalWrite(13, LOW); + Bridge.begin(); + digitalWrite(13, HIGH); + + delay(2000); + int handle = Bridge.beginCommand("curl"); + Bridge.commandAddEscapedParam("http://arduino.cc/asciilogo.txt"); + Bridge.endCommand(); + + while (Bridge.commandIsRunning(handle)) + delay(250); + + int size = Bridge.commandOutputSize(handle); + char buff[20]; + Bridge.readCommandOutput(handle, 0, size, buff); + buff[size]=0; + Bridge.print(buff);brk(); +} + +void loop() { +} + + diff --git a/libraries/Bridge/examples/FileTest/FileTest.ino b/libraries/Bridge/examples/FileTest/FileTest.ino new file mode 100644 index 0000000..3fd7ce9 --- /dev/null +++ b/libraries/Bridge/examples/FileTest/FileTest.ino @@ -0,0 +1,50 @@ + +#include <FileIO.h> + +void setup() { + Bridge.begin(); + SD.begin(); + + boolean r; + r=SD.exists("/arduino/test"); + if (r) error("1"); + r=SD.exists("/arduino"); + if (!r) error("2"); + + r=SD.mkdir("/arduino/test"); + if (!r) error("3"); + r=SD.exists("/arduino/test"); + if (!r) error("4"); + + File f = SD.open("/arduino/test/bla", FILE_WRITE); + if (!f) error("5"); + f.println("CIAO!"); + f.close(); + + delay(10000); + + r=SD.rmdir("/arduino/test"); + if (r) error("6"); + r=SD.remove("/arduino/test"); + if (r) error("7"); + + r=SD.remove("/arduino/test/bla"); + if (!r) error("8"); + r=SD.rmdir("/arduino/test"); + if (!r) error("9"); + r=SD.exists("/arduino/test"); + if (r) error("10"); +} + + +void error(const char *s) { + Bridge.print("# ERROR "); + Bridge.println(s); + while (true); +} + +void loop() { +} + + + diff --git a/libraries/Bridge/examples/HttpClient/HttpClient.ino b/libraries/Bridge/examples/HttpClient/HttpClient.ino new file mode 100644 index 0000000..bf5e8ff --- /dev/null +++ b/libraries/Bridge/examples/HttpClient/HttpClient.ino @@ -0,0 +1,23 @@ + +#include <HttpClient.h> + +void setup() { + pinMode(13, OUTPUT); + digitalWrite(13, LOW); + Bridge.begin(); +} + +void loop() { + HttpClient client; + client.get("http://my.server.address/file.php"); + + char c = client.read(); + if (c=='1') + digitalWrite(13, HIGH); + if (c=='0') + digitalWrite(13, LOW); + + delay(5000); +} + + diff --git a/libraries/Bridge/examples/Process/Process.ino b/libraries/Bridge/examples/Process/Process.ino new file mode 100644 index 0000000..f954646 --- /dev/null +++ b/libraries/Bridge/examples/Process/Process.ino @@ -0,0 +1,24 @@ +#include <Process.h> + +void brk() { + Bridge.print((char)3); + Bridge.find("#"); +} + +void setup() { + Bridge.begin(); + + Process p; + p.begin("curl"); + p.addParameter("http://arduino.cc/asciilogo.txt"); + p.run(); + + String res = ""; + while (p.IO.available()>0) { + p.IO.read(); + } +} + +void loop() { +} + |