KPN Things Device SDK
senml_binary_record.h
Go to the documentation of this file.
1/* _ __ ____ _ _
2 * | |/ / | _ \ | \ | |
3 * | ' / | |_) | | \| |
4 * | . \ | __/ | |\ |
5 * |_|\_\ |_| |_| \_|
6 *
7 * (c) 2020 KPN
8 * License: MIT License.
9 * Author: Joseph Verburg, Jan Bogaerts
10 *
11 * support for binary sensors header
12 */
13
14#ifndef SENMLBINARYRECORD
15#define SENMLBINARYRECORD
16
17#include "senml_record.h"
18
25 public:
26 SenMLBinaryRecord(const char *name) : SenMLRecord(name){};
27 SenMLBinaryRecord(const char *name, SenMLUnit unit) : SenMLRecord(name, unit){};
29
30#ifdef __MBED__
31
37 bool set(unsigned char *value, unsigned int length) {
38 return this->set(value, length, NAN);
39 }
40
46 bool set(unsigned char *value, unsigned int length, double time);
47
48#else
54 bool set(unsigned char *value, unsigned int length, double time = NAN);
55
56#endif
57
58 unsigned char * get();
59
67 virtual int fieldsToJson();
68
77 virtual int fieldsToCbor();
78
79 protected:
80 private:
81 unsigned char *_value; // raw data buffer (not null terminated)
82 unsigned int _length; // size of the _data packet
83};
84
85#endif // SENMLBINARYRECORD
Definition: senml_binary_record.h:24
unsigned char * get()
Definition: senml_binary_record.cpp:43
SenMLBinaryRecord(const char *name, SenMLUnit unit)
Definition: senml_binary_record.h:27
virtual int fieldsToJson()
Definition: senml_binary_record.cpp:26
SenMLBinaryRecord(ThingsMLMeasurementIndex idx)
Definition: senml_binary_record.h:28
bool set(unsigned char *value, unsigned int length, double time=NAN)
Definition: senml_binary_record.cpp:18
virtual int fieldsToCbor()
Definition: senml_binary_record.cpp:35
SenMLBinaryRecord(const char *name)
Definition: senml_binary_record.h:26
Definition: senml_record.h:33
SenMLUnit
Definition: senml_enums.h:97
ThingsMLMeasurementIndex
Definition: senml_enums.h:51