KPN IoT / senml

Fork of kpn_senml by KPN IoT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers senml_string_record.cpp Source File

senml_string_record.cpp

00001 /*  _  __  ____    _   _ 
00002  * | |/ / |  _ \  | \ | |
00003  * | ' /  | |_) | |  \| |
00004  * | . \  |  __/  | |\  |
00005  * |_|\_\ |_|     |_| \_|
00006  * 
00007  * (c) 2018 KPN
00008  * License: MIT License.
00009  * Author: Jan Bogaerts
00010  * 
00011  * support for string sensors
00012  */
00013 
00014 
00015 #include <senml_string_record.h>
00016 #include <cbor.h>
00017 #include <senml_helpers.h>
00018 
00019 void SenMLStringRecord::fieldsToJson()
00020 {
00021     SenMLRecord::fieldsToJson();
00022     printText(",\"vs\":\"", 7);
00023     String val = this->get();
00024     printText(val.c_str(), val.length());
00025     printText("\"", 1);
00026 }
00027 int SenMLStringRecord::fieldsToCbor()
00028 {
00029     int res = SenMLRecord::fieldsToCbor();
00030     res += cbor_serialize_int(SENML_CBOR_VS_LABEL);
00031     res += cbor_serialize_unicode_string(this->get().c_str());
00032     return res;
00033 }
00034 
00035 
00036 
00037 
00038 
00039 
00040