test
Fork of mbed-libxively-6eca970 by
src/libxively/xively.c@0:82702e998d3f, 2013-06-26 (annotated)
- Committer:
- xively
- Date:
- Wed Jun 26 10:40:43 2013 +0000
- Revision:
- 0:82702e998d3f
- Child:
- 1:0556e1894817
libxively v0.1.1-rc0 (34c8b32)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
xively | 0:82702e998d3f | 1 | // Copyright (c) 2003-2013, LogMeIn, Inc. All rights reserved. |
xively | 0:82702e998d3f | 2 | // This is part of Xively C library, it is under the BSD 3-Clause license. |
xively | 0:82702e998d3f | 3 | |
xively | 0:82702e998d3f | 4 | /** |
xively | 0:82702e998d3f | 5 | * \file xively.c |
xively | 0:82702e998d3f | 6 | * \brief Xively C library [see xively.h] |
xively | 0:82702e998d3f | 7 | */ |
xively | 0:82702e998d3f | 8 | |
xively | 0:82702e998d3f | 9 | #include <string.h> |
xively | 0:82702e998d3f | 10 | #include <assert.h> |
xively | 0:82702e998d3f | 11 | #include <stdio.h> |
xively | 0:82702e998d3f | 12 | #include <stdlib.h> |
xively | 0:82702e998d3f | 13 | |
xively | 0:82702e998d3f | 14 | #include "xi_allocator.h" |
xively | 0:82702e998d3f | 15 | #include "xively.h" |
xively | 0:82702e998d3f | 16 | #include "http_transport.h" |
xively | 0:82702e998d3f | 17 | #include "csv_data_layer.h" |
xively | 0:82702e998d3f | 18 | #include "xi_macros.h" |
xively | 0:82702e998d3f | 19 | #include "xi_debug.h" |
xively | 0:82702e998d3f | 20 | #include "xi_helpers.h" |
xively | 0:82702e998d3f | 21 | #include "xi_err.h" |
xively | 0:82702e998d3f | 22 | #include "xi_globals.h" |
xively | 0:82702e998d3f | 23 | |
xively | 0:82702e998d3f | 24 | #ifdef __cplusplus |
xively | 0:82702e998d3f | 25 | extern "C" { |
xively | 0:82702e998d3f | 26 | #endif |
xively | 0:82702e998d3f | 27 | |
xively | 0:82702e998d3f | 28 | /** |
xively | 0:82702e998d3f | 29 | * \brief Get instance of _communication layer_ |
xively | 0:82702e998d3f | 30 | * |
xively | 0:82702e998d3f | 31 | * \note Although the interface is of the _communication layer_ should |
xively | 0:82702e998d3f | 32 | * stay the same, some implemantation may differ. |
xively | 0:82702e998d3f | 33 | * |
xively | 0:82702e998d3f | 34 | * \return Pointer to the communication layer interface |
xively | 0:82702e998d3f | 35 | */ |
xively | 0:82702e998d3f | 36 | const comm_layer_t* get_comm_layer( void ); |
xively | 0:82702e998d3f | 37 | |
xively | 0:82702e998d3f | 38 | #include "comm_layer.h" |
xively | 0:82702e998d3f | 39 | |
xively | 0:82702e998d3f | 40 | //----------------------------------------------------------------------- |
xively | 0:82702e998d3f | 41 | // HELPER MACROS |
xively | 0:82702e998d3f | 42 | //----------------------------------------------------------------------- |
xively | 0:82702e998d3f | 43 | |
xively | 0:82702e998d3f | 44 | #define XI_FUNCTION_VARIABLES connection_t* conn = 0;\ |
xively | 0:82702e998d3f | 45 | const comm_layer_t* comm_layer = 0;\ |
xively | 0:82702e998d3f | 46 | const transport_layer_t* transport_layer = 0;\ |
xively | 0:82702e998d3f | 47 | const data_layer_t* data_layer = 0;\ |
xively | 0:82702e998d3f | 48 | char buffer[ XI_HTTP_MAX_CONTENT_SIZE ];\ |
xively | 0:82702e998d3f | 49 | const xi_response_t* response = 0;\ |
xively | 0:82702e998d3f | 50 | int sent = 0;\ |
xively | 0:82702e998d3f | 51 | int recv = 0; |
xively | 0:82702e998d3f | 52 | |
xively | 0:82702e998d3f | 53 | #define XI_FUNCTION_PROLOGUE XI_FUNCTION_VARIABLES\ |
xively | 0:82702e998d3f | 54 | xi_debug_log_str( "Getting the comm layer...\n" );\ |
xively | 0:82702e998d3f | 55 | comm_layer = get_comm_layer();\ |
xively | 0:82702e998d3f | 56 | xi_debug_log_str( "Getting the transport layer...\n" );\ |
xively | 0:82702e998d3f | 57 | transport_layer = get_http_transport_layer();\ |
xively | 0:82702e998d3f | 58 | xi_debug_log_str( "Getting the data layer...\n");\ |
xively | 0:82702e998d3f | 59 | data_layer = get_csv_data_layer();\ |
xively | 0:82702e998d3f | 60 | |
xively | 0:82702e998d3f | 61 | #define XI_FUNCTION_GET_RESPONSE if( data == 0 ) { goto err_handling; }\ |
xively | 0:82702e998d3f | 62 | xi_debug_log_str( "Connecting to the endpoint...\n" );\ |
xively | 0:82702e998d3f | 63 | conn = comm_layer->open_connection( XI_HOST, XI_PORT );\ |
xively | 0:82702e998d3f | 64 | if( conn == 0 ) { goto err_handling; }\ |
xively | 0:82702e998d3f | 65 | xi_debug_log_str( "Sending data:\n" );\ |
xively | 0:82702e998d3f | 66 | xi_debug_log_data( data );\ |
xively | 0:82702e998d3f | 67 | sent = comm_layer->send_data( conn, data, strlen( data ) );\ |
xively | 0:82702e998d3f | 68 | if( sent == -1 ) { goto err_handling; }\ |
xively | 0:82702e998d3f | 69 | xi_debug_log_str( "Sent: " );\ |
xively | 0:82702e998d3f | 70 | xi_debug_log_int( ( int ) sent );\ |
xively | 0:82702e998d3f | 71 | xi_debug_log_endl();\ |
xively | 0:82702e998d3f | 72 | xi_debug_log_str( "Reading data...\n" );\ |
xively | 0:82702e998d3f | 73 | recv = comm_layer->read_data( conn, buffer, XI_HTTP_MAX_CONTENT_SIZE );\ |
xively | 0:82702e998d3f | 74 | if( recv == -1 ) { goto err_handling; }\ |
xively | 0:82702e998d3f | 75 | xi_debug_log_str( "Received: " );\ |
xively | 0:82702e998d3f | 76 | xi_debug_log_int( ( int ) recv );\ |
xively | 0:82702e998d3f | 77 | xi_debug_log_endl();\ |
xively | 0:82702e998d3f | 78 | xi_debug_log_str( "Response:\n" );\ |
xively | 0:82702e998d3f | 79 | xi_debug_log_data( buffer );\ |
xively | 0:82702e998d3f | 80 | xi_debug_log_endl();\ |
xively | 0:82702e998d3f | 81 | response = transport_layer->decode_reply(\ |
xively | 0:82702e998d3f | 82 | data_layer, buffer );\ |
xively | 0:82702e998d3f | 83 | if( response == 0 ) { goto err_handling; }\ |
xively | 0:82702e998d3f | 84 | |
xively | 0:82702e998d3f | 85 | #define XI_FUNCTION_EPILOGUE xi_debug_log_str( "Closing connection...\n" );\ |
xively | 0:82702e998d3f | 86 | err_handling:\ |
xively | 0:82702e998d3f | 87 | if( conn )\ |
xively | 0:82702e998d3f | 88 | {\ |
xively | 0:82702e998d3f | 89 | comm_layer->close_connection( conn );\ |
xively | 0:82702e998d3f | 90 | }\ |
xively | 0:82702e998d3f | 91 | return response;\ |
xively | 0:82702e998d3f | 92 | |
xively | 0:82702e998d3f | 93 | //----------------------------------------------------------------------- |
xively | 0:82702e998d3f | 94 | // HELPER FUNCTIONS |
xively | 0:82702e998d3f | 95 | //----------------------------------------------------------------------- |
xively | 0:82702e998d3f | 96 | |
xively | 0:82702e998d3f | 97 | xi_datapoint_t* xi_set_value_i32( xi_datapoint_t* p, int32_t value ) |
xively | 0:82702e998d3f | 98 | { |
xively | 0:82702e998d3f | 99 | // PRECONDITION |
xively | 0:82702e998d3f | 100 | assert( p != 0 ); |
xively | 0:82702e998d3f | 101 | |
xively | 0:82702e998d3f | 102 | p->value.i32_value = value; |
xively | 0:82702e998d3f | 103 | p->value_type = XI_VALUE_TYPE_I32; |
xively | 0:82702e998d3f | 104 | |
xively | 0:82702e998d3f | 105 | return p; |
xively | 0:82702e998d3f | 106 | } |
xively | 0:82702e998d3f | 107 | |
xively | 0:82702e998d3f | 108 | xi_datapoint_t* xi_set_value_f32( xi_datapoint_t* p, float value ) |
xively | 0:82702e998d3f | 109 | { |
xively | 0:82702e998d3f | 110 | // PRECONDITION |
xively | 0:82702e998d3f | 111 | assert( p != 0 ); |
xively | 0:82702e998d3f | 112 | |
xively | 0:82702e998d3f | 113 | p->value.f32_value = value; |
xively | 0:82702e998d3f | 114 | p->value_type = XI_VALUE_TYPE_F32; |
xively | 0:82702e998d3f | 115 | |
xively | 0:82702e998d3f | 116 | return p; |
xively | 0:82702e998d3f | 117 | } |
xively | 0:82702e998d3f | 118 | |
xively | 0:82702e998d3f | 119 | xi_datapoint_t* xi_set_value_str( xi_datapoint_t* p, const char* value ) |
xively | 0:82702e998d3f | 120 | { |
xively | 0:82702e998d3f | 121 | // PRECONDITION |
xively | 0:82702e998d3f | 122 | assert( p != 0 ); |
xively | 0:82702e998d3f | 123 | |
xively | 0:82702e998d3f | 124 | int s = xi_str_copy_untiln( p->value.str_value |
xively | 0:82702e998d3f | 125 | , XI_VALUE_STRING_MAX_SIZE, value, '\0' ); |
xively | 0:82702e998d3f | 126 | |
xively | 0:82702e998d3f | 127 | XI_CHECK_SIZE( s, XI_VALUE_STRING_MAX_SIZE, XI_DATAPOINT_VALUE_BUFFER_OVERFLOW ); |
xively | 0:82702e998d3f | 128 | |
xively | 0:82702e998d3f | 129 | p->value_type = XI_VALUE_TYPE_STR; |
xively | 0:82702e998d3f | 130 | |
xively | 0:82702e998d3f | 131 | return p; |
xively | 0:82702e998d3f | 132 | |
xively | 0:82702e998d3f | 133 | err_handling: |
xively | 0:82702e998d3f | 134 | return 0; |
xively | 0:82702e998d3f | 135 | } |
xively | 0:82702e998d3f | 136 | |
xively | 0:82702e998d3f | 137 | void xi_set_network_timeout( uint32_t timeout ) |
xively | 0:82702e998d3f | 138 | { |
xively | 0:82702e998d3f | 139 | xi_globals.network_timeout = timeout; |
xively | 0:82702e998d3f | 140 | } |
xively | 0:82702e998d3f | 141 | |
xively | 0:82702e998d3f | 142 | uint32_t xi_get_network_timeout( void ) |
xively | 0:82702e998d3f | 143 | { |
xively | 0:82702e998d3f | 144 | return xi_globals.network_timeout; |
xively | 0:82702e998d3f | 145 | } |
xively | 0:82702e998d3f | 146 | |
xively | 0:82702e998d3f | 147 | //----------------------------------------------------------------------- |
xively | 0:82702e998d3f | 148 | // MAIN LIBRARY FUNCTIONS |
xively | 0:82702e998d3f | 149 | //----------------------------------------------------------------------- |
xively | 0:82702e998d3f | 150 | |
xively | 0:82702e998d3f | 151 | xi_context_t* xi_create_context( |
xively | 0:82702e998d3f | 152 | xi_protocol_t protocol, const char* api_key |
xively | 0:82702e998d3f | 153 | , int32_t feed_id ) |
xively | 0:82702e998d3f | 154 | { |
xively | 0:82702e998d3f | 155 | // allocate the structure to store new context |
xively | 0:82702e998d3f | 156 | xi_context_t* ret = ( xi_context_t* ) xi_alloc( sizeof( xi_context_t ) ); |
xively | 0:82702e998d3f | 157 | |
xively | 0:82702e998d3f | 158 | XI_CHECK_MEMORY( ret ); |
xively | 0:82702e998d3f | 159 | |
xively | 0:82702e998d3f | 160 | // copy given numeric parameters as is |
xively | 0:82702e998d3f | 161 | ret->protocol = protocol; |
xively | 0:82702e998d3f | 162 | ret->feed_id = feed_id; |
xively | 0:82702e998d3f | 163 | |
xively | 0:82702e998d3f | 164 | // copy string parameters carefully |
xively | 0:82702e998d3f | 165 | if( api_key ) |
xively | 0:82702e998d3f | 166 | { |
xively | 0:82702e998d3f | 167 | // duplicate the string |
xively | 0:82702e998d3f | 168 | ret->api_key = xi_str_dup( api_key ); |
xively | 0:82702e998d3f | 169 | |
xively | 0:82702e998d3f | 170 | XI_CHECK_MEMORY( ret->api_key ); |
xively | 0:82702e998d3f | 171 | } |
xively | 0:82702e998d3f | 172 | else |
xively | 0:82702e998d3f | 173 | { |
xively | 0:82702e998d3f | 174 | ret->api_key = 0; |
xively | 0:82702e998d3f | 175 | } |
xively | 0:82702e998d3f | 176 | |
xively | 0:82702e998d3f | 177 | return ret; |
xively | 0:82702e998d3f | 178 | |
xively | 0:82702e998d3f | 179 | err_handling: |
xively | 0:82702e998d3f | 180 | if( ret ) |
xively | 0:82702e998d3f | 181 | { |
xively | 0:82702e998d3f | 182 | XI_SAFE_FREE( ret ); |
xively | 0:82702e998d3f | 183 | } |
xively | 0:82702e998d3f | 184 | |
xively | 0:82702e998d3f | 185 | return 0; |
xively | 0:82702e998d3f | 186 | } |
xively | 0:82702e998d3f | 187 | |
xively | 0:82702e998d3f | 188 | void xi_delete_context( xi_context_t* context ) |
xively | 0:82702e998d3f | 189 | { |
xively | 0:82702e998d3f | 190 | if( context ) |
xively | 0:82702e998d3f | 191 | { |
xively | 0:82702e998d3f | 192 | XI_SAFE_FREE( context->api_key ); |
xively | 0:82702e998d3f | 193 | } |
xively | 0:82702e998d3f | 194 | XI_SAFE_FREE( context ); |
xively | 0:82702e998d3f | 195 | } |
xively | 0:82702e998d3f | 196 | |
xively | 0:82702e998d3f | 197 | const xi_response_t* xi_feed_get( |
xively | 0:82702e998d3f | 198 | xi_context_t* xi |
xively | 0:82702e998d3f | 199 | , xi_feed_t* feed ) |
xively | 0:82702e998d3f | 200 | { |
xively | 0:82702e998d3f | 201 | XI_FUNCTION_PROLOGUE |
xively | 0:82702e998d3f | 202 | |
xively | 0:82702e998d3f | 203 | const char* data = transport_layer->encode_get_feed( |
xively | 0:82702e998d3f | 204 | data_layer |
xively | 0:82702e998d3f | 205 | , xi->api_key |
xively | 0:82702e998d3f | 206 | , feed ); |
xively | 0:82702e998d3f | 207 | |
xively | 0:82702e998d3f | 208 | if( data == 0 ) { goto err_handling; } |
xively | 0:82702e998d3f | 209 | |
xively | 0:82702e998d3f | 210 | XI_FUNCTION_GET_RESPONSE |
xively | 0:82702e998d3f | 211 | |
xively | 0:82702e998d3f | 212 | feed = data_layer->decode_feed( response->http.http_content, feed ); |
xively | 0:82702e998d3f | 213 | if( feed == 0 ) { goto err_handling; } |
xively | 0:82702e998d3f | 214 | |
xively | 0:82702e998d3f | 215 | XI_FUNCTION_EPILOGUE |
xively | 0:82702e998d3f | 216 | } |
xively | 0:82702e998d3f | 217 | |
xively | 0:82702e998d3f | 218 | const xi_response_t* xi_feed_update( |
xively | 0:82702e998d3f | 219 | xi_context_t* xi |
xively | 0:82702e998d3f | 220 | , const xi_feed_t* feed ) |
xively | 0:82702e998d3f | 221 | { |
xively | 0:82702e998d3f | 222 | XI_FUNCTION_PROLOGUE |
xively | 0:82702e998d3f | 223 | |
xively | 0:82702e998d3f | 224 | const char* data = transport_layer->encode_update_feed( |
xively | 0:82702e998d3f | 225 | data_layer |
xively | 0:82702e998d3f | 226 | , xi->api_key |
xively | 0:82702e998d3f | 227 | , feed ); |
xively | 0:82702e998d3f | 228 | |
xively | 0:82702e998d3f | 229 | if( data == 0 ) { goto err_handling; } |
xively | 0:82702e998d3f | 230 | |
xively | 0:82702e998d3f | 231 | XI_FUNCTION_GET_RESPONSE |
xively | 0:82702e998d3f | 232 | |
xively | 0:82702e998d3f | 233 | XI_FUNCTION_EPILOGUE |
xively | 0:82702e998d3f | 234 | } |
xively | 0:82702e998d3f | 235 | |
xively | 0:82702e998d3f | 236 | const xi_response_t* xi_datastream_get( |
xively | 0:82702e998d3f | 237 | xi_context_t* xi, int32_t feed_id |
xively | 0:82702e998d3f | 238 | , const char * datastream_id, xi_datapoint_t* o ) |
xively | 0:82702e998d3f | 239 | { |
xively | 0:82702e998d3f | 240 | XI_FUNCTION_PROLOGUE |
xively | 0:82702e998d3f | 241 | |
xively | 0:82702e998d3f | 242 | const char* data = transport_layer->encode_get_datastream( |
xively | 0:82702e998d3f | 243 | data_layer |
xively | 0:82702e998d3f | 244 | , xi->api_key |
xively | 0:82702e998d3f | 245 | , feed_id |
xively | 0:82702e998d3f | 246 | , datastream_id ); |
xively | 0:82702e998d3f | 247 | |
xively | 0:82702e998d3f | 248 | if( data == 0 ) { goto err_handling; } |
xively | 0:82702e998d3f | 249 | |
xively | 0:82702e998d3f | 250 | XI_FUNCTION_GET_RESPONSE |
xively | 0:82702e998d3f | 251 | |
xively | 0:82702e998d3f | 252 | o = data_layer->decode_datapoint( |
xively | 0:82702e998d3f | 253 | response->http.http_content, o ); |
xively | 0:82702e998d3f | 254 | |
xively | 0:82702e998d3f | 255 | if( o == 0 ) { goto err_handling; } |
xively | 0:82702e998d3f | 256 | |
xively | 0:82702e998d3f | 257 | XI_FUNCTION_EPILOGUE |
xively | 0:82702e998d3f | 258 | } |
xively | 0:82702e998d3f | 259 | |
xively | 0:82702e998d3f | 260 | |
xively | 0:82702e998d3f | 261 | const xi_response_t* xi_datastream_create( |
xively | 0:82702e998d3f | 262 | xi_context_t* xi, int32_t feed_id |
xively | 0:82702e998d3f | 263 | , const char * datastream_id |
xively | 0:82702e998d3f | 264 | , const xi_datapoint_t* datapoint ) |
xively | 0:82702e998d3f | 265 | { |
xively | 0:82702e998d3f | 266 | XI_FUNCTION_PROLOGUE |
xively | 0:82702e998d3f | 267 | |
xively | 0:82702e998d3f | 268 | const char* data = transport_layer->encode_create_datastream( |
xively | 0:82702e998d3f | 269 | data_layer |
xively | 0:82702e998d3f | 270 | , xi->api_key |
xively | 0:82702e998d3f | 271 | , feed_id |
xively | 0:82702e998d3f | 272 | , datastream_id |
xively | 0:82702e998d3f | 273 | , datapoint ); |
xively | 0:82702e998d3f | 274 | |
xively | 0:82702e998d3f | 275 | if( data == 0 ) { goto err_handling; } |
xively | 0:82702e998d3f | 276 | |
xively | 0:82702e998d3f | 277 | XI_FUNCTION_GET_RESPONSE |
xively | 0:82702e998d3f | 278 | XI_FUNCTION_EPILOGUE |
xively | 0:82702e998d3f | 279 | } |
xively | 0:82702e998d3f | 280 | |
xively | 0:82702e998d3f | 281 | const xi_response_t* xi_datastream_update( |
xively | 0:82702e998d3f | 282 | xi_context_t* xi, int32_t feed_id |
xively | 0:82702e998d3f | 283 | , const char * datastream_id |
xively | 0:82702e998d3f | 284 | , const xi_datapoint_t* datapoint ) |
xively | 0:82702e998d3f | 285 | { |
xively | 0:82702e998d3f | 286 | XI_FUNCTION_PROLOGUE |
xively | 0:82702e998d3f | 287 | |
xively | 0:82702e998d3f | 288 | const char* data = transport_layer->encode_update_datastream( |
xively | 0:82702e998d3f | 289 | data_layer |
xively | 0:82702e998d3f | 290 | , xi->api_key |
xively | 0:82702e998d3f | 291 | , feed_id |
xively | 0:82702e998d3f | 292 | , datastream_id |
xively | 0:82702e998d3f | 293 | , datapoint ); |
xively | 0:82702e998d3f | 294 | |
xively | 0:82702e998d3f | 295 | |
xively | 0:82702e998d3f | 296 | if( data == 0 ) { goto err_handling; } |
xively | 0:82702e998d3f | 297 | |
xively | 0:82702e998d3f | 298 | XI_FUNCTION_GET_RESPONSE |
xively | 0:82702e998d3f | 299 | |
xively | 0:82702e998d3f | 300 | |
xively | 0:82702e998d3f | 301 | XI_FUNCTION_EPILOGUE |
xively | 0:82702e998d3f | 302 | } |
xively | 0:82702e998d3f | 303 | const xi_response_t* xi_datastream_delete( |
xively | 0:82702e998d3f | 304 | xi_context_t* xi, int32_t feed_id |
xively | 0:82702e998d3f | 305 | , const char * datastream_id ) |
xively | 0:82702e998d3f | 306 | { |
xively | 0:82702e998d3f | 307 | XI_FUNCTION_PROLOGUE |
xively | 0:82702e998d3f | 308 | |
xively | 0:82702e998d3f | 309 | const char* data = transport_layer->encode_delete_datastream( |
xively | 0:82702e998d3f | 310 | data_layer |
xively | 0:82702e998d3f | 311 | , xi->api_key |
xively | 0:82702e998d3f | 312 | , feed_id |
xively | 0:82702e998d3f | 313 | , datastream_id ); |
xively | 0:82702e998d3f | 314 | |
xively | 0:82702e998d3f | 315 | if( data == 0 ) { goto err_handling; } |
xively | 0:82702e998d3f | 316 | |
xively | 0:82702e998d3f | 317 | XI_FUNCTION_GET_RESPONSE |
xively | 0:82702e998d3f | 318 | |
xively | 0:82702e998d3f | 319 | XI_FUNCTION_EPILOGUE |
xively | 0:82702e998d3f | 320 | } |
xively | 0:82702e998d3f | 321 | |
xively | 0:82702e998d3f | 322 | const xi_response_t* xi_datapoint_delete( |
xively | 0:82702e998d3f | 323 | const xi_context_t* xi, int feed_id |
xively | 0:82702e998d3f | 324 | , const char * datastream_id |
xively | 0:82702e998d3f | 325 | , const xi_datapoint_t* o ) |
xively | 0:82702e998d3f | 326 | { |
xively | 0:82702e998d3f | 327 | XI_FUNCTION_PROLOGUE |
xively | 0:82702e998d3f | 328 | |
xively | 0:82702e998d3f | 329 | const char* data = transport_layer->encode_delete_datapoint( |
xively | 0:82702e998d3f | 330 | data_layer |
xively | 0:82702e998d3f | 331 | , xi->api_key |
xively | 0:82702e998d3f | 332 | , feed_id |
xively | 0:82702e998d3f | 333 | , datastream_id |
xively | 0:82702e998d3f | 334 | , o ); |
xively | 0:82702e998d3f | 335 | |
xively | 0:82702e998d3f | 336 | if( data == 0 ) { goto err_handling; } |
xively | 0:82702e998d3f | 337 | |
xively | 0:82702e998d3f | 338 | XI_FUNCTION_GET_RESPONSE |
xively | 0:82702e998d3f | 339 | XI_FUNCTION_EPILOGUE |
xively | 0:82702e998d3f | 340 | } |
xively | 0:82702e998d3f | 341 | |
xively | 0:82702e998d3f | 342 | extern const xi_response_t* xi_datapoint_delete_range( |
xively | 0:82702e998d3f | 343 | const xi_context_t* xi, int feed_id |
xively | 0:82702e998d3f | 344 | , const char * datastream_id |
xively | 0:82702e998d3f | 345 | , const xi_timestamp_t* start |
xively | 0:82702e998d3f | 346 | , const xi_timestamp_t* end ) |
xively | 0:82702e998d3f | 347 | { |
xively | 0:82702e998d3f | 348 | XI_FUNCTION_PROLOGUE |
xively | 0:82702e998d3f | 349 | |
xively | 0:82702e998d3f | 350 | const char* data = transport_layer->encode_datapoint_delete_range( |
xively | 0:82702e998d3f | 351 | data_layer |
xively | 0:82702e998d3f | 352 | , xi->api_key |
xively | 0:82702e998d3f | 353 | , feed_id |
xively | 0:82702e998d3f | 354 | , datastream_id |
xively | 0:82702e998d3f | 355 | , start |
xively | 0:82702e998d3f | 356 | , end ); |
xively | 0:82702e998d3f | 357 | |
xively | 0:82702e998d3f | 358 | if( data == 0 ) { goto err_handling; } |
xively | 0:82702e998d3f | 359 | |
xively | 0:82702e998d3f | 360 | XI_FUNCTION_GET_RESPONSE |
xively | 0:82702e998d3f | 361 | XI_FUNCTION_EPILOGUE |
xively | 0:82702e998d3f | 362 | } |
xively | 0:82702e998d3f | 363 | |
xively | 0:82702e998d3f | 364 | |
xively | 0:82702e998d3f | 365 | #ifdef __cplusplus |
xively | 0:82702e998d3f | 366 | } |
xively | 0:82702e998d3f | 367 | #endif |