A test program for Pachube library.
Dependencies: mbed ThermistorPack Pachube EthernetNetIf
Diff: main.cpp
- Revision:
- 0:edeb42b3d357
- Child:
- 1:d4f8908bf66f
--- /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(); +}