Arman Habibi / mbed-libxively-6eca970

Fork of mbed-libxively-6eca970 by Xively Official

Embed: (wiki syntax)

« Back to documentation index

xively.h File Reference

xively.h File Reference

Xively C library. More...

Go to the source code of this file.

Data Structures

struct  xi_context_t
 _The context structure_ - it's the first agument for all functions that communicate with Xively API (_i.e. More...
struct  xi_response_t
 _The response structure_ - it's the return type for all functions that communicate with Xively API (_i.e. More...
union  xi_datapoint_value_t
 The datapoint value union. More...
struct  xi_timestamp_t
 The datapoint timestamp. More...
struct  xi_datapoint_t
 _Xively datapoint structure_ - it contains value and timestamp More...
struct  xi_feed_t
 _Xively feed structure_ - it contains a fixed array of datastream More...

Enumerations

enum  xi_protocol_t {
  XI_HTTP, XI_HTTPS, XI_TCP, XI_TCPS,
  XI_WS, XI_WSS
}
 

The protocols currently supported by Xively.

More...
enum  http_header_type_t {
  XI_HTTP_HEADER_DATE = 0, XI_HTTP_HEADER_CONTENT_TYPE, XI_HTTP_HEADER_CONTENT_LENGTH, XI_HTTP_HEADER_CONNECTION,
  XI_HTTP_HEADER_X_REQUEST_ID, XI_HTTP_HEADER_CACHE_CONTROL, XI_HTTP_HEADER_VARY, XI_HTTP_HEADER_COUNT,
  XI_HTTP_HEADER_AGE
}
 

HTTP headers.

More...
enum  xi_value_type_t { XI_VALUE_TYPE_I32 = 0, XI_VALUE_TYPE_F32, XI_VALUE_TYPE_STR }
 

Datapoint value types.

More...

Functions

xi_datapoint_txi_set_value_i32 (xi_datapoint_t *dp, int32_t v)
 Sets the xi_datapoint_t value field to `int32_t` value.
xi_datapoint_txi_set_value_f32 (xi_datapoint_t *dp, float v)
 Sets the `xi_datapoint_t` value field to `float` value.
xi_datapoint_txi_set_value_str (xi_datapoint_t *dp, const char *v)
 Sets the `xi_datapoint_t` value field to zero-terminated string value.
void xi_set_network_timeout (uint32_t milliseconds)
 Sets the timeout for network operations.
uint32_t xi_get_network_timeout (void)
 Gets the current network timeout.
xi_context_txi_create_context (xi_protocol_t protocol, const char *api_key, int32_t feed_id)
 Library context constructor.
void xi_delete_context (xi_context_t *context)
 Library context destructor.
const xi_response_txi_feed_update (xi_context_t *xi, const xi_feed_t *value)
 Update Xively feed.
const xi_response_txi_feed_get (xi_context_t *xi, xi_feed_t *value)
 Retrieve Xively feed.
const xi_response_txi_datastream_create (xi_context_t *xi, int32_t feed_id, const char *datastream_id, const xi_datapoint_t *value)
 Create a datastream with given value using server timestamp.
const xi_response_txi_datastream_update (xi_context_t *xi, int32_t feed_id, const char *datastream_id, const xi_datapoint_t *value)
 Update a datastream with given datapoint using server or local timestamp.
const xi_response_txi_datastream_get (xi_context_t *xi, int32_t feed_id, const char *datastream_id, xi_datapoint_t *dp)
 Retrieve latest datapoint from a given datastream.
const xi_response_txi_datastream_delete (xi_context_t *xi, int feed_id, const char *datastream_id)
 Delete datastream.
const xi_response_txi_datapoint_delete (const xi_context_t *xi, int feed_id, const char *datastream_id, const xi_datapoint_t *dp)
 Delete datapoint at a given timestamp.
const xi_response_txi_datapoint_delete_range (const xi_context_t *xi, int feed_id, const char *datastream_id, const xi_timestamp_t *start, const xi_timestamp_t *end)
 Delete all datapoints in given time range.

Detailed Description

Xively C library.

Definition in file xively.h.


Enumeration Type Documentation

HTTP headers.

Enumerator:
XI_HTTP_HEADER_DATE 

`Date`

XI_HTTP_HEADER_CONTENT_TYPE 

`Content-Type`

XI_HTTP_HEADER_CONTENT_LENGTH 

`Content-Length`

XI_HTTP_HEADER_CONNECTION 

`Connection`

XI_HTTP_HEADER_X_REQUEST_ID 

`X-Request-Id`

XI_HTTP_HEADER_CACHE_CONTROL 

`Cache-Control`

XI_HTTP_HEADER_VARY 

`Vary`

XI_HTTP_HEADER_COUNT 

`Count`

XI_HTTP_HEADER_AGE 

`Age`

Definition at line 60 of file xively.h.

The protocols currently supported by Xively.

Note:
See source code for details of what's implemented.
Enumerator:
XI_HTTP 

`http://api.xively.com`

XI_HTTPS 

`https://api.xively.com`

XI_TCP 

`telnet api.xively.com 8081`

XI_TCPS 

`openssl s_client -host api.xively.com -port 8091 -tls1`

XI_WS 

`ws://api.xively.com:8080`

XI_WSS 

`wss://api.xively.com:8090`

Definition at line 32 of file xively.h.

Datapoint value types.

Enumerator:
XI_VALUE_TYPE_I32 

32-bit signed integer

XI_VALUE_TYPE_F32 

32-bit floating point number

XI_VALUE_TYPE_STR 

any string-econded data

Definition at line 87 of file xively.h.


Function Documentation

xi_context_t* xi_create_context ( xi_protocol_t  protocol,
const char *  api_key,
int32_t  feed_id 
)

Library context constructor.

The purpose of this function is to allocate memory and initialise the data structures needed in order to use any other library functions.

Returns:
Initialised context structure or `0` if an error occurred

Definition at line 151 of file xively.c.

const xi_response_t* xi_datapoint_delete ( const xi_context_t xi,
int  feed_id,
const char *  datastream_id,
const xi_datapoint_t dp 
)

Delete datapoint at a given timestamp.

Warning:
This function destroys the data in Xively and there is no way to restore it!
Note:
You need to provide exact timestamp value to guarantee successful response from the API, i.e. it will respond with error 404 if datapoint didn't exist. If you need to determine the exact timestamp, it may be easier to call `xi_datapoint_delete_range()` with short range instead.

Definition at line 320 of file xively.c.

const xi_response_t* xi_datapoint_delete_range ( const xi_context_t xi,
int  feed_id,
const char *  datastream_id,
const xi_timestamp_t start,
const xi_timestamp_t end 
)

Delete all datapoints in given time range.

Warning:
This function destroys the data in Xively and there is no way to restore it!

Definition at line 340 of file xively.c.

const xi_response_t* xi_datastream_create ( xi_context_t xi,
int32_t  feed_id,
const char *  datastream_id,
const xi_datapoint_t value 
)

Create a datastream with given value using server timestamp.

Definition at line 259 of file xively.c.

const xi_response_t* xi_datastream_delete ( xi_context_t xi,
int  feed_id,
const char *  datastream_id 
)

Delete datastream.

Warning:
This function destroys the data in Xively and there is no way to restore it!
const xi_response_t* xi_datastream_get ( xi_context_t xi,
int32_t  feed_id,
const char *  datastream_id,
xi_datapoint_t dp 
)

Retrieve latest datapoint from a given datastream.

Definition at line 234 of file xively.c.

const xi_response_t* xi_datastream_update ( xi_context_t xi,
int32_t  feed_id,
const char *  datastream_id,
const xi_datapoint_t value 
)

Update a datastream with given datapoint using server or local timestamp.

Definition at line 279 of file xively.c.

void xi_delete_context ( xi_context_t context )

Library context destructor.

The purpose of this fucntion is to free all allocated resources when the application is intending to terminate or stop using the library.

Definition at line 188 of file xively.c.

const xi_response_t* xi_feed_get ( xi_context_t xi,
xi_feed_t value 
)

Retrieve Xively feed.

Definition at line 197 of file xively.c.

const xi_response_t* xi_feed_update ( xi_context_t xi,
const xi_feed_t value 
)

Update Xively feed.

Definition at line 218 of file xively.c.

uint32_t xi_get_network_timeout ( void   )

Gets the current network timeout.

Definition at line 142 of file xively.c.

void xi_set_network_timeout ( uint32_t  milliseconds )

Sets the timeout for network operations.

Note:
The timeout is used by the comunication layer to determine whenever it should treat the lag in a connection as an error, so if your device or your connection is slow, you can try to increase the timeout for network operations. It only affects the send/recv operations it does not work with connect but that behaviour may differ between platforms and communication layer imlementations.

Definition at line 137 of file xively.c.

xi_datapoint_t* xi_set_value_f32 ( xi_datapoint_t dp,
float  v 
)

Sets the `xi_datapoint_t` value field to `float` value.

Returns:
Pointer or `0` if an error occurred.

Definition at line 108 of file xively.c.

xi_datapoint_t* xi_set_value_i32 ( xi_datapoint_t dp,
int32_t  v 
)

Sets the xi_datapoint_t value field to `int32_t` value.

Returns:
Pointer or `0` if an error occurred.

Definition at line 97 of file xively.c.

xi_datapoint_t* xi_set_value_str ( xi_datapoint_t dp,
const char *  v 
)

Sets the `xi_datapoint_t` value field to zero-terminated string value.

Returns:
Pointer or `0` if an error occurred.

Definition at line 119 of file xively.c.