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

Committer:
xinlei
Date:
Mon Aug 08 11:05:57 2016 +0000
Revision:
139:f8ab852e83e7
Parent:
101:dbcd3bc51758
Etisalat and Teleena APN.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
xinlei 101:dbcd3bc51758 1 #include <string.h>
Cumulocity 41:804f6a0bda26 2 #include "SmartRestTemplate.h"
Cumulocity 41:804f6a0bda26 3
Cumulocity 41:804f6a0bda26 4 SmartRestTemplate::SmartRestTemplate()
Cumulocity 41:804f6a0bda26 5 {
Cumulocity 41:804f6a0bda26 6 _len = NULL;
Cumulocity 41:804f6a0bda26 7 }
Cumulocity 41:804f6a0bda26 8
Cumulocity 41:804f6a0bda26 9 bool SmartRestTemplate::add(const char *line)
Cumulocity 41:804f6a0bda26 10 {
Cumulocity 41:804f6a0bda26 11 if (_len == SMARTREST_TEMPLATE_FIXED_SIZE)
Cumulocity 41:804f6a0bda26 12 return false;
Cumulocity 41:804f6a0bda26 13 _buffer[_len++] = line;
xinlei 92:48069375dffa 14 return true;
Cumulocity 41:804f6a0bda26 15 }
Cumulocity 41:804f6a0bda26 16
Cumulocity 41:804f6a0bda26 17 size_t SmartRestTemplate::writeTo(AbstractDataSink& sink) const
Cumulocity 41:804f6a0bda26 18 {
Cumulocity 41:804f6a0bda26 19 size_t len = 0;
Cumulocity 41:804f6a0bda26 20
Cumulocity 41:804f6a0bda26 21 for (size_t n = 0; n < _len; n++)
Cumulocity 41:804f6a0bda26 22 len += sink.write((char*)_buffer[n], strlen(_buffer[n]));
Cumulocity 41:804f6a0bda26 23
Cumulocity 41:804f6a0bda26 24 return len;
Cumulocity 41:804f6a0bda26 25 }
Cumulocity 41:804f6a0bda26 26
Cumulocity 41:804f6a0bda26 27 size_t SmartRestTemplate::writtenLength() const
Cumulocity 41:804f6a0bda26 28 {
Cumulocity 41:804f6a0bda26 29 size_t len = 0;
Cumulocity 41:804f6a0bda26 30
Cumulocity 41:804f6a0bda26 31 for (size_t n = 0; n < _len; n++)
Cumulocity 41:804f6a0bda26 32 len += strlen(_buffer[n]);
Cumulocity 41:804f6a0bda26 33
Cumulocity 41:804f6a0bda26 34 return len;
Cumulocity 41:804f6a0bda26 35 }
Cumulocity 41:804f6a0bda26 36
Cumulocity 41:804f6a0bda26 37 DataGenerator * SmartRestTemplate::copy() const
Cumulocity 41:804f6a0bda26 38 {
Cumulocity 41:804f6a0bda26 39 return NULL;
Cumulocity 41:804f6a0bda26 40 }