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

Revision:
0:a9259748d982
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/senml_bool_record.cpp	Sat May 19 17:35:20 2018 +0000
@@ -0,0 +1,50 @@
+/*  _  __  ____    _   _ 
+ * | |/ / |  _ \  | \ | |
+ * | ' /  | |_) | |  \| |
+ * | . \  |  __/  | |\  |
+ * |_|\_\ |_|     |_| \_|
+ * 
+ * (c) 2018 KPN
+ * License: MIT License.
+ * Author: Jan Bogaerts
+ * 
+ * support for bool sensor 
+ */
+
+
+#include <senml_bool_record.h>
+#include <cbor.h>
+#include <senml_helpers.h>
+
+SenMLBoolRecord::SenMLBoolRecord(const char* name): SenMLRecordTemplate(name)
+{
+}
+
+SenMLBoolRecord::SenMLBoolRecord(const char* name, SenMLUnit unit): SenMLRecordTemplate(name, unit)
+{
+}
+
+void SenMLBoolRecord::fieldsToJson()
+{
+    SenMLRecord::fieldsToJson();
+    printText(",\"vb\":", 6);
+    if(this->get())
+        printText("true", 4);
+    else
+        printText("false", 5);
+}
+
+int SenMLBoolRecord::fieldsToCbor()
+{
+    int res = SenMLRecord::fieldsToCbor();
+    res += cbor_serialize_int(SENML_CBOR_VB_LABEL);
+    res += cbor_serialize_bool(this->get());
+    return res;
+}
+
+
+
+
+
+
+