Xively Official / mbed-libxively-5d6fdd4

Dependents:   xively-jumpstart-demo

Embed: (wiki syntax)

« Back to documentation index

xively.c File Reference

xively.c File Reference

Xively C library [see xively.h]. More...

Go to the source code of this file.

Functions

const comm_layer_tget_comm_layer (void)
 Get instance of _communication layer_.
xi_datapoint_txi_set_value_i32 (xi_datapoint_t *p, int32_t value)
 Sets the xi_datapoint_t value field to `int32_t` value.
xi_datapoint_txi_set_value_f32 (xi_datapoint_t *p, float value)
 Sets the `xi_datapoint_t` value field to `float` value.
xi_datapoint_txi_set_value_str (xi_datapoint_t *p, const char *value)
 Sets the `xi_datapoint_t` value field to zero-terminated string value.
void xi_set_network_timeout (uint32_t timeout)
 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_get (xi_context_t *xi, xi_feed_t *feed)
 Retrieve Xively feed.
const xi_response_txi_feed_update (xi_context_t *xi, const xi_feed_t *feed)
 Update Xively feed.
const xi_response_txi_datastream_get (xi_context_t *xi, int32_t feed_id, const char *datastream_id, xi_datapoint_t *o)
 Retrieve latest datapoint from a given datastream.
const xi_response_txi_datastream_create (xi_context_t *xi, int32_t feed_id, const char *datastream_id, const xi_datapoint_value_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_value_t *value)
 Update a datastream with given datapoint using server or local timestamp.
const xi_response_txi_datapoint_delete (const xi_context_t *xi, int feed_id, const char *datastream_id, const xi_datapoint_t *o)
 Delete datapoint at a given timestamp.
const xi_response_txi_datapoint_delete_range (const xi_context_t *xi, int feed_id, 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 [see xively.h].

Definition in file xively.c.


Function Documentation

const comm_layer_t* get_comm_layer ( void   )

Get instance of _communication layer_.

Note:
Although the interface is of the _communication layer_ should stay the same, some implemantation may differ.
Returns:
Pointer to the communication layer interface

Get instance of _communication layer_.

Initialise an implementation of the _communication layer_.

Definition at line 16 of file mbed_comm_layer.c.

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 322 of file xively.c.

const xi_response_t* xi_datapoint_delete_range ( const xi_context_t xi,
int  feed_id,
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 342 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_value_t value 
)

Create a datastream with given value using server timestamp.

Definition at line 261 of file xively.c.

const xi_response_t* xi_datastream_get ( xi_context_t xi,
int32_t  feed_id,
const char *  datastream_id,
xi_datapoint_t o 
)

Retrieve latest datapoint from a given datastream.

Definition at line 236 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_value_t value 
)

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

Definition at line 281 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 feed 
)

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 feed 
)

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.