Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of kpn_senml by
senml_int_pack.h
00001 /* _ __ ____ _ _ 00002 * | |/ / | _ \ | \ | | 00003 * | ' / | |_) | | \| | 00004 * | . \ | __/ | |\ | 00005 * |_|\_\ |_| |_| \_| 00006 * 00007 * (c) 2018 KPN 00008 * License: MIT License. 00009 * Author: Jan Bogaerts 00010 * 00011 * pack (document) with int base values header 00012 */ 00013 00014 #ifndef SENMLINTPACK 00015 #define SENMLINTPACK 00016 00017 #include <senml_pack_t.h> 00018 00019 /** 00020 * An implimentation of the SenMLPack template that stores integer base value and base-sum. 00021 */ 00022 class SenMLIntPack: public SenMLPackTemplate<int> 00023 { 00024 public: 00025 00026 SenMLIntPack(const char* baseName): SenMLPackTemplate(baseName, SENML_UNIT_NONE, NAN) {}; 00027 SenMLIntPack(const char* baseName, SenMLUnit baseUnit): SenMLPackTemplate(baseName, baseUnit, NAN) {}; 00028 SenMLIntPack(const char* baseName, SenMLUnit baseUnit, double baseTime): SenMLPackTemplate(baseName, baseUnit, baseTime) {}; 00029 00030 SenMLIntPack(PACK_ACTUATOR_SIGNATURE): SenMLPackTemplate("", SENML_UNIT_NONE, NAN, callback) {}; 00031 SenMLIntPack(const char* baseName, PACK_ACTUATOR_SIGNATURE): SenMLPackTemplate(baseName, SENML_UNIT_NONE, NAN, callback) {}; 00032 SenMLIntPack(const char* baseName, SenMLUnit baseUnit, PACK_ACTUATOR_SIGNATURE): SenMLPackTemplate(baseName, baseUnit, NAN, callback) {}; 00033 SenMLIntPack(const char* baseName, SenMLUnit baseUnit, double baseTime, PACK_ACTUATOR_SIGNATURE): SenMLPackTemplate(baseName, baseUnit, baseTime, callback){}; 00034 00035 00036 00037 ~SenMLIntPack(){}; 00038 00039 /** 00040 * renders all the fields to json, without the starting and ending brackets. 00041 * Inheriters can extend this function if they want to add extra fields to the json output 00042 * note: this is public so that custom implementations for the record object can use other objects 00043 * internally and render to json using this function (ex: coordinatesRecord using 3 floatRecrods for lat, lon & alt. 00044 * @returns: None 00045 */ 00046 virtual void fieldsToJson(); 00047 00048 /** 00049 * renders all the fields to cbor format. renders all the fields of the object without the length info 00050 * at the beginning 00051 * note: this is public so that custom implementations for the record object can use other objects 00052 * internally and render to json using this function (ex: coordinatesRecord using 3 floatRecrods for 00053 * lat, lon & alt. 00054 * @returns: The number of bytes that were written. 00055 */ 00056 virtual int fieldsToCbor(); 00057 00058 protected: 00059 00060 virtual void setupStreamCtx(Stream *dest, SenMLStreamMethod format); 00061 virtual void setupStreamCtx(char *dest, int length, SenMLStreamMethod format); 00062 00063 00064 00065 private: 00066 int getAdjustedValue(); 00067 }; 00068 00069 #endif // SENMLINTPACK 00070 00071 00072 00073 00074 00075 00076
Generated on Tue Jul 12 2022 23:07:22 by
