KPN IoT / senml

Fork of kpn_senml by KPN IoT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers senml_string_actuator.h Source File

senml_string_actuator.h

00001 /*  _  __  ____    _   _ 
00002  * | |/ / |  _ \  | \ | |
00003  * | ' /  | |_) | |  \| |
00004  * | . \  |  __/  | |\  |
00005  * |_|\_\ |_|     |_| \_|
00006  * 
00007  * (c) 2018 KPN
00008  * License: MIT License.
00009  * Author: Jan Bogaerts
00010  * 
00011  * support for string actuators
00012  */
00013 
00014 #ifndef SENMLSTRINGACTUATOR
00015 #define SENMLSTRINGACTUATOR
00016 
00017 #include <senml_string_record.h>
00018 
00019 #define STRING_ACTUATOR_SIGNATURE void (*callback)(const char*)
00020 
00021 /**
00022  * A SenMLRecord that stores text data and supports actuation.
00023  */ 
00024 class SenMLStringActuator: public SenMLStringRecord
00025 {
00026 public:
00027     SenMLStringActuator(const char* name, STRING_ACTUATOR_SIGNATURE): SenMLStringRecord(name, SENML_UNIT_NONE, NULL), callback(callback) {};
00028     SenMLStringActuator(const char* name, SenMLUnit unit, STRING_ACTUATOR_SIGNATURE): SenMLStringRecord(name, unit, NULL), callback(callback) {};
00029     SenMLStringActuator(const char* name, SenMLUnit unit, const char* value, STRING_ACTUATOR_SIGNATURE):  SenMLStringRecord(name, unit, value), callback(callback) {};
00030     ~SenMLStringActuator(){};
00031 
00032 protected:
00033 
00034     /**
00035      * called while parsing a senml message, when the parser found the value for an SenMLJsonListener
00036      */
00037     virtual void actuate(const void* value, int dataLength, SenMLDataType dataType);
00038 
00039 private:
00040     STRING_ACTUATOR_SIGNATURE;
00041 };
00042 
00043 #endif // SENMLSTRINGACTUATOR
00044 
00045 
00046 
00047 
00048 
00049 
00050