Vertical M2M, mDot / Conduit sensors managment

Dependencies:   libmDot-mbed5

/media/uploads/vm2m/protocol_lora.docx /media/uploads/vm2m/lora.fzz

Sensors.h

Committer:
vm2m
Date:
2015-09-13
Revision:
0:f60fa86d08fd
Child:
1:12bd28e154ca

File content as of revision 0:f60fa86d08fd:

/* Copyright (c) 2015 Vertical M2M, MIT License
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
 * and associated documentation files (the "Software"), to deal in the Software without restriction, 
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or 
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef __SENSORS__
#define __SENSORS__

#include "mbed.h"
#include "rtos.h"
#include "DHT.h"

#include <string>

struct SensorsConfig_t
{
    PinName dht;
    PinName motion;
    PinName power;
    PinName light;
    PinName switch1;
    PinName switch2;
};

class Sensors {
public:
    Sensors(SensorsConfig_t p_config);
    ~Sensors();
    
    void updateValues();
    
    float getTemp();
    float getHumidity();
    bool getMotion();
    float getLight();
    float getPower();
    bool getSwitch1();
    bool getSwitch2();
    void setSwitch1(bool value);
    void setSwitch2(bool value);
    
private:
    /**
     * Sensors
     */
    DHT m_sDht;
    DigitalIn m_sMotion;
    AnalogIn m_sLight;
    AnalogIn m_sPower;
    DigitalOut m_sSwitch1;
    DigitalOut m_sSwitch2;
    
    /**
     * Values
     */
    float m_temp;
    float m_humidity; 
    bool m_motion;
    float m_light;
    float m_power;
    bool m_switch1;
    bool m_switch2;
    
    /**
     * Getting data thread
     */
    RtosTimer m_timer;
};

#endif