KPN Things Device SDK
senml_binary_actuator.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 actuators header
12 */
13
14#ifndef SENMLBINARYACTUATOR
15#define SENMLBINARYACTUATOR
16
17#include "../record/senml_binary_record.h"
18
19#define BINARY_ACTUATOR_SIGNATURE void (*callback)(const unsigned char *, int)
20
25 friend class SenMLCborParser;
26
27 public:
29 : SenMLBinaryRecord(name, SENML_UNIT_NONE), callback(callback){};
31 : SenMLBinaryRecord(name, unit), callback(callback){};
33 : SenMLBinaryRecord(index), callback(callback){};
34
35 SenMLBinaryActuator(const char *name) : SenMLBinaryRecord(name){};
36 SenMLBinaryActuator(const char *name, SenMLUnit unit) : SenMLBinaryRecord(name, unit){};
38
40
41 virtual bool set(unsigned char *value, unsigned int length, double time = NAN);
42
43 protected:
44 // called while parsing a senml message, when the parser found the value for an SenMLJsonListener
45 virtual void actuate(const void *value, int dataLength, SenMLDataType dataType);
46
47 private:
49 unsigned char * lastAllocated = nullptr;
50};
51
52#endif // SENMLBINARYACTUATOR
Definition: senml_binary_actuator.h:24
SenMLBinaryActuator(ThingsMLMeasurementIndex index, BINARY_ACTUATOR_SIGNATURE)
Definition: senml_binary_actuator.h:32
~SenMLBinaryActuator()
Definition: senml_binary_actuator.h:39
virtual void actuate(const void *value, int dataLength, SenMLDataType dataType)
Definition: senml_binary_actuator.cpp:19
SenMLBinaryActuator(const char *name, BINARY_ACTUATOR_SIGNATURE)
Definition: senml_binary_actuator.h:28
SenMLBinaryActuator(const char *name, SenMLUnit unit)
Definition: senml_binary_actuator.h:36
SenMLBinaryActuator(ThingsMLMeasurementIndex index)
Definition: senml_binary_actuator.h:37
SenMLBinaryActuator(const char *name)
Definition: senml_binary_actuator.h:35
SenMLBinaryActuator(const char *name, SenMLUnit unit, BINARY_ACTUATOR_SIGNATURE)
Definition: senml_binary_actuator.h:30
virtual bool set(unsigned char *value, unsigned int length, double time=NAN)
Definition: senml_binary_actuator.cpp:44
Definition: senml_binary_record.h:24
Definition: senml_cbor_parser.h:31
#define BINARY_ACTUATOR_SIGNATURE
Definition: senml_binary_actuator.h:19
SenMLUnit
Definition: senml_enums.h:97
@ SENML_UNIT_NONE
Definition: senml_enums.h:98
ThingsMLMeasurementIndex
Definition: senml_enums.h:51
SenMLDataType
Definition: senml_enums.h:25