Skip to content
This repository was archived by the owner on Aug 4, 2020. It is now read-only.

Commit 8bd6dd2

Browse files
committed
Merge pull request #6 from xively/document_error_codes
[doc] Add details on error codes
2 parents 00725d1 + 25b3c6b commit 8bd6dd2

File tree

7 files changed

+37
-9
lines changed

7 files changed

+37
-9
lines changed

README.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A library for Arduino to make it easier to talk to Xively.
44

55
_This library requires [_HTTP Client_](https://github.com/amcewen/HttpClient)._
66

7-
[![Build Status](https://travis-ci.org/xively/xively-arduino.png?branch=master)](https://travis-ci.org/xively/xively-arduino)
7+
[![Build Status](https://travis-ci.org/xively/xively_arduino.png?branch=master)](https://travis-ci.org/xively/xively_arduino)
88

99
##Features
1010

@@ -20,7 +20,7 @@ _This library requires [_HTTP Client_](https://github.com/amcewen/HttpClient)._
2020
##For a Quickstart Example
2121
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.
2222

23-
>In Arduino, go to Files > Examples and choose DatastreamUpload or DatastreamDownload from the xively-arduino library folder
23+
>In Arduino, go to Files > Examples and choose DatastreamUpload or DatastreamDownload from the xively_arduino library folder
2424
2525
##Setup Your Sketch
2626

@@ -141,4 +141,32 @@ datastreams[2].setString("Pretty comfy temperature"); // Push a String datapoi
141141
datastreams[3].setBuffer("But quite dry"); // Push a char buffer datapoint
142142
```
143143

144-
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/fa828feced5044961a2e1b6481ed83a9 "githalytics.com")](http://githalytics.com/xively/xively-arduino)
144+
##Error codes
145+
146+
This library uses [_amcewen/HttpClient_](https://github.com/amcewen/HttpClient/blob/master/HttpClient.h) which has following error codes:
147+
148+
* `HTTP_SUCCESS = 0` - no error
149+
* `HTTP_ERROR_CONNECTION_FAILED = -1` - connection to _api.xively.com_ has failed
150+
* `HTTP_ERROR_API = -2` - a method of _HttpClient_ class was called incorrectly
151+
* `HTTP_ERROR_TIMED_OUT = -3` - connection with _api.xively.com_ has timed-out
152+
* `HTTP_ERROR_INVALID_RESPONSE = -4` - invalid or unexpected response from the server
153+
154+
Apart from the above, the library will convert any _non-2xx_ status code to a nagative value like so:
155+
```c
156+
ret = http.responseStatusCode();
157+
if ((ret < 200) || (ret > 299))
158+
{
159+
160+
if (ret > 0)
161+
{
162+
ret = ret * -1;
163+
}
164+
}
165+
```
166+
167+
Therefore:
168+
* if we got a _2xx_, we will return that as is
169+
* if we got a negative value (e.g. `HTTP_ERROR_CONNECTION_FAILED`, `HTTP_ERROR_TIMED_OUT` or other), we will return that as is
170+
* any _non-2xx_ status code is returned multiplied by _-1_, i.e. a _403 (Authentication error)_ will be returned as _-403_
171+
172+
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/fa828feced5044961a2e1b6481ed83a9 "githalytics.com")](http://githalytics.com/xively/xively_arduino)

examples/DatastreamDownload/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BOARD_TAG = uno
22
ARDUINO_PORT = /dev/cu.usb*
3-
ARDUINO_LIBS = Ethernet Ethernet/utility SPI HttpClient xively-arduino
3+
ARDUINO_LIBS = Ethernet Ethernet/utility SPI HttpClient xively_arduino
44

55
include Arduino.mk

examples/DatastreamUpload/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BOARD_TAG = uno
22
ARDUINO_PORT = /dev/cu.usb*
3-
ARDUINO_LIBS = Ethernet Ethernet/utility SPI HttpClient xively-arduino
3+
ARDUINO_LIBS = Ethernet Ethernet/utility SPI HttpClient xively_arduino
44

55
include Arduino.mk
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BOARD_TAG = uno
22
ARDUINO_PORT = /dev/cu.usb*
3-
ARDUINO_LIBS = Ethernet Ethernet/utility SPI HttpClient xively-arduino
3+
ARDUINO_LIBS = Ethernet Ethernet/utility SPI HttpClient xively_arduino
44

55
include Arduino.mk
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BOARD_TAG = uno
22
ARDUINO_PORT = /dev/cu.usb*
3-
ARDUINO_LIBS = WiFi WiFi/utility SPI HttpClient xively-arduino
3+
ARDUINO_LIBS = WiFi WiFi/utility SPI HttpClient xively_arduino
44

55
include Arduino.mk
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BOARD_TAG = uno
22
ARDUINO_PORT = /dev/cu.usb*
3-
ARDUINO_LIBS = WiFi WiFi/utility SPI HttpClient xively-arduino
3+
ARDUINO_LIBS = WiFi WiFi/utility SPI HttpClient xively_arduino
44

55
include Arduino.mk
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BOARD_TAG = uno
22
ARDUINO_PORT = /dev/cu.usb*
3-
ARDUINO_LIBS = WiFi WiFi/utility SPI HttpClient xively-arduino
3+
ARDUINO_LIBS = WiFi WiFi/utility SPI HttpClient xively_arduino
44

55
include Arduino.mk

0 commit comments

Comments
 (0)