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
util/SmartRestTemplate.cpp@55:a0f7295ed6b6, 2014-10-23 (annotated)
- Committer:
- vwochnik
- Date:
- Thu Oct 23 12:50:07 2014 +0000
- Revision:
- 55:a0f7295ed6b6
- Parent:
- utils/SmartRestTemplate.cpp@41:804f6a0bda26
- Child:
- 92:48069375dffa
thread safe smartrest
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Cumulocity | 41:804f6a0bda26 | 1 | #include "SmartRestTemplate.h" |
Cumulocity | 41:804f6a0bda26 | 2 | #include <string.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; |
Cumulocity | 41:804f6a0bda26 | 14 | } |
Cumulocity | 41:804f6a0bda26 | 15 | |
Cumulocity | 41:804f6a0bda26 | 16 | size_t SmartRestTemplate::writeTo(AbstractDataSink& sink) const |
Cumulocity | 41:804f6a0bda26 | 17 | { |
Cumulocity | 41:804f6a0bda26 | 18 | size_t len = 0; |
Cumulocity | 41:804f6a0bda26 | 19 | |
Cumulocity | 41:804f6a0bda26 | 20 | for (size_t n = 0; n < _len; n++) |
Cumulocity | 41:804f6a0bda26 | 21 | len += sink.write((char*)_buffer[n], strlen(_buffer[n])); |
Cumulocity | 41:804f6a0bda26 | 22 | |
Cumulocity | 41:804f6a0bda26 | 23 | return len; |
Cumulocity | 41:804f6a0bda26 | 24 | } |
Cumulocity | 41:804f6a0bda26 | 25 | |
Cumulocity | 41:804f6a0bda26 | 26 | size_t SmartRestTemplate::writtenLength() const |
Cumulocity | 41:804f6a0bda26 | 27 | { |
Cumulocity | 41:804f6a0bda26 | 28 | size_t len = 0; |
Cumulocity | 41:804f6a0bda26 | 29 | |
Cumulocity | 41:804f6a0bda26 | 30 | for (size_t n = 0; n < _len; n++) |
Cumulocity | 41:804f6a0bda26 | 31 | len += strlen(_buffer[n]); |
Cumulocity | 41:804f6a0bda26 | 32 | |
Cumulocity | 41:804f6a0bda26 | 33 | return len; |
Cumulocity | 41:804f6a0bda26 | 34 | } |
Cumulocity | 41:804f6a0bda26 | 35 | |
Cumulocity | 41:804f6a0bda26 | 36 | DataGenerator * SmartRestTemplate::copy() const |
Cumulocity | 41:804f6a0bda26 | 37 | { |
Cumulocity | 41:804f6a0bda26 | 38 | return NULL; |
Cumulocity | 41:804f6a0bda26 | 39 | } |