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_bool_record.cpp
00001 /* _ __ ____ _ _ 00002 * | |/ / | _ \ | \ | | 00003 * | ' / | |_) | | \| | 00004 * | . \ | __/ | |\ | 00005 * |_|\_\ |_| |_| \_| 00006 * 00007 * (c) 2018 KPN 00008 * License: MIT License. 00009 * Author: Jan Bogaerts 00010 * 00011 * support for bool sensor 00012 */ 00013 00014 00015 #include <senml_bool_record.h> 00016 #include <cbor.h> 00017 #include <senml_helpers.h> 00018 00019 SenMLBoolRecord::SenMLBoolRecord(const char* name): SenMLRecordTemplate(name) 00020 { 00021 } 00022 00023 SenMLBoolRecord::SenMLBoolRecord(const char* name, SenMLUnit unit): SenMLRecordTemplate(name, unit) 00024 { 00025 } 00026 00027 void SenMLBoolRecord::fieldsToJson() 00028 { 00029 SenMLRecord::fieldsToJson(); 00030 printText(",\"vb\":", 6); 00031 if(this->get()) 00032 printText("true", 4); 00033 else 00034 printText("false", 5); 00035 } 00036 00037 int SenMLBoolRecord::fieldsToCbor() 00038 { 00039 int res = SenMLRecord::fieldsToCbor(); 00040 res += cbor_serialize_int(SENML_CBOR_VB_LABEL); 00041 res += cbor_serialize_bool(this->get()); 00042 return res; 00043 } 00044 00045 00046 00047 00048 00049 00050
Generated on Tue Jul 12 2022 23:07:21 by
