A test program for Pachube library.

Dependencies:   mbed ThermistorPack Pachube EthernetNetIf

Files at this revision

API Documentation at this revision

Comitter:
shintamainjp
Date:
Thu Sep 30 22:23:27 2010 +0000
Child:
1:d4f8908bf66f
Commit message:

Changed in this revision

extlib/EthernetNetIf.lib Show annotated file Show diff for this revision Revisions of this file
extlib/HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
mylib/Pachube.lib Show annotated file Show diff for this revision Revisions of this file
mylib/ThermistorPack.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extlib/EthernetNetIf.lib	Thu Sep 30 22:23:27 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/EthernetNetIf/#bc7df6da7589
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extlib/HTTPClient.lib	Thu Sep 30 22:23:27 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/HTTPClient/#d97a4fc01c86
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Sep 30 22:23:27 2010 +0000
@@ -0,0 +1,67 @@
+/**
+ * A test program for Pachube API interface driver. (Version 0.0.1)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#include "mbed.h"
+#include "PachubeV2CSV.h"
+#include "EthernetNetIf.h"
+#include "HTTPClient.h"
+#include "ThermistorMCP9701.h"
+
+PachubeV2CSV web("Your API key is here");
+EthernetNetIf eth;
+ThermistorMCP9701 thermistor1(p16);
+
+void example1() {
+    int page = 1;
+    int per_page = 10;
+    std::string content = "";
+    std::string q = "";
+    std::string tag = "";
+    std::string user = "";
+    std::string units = "";
+    std::string status = "";
+    std::string order = "";
+    std::string datatext = "";
+    web.listAllAvailableFeeds(
+        page,
+        per_page,
+        content,
+        q,
+        tag,
+        user,
+        units,
+        status,
+        order,
+        datatext);
+    printf("====Data====\n%s\n============\n", datatext.c_str());
+}
+
+void example2_loop() {
+    const int feed_id = 999999; // <- Your feed ID is here.;
+    const std::string stream_id = "Your ID is here";
+    
+    int cnt = 0;
+    while (1) {
+        double val1 = thermistor1.read();
+        char val1_text[32];
+        sprintf(val1_text, "%f", val1);
+        if (cnt == 0) {
+            printf("createNewDataStream(%d)\n", web.createNewDataStream(feed_id, stream_id, std::string(val1_text)));
+        } else {
+            printf("updateDataStream(%d)\n", web.updateDataStream(feed_id, stream_id, std::string(val1_text)));
+        }
+        cnt++;
+        wait(10);
+    }
+}
+
+int main() {
+    eth.setup();
+
+    example1();
+    example2_loop();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Sep 30 22:23:27 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mylib/Pachube.lib	Thu Sep 30 22:23:27 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/shintamainjp/code/Pachube/#19accbe9a05e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mylib/ThermistorPack.lib	Thu Sep 30 22:23:27 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/shintamainjp/code/ThermistorPack/#4f84f03b1703