KPN IoT / senml

Fork of kpn_senml by KPN IoT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers senml_int_record.h Source File

senml_int_record.h

00001 /*  _  __  ____    _   _ 
00002  * | |/ / |  _ \  | \ | |
00003  * | ' /  | |_) | |  \| |
00004  * | . \  |  __/  | |\  |
00005  * |_|\_\ |_|     |_| \_|
00006  * 
00007  * (c) 2018 KPN
00008  * License: MIT License.
00009  * Author: Jan Bogaerts
00010  * 
00011  * support for int sensors header
00012  */
00013 
00014 #ifndef SENMLINTRECORD
00015 #define SENMLINTRECORD
00016 
00017 #include <senml_record_t.h>
00018 
00019 /**
00020  * A SenMLRecord that stores integer data.
00021  * This type of object can only be used for sensor data. If actuation is needed, use SenMLIntActuator
00022  * instead.
00023  */ 
00024 class SenMLIntRecord: public SenMLRecordTemplate<int>
00025 {
00026 public:
00027     SenMLIntRecord(const char* name);
00028     SenMLIntRecord(const char* name, SenMLUnit unit);
00029     SenMLIntRecord(const char* name, SenMLUnit unit, int value):  SenMLRecordTemplate(name, unit, value){};
00030     ~SenMLIntRecord(){};
00031 
00032     /**
00033      * renders all the fields to json, without the starting and ending brackets.
00034      * Inheriters can extend this function if they want to add extra fields to the json output
00035      * note: this is public so that custom implementations for the record object can use other objects 
00036      * internally and render to json using this function (ex: coordinatesRecord using 3 floatRecrods for lat, lon & alt.
00037      * @returns: None
00038     */
00039     virtual void fieldsToJson();
00040 
00041     /**
00042      * renders all the fields to cbor format. renders all the fields of the object without the length info 
00043      * at the beginning
00044      * note: this is public so that custom implementations for the record object can use other objects 
00045      * internally and render to json using this function (ex: coordinatesRecord using 3 floatRecrods for 
00046      * lat, lon & alt.
00047      * @returns: The number of bytes that were written.
00048     */
00049     virtual int fieldsToCbor();
00050 
00051 protected:
00052 
00053     
00054 
00055 private:
00056     int getAdjustedValue();
00057     double getAdjustedValueD();
00058 };
00059 
00060 #endif // SENMLINTRECORD
00061 
00062 
00063 
00064 
00065 
00066 
00067