Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetNetIf TextLCD mbed
PachubeClient.cpp
00001 #include "PachubeClient.h" 00002 00003 PachubeClient::PachubeClient(const string& apiKey) : _client(), _csvContent("text/csv") { 00004 _client.setRequestHeader("X-PachubeApiKey", apiKey); 00005 } 00006 00007 PachubeClient::~PachubeClient() { 00008 } 00009 00010 // put csv method to feed 00011 void PachubeClient::PutCsv(const string& environmentID, const string& data) { 00012 _csvContent.set(data); 00013 string uri = "http://api.pachube.com/v1/feeds/" + environmentID + ".csv?_method=put"; 00014 _result = _client.post(uri.c_str(), _csvContent, NULL); 00015 _response = _client.getHTTPResponseCode(); 00016 } 00017 00018 // put csv method to datastream 00019 void PachubeClient::PutCsv(const string& environmentID, const string& datastreamID, const string& data) { 00020 _csvContent.set(data); 00021 string uri = "http://api.pachube.com/v1/feeds/" + environmentID + "/datastreams/" + datastreamID + ".csv?_method=put"; 00022 _result = _client.post(uri.c_str(), _csvContent, NULL); 00023 _response = _client.getHTTPResponseCode(); 00024 } 00025 00026 // http result and response 00027 HTTPResult PachubeClient::Result() { 00028 return _result; 00029 } 00030 int PachubeClient::Response() { 00031 return _response; 00032 }
Generated on Wed Jul 27 2022 06:49:36 by
1.7.2