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

senml_bool_actuator.cpp

Committer:
kpniot
Date:
2018-05-19
Revision:
0:a9259748d982

File content as of revision 0:a9259748d982:

/*  _  __  ____    _   _ 
 * | |/ / |  _ \  | \ | |
 * | ' /  | |_) | |  \| |
 * | . \  |  __/  | |\  |
 * |_|\_\ |_|     |_| \_|
 * 
 * (c) 2018 KPN
 * License: MIT License.
 * Author: Jan Bogaerts
 * 
 * support for bool actuators
 */

#include <senml_bool_actuator.h>
#include <senml_logging.h>

void SenMLBoolActuator::actuate(const void* value, int dataLength, SenMLDataType dataType)
{
    if(dataType == SENML_TYPE_BOOL || dataType == CBOR_TYPE_BOOL){
        this->set(*((bool*)value));
        if(this->callback){
            this->callback(*((bool*)value));
        }
    }
    else{
        log_debug("invalid type");
    }
}