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
senml_float_actuator.cpp
- Committer:
- kpniot
- Date:
- 2018-05-27
- Revision:
- 2:9b44be6e79ac
- Parent:
- 0:a9259748d982
File content as of revision 2:9b44be6e79ac:
/* _ __ ____ _ _ * | |/ / | _ \ | \ | | * | ' / | |_) | | \| | * | . \ | __/ | |\ | * |_|\_\ |_| |_| \_| * * (c) 2018 KPN * License: MIT License. * Author: Jan Bogaerts * * support for float actuators */ #include <senml_float_actuator.h> #include <senml_logging.h> void SenMLFloatActuator::actuate(const void* value, int dataLength, SenMLDataType dataType) { if(dataType == SENML_TYPE_NR || dataType == CBOR_TYPE_DOUBLE){ this->set((float)*((double*)value)); if(this->callback) this->callback((float)*((double*)value)); } else if(dataType == CBOR_TYPE_FLOAT){ this->set(*((float*)value)); if(this->callback) this->callback(*((float*)value)); } else log_debug("invalid type"); }