Skip to content

Commit 5372f80

Browse files
committed
renamed cosm to xively
1 parent 12d4ba8 commit 5372f80

File tree

23 files changed

+175
-175
lines changed

23 files changed

+175
-175
lines changed

Cosm.h

Lines changed: 0 additions & 5 deletions
This file was deleted.

CosmFeed.h

Lines changed: 0 additions & 25 deletions
This file was deleted.

README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Cosm Arduino library
1+
Xively Arduino library
22
================
33

4-
A library for Arduino to make it easier to talk to Cosm (the service formerly known as Pachube).
4+
A library for Arduino to make it easier to talk to Xively (the service formerly known as Pachube).
55

66
This library **requires** the HTTP Client library at https://github.com/amcewen/HttpClient
77

@@ -18,21 +18,21 @@ This library **requires** the HTTP Client library at https://github.com/amcewen/
1818
##For a Quickstart Example
1919
Look no further! If you want a quick example, connect your Arduino board to your computer and an ethernet cable and try out one of the examples included with this library.
2020

21-
>In Arduino, go to Files > Examples and choose DatastreamUpload or DatastreamDownload from the cosm-arduino library folder
21+
>In Arduino, go to Files > Examples and choose DatastreamUpload or DatastreamDownload from the xively-arduino library folder
2222
2323
##Setup Your Sketch
2424

2525
**1. Specify your API key and Feed ID**
2626
```c
27-
char cosmKey[] = "YOUR_COSM_API_KEY";
27+
char xivelyKey[] = "YOUR_XIVELY_API_KEY";
2828
// Should be something like "HsNiCoe_Es2YYWltKeRFPZL2xhqSAKxIV21aV3lTL2h5OD0g"
2929
#define FEED_ID XXXXXX
30-
// The 3 to 6-digit number (like 504 or 104097), that identifies the Cosm Feed you're using
30+
// The 3 to 6-digit number (like 504 or 104097), that identifies the Xively Feed you're using
3131
```
3232

3333
**2. Create IDs for your datastreams as `char` arrays (or `String` objects for a `String` datastream)**
3434

35-
In Cosm, the name of a datastream is known as the **Stream ID**. In the example below, we'll give the datastreams names by setting their **Stream IDs** as "humidity", "temperature", "my_thoughts_on_the_temperature" and "more_thoughts".
35+
In Xively, the name of a datastream is known as the **Stream ID**. In the example below, we'll give the datastreams names by setting their **Stream IDs** as "humidity", "temperature", "my_thoughts_on_the_temperature" and "more_thoughts".
3636

3737
```c
3838
// For datastreams of floats:
@@ -47,26 +47,26 @@ const int bufferSize = 140; // size of the array
4747
char bufferValue[bufferSize]; // the array of chars itself
4848
```
4949
50-
`String` datastreams and `char` buffer datastreams are similar: both will be able to send strings to Cosm datastreams. For beginners, using `String` datastreams will be fine much of the time.
50+
`String` datastreams and `char` buffer datastreams are similar: both will be able to send strings to Xively datastreams. For beginners, using `String` datastreams will be fine much of the time.
5151
52-
Using char buffers reduces the memory footprint of your sketch by not requiring the String library. Also, using char buffers allows you to specify exactly how much memory is used for a datapoint, so you don't accidentally overflow the Arduino's mem capacity with a huge string datapoint. It's a little bit harder to understand for beginners -- consult CosmDatastream.cpp for info.
52+
Using char buffers reduces the memory footprint of your sketch by not requiring the String library. Also, using char buffers allows you to specify exactly how much memory is used for a datapoint, so you don't accidentally overflow the Arduino's mem capacity with a huge string datapoint. It's a little bit harder to understand for beginners -- consult XivelyDatastream.cpp for info.
5353
54-
**3. Create an array of `CosmDatastream` objects**
54+
**3. Create an array of `XivelyDatastream` objects**
5555
5656
```c
57-
CosmDatastream datastreams[] = {
57+
XivelyDatastream datastreams[] = {
5858
// Float datastreams are set up like this:
59-
CosmDatastream(myFloatStream, strlen(myFloatStream), DATASTREAM_FLOAT),
59+
XivelyDatastream(myFloatStream, strlen(myFloatStream), DATASTREAM_FLOAT),
6060
// Int datastreams are set up like this:
61-
CosmDatastream(myIntStream, strlen(myIntStream), DATASTREAM_INT),
61+
XivelyDatastream(myIntStream, strlen(myIntStream), DATASTREAM_INT),
6262
// String datastreams are set up like this:
63-
CosmDatastream(myStringStream, DATASTREAM_STRING),
63+
XivelyDatastream(myStringStream, DATASTREAM_STRING),
6464
// Char buffer datastreams are set up like this:
65-
CosmDatastream(myCharBufferStream, strlen(myCharBufferStream), DATASTREAM_BUFFER, bufferValue, bufferSize),
65+
XivelyDatastream(myCharBufferStream, strlen(myCharBufferStream), DATASTREAM_BUFFER, bufferValue, bufferSize),
6666
};
6767
```
6868

69-
`CosmDatastream` objects can contains some or all of the following variables, depending on what type of datapoints are in the datastream (see above example for which are required):
69+
`XivelyDatastream` objects can contains some or all of the following variables, depending on what type of datapoints are in the datastream (see above example for which are required):
7070

7171
| | Variable | Type | Description |
7272
|---|---|:---:|---|
@@ -77,47 +77,47 @@ CosmDatastream datastreams[] = {
7777
| 5 | aValueBufferLength | int | The number of elements in the `char` array
7878

7979

80-
**4. Last, wrap this array of `CosmDatastream` objects into a `CosmFeed`**
80+
**4. Last, wrap this array of `XivelyDatastream` objects into a `XivelyFeed`**
8181

82-
Unlike the **Stream ID**, which is what a _Datastream's_ name is stored as, the **ID** of a _Feed_ is a number which is used to uniquely identify which Cosm Feed you are addressing. For example, a Feed **ID** of 504 would mean that you were using the feed at cosm.com/feeds/504.
82+
Unlike the **Stream ID**, which is what a _Datastream's_ name is stored as, the **ID** of a _Feed_ is a number which is used to uniquely identify which Xively Feed you are addressing. For example, a Feed **ID** of 504 would mean that you were using the feed at xively.com/feeds/504.
8383

8484
```c
85-
CosmFeed feed(FEED_ID, datastreams, 4);
85+
XivelyFeed feed(FEED_ID, datastreams, 4);
8686
```
8787
8888
| | Variable | Type | Description |
8989
|---|---|:---:|---|
9090
| 1 | aID | unsigned long | The Feed's **ID**, as defined at the top of your sketch
91-
| 2 | aDatastreams | CosmDatastream* |Your `CosmDatastream` array
91+
| 2 | aDatastreams | XivelyDatastream* |Your `XivelyDatastream` array
9292
| 3 | aDatastreamsCount | int | How many datastreams are in the array
9393
94-
**5. Instantiate the library's Cosm client**
94+
**5. Instantiate the library's Xively client**
9595
9696
Connecting by ethernet:
9797
9898
>If you're using the Ethernet library:
9999
```c
100100
EthernetClient client;
101-
CosmClient cosmclient(client);
101+
XivelyClient xivelyclient(client);
102102
```
103103

104104

105105
If you're on wireless, be sure to enter your SSID and password as the library requires, and then:
106106
>If you're using the built-in WiFi library:
107107
```c
108108
WiFiClient client;
109-
CosmClient cosmclient(client);
109+
XivelyClient xivelyclient(client);
110110
```
111111
112112
---
113113
>If you're using the [Sparkfun WiFly] [1] library:
114114
```c
115115
WiFlyClient client;
116-
CosmClient cosmclient(client);
116+
XivelyClient xivelyclient(client);
117117
```
118118
[1]: https://github.com/jmr13031/WiFly-Shield
119119

120-
##Sending and Retrieving Cosm Datapoints
120+
##Sending and Retrieving Xively Datapoints
121121

122122
###Read a Datapoint
123123
```c
@@ -137,4 +137,4 @@ datastreams[0].setFloat(1.5); // Push a float datapoin
137137
datastreams[1].setInt(23); // Push an int datapoint
138138
datastreams[2].setString("Pretty comfy temperature"); // Push a String datapoint
139139
datastreams[3].setBuffer("But quite dry"); // Push a char buffer datapoint
140-
```
140+
```

Xively.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
#include <XivelyDatastream.h>
3+
#include <XivelyFeed.h>
4+
#include <XivelyClient.h>
5+

CosmClient.cpp renamed to XivelyClient.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
#include <Cosm.h>
1+
#include <Xively.h>
22
#include <HttpClient.h>
33
#include <CountingStream.h>
44

5-
CosmClient::CosmClient(Client& aClient)
5+
XivelyClient::XivelyClient(Client& aClient)
66
: _client(aClient)
77
{
88
}
99

10-
int CosmClient::put(CosmFeed& aFeed, const char* aApiKey)
10+
int XivelyClient::put(XivelyFeed& aFeed, const char* aApiKey)
1111
{
1212
HttpClient http(_client);
1313
char path[30];
1414
buildPath(path, aFeed.id(), "json");
1515
http.beginRequest();
16-
int ret = http.put("api.cosm.com", path);
16+
int ret = http.put("api.xively.com", path);
1717
if (ret == 0)
1818
{
1919
http.sendHeader("X-ApiKey", aApiKey);
20-
http.sendHeader("User-Agent", "Cosm-Arduino-Lib/1.0");
20+
http.sendHeader("User-Agent", "Xively-Arduino-Lib/1.0");
2121

2222
CountingStream countingStream; // Used to work out how long that data will be
2323
for (int i =kCalculateDataLength; i <= kSendData; i++)
@@ -57,7 +57,7 @@ int CosmClient::put(CosmFeed& aFeed, const char* aApiKey)
5757
return ret;
5858
}
5959

60-
void CosmClient::buildPath(char* aDest, unsigned long aFeedId, const char* aFormat)
60+
void XivelyClient::buildPath(char* aDest, unsigned long aFeedId, const char* aFormat)
6161
{
6262
char idstr[12];
6363
strcpy(aDest, "/v2/feeds/");
@@ -69,17 +69,17 @@ void CosmClient::buildPath(char* aDest, unsigned long aFeedId, const char* aForm
6969
strcat(aDest, aFormat);
7070
}
7171

72-
int CosmClient::get(CosmFeed& aFeed, const char* aApiKey)
72+
int XivelyClient::get(XivelyFeed& aFeed, const char* aApiKey)
7373
{
7474
HttpClient http(_client);
7575
char path[30];
7676
buildPath(path, aFeed.id(), "csv");
7777
http.beginRequest();
78-
int ret = http.get("api.cosm.com", path);
78+
int ret = http.get("api.xively.com", path);
7979
if (ret == 0)
8080
{
8181
http.sendHeader("X-ApiKey", aApiKey);
82-
http.sendHeader("User-Agent", "Cosm-Arduino-Lib/1.0");
82+
http.sendHeader("User-Agent", "Xively-Arduino-Lib/1.0");
8383
http.endRequest();
8484

8585
ret = http.responseStatusCode();

CosmClient.h renamed to XivelyClient.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11

2-
#ifndef COSMCLIENT_H
3-
#define COSMCLIENT_H
2+
#ifndef XIVELYCLIENT_H
3+
#define XIVELYCLIENT_H
44

55
#include <Client.h>
6-
#include <CosmFeed.h>
6+
#include <XivelyFeed.h>
77

8-
class CosmClient
8+
class XivelyClient
99
{
1010
public:
11-
CosmClient(Client& aClient);
11+
XivelyClient(Client& aClient);
1212

13-
int get(CosmFeed& aFeed, const char* aApiKey);
14-
int put(CosmFeed& aFeed, const char* aApiKey);
13+
int get(XivelyFeed& aFeed, const char* aApiKey);
14+
int put(XivelyFeed& aFeed, const char* aApiKey);
1515

1616
protected:
1717
static const int kCalculateDataLength =0;

CosmDatastream.cpp renamed to XivelyDatastream.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
#include <CosmDatastream.h>
1+
#include <XivelyDatastream.h>
22
// FIXME Only needed until readStringUntil is available in Stream
33
#include <Arduino.h>
44

5-
CosmDatastream::CosmDatastream(String& aId, int aType)
5+
XivelyDatastream::XivelyDatastream(String& aId, int aType)
66
: _idType(DATASTREAM_STRING), _valueType(aType), _idString(aId)
77
{
88
}
99

10-
CosmDatastream::CosmDatastream(char* aIdBuffer, int aIdBufferSize, int aType)
10+
XivelyDatastream::XivelyDatastream(char* aIdBuffer, int aIdBufferSize, int aType)
1111
: _idType(DATASTREAM_BUFFER), _valueType(aType), _idString(), _valueString()
1212
{
1313
_idBuffer._buffer = aIdBuffer;
1414
_idBuffer._bufferSize = aIdBufferSize;
1515
}
1616

17-
CosmDatastream::CosmDatastream(char* aIdBuffer, int aIdBufferSize, int aType, char* aValueBuffer, int aValueBufferSize)
17+
XivelyDatastream::XivelyDatastream(char* aIdBuffer, int aIdBufferSize, int aType, char* aValueBuffer, int aValueBufferSize)
1818
: _idType(DATASTREAM_BUFFER), _valueType(aType)
1919
{
2020
_idBuffer._buffer = aIdBuffer;
@@ -23,7 +23,7 @@ CosmDatastream::CosmDatastream(char* aIdBuffer, int aIdBufferSize, int aType, ch
2323
_value._valueBuffer._bufferSize = aValueBufferSize;
2424
}
2525

26-
int CosmDatastream::updateValue(Stream& aStream)
26+
int XivelyDatastream::updateValue(Stream& aStream)
2727
{
2828
switch (_valueType)
2929
{
@@ -53,7 +53,7 @@ int CosmDatastream::updateValue(Stream& aStream)
5353
};
5454
}
5555

56-
int CosmDatastream::timedRead(Stream& aStream)
56+
int XivelyDatastream::timedRead(Stream& aStream)
5757
{
5858
int c;
5959
long _startMillis = millis();
@@ -65,39 +65,39 @@ int CosmDatastream::timedRead(Stream& aStream)
6565
}
6666

6767

68-
void CosmDatastream::setInt(int aValue)
68+
void XivelyDatastream::setInt(int aValue)
6969
{
7070
if (_valueType == DATASTREAM_INT)
7171
{
7272
_value._valueInt = aValue;
7373
}
7474
}
7575

76-
void CosmDatastream::setFloat(float aValue)
76+
void XivelyDatastream::setFloat(float aValue)
7777
{
7878
if (_valueType == DATASTREAM_FLOAT)
7979
{
8080
_value._valueFloat = aValue;
8181
}
8282
}
8383

84-
void CosmDatastream::setString(String& aValue)
84+
void XivelyDatastream::setString(String& aValue)
8585
{
8686
if (_valueType == DATASTREAM_STRING)
8787
{
8888
_valueString = aValue;
8989
}
9090
}
9191

92-
void CosmDatastream::setBuffer(const char* aBuffer)
92+
void XivelyDatastream::setBuffer(const char* aBuffer)
9393
{
9494
if (_valueType == DATASTREAM_BUFFER)
9595
{
9696
strncpy(_value._valueBuffer._buffer, aBuffer, _value._valueBuffer._bufferSize);
9797
}
9898
}
9999

100-
int CosmDatastream::getInt()
100+
int XivelyDatastream::getInt()
101101
{
102102
if (_valueType == DATASTREAM_INT)
103103
{
@@ -109,7 +109,7 @@ int CosmDatastream::getInt()
109109
}
110110
}
111111

112-
float CosmDatastream::getFloat()
112+
float XivelyDatastream::getFloat()
113113
{
114114
if (_valueType == DATASTREAM_FLOAT)
115115
{
@@ -121,12 +121,12 @@ float CosmDatastream::getFloat()
121121
}
122122
}
123123

124-
String& CosmDatastream::getString()
124+
String& XivelyDatastream::getString()
125125
{
126126
return _valueString;
127127
}
128128

129-
char* CosmDatastream::getBuffer()
129+
char* XivelyDatastream::getBuffer()
130130
{
131131
if (_valueType == DATASTREAM_BUFFER)
132132
{
@@ -138,7 +138,7 @@ char* CosmDatastream::getBuffer()
138138
}
139139
}
140140

141-
size_t CosmDatastream::printTo(Print& aPrint) const
141+
size_t XivelyDatastream::printTo(Print& aPrint) const
142142
{
143143
size_t count =0;
144144
count += aPrint.print("{ \"id\" : \"");

0 commit comments

Comments
 (0)