The Cayenne MQTT mbed Library provides functions to easily connect to the Cayenne IoT project builder.
Fork of Cayenne-MQTT-mbed by
src/CayenneUtils/CayenneDataArray.h@0:09ef59d2d0f7, 2016-10-07 (annotated)
- Committer:
- jburhenn
- Date:
- Fri Oct 07 17:21:45 2016 +0000
- Revision:
- 0:09ef59d2d0f7
- Child:
- 1:90dccf306268
Initial commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jburhenn | 0:09ef59d2d0f7 | 1 | /* |
jburhenn | 0:09ef59d2d0f7 | 2 | The MIT License(MIT) |
jburhenn | 0:09ef59d2d0f7 | 3 | |
jburhenn | 0:09ef59d2d0f7 | 4 | Cayenne MQTT Client Library |
jburhenn | 0:09ef59d2d0f7 | 5 | Copyright (c) 2016 myDevices |
jburhenn | 0:09ef59d2d0f7 | 6 | |
jburhenn | 0:09ef59d2d0f7 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
jburhenn | 0:09ef59d2d0f7 | 8 | documentation files(the "Software"), to deal in the Software without restriction, including without limitation |
jburhenn | 0:09ef59d2d0f7 | 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, |
jburhenn | 0:09ef59d2d0f7 | 10 | and to permit persons to whom the Software is furnished to do so, subject to the following conditions : |
jburhenn | 0:09ef59d2d0f7 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
jburhenn | 0:09ef59d2d0f7 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
jburhenn | 0:09ef59d2d0f7 | 13 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR |
jburhenn | 0:09ef59d2d0f7 | 14 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
jburhenn | 0:09ef59d2d0f7 | 15 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
jburhenn | 0:09ef59d2d0f7 | 16 | */ |
jburhenn | 0:09ef59d2d0f7 | 17 | |
jburhenn | 0:09ef59d2d0f7 | 18 | #ifndef _CAYENNEDATAARRAY_h |
jburhenn | 0:09ef59d2d0f7 | 19 | #define _CAYENNEDATAARRAY_h |
jburhenn | 0:09ef59d2d0f7 | 20 | |
jburhenn | 0:09ef59d2d0f7 | 21 | #include "CayenneUtils.h" |
jburhenn | 0:09ef59d2d0f7 | 22 | |
jburhenn | 0:09ef59d2d0f7 | 23 | #if defined(__cplusplus) |
jburhenn | 0:09ef59d2d0f7 | 24 | |
jburhenn | 0:09ef59d2d0f7 | 25 | // C++ version of the data array. This is defined here so it requires no source file. |
jburhenn | 0:09ef59d2d0f7 | 26 | |
jburhenn | 0:09ef59d2d0f7 | 27 | namespace Cayenne |
jburhenn | 0:09ef59d2d0f7 | 28 | { |
jburhenn | 0:09ef59d2d0f7 | 29 | template<int BUFFER_SIZE = CAYENNE_MAX_MESSAGE_SIZE, int MAX_VALUES = CAYENNE_MAX_MESSAGE_VALUES> |
jburhenn | 0:09ef59d2d0f7 | 30 | class DataArray |
jburhenn | 0:09ef59d2d0f7 | 31 | { |
jburhenn | 0:09ef59d2d0f7 | 32 | public: |
jburhenn | 0:09ef59d2d0f7 | 33 | DataArray() { |
jburhenn | 0:09ef59d2d0f7 | 34 | clear(); |
jburhenn | 0:09ef59d2d0f7 | 35 | } |
jburhenn | 0:09ef59d2d0f7 | 36 | |
jburhenn | 0:09ef59d2d0f7 | 37 | void clear() { |
jburhenn | 0:09ef59d2d0f7 | 38 | for (int i = 0; i < CAYENNE_MAX_MESSAGE_VALUES; ++i) { |
jburhenn | 0:09ef59d2d0f7 | 39 | _values[i].unit = NULL; |
jburhenn | 0:09ef59d2d0f7 | 40 | _values[i].value = NULL; |
jburhenn | 0:09ef59d2d0f7 | 41 | } |
jburhenn | 0:09ef59d2d0f7 | 42 | _valueCount = 0; |
jburhenn | 0:09ef59d2d0f7 | 43 | _index = 0; |
jburhenn | 0:09ef59d2d0f7 | 44 | } |
jburhenn | 0:09ef59d2d0f7 | 45 | |
jburhenn | 0:09ef59d2d0f7 | 46 | void add(const char* unit, const char* value, bool unitInFlash = false, bool valueInFlash = false) { |
jburhenn | 0:09ef59d2d0f7 | 47 | if (_valueCount >= CAYENNE_MAX_MESSAGE_VALUES) |
jburhenn | 0:09ef59d2d0f7 | 48 | return; |
jburhenn | 0:09ef59d2d0f7 | 49 | |
jburhenn | 0:09ef59d2d0f7 | 50 | size_t unitLength = 0; |
jburhenn | 0:09ef59d2d0f7 | 51 | if (unit) { |
jburhenn | 0:09ef59d2d0f7 | 52 | unitLength = (unitInFlash ? CAYENNE_STRLEN(unit) : strlen(unit)) + 1; |
jburhenn | 0:09ef59d2d0f7 | 53 | } |
jburhenn | 0:09ef59d2d0f7 | 54 | size_t valueLength = 0; |
jburhenn | 0:09ef59d2d0f7 | 55 | if (value) { |
jburhenn | 0:09ef59d2d0f7 | 56 | valueLength = (valueInFlash ? CAYENNE_STRLEN(value) : strlen(value)) + 1; |
jburhenn | 0:09ef59d2d0f7 | 57 | } |
jburhenn | 0:09ef59d2d0f7 | 58 | if (_index + unitLength + valueLength > BUFFER_SIZE) |
jburhenn | 0:09ef59d2d0f7 | 59 | return; |
jburhenn | 0:09ef59d2d0f7 | 60 | |
jburhenn | 0:09ef59d2d0f7 | 61 | if (unit) { |
jburhenn | 0:09ef59d2d0f7 | 62 | unitInFlash ? CAYENNE_MEMCPY(_buffer + _index, unit, unitLength) : memcpy(_buffer + _index, unit, unitLength); |
jburhenn | 0:09ef59d2d0f7 | 63 | _values[_valueCount].unit = _buffer + _index; |
jburhenn | 0:09ef59d2d0f7 | 64 | _index += unitLength; |
jburhenn | 0:09ef59d2d0f7 | 65 | } |
jburhenn | 0:09ef59d2d0f7 | 66 | else { |
jburhenn | 0:09ef59d2d0f7 | 67 | _values[_valueCount].unit = NULL; |
jburhenn | 0:09ef59d2d0f7 | 68 | } |
jburhenn | 0:09ef59d2d0f7 | 69 | |
jburhenn | 0:09ef59d2d0f7 | 70 | if (value) { |
jburhenn | 0:09ef59d2d0f7 | 71 | valueInFlash ? CAYENNE_MEMCPY(_buffer + _index, value, valueLength) : memcpy(_buffer + _index, value, valueLength); |
jburhenn | 0:09ef59d2d0f7 | 72 | _values[_valueCount].value = _buffer + _index; |
jburhenn | 0:09ef59d2d0f7 | 73 | _index += valueLength; |
jburhenn | 0:09ef59d2d0f7 | 74 | } |
jburhenn | 0:09ef59d2d0f7 | 75 | else { |
jburhenn | 0:09ef59d2d0f7 | 76 | _values[_valueCount].value = NULL; |
jburhenn | 0:09ef59d2d0f7 | 77 | } |
jburhenn | 0:09ef59d2d0f7 | 78 | |
jburhenn | 0:09ef59d2d0f7 | 79 | _valueCount++; |
jburhenn | 0:09ef59d2d0f7 | 80 | } |
jburhenn | 0:09ef59d2d0f7 | 81 | |
jburhenn | 0:09ef59d2d0f7 | 82 | inline void add(const char* unit, const int value) { |
jburhenn | 0:09ef59d2d0f7 | 83 | char str[2 + 8 * sizeof(value)]; |
jburhenn | 0:09ef59d2d0f7 | 84 | #if defined(__AVR__) || defined (ARDUINO_ARCH_ARC32) |
jburhenn | 0:09ef59d2d0f7 | 85 | itoa(value, str, 10); |
jburhenn | 0:09ef59d2d0f7 | 86 | #else |
jburhenn | 0:09ef59d2d0f7 | 87 | snprintf(str, sizeof(str), "%d", value); |
jburhenn | 0:09ef59d2d0f7 | 88 | #endif |
jburhenn | 0:09ef59d2d0f7 | 89 | add(unit, str); |
jburhenn | 0:09ef59d2d0f7 | 90 | } |
jburhenn | 0:09ef59d2d0f7 | 91 | |
jburhenn | 0:09ef59d2d0f7 | 92 | inline void add(const char* unit, const unsigned int value) { |
jburhenn | 0:09ef59d2d0f7 | 93 | char str[1 + 8 * sizeof(value)]; |
jburhenn | 0:09ef59d2d0f7 | 94 | #if defined(__AVR__) || defined (ARDUINO_ARCH_ARC32) |
jburhenn | 0:09ef59d2d0f7 | 95 | utoa(value, str, 10); |
jburhenn | 0:09ef59d2d0f7 | 96 | #else |
jburhenn | 0:09ef59d2d0f7 | 97 | snprintf(str, sizeof(str), "%u", value); |
jburhenn | 0:09ef59d2d0f7 | 98 | #endif |
jburhenn | 0:09ef59d2d0f7 | 99 | add(unit, str); |
jburhenn | 0:09ef59d2d0f7 | 100 | } |
jburhenn | 0:09ef59d2d0f7 | 101 | |
jburhenn | 0:09ef59d2d0f7 | 102 | inline void add(const char* unit, const long value) { |
jburhenn | 0:09ef59d2d0f7 | 103 | char str[2 + 8 * sizeof(value)]; |
jburhenn | 0:09ef59d2d0f7 | 104 | #if defined(__AVR__) || defined (ARDUINO_ARCH_ARC32) |
jburhenn | 0:09ef59d2d0f7 | 105 | ltoa(value, str, 10); |
jburhenn | 0:09ef59d2d0f7 | 106 | #else |
jburhenn | 0:09ef59d2d0f7 | 107 | snprintf(str, sizeof(str), "%ld", value); |
jburhenn | 0:09ef59d2d0f7 | 108 | #endif |
jburhenn | 0:09ef59d2d0f7 | 109 | add(unit, str); |
jburhenn | 0:09ef59d2d0f7 | 110 | } |
jburhenn | 0:09ef59d2d0f7 | 111 | |
jburhenn | 0:09ef59d2d0f7 | 112 | inline void add(const char* unit, const unsigned long value) { |
jburhenn | 0:09ef59d2d0f7 | 113 | char str[1 + 8 * sizeof(value)]; |
jburhenn | 0:09ef59d2d0f7 | 114 | #if defined(__AVR__) || defined (ARDUINO_ARCH_ARC32) |
jburhenn | 0:09ef59d2d0f7 | 115 | ultoa(value, str, 10); |
jburhenn | 0:09ef59d2d0f7 | 116 | #else |
jburhenn | 0:09ef59d2d0f7 | 117 | snprintf(str, sizeof(str), "%lu", value); |
jburhenn | 0:09ef59d2d0f7 | 118 | #endif |
jburhenn | 0:09ef59d2d0f7 | 119 | add(unit, str); |
jburhenn | 0:09ef59d2d0f7 | 120 | } |
jburhenn | 0:09ef59d2d0f7 | 121 | |
jburhenn | 0:09ef59d2d0f7 | 122 | #if defined(__AVR__) || defined (ARDUINO_ARCH_ARC32) |
jburhenn | 0:09ef59d2d0f7 | 123 | |
jburhenn | 0:09ef59d2d0f7 | 124 | inline void add(const char* unit, const float value) { |
jburhenn | 0:09ef59d2d0f7 | 125 | char str[33]; |
jburhenn | 0:09ef59d2d0f7 | 126 | dtostrf(value, 5, 3, str); |
jburhenn | 0:09ef59d2d0f7 | 127 | add(unit, str); |
jburhenn | 0:09ef59d2d0f7 | 128 | } |
jburhenn | 0:09ef59d2d0f7 | 129 | |
jburhenn | 0:09ef59d2d0f7 | 130 | inline void add(const char* unit, const double value) { |
jburhenn | 0:09ef59d2d0f7 | 131 | char str[33]; |
jburhenn | 0:09ef59d2d0f7 | 132 | dtostrf(value, 5, 3, str); |
jburhenn | 0:09ef59d2d0f7 | 133 | add(unit, str); |
jburhenn | 0:09ef59d2d0f7 | 134 | } |
jburhenn | 0:09ef59d2d0f7 | 135 | |
jburhenn | 0:09ef59d2d0f7 | 136 | #else |
jburhenn | 0:09ef59d2d0f7 | 137 | |
jburhenn | 0:09ef59d2d0f7 | 138 | inline void add(const char* unit, const float value) { |
jburhenn | 0:09ef59d2d0f7 | 139 | char str[33]; |
jburhenn | 0:09ef59d2d0f7 | 140 | snprintf(str, 33, "%2.3f", value); |
jburhenn | 0:09ef59d2d0f7 | 141 | add(unit, str); |
jburhenn | 0:09ef59d2d0f7 | 142 | } |
jburhenn | 0:09ef59d2d0f7 | 143 | |
jburhenn | 0:09ef59d2d0f7 | 144 | inline void add(const char* unit, const double value) { |
jburhenn | 0:09ef59d2d0f7 | 145 | char str[33]; |
jburhenn | 0:09ef59d2d0f7 | 146 | snprintf(str, 33, "%2.3f", value); |
jburhenn | 0:09ef59d2d0f7 | 147 | add(unit, str); |
jburhenn | 0:09ef59d2d0f7 | 148 | } |
jburhenn | 0:09ef59d2d0f7 | 149 | |
jburhenn | 0:09ef59d2d0f7 | 150 | #endif |
jburhenn | 0:09ef59d2d0f7 | 151 | |
jburhenn | 0:09ef59d2d0f7 | 152 | #ifdef CAYENNE_USING_PROGMEM |
jburhenn | 0:09ef59d2d0f7 | 153 | |
jburhenn | 0:09ef59d2d0f7 | 154 | void add(const char* unit, const __FlashStringHelper* value) { |
jburhenn | 0:09ef59d2d0f7 | 155 | const char* valueString = reinterpret_cast<const char *>(value); |
jburhenn | 0:09ef59d2d0f7 | 156 | add(unit, valueString, false, true); |
jburhenn | 0:09ef59d2d0f7 | 157 | } |
jburhenn | 0:09ef59d2d0f7 | 158 | |
jburhenn | 0:09ef59d2d0f7 | 159 | void add(const __FlashStringHelper* unit, const char* value) { |
jburhenn | 0:09ef59d2d0f7 | 160 | const char* unitString = reinterpret_cast<const char *>(unit); |
jburhenn | 0:09ef59d2d0f7 | 161 | add(unitString, value, true, false); |
jburhenn | 0:09ef59d2d0f7 | 162 | } |
jburhenn | 0:09ef59d2d0f7 | 163 | |
jburhenn | 0:09ef59d2d0f7 | 164 | void add(const __FlashStringHelper* unit, const __FlashStringHelper* value) { |
jburhenn | 0:09ef59d2d0f7 | 165 | const char* unitString = reinterpret_cast<const char *>(unit); |
jburhenn | 0:09ef59d2d0f7 | 166 | const char* valueString = reinterpret_cast<const char *>(value); |
jburhenn | 0:09ef59d2d0f7 | 167 | add(unitString, valueString, true, true); |
jburhenn | 0:09ef59d2d0f7 | 168 | } |
jburhenn | 0:09ef59d2d0f7 | 169 | |
jburhenn | 0:09ef59d2d0f7 | 170 | inline void add(const __FlashStringHelper* unit, const int value) { |
jburhenn | 0:09ef59d2d0f7 | 171 | char str[2 + 8 * sizeof(value)]; |
jburhenn | 0:09ef59d2d0f7 | 172 | itoa(value, str, 10); |
jburhenn | 0:09ef59d2d0f7 | 173 | add(unit, str); |
jburhenn | 0:09ef59d2d0f7 | 174 | } |
jburhenn | 0:09ef59d2d0f7 | 175 | |
jburhenn | 0:09ef59d2d0f7 | 176 | inline void add(const __FlashStringHelper* unit, const unsigned int value) { |
jburhenn | 0:09ef59d2d0f7 | 177 | char str[1 + 8 * sizeof(value)]; |
jburhenn | 0:09ef59d2d0f7 | 178 | utoa(value, str, 10); |
jburhenn | 0:09ef59d2d0f7 | 179 | add(unit, str); |
jburhenn | 0:09ef59d2d0f7 | 180 | } |
jburhenn | 0:09ef59d2d0f7 | 181 | |
jburhenn | 0:09ef59d2d0f7 | 182 | inline void add(const __FlashStringHelper* unit, const long value) { |
jburhenn | 0:09ef59d2d0f7 | 183 | char str[2 + 8 * sizeof(value)]; |
jburhenn | 0:09ef59d2d0f7 | 184 | ltoa(value, str, 10); |
jburhenn | 0:09ef59d2d0f7 | 185 | add(unit, str); |
jburhenn | 0:09ef59d2d0f7 | 186 | } |
jburhenn | 0:09ef59d2d0f7 | 187 | |
jburhenn | 0:09ef59d2d0f7 | 188 | inline void add(const __FlashStringHelper* unit, const unsigned long value) { |
jburhenn | 0:09ef59d2d0f7 | 189 | char str[1 + 8 * sizeof(value)]; |
jburhenn | 0:09ef59d2d0f7 | 190 | ultoa(value, str, 10); |
jburhenn | 0:09ef59d2d0f7 | 191 | add(unit, str); |
jburhenn | 0:09ef59d2d0f7 | 192 | } |
jburhenn | 0:09ef59d2d0f7 | 193 | |
jburhenn | 0:09ef59d2d0f7 | 194 | inline void add(const __FlashStringHelper* unit, const float value) { |
jburhenn | 0:09ef59d2d0f7 | 195 | char str[33]; |
jburhenn | 0:09ef59d2d0f7 | 196 | dtostrf(value, 5, 3, str); |
jburhenn | 0:09ef59d2d0f7 | 197 | add(unit, str); |
jburhenn | 0:09ef59d2d0f7 | 198 | } |
jburhenn | 0:09ef59d2d0f7 | 199 | |
jburhenn | 0:09ef59d2d0f7 | 200 | inline void add(const __FlashStringHelper* unit, const double value) { |
jburhenn | 0:09ef59d2d0f7 | 201 | char str[33]; |
jburhenn | 0:09ef59d2d0f7 | 202 | dtostrf(value, 5, 3, str); |
jburhenn | 0:09ef59d2d0f7 | 203 | add(unit, str); |
jburhenn | 0:09ef59d2d0f7 | 204 | } |
jburhenn | 0:09ef59d2d0f7 | 205 | |
jburhenn | 0:09ef59d2d0f7 | 206 | #endif |
jburhenn | 0:09ef59d2d0f7 | 207 | |
jburhenn | 0:09ef59d2d0f7 | 208 | const CayenneValuePair* getArray() const { |
jburhenn | 0:09ef59d2d0f7 | 209 | return _values; |
jburhenn | 0:09ef59d2d0f7 | 210 | } |
jburhenn | 0:09ef59d2d0f7 | 211 | |
jburhenn | 0:09ef59d2d0f7 | 212 | size_t getCount() const { |
jburhenn | 0:09ef59d2d0f7 | 213 | return _valueCount; |
jburhenn | 0:09ef59d2d0f7 | 214 | } |
jburhenn | 0:09ef59d2d0f7 | 215 | |
jburhenn | 0:09ef59d2d0f7 | 216 | private: |
jburhenn | 0:09ef59d2d0f7 | 217 | CayenneValuePair _values[MAX_VALUES]; |
jburhenn | 0:09ef59d2d0f7 | 218 | size_t _valueCount; |
jburhenn | 0:09ef59d2d0f7 | 219 | char _buffer[BUFFER_SIZE]; |
jburhenn | 0:09ef59d2d0f7 | 220 | size_t _index; |
jburhenn | 0:09ef59d2d0f7 | 221 | }; |
jburhenn | 0:09ef59d2d0f7 | 222 | } |
jburhenn | 0:09ef59d2d0f7 | 223 | |
jburhenn | 0:09ef59d2d0f7 | 224 | typedef Cayenne::DataArray<> CayenneDataArray; |
jburhenn | 0:09ef59d2d0f7 | 225 | |
jburhenn | 0:09ef59d2d0f7 | 226 | #else |
jburhenn | 0:09ef59d2d0f7 | 227 | |
jburhenn | 0:09ef59d2d0f7 | 228 | // C version of the data array. Requires source file to be compiled and linked. |
jburhenn | 0:09ef59d2d0f7 | 229 | |
jburhenn | 0:09ef59d2d0f7 | 230 | typedef struct CayenneDataArray |
jburhenn | 0:09ef59d2d0f7 | 231 | { |
jburhenn | 0:09ef59d2d0f7 | 232 | CayenneValuePair values[CAYENNE_MAX_MESSAGE_VALUES]; |
jburhenn | 0:09ef59d2d0f7 | 233 | unsigned int valueCount; |
jburhenn | 0:09ef59d2d0f7 | 234 | char* buffer; |
jburhenn | 0:09ef59d2d0f7 | 235 | unsigned int bufferSize; |
jburhenn | 0:09ef59d2d0f7 | 236 | unsigned int bufferIndex; |
jburhenn | 0:09ef59d2d0f7 | 237 | } CayenneDataArray; |
jburhenn | 0:09ef59d2d0f7 | 238 | |
jburhenn | 0:09ef59d2d0f7 | 239 | /** |
jburhenn | 0:09ef59d2d0f7 | 240 | * Initialize a data array of unit/value pairs. |
jburhenn | 0:09ef59d2d0f7 | 241 | * @param[out] dataArray The initialized data array |
jburhenn | 0:09ef59d2d0f7 | 242 | * @param[in] buffer Buffer for storing unit/value pairs. This buffer should be available for as long as the data array is used. |
jburhenn | 0:09ef59d2d0f7 | 243 | * @param[in] bufferSize Size of the buffer |
jburhenn | 0:09ef59d2d0f7 | 244 | */ |
jburhenn | 0:09ef59d2d0f7 | 245 | DLLExport void CayenneDataArrayInit(CayenneDataArray* dataArray, char* buffer, unsigned int bufferSize); |
jburhenn | 0:09ef59d2d0f7 | 246 | |
jburhenn | 0:09ef59d2d0f7 | 247 | /** |
jburhenn | 0:09ef59d2d0f7 | 248 | * Add the specified unit/value pair to the array. |
jburhenn | 0:09ef59d2d0f7 | 249 | * @param[in] dataArray The data array to add values to |
jburhenn | 0:09ef59d2d0f7 | 250 | * @param[in] unit The unit to add |
jburhenn | 0:09ef59d2d0f7 | 251 | * @param[in] value The value to add |
jburhenn | 0:09ef59d2d0f7 | 252 | * @return CAYENNE_SUCCESS if unit/value pair was add, CAYENNE_FAILURE otherwise |
jburhenn | 0:09ef59d2d0f7 | 253 | */ |
jburhenn | 0:09ef59d2d0f7 | 254 | DLLExport int CayenneDataArrayAdd(CayenneDataArray* dataArray, const char* unit, const char* value); |
jburhenn | 0:09ef59d2d0f7 | 255 | |
jburhenn | 0:09ef59d2d0f7 | 256 | /** |
jburhenn | 0:09ef59d2d0f7 | 257 | * Add the specified unit/value pair to the array. |
jburhenn | 0:09ef59d2d0f7 | 258 | * @param[in] dataArray The data array to add values to |
jburhenn | 0:09ef59d2d0f7 | 259 | * @param[in] unit The unit to add |
jburhenn | 0:09ef59d2d0f7 | 260 | * @param[in] value The value to add |
jburhenn | 0:09ef59d2d0f7 | 261 | * @return CAYENNE_SUCCESS if unit/value pair was add, CAYENNE_FAILURE otherwise |
jburhenn | 0:09ef59d2d0f7 | 262 | */ |
jburhenn | 0:09ef59d2d0f7 | 263 | DLLExport int CayenneDataArrayAddInt(CayenneDataArray* dataArray, const char* unit, int value); |
jburhenn | 0:09ef59d2d0f7 | 264 | |
jburhenn | 0:09ef59d2d0f7 | 265 | /** |
jburhenn | 0:09ef59d2d0f7 | 266 | * Add the specified unit/value pair to the array. |
jburhenn | 0:09ef59d2d0f7 | 267 | * @param[in] dataArray The data array to add values to |
jburhenn | 0:09ef59d2d0f7 | 268 | * @param[in] unit The unit to add |
jburhenn | 0:09ef59d2d0f7 | 269 | * @param[in] value The value to add |
jburhenn | 0:09ef59d2d0f7 | 270 | * @return CAYENNE_SUCCESS if unit/value pair was add, CAYENNE_FAILURE otherwise |
jburhenn | 0:09ef59d2d0f7 | 271 | */ |
jburhenn | 0:09ef59d2d0f7 | 272 | DLLExport int CayenneDataArrayAddUInt(CayenneDataArray* dataArray, const char* unit, unsigned int value); |
jburhenn | 0:09ef59d2d0f7 | 273 | |
jburhenn | 0:09ef59d2d0f7 | 274 | /** |
jburhenn | 0:09ef59d2d0f7 | 275 | * Add the specified unit/value pair to the array. |
jburhenn | 0:09ef59d2d0f7 | 276 | * @param[in] dataArray The data array to add values to |
jburhenn | 0:09ef59d2d0f7 | 277 | * @param[in] unit The unit to add |
jburhenn | 0:09ef59d2d0f7 | 278 | * @param[in] value The value to add |
jburhenn | 0:09ef59d2d0f7 | 279 | * @return CAYENNE_SUCCESS if unit/value pair was add, CAYENNE_FAILURE otherwise |
jburhenn | 0:09ef59d2d0f7 | 280 | */ |
jburhenn | 0:09ef59d2d0f7 | 281 | DLLExport int CayenneDataArrayAddLong(CayenneDataArray* dataArray, const char* unit, long value); |
jburhenn | 0:09ef59d2d0f7 | 282 | |
jburhenn | 0:09ef59d2d0f7 | 283 | /** |
jburhenn | 0:09ef59d2d0f7 | 284 | * Add the specified unit/value pair to the array. |
jburhenn | 0:09ef59d2d0f7 | 285 | * @param[in] dataArray The data array to add values to |
jburhenn | 0:09ef59d2d0f7 | 286 | * @param[in] unit The unit to add |
jburhenn | 0:09ef59d2d0f7 | 287 | * @param[in] value The value to add |
jburhenn | 0:09ef59d2d0f7 | 288 | * @return CAYENNE_SUCCESS if unit/value pair was add, CAYENNE_FAILURE otherwise |
jburhenn | 0:09ef59d2d0f7 | 289 | */ |
jburhenn | 0:09ef59d2d0f7 | 290 | DLLExport int CayenneDataArrayAddULong(CayenneDataArray* dataArray, const char* unit, unsigned long value); |
jburhenn | 0:09ef59d2d0f7 | 291 | |
jburhenn | 0:09ef59d2d0f7 | 292 | /** |
jburhenn | 0:09ef59d2d0f7 | 293 | * Add the specified unit/value pair to the array. |
jburhenn | 0:09ef59d2d0f7 | 294 | * @param[in] dataArray The data array to add values to |
jburhenn | 0:09ef59d2d0f7 | 295 | * @param[in] unit The unit to add |
jburhenn | 0:09ef59d2d0f7 | 296 | * @param[in] value The value to add |
jburhenn | 0:09ef59d2d0f7 | 297 | * @return CAYENNE_SUCCESS if unit/value pair was add, CAYENNE_FAILURE otherwise |
jburhenn | 0:09ef59d2d0f7 | 298 | */ |
jburhenn | 0:09ef59d2d0f7 | 299 | DLLExport int CayenneDataArrayAddDouble(CayenneDataArray* dataArray, const char* unit, double value); |
jburhenn | 0:09ef59d2d0f7 | 300 | |
jburhenn | 0:09ef59d2d0f7 | 301 | /** |
jburhenn | 0:09ef59d2d0f7 | 302 | * Add the specified unit/value pair to the array. |
jburhenn | 0:09ef59d2d0f7 | 303 | * @param[in] dataArray The data array to add values to |
jburhenn | 0:09ef59d2d0f7 | 304 | * @param[in] unit The unit to add |
jburhenn | 0:09ef59d2d0f7 | 305 | * @param[in] value The value to add |
jburhenn | 0:09ef59d2d0f7 | 306 | * @return CAYENNE_SUCCESS if unit/value pair was add, CAYENNE_FAILURE otherwise |
jburhenn | 0:09ef59d2d0f7 | 307 | */ |
jburhenn | 0:09ef59d2d0f7 | 308 | DLLExport int CayenneDataArrayAddFloat(CayenneDataArray* dataArray, const char* unit, float value); |
jburhenn | 0:09ef59d2d0f7 | 309 | |
jburhenn | 0:09ef59d2d0f7 | 310 | /** |
jburhenn | 0:09ef59d2d0f7 | 311 | * Clear the data array. |
jburhenn | 0:09ef59d2d0f7 | 312 | * @param[in] dataArray The data array to clear |
jburhenn | 0:09ef59d2d0f7 | 313 | */ |
jburhenn | 0:09ef59d2d0f7 | 314 | DLLExport void CayenneDataArrayClear(CayenneDataArray* dataArray); |
jburhenn | 0:09ef59d2d0f7 | 315 | |
jburhenn | 0:09ef59d2d0f7 | 316 | #endif |
jburhenn | 0:09ef59d2d0f7 | 317 | |
jburhenn | 0:09ef59d2d0f7 | 318 | #endif |