The KPN SenML library helps you create and parse senml documents in both json and cbor format. The library can be used for sending sensor data and receiving actuator commands.

Fork of kpn_senml by KPN IoT

Committer:
kpniot
Date:
Sun May 27 14:31:44 2018 +0000
Revision:
2:9b44be6e79ac
Parent:
0:a9259748d982
try to fix repo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kpniot 0:a9259748d982 1 /* _ __ ____ _ _
kpniot 0:a9259748d982 2 * | |/ / | _ \ | \ | |
kpniot 0:a9259748d982 3 * | ' / | |_) | | \| |
kpniot 0:a9259748d982 4 * | . \ | __/ | |\ |
kpniot 0:a9259748d982 5 * |_|\_\ |_| |_| \_|
kpniot 0:a9259748d982 6 *
kpniot 0:a9259748d982 7 * (c) 2018 KPN
kpniot 0:a9259748d982 8 * License: MIT License.
kpniot 0:a9259748d982 9 * Author: Jan Bogaerts
kpniot 0:a9259748d982 10 *
kpniot 0:a9259748d982 11 * support for bool sensor header
kpniot 0:a9259748d982 12 */
kpniot 0:a9259748d982 13
kpniot 0:a9259748d982 14 #ifndef SENMLBOOLRECORD
kpniot 0:a9259748d982 15 #define SENMLBOOLRECORD
kpniot 0:a9259748d982 16
kpniot 0:a9259748d982 17 #include <senml_record_t.h>
kpniot 0:a9259748d982 18
kpniot 0:a9259748d982 19 /**
kpniot 0:a9259748d982 20 * A SenMLRecord that stores boolean data.
kpniot 0:a9259748d982 21 * This type of object can only be used for sensor data. If actuation is needed, use SenMLBoolActuator
kpniot 0:a9259748d982 22 * instead.
kpniot 0:a9259748d982 23 */
kpniot 0:a9259748d982 24 class SenMLBoolRecord: public SenMLRecordTemplate<bool>
kpniot 0:a9259748d982 25 {
kpniot 0:a9259748d982 26 public:
kpniot 0:a9259748d982 27 SenMLBoolRecord(const char* name);
kpniot 0:a9259748d982 28 SenMLBoolRecord(const char* name, SenMLUnit unit);
kpniot 0:a9259748d982 29 SenMLBoolRecord(const char* name, SenMLUnit unit, bool value): SenMLRecordTemplate(name, unit, value){};
kpniot 0:a9259748d982 30 ~SenMLBoolRecord(){};
kpniot 0:a9259748d982 31
kpniot 0:a9259748d982 32 /**
kpniot 0:a9259748d982 33 * renders all the fields to json, without the starting and ending brackets.
kpniot 0:a9259748d982 34 * Inheriters can extend this function if they want to add extra fields to the json output
kpniot 0:a9259748d982 35 * note: this is public so that custom implementations for the record object can use other objects
kpniot 0:a9259748d982 36 * internally and render to json using this function (ex: coordinatesRecord using 3 floatRecrods for lat, lon & alt.
kpniot 0:a9259748d982 37 * @returns: None
kpniot 0:a9259748d982 38 */
kpniot 0:a9259748d982 39 virtual void fieldsToJson();
kpniot 0:a9259748d982 40
kpniot 0:a9259748d982 41 /**
kpniot 0:a9259748d982 42 * renders all the fields to cbor format. renders all the fields of the object without the length info
kpniot 0:a9259748d982 43 * at the beginning
kpniot 0:a9259748d982 44 * note: this is public so that custom implementations for the record object can use other objects
kpniot 0:a9259748d982 45 * internally and render to json using this function (ex: coordinatesRecord using 3 floatRecrods for
kpniot 0:a9259748d982 46 * lat, lon & alt.
kpniot 0:a9259748d982 47 * @returns: The number of bytes that were written.
kpniot 0:a9259748d982 48 */
kpniot 0:a9259748d982 49 virtual int fieldsToCbor();
kpniot 0:a9259748d982 50
kpniot 0:a9259748d982 51 protected:
kpniot 0:a9259748d982 52
kpniot 0:a9259748d982 53 private:
kpniot 0:a9259748d982 54 };
kpniot 0:a9259748d982 55
kpniot 0:a9259748d982 56 #endif // SENMLBOOLRECORD
kpniot 0:a9259748d982 57
kpniot 0:a9259748d982 58
kpniot 0:a9259748d982 59
kpniot 0:a9259748d982 60
kpniot 0:a9259748d982 61
kpniot 0:a9259748d982 62
kpniot 0:a9259748d982 63