OpenDevice
Open IoT (Internet Of Things) Platform and Framework http://opendevice.io
Device Class Reference

Public Types

enum  DeviceType {
  DIGITAL = 1, ANALOG = 2, ANALOG_SIGNED = 3, NUMERIC = 4,
  FLOAT2 = 5, FLOAT2_SIGNED = 6, FLOAT4 = 7, CHARACTER = 8,
  BOARD = 10, MANAGER = 11
}
 

Public Member Functions

 Device (uint8_t ipin)
 
 Device (uint8_t ipin, DeviceType type)
 
 Device (uint8_t ipin, DeviceType type, bool sensor)
 
 Device (uint8_t iid, uint8_t ipin, DeviceType type)
 
 Device (uint8_t iid, uint8_t ipin, DeviceType type, bool sensor)
 
bool setValue (value_t value, bool sync=true)
 
void on ()
 
void off ()
 
bool isON ()
 
bool isOFF ()
 
value_t getValue ()
 
virtual size_t serializeExtraData (DeviceConnection *conn)
 
virtual void deserializeExtraData (Command *cmd, DeviceConnection *conn)
 
virtual bool hasChanged ()
 
bool canReadSensor ()
 
void name (const char *name)
 
const char * name ()
 
DeviceenableInterrupt (uint8_t mode=CHANGE)
 
DeviceinvertedState ()
 
DeviceactiveLow ()
 
virtual void init ()
 
DevicesetInterval (int32_t _interval)
 
void onChange (DeviceListener)
 
void setSyncListener (DeviceListener listener)
 
bool notifyListeners ()
 
int toString (char buffer[])
 

Public Attributes

uint8_t id
 
uint8_t pin
 
value_t currentValue
 
DeviceType type
 
const char * deviceName
 
bool sensor
 
int32_t readLastTime
 
int32_t readInterval
 
uint8_t targetID
 
bool inverted
 
volatile bool needSync
 
bool interruptEnabled
 
uint8_t interruptMode
 

Static Public Attributes

static const uint8_t MAX_ANALOG_VALUE = 255
 

Detailed Description

Base class of Devices

Date
05/02/2013
Author
: Ricardo JL Rufino

Member Function Documentation

◆ canReadSensor()

bool Device::canReadSensor ( )

For Sensors :: If set readInterval has set, check if time as elapsed

◆ enableInterrupt()

Device * Device::enableInterrupt ( uint8_t  mode = CHANGE)

Enable to read value using interruptions.
NOTE: It is necessary to enable support in the general settings.

◆ getValue()

value_t Device::getValue ( )

Get current value.

◆ hasChanged()

bool Device::hasChanged ( )
virtual

For Sensors :: read sensor ans check if value has changed

Reimplemented in IRSensor, AdafruitSensor, CustomSensor, RFIDSensor, and RFSensor.

◆ init()

void Device::init ( )
virtual

This will be called on ODev.begin() to do extra initialization

Reimplemented in IRSensor, AdafruitSensor, and RFIDSensor.

◆ invertedState()

Device * Device::invertedState ( )

It allows device operate in an inverted logic (the 'ON' command will generate a LOW LEVEL)

◆ notifyListeners()

bool Device::notifyListeners ( )

fire 'onChange' listener

◆ setInterval()

Device * Device::setInterval ( int32_t  _interval)

Set reading interval for sensor's

◆ setValue()

bool Device::setValue ( value_t  value,
bool  sync = true 
)

Change value / state of Device

Parameters
sync- sync with server

The documentation for this class was generated from the following files: