KPN IoT / senml

Fork of kpn_senml by KPN IoT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers senml_int_actuator.cpp Source File

senml_int_actuator.cpp

00001 /*  _  __  ____    _   _ 
00002  * | |/ / |  _ \  | \ | |
00003  * | ' /  | |_) | |  \| |
00004  * | . \  |  __/  | |\  |
00005  * |_|\_\ |_|     |_| \_|
00006  * 
00007  * (c) 2018 KPN
00008  * License: MIT License.
00009  * Author: Jan Bogaerts
00010  * 
00011  * support for int actuators
00012  */
00013 
00014 #include <senml_int_actuator.h>
00015 #include <senml_logging.h>
00016 
00017 void SenMLIntActuator::actuate(const void* value, int dataLength, SenMLDataType dataType)
00018 {
00019     if(dataType == SENML_TYPE_NR){
00020         this->set((int)*((double*)value));
00021         if(this->callback)
00022             this->callback((int)*((double*)value));
00023     }
00024     else if(dataType == CBOR_TYPE_INT){
00025         int64_t val = *((int64_t*)value);
00026         this->set((int)val);
00027         if(this->callback)
00028             this->callback((int)val);
00029     }
00030     else if(dataType == CBOR_TYPE_UINT){
00031         uint64_t val = *((uint64_t*)value);
00032         this->set((int)val);
00033         if(this->callback)
00034             this->callback((int)val);
00035     }
00036     else
00037         log_debug("invalid type");
00038 }
00039 
00040 
00041 
00042 
00043 
00044 
00045