Official reference client implementation for Cumulocity SmartREST on u-blox C027.

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Vincent Wochnik

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SmartRestTemplate.cpp Source File

SmartRestTemplate.cpp

00001 #include <string.h>
00002 #include "SmartRestTemplate.h"
00003 
00004 SmartRestTemplate::SmartRestTemplate()
00005 {
00006     _len = NULL;
00007 }
00008 
00009 bool SmartRestTemplate::add(const char *line)
00010 {
00011     if (_len == SMARTREST_TEMPLATE_FIXED_SIZE)
00012         return false;
00013     _buffer[_len++] = line;
00014     return true;
00015 }
00016 
00017 size_t SmartRestTemplate::writeTo(AbstractDataSink& sink) const
00018 {
00019     size_t len = 0;
00020     
00021     for (size_t n = 0; n < _len; n++)
00022         len += sink.write((char*)_buffer[n], strlen(_buffer[n]));
00023     
00024     return len;
00025 }
00026 
00027 size_t SmartRestTemplate::writtenLength() const
00028 {
00029     size_t len = 0;
00030     
00031     for (size_t n = 0; n < _len; n++)
00032         len += strlen(_buffer[n]);
00033     
00034     return len;
00035 }
00036 
00037 DataGenerator * SmartRestTemplate::copy() const
00038 {
00039     return NULL;
00040 }