Changes in oregon protocol. issue 18
This commit is contained in:
parent
c9a030774b
commit
bfc7308cce
5 changed files with 192 additions and 186 deletions
|
|
@ -6,19 +6,20 @@
|
||||||
|
|
||||||
// POWER CONSUMPTION SENSOR
|
// POWER CONSUMPTION SENSOR
|
||||||
#define POWERCON_ENABLED // comment out to disable sensor
|
#define POWERCON_ENABLED // comment out to disable sensor
|
||||||
#define POWERCON_HARDWARE HW_BH1750
|
#define POWERCON_HARDWARE HardwareDH1750()
|
||||||
#define POWERCON_PROTOCOL PROT_OREGON
|
#define POWERCON_PROTOCOL ProtocolOregon(118)
|
||||||
|
#define POWER_TIMER_MULTIPLIER 1 // poling in minutes
|
||||||
|
|
||||||
// TEMPERATURE SENSOR
|
// TEMPERATURE SENSOR
|
||||||
#define TEMPERATURE_ENABLED // comment out to disable sensor
|
#define TEMPERATURE_ENABLED // comment out to disable sensor
|
||||||
#define TEMPERATURE_HARDWARE HW_DHT11
|
#define TEMPERATURE_HARDWARE HW_DHT11
|
||||||
#define TEMPERATURE_PROTOCOL PROT_OREGON
|
#define TEMPERATURE_PROTOCOL ProtocolOregon(100)
|
||||||
#define TEMPERATURE_TIMER_MULTIPLIER 1 // poling in minutes
|
#define TEMPERATURE_TIMER_MULTIPLIER 1 // poling in minutes
|
||||||
|
|
||||||
// LIGHT SENSOR
|
// LIGHT SENSOR
|
||||||
#define LIGHT_ENABLED // comment out to disable sensor
|
//#define LIGHT_ENABLED // comment out to disable sensor
|
||||||
#define LIGHT_HARDWARE HW_BHI750
|
#define LIGHT_HARDWARE HardwareDH1750()
|
||||||
#define LIGHT_PROTOCOL PROT_OREGON
|
#define LIGHT_PROTOCOL ?
|
||||||
#define LIGHT_TIMER_MULTIPLIER 1 // poling in minutes
|
#define LIGHT_TIMER_MULTIPLIER 1 // poling in minutes
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
#ifndef HALDEFINITIONS_H
|
#ifndef HALDEFINITIONS_H
|
||||||
#define HALDEFINITIONS_H
|
#define HALDEFINITIONS_H
|
||||||
|
|
||||||
//////// PROTOCOLS
|
|
||||||
#define PROT_NEXA_SELFLEARNING
|
|
||||||
#define PROT_OREGON_SELFLEARNING
|
|
||||||
|
|
||||||
/////// HARDWARE
|
/////// HARDWARE
|
||||||
#define HW_BH1750
|
#include "HardwareBH1750.h"
|
||||||
#define HW_DHT11
|
#include "HardwareDHT11.h"
|
||||||
#define HW_PHOTOCELL
|
#include "HardwarePhotocell.h"
|
||||||
|
|
||||||
|
//////// PROTOCOLS
|
||||||
|
#include "ProtocolNexa.h"
|
||||||
|
#include "ProtocolOregon.h"
|
||||||
|
|
||||||
|
|
||||||
#endif // HALDEFINITIONS_H
|
#endif // HALDEFINITIONS_H
|
||||||
|
|
@ -10,16 +10,51 @@ unsigned int timerMultiplier = 0;
|
||||||
|
|
||||||
// Sensors
|
// Sensors
|
||||||
HardwarePowerConsumption powerSensor;
|
HardwarePowerConsumption powerSensor;
|
||||||
HardwareTemperature temperatureSensor;
|
HardwareTemperature tempSensor;
|
||||||
HardwareLight lightSensor;
|
HardwareLight lightSensor;
|
||||||
|
|
||||||
// Protocols
|
// Protocols
|
||||||
HardwarePowerConsumption powerProtocol;
|
HardwarePowerConsumption powerProtocol;
|
||||||
HardwareTemperature temperatureProtocol;
|
HardwareTemperature tempProtocol;
|
||||||
HardwareLight lightProtocol;
|
HardwareLight lightProtocol;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void timerInterrupt();
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
timerMultipleMAX = POWER_TIMER_MULTIPLIER * TEMPERATURE_TIMER_MULTIPLIER * LIGHT_TIMER_MULTIPLIER; // Find a lowest common denominator
|
||||||
|
pinInterrupt = InterruptUtil(timerInterrupt);
|
||||||
|
pinInterrupt.setupTimerInterrupt(60*1000); // one minute scheduled interrupt
|
||||||
|
|
||||||
|
// Setup Sensors and protocols
|
||||||
|
#ifdef POWERCON_ENABLED
|
||||||
|
powerSensor = POWERCON_HARDWARE;
|
||||||
|
powerSensor.setup();
|
||||||
|
powerProtocol = POWERCON_PROTOCOL;
|
||||||
|
powerProtocol.setup();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TEMPERATURE_ENABLED
|
||||||
|
tempSensor = TEMPERATURE_HARDWARE;
|
||||||
|
tempSensor.setup();
|
||||||
|
tempProtocol = TEMPERATURE_PROTOCOL;
|
||||||
|
tempProtocol.setup();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LIGHT_ENABLED
|
||||||
|
lightSensor = LIGHT_HARDWARE;
|
||||||
|
lightSensor.setup();
|
||||||
|
lightProtocol = LIGHT_PROTOCOL;
|
||||||
|
lightProtocol.setup();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void loop() {}
|
||||||
|
|
||||||
|
|
||||||
void timerInterrupt()
|
void timerInterrupt()
|
||||||
{
|
{
|
||||||
++timerMultiplier;
|
++timerMultiplier;
|
||||||
|
|
@ -27,27 +62,30 @@ void timerInterrupt()
|
||||||
timerMultiplier = 1;
|
timerMultiplier = 1;
|
||||||
|
|
||||||
// Send power consumption
|
// Send power consumption
|
||||||
#ifndef POWERCON_ENABLED
|
#ifdef POWERCON_ENABLED
|
||||||
unsigned int consumption = powerSensor.getConsumption();
|
if(timerMultiplier == POWER_TIMER_MULTIPLIER)
|
||||||
powerSensor.reset();
|
{
|
||||||
powerProtocol.setConsumption(consumption);
|
unsigned int consumption = powerSensor.getConsumption();
|
||||||
powerProtocol.send();
|
powerSensor.reset();
|
||||||
|
powerProtocol.setConsumption(consumption);
|
||||||
|
powerProtocol.send();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Handle temperature sensor
|
// Handle temperature sensor
|
||||||
#ifndef TEMPERATURE_ENABLED
|
#ifdef TEMPERATURE_ENABLED
|
||||||
if(timerMultiplier == TEMPERATURE_TIMER_MULTIPLIER)
|
if(timerMultiplier == TEMPERATURE_TIMER_MULTIPLIER)
|
||||||
{
|
{
|
||||||
unsigned int temperature = temperatureSensor.getTemperature();
|
unsigned int temperature = tempSensor.getTemperature();
|
||||||
unsigned int humidity = temperatureSensor.getHumidity();
|
unsigned int humidity = tempSensor.getHumidity();
|
||||||
temperatureProtocol.setTemperature(temperature);
|
tempProtocol.setTemperature(temperature);
|
||||||
temperatureProtocol.setHumidity(humidity);
|
tempProtocol.setHumidity(humidity);
|
||||||
temperatureProtocol.send();
|
tempProtocol.send();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Handle light sensor
|
// Handle light sensor
|
||||||
#ifndef TEMPERATURE_ENABLED
|
#ifdef TEMPERATURE_ENABLED
|
||||||
if(timerMultiplier == LIGHT_TIMER_MULTIPLIER)
|
if(timerMultiplier == LIGHT_TIMER_MULTIPLIER)
|
||||||
{
|
{
|
||||||
unsigned int lumen = lightSensor.getLuminosity();
|
unsigned int lumen = lightSensor.getLuminosity();
|
||||||
|
|
@ -58,13 +96,3 @@ void timerInterrupt()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
timerMultipleMAX = LIGHT_TIMER_MULTIPLIER * TEMPERATURE_TIMER_MULTIPLIER; // Find a lowest common denominator
|
|
||||||
pinInterrupt = InterruptUtil(timerInterrupt);
|
|
||||||
pinInterrupt.setupTimerInterrupt(60*1000); // one minute scheduled interrupt
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void loop() {}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,61 +1,90 @@
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
#define TX_PIN = 10;
|
#define RF_TX_PIN = 10;
|
||||||
const unsigned long TIME = 512;
|
#define RF_DELAY = 512;
|
||||||
#define TWOTIME TIME*2;
|
#define RF_DELAY_LONG RF_DELAY*2;
|
||||||
#define SEND_HIGH() digitalWrite(TX_PIN, HIGH)
|
#define RF_SEND_HIGH() digitalWrite(RF_TX_PIN, HIGH)
|
||||||
#define SEND_LOW() digitalWrite(TX_PIN, LOW)
|
#define RF_SEND_LOW() digitalWrite(RF_TX_PIN, LOW)
|
||||||
byte OregonMessageBuffer[9];
|
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void ProtocolOregon::setup()
|
||||||
{
|
{
|
||||||
pinMode(TX_PIN, OUTPUT);
|
pinMode(RF_TX_PIN, OUTPUT);
|
||||||
SEND_LOW();
|
RF_SEND_LOW();
|
||||||
byte ID[] = { 0x1A,0x2D }; //temperature/humidity sensor (THGR2228N)
|
}
|
||||||
setType(OregonMessageBuffer, ID);
|
|
||||||
setChannel(OregonMessageBuffer, 0x20);
|
virtual void ProtocolOregon::setTemperature(float temp)
|
||||||
|
{
|
||||||
|
this.temperature = temp;
|
||||||
|
}
|
||||||
|
virtual void ProtocolOregon::setHumidity(unsigned char humidity)
|
||||||
|
{
|
||||||
|
this.humidity = humidity;
|
||||||
|
}
|
||||||
|
virtual void ProtocolOregon::setConsumption(unsigned int cons)
|
||||||
|
{
|
||||||
|
this.temperature = cons;
|
||||||
|
this.humidity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProtocolOregon::send()
|
||||||
|
{
|
||||||
|
byte buffer[9];
|
||||||
|
setType(buffer, { 0x1A,0x2D }); //temperature/humidity sensor (THGR2228N)
|
||||||
|
setChannel(buffer, 0x20);
|
||||||
|
setId(buffer, address); //set id of the sensor, BB=187
|
||||||
|
setBatteryLevel(buffer, true); // false : low, true : high
|
||||||
|
setTemperature(buffer, temperature); //org setTemperature(OregonMessageBuffer, 55.5);
|
||||||
|
setHumidity(buffer, humidity);
|
||||||
|
calculateAndSetChecksum(buffer);
|
||||||
|
|
||||||
|
// Send the Message over RF
|
||||||
|
rfSend(buffer, sizeof(buffer));
|
||||||
|
// Send a "pause"
|
||||||
|
RF_SEND_LOW();
|
||||||
|
delayMicroseconds(RF_DELAY_LONG * 8);
|
||||||
|
// Send a copy of the first message. The v2.1 protocol send the message two RF_DELAYs
|
||||||
|
rfSend(buffer, sizeof(buffer));
|
||||||
|
RF_SEND_LOW();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the sensor type
|
||||||
|
* \param data Oregon message
|
||||||
|
* \param type Sensor type
|
||||||
|
*/
|
||||||
|
inline void setType(byte *data, byte* type)
|
||||||
|
{
|
||||||
|
data[0] = type[0];
|
||||||
|
data[1] = type[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the sensor channel
|
||||||
|
* \param data Oregon message
|
||||||
|
* \param channel Sensor channel (0x10, 0x20, 0x30)
|
||||||
|
*/
|
||||||
|
inline void setChannel(byte *data, byte channel)
|
||||||
|
{
|
||||||
|
data[2] = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void setId(byte *data, byte id)
|
||||||
void send433(float temperature, byte humidity, byte Identitet)
|
|
||||||
{
|
{
|
||||||
setId(OregonMessageBuffer, Identitet); //set id of the sensor, BB=187
|
data[3] = id;
|
||||||
setBatteryLevel(OregonMessageBuffer, 1); // 0 : low, 1 : high
|
|
||||||
setTemperature(OregonMessageBuffer, temperature); //org setTemperature(OregonMessageBuffer, 55.5);
|
|
||||||
setHumidity(OregonMessageBuffer, humidity);
|
|
||||||
calculateAndSetChecksum(OregonMessageBuffer);
|
|
||||||
|
|
||||||
// Show the Oregon Message
|
|
||||||
for (byte i = 0; i < sizeof(OregonMessageBuffer); ++i) {
|
|
||||||
Serial.print(OregonMessageBuffer[i] >> 4, HEX);
|
|
||||||
Serial.print(OregonMessageBuffer[i] & 0x0F, HEX);
|
|
||||||
}
|
|
||||||
Serial.println();
|
|
||||||
|
|
||||||
// Send the Message over RF
|
|
||||||
sendOregon(OregonMessageBuffer, sizeof(OregonMessageBuffer));
|
|
||||||
// Send a "pause"
|
|
||||||
SEND_LOW();
|
|
||||||
delayMicroseconds(TWOTIME*8);
|
|
||||||
// Send a copie of the first message. The v2.1 protocol send the message two time
|
|
||||||
sendOregon(OregonMessageBuffer, sizeof(OregonMessageBuffer));
|
|
||||||
SEND_LOW();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setId(byte *data, byte ID)
|
/**
|
||||||
{
|
* \param level false: low, true: high
|
||||||
data[3] = ID;
|
*/
|
||||||
}
|
inline void setBatteryLevel(byte *data, bool level)
|
||||||
|
|
||||||
void setBatteryLevel(byte *data, byte level)
|
|
||||||
{
|
{
|
||||||
if(!level) data[4] = 0x0C;
|
if(!level) data[4] = 0x0C;
|
||||||
else data[4] = 0x00;
|
else data[4] = 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTemperature(byte *data, float temp)
|
inline void setTemperature(byte *data, float temp)
|
||||||
{
|
{
|
||||||
// Set temperature sign
|
// Set temperature sign
|
||||||
if(temp < 0)
|
if(temp < 0)
|
||||||
|
|
@ -83,13 +112,13 @@ void setTemperature(byte *data, float temp)
|
||||||
data[4] |= (tempFloat << 4);
|
data[4] |= (tempFloat << 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setHumidity(byte* data, byte hum)
|
inline void setHumidity(byte* data, byte hum)
|
||||||
{
|
{
|
||||||
data[7] = (hum/10);
|
data[7] = (hum/10);
|
||||||
data[6] |= (hum - data[7]*10) << 4;
|
data[6] |= (hum - data[7]*10) << 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void calculateAndSetChecksum(byte* data)
|
inline void calculateAndSetChecksum(byte* data)
|
||||||
{
|
{
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for(byte i = 0; i<8;i++)
|
for(byte i = 0; i<8;i++)
|
||||||
|
|
@ -108,59 +137,36 @@ void calculateAndSetChecksum(byte* data)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Send logical "0" over RF
|
* \brief Send logical "0" over RF
|
||||||
* \details azero bit be represented by an off-to-on transition
|
* \details a zero bit be represented by an off-to-on transition
|
||||||
* \ of the RF signal at the middle of a clock period.
|
* \ of the RF signal at the middle of a clock period.
|
||||||
* \ Remenber, the Oregon v2.1 protocol add an inverted bit first
|
* \ Remember, the Oregon v2.1 protocol adds an inverted bit first
|
||||||
*/
|
*/
|
||||||
inline void sendZero(void)
|
inline void sendZero(void)
|
||||||
{
|
{
|
||||||
SEND_HIGH();
|
RF_SEND_HIGH();
|
||||||
delayMicroseconds(TIME);
|
delayMicroseconds(RF_DELAY);
|
||||||
SEND_LOW();
|
RF_SEND_LOW();
|
||||||
delayMicroseconds(TWOTIME);
|
delayMicroseconds(RF_DELAY_LONG);
|
||||||
SEND_HIGH();
|
RF_SEND_HIGH();
|
||||||
delayMicroseconds(TIME);
|
delayMicroseconds(RF_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Send logical "1" over RF
|
* \brief Send logical "1" over RF
|
||||||
* \details a one bit be represented by an on-to-off transition
|
* \details a one bit be represented by an on-to-off transition
|
||||||
* \ of the RF signal at the middle of a clock period.
|
* \ of the RF signal at the middle of a clock period.
|
||||||
* \ Remenber, the Oregon v2.1 protocol add an inverted bit first
|
* \ Remember, the Oregon v2.1 protocol add an inverted bit first
|
||||||
*/
|
*/
|
||||||
inline void sendOne(void)
|
inline void sendOne(void)
|
||||||
{
|
{
|
||||||
SEND_LOW();
|
RF_SEND_LOW();
|
||||||
delayMicroseconds(TIME);
|
delayMicroseconds(RF_DELAY);
|
||||||
SEND_HIGH();
|
RF_SEND_HIGH();
|
||||||
delayMicroseconds(TWOTIME);
|
delayMicroseconds(RF_DELAY_LONG);
|
||||||
SEND_LOW();
|
RF_SEND_LOW();
|
||||||
delayMicroseconds(TIME);
|
delayMicroseconds(RF_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Send a bits quarter (4 bits = MSB from 8 bits value) over RF
|
|
||||||
* \param data Data to send
|
|
||||||
*/
|
|
||||||
inline void sendQuarterMSB(const byte data)
|
|
||||||
{
|
|
||||||
(bitRead(data, 4)) ? sendOne() : sendZero();
|
|
||||||
(bitRead(data, 5)) ? sendOne() : sendZero();
|
|
||||||
(bitRead(data, 6)) ? sendOne() : sendZero();
|
|
||||||
(bitRead(data, 7)) ? sendOne() : sendZero();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Send a bits quarter (4 bits = LSB from 8 bits value) over RF
|
|
||||||
* \param data Data to send
|
|
||||||
*/
|
|
||||||
inline void sendQuarterLSB(const byte data)
|
|
||||||
{
|
|
||||||
(bitRead(data, 0)) ? sendOne() : sendZero();
|
|
||||||
(bitRead(data, 1)) ? sendOne() : sendZero();
|
|
||||||
(bitRead(data, 2)) ? sendOne() : sendZero();
|
|
||||||
(bitRead(data, 3)) ? sendOne() : sendZero();
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
@ -169,14 +175,20 @@ inline void sendQuarterLSB(const byte data)
|
||||||
/**
|
/**
|
||||||
* \brief Send a buffer over RF
|
* \brief Send a buffer over RF
|
||||||
* \param data Data to send
|
* \param data Data to send
|
||||||
* \param size size of data to send
|
* \param length size of data array
|
||||||
*/
|
*/
|
||||||
void sendData(byte *data, byte size)
|
void sendData(byte *data, byte length)
|
||||||
{
|
{
|
||||||
for(byte i = 0; i < size; ++i)
|
for(byte i = 0; i < length; ++i)
|
||||||
{
|
{
|
||||||
sendQuarterLSB(data[i]);
|
(bitRead(data[i], 0)) ? sendOne() : sendZero();
|
||||||
sendQuarterMSB(data[i]);
|
(bitRead(data[i], 1)) ? sendOne() : sendZero();
|
||||||
|
(bitRead(data[i], 2)) ? sendOne() : sendZero();
|
||||||
|
(bitRead(data[i], 3)) ? sendOne() : sendZero();
|
||||||
|
(bitRead(data[i], 4)) ? sendOne() : sendZero();
|
||||||
|
(bitRead(data[i], 5)) ? sendOne() : sendZero();
|
||||||
|
(bitRead(data[i], 6)) ? sendOne() : sendZero();
|
||||||
|
(bitRead(data[i], 7)) ? sendOne() : sendZero();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -184,67 +196,15 @@ void sendData(byte *data, byte size)
|
||||||
* \brief Send an Oregon message
|
* \brief Send an Oregon message
|
||||||
* \param data The Oregon message
|
* \param data The Oregon message
|
||||||
*/
|
*/
|
||||||
void sendOregon(byte *data, byte size)
|
void rfSend(byte *data, byte size)
|
||||||
{
|
{
|
||||||
sendPreamble();
|
// Send preamble
|
||||||
//sendSync();
|
sendData({ 0xFF,0xFF }, 2);
|
||||||
sendData(data, size);
|
// Send sync nibble
|
||||||
sendPostamble();
|
//sendQuarterLSB(0xA); // It is not use in this version since the sync nibble is include in the Oregon message to send.
|
||||||
|
// Send data
|
||||||
|
sendData(data, size);
|
||||||
|
// Send postamble
|
||||||
|
sendData({ 0x00 }, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Send preamble
|
|
||||||
* \details The preamble consists of 16 "1" bits
|
|
||||||
*/
|
|
||||||
inline void sendPreamble(void)
|
|
||||||
{
|
|
||||||
byte PREAMBLE[]={
|
|
||||||
0xFF,0xFF };
|
|
||||||
sendData(PREAMBLE, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Send postamble
|
|
||||||
* \details The postamble consists of 8 "0" bits
|
|
||||||
*/
|
|
||||||
inline void sendPostamble(void)
|
|
||||||
{
|
|
||||||
byte POSTAMBLE[]={
|
|
||||||
0x00 };
|
|
||||||
sendData(POSTAMBLE, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Send sync nibble
|
|
||||||
* \details The sync is 0xA. It is not use in this version since the sync nibble
|
|
||||||
* \ is include in the Oregon message to send.
|
|
||||||
*/
|
|
||||||
inline void sendSync(void)
|
|
||||||
{
|
|
||||||
sendQuarterLSB(0xA);
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************/
|
|
||||||
/******************************************************************/
|
|
||||||
/******************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set the sensor type
|
|
||||||
* \param data Oregon message
|
|
||||||
* \param type Sensor type
|
|
||||||
*/
|
|
||||||
inline void setType(byte *data, byte* type)
|
|
||||||
{
|
|
||||||
data[0] = type[0];
|
|
||||||
data[1] = type[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set the sensor channel
|
|
||||||
* \param data Oregon message
|
|
||||||
* \param channel Sensor channel (0x10, 0x20, 0x30)
|
|
||||||
*/
|
|
||||||
inline void setChannel(byte *data, byte channel)
|
|
||||||
{
|
|
||||||
data[2] = channel;
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,21 @@
|
||||||
#ifndef PROTOCOLOREGON_H
|
#ifndef PROTOCOLOREGON_H
|
||||||
#define PROTOCOLOREGON_H
|
#define PROTOCOLOREGON_H
|
||||||
|
|
||||||
|
|
||||||
|
class ProtocolOregon : public ProtocolTemperature : public ProtocolPower
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ProtocolOregon(unsigned char address) : address(address){}
|
||||||
|
|
||||||
|
virtual void setup();
|
||||||
|
virtual void setTemperature(float temp);
|
||||||
|
virtual void setHumidity(unsigned char humidity);
|
||||||
|
virtual void setConsumption(unsigned int cons); //Power
|
||||||
|
virtual void send();
|
||||||
|
private:
|
||||||
|
unsigned char address;
|
||||||
|
unsigned float temperature;
|
||||||
|
unsigned char humidity;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // PROTOCOLOREGON_H
|
#endif // PROTOCOLOREGON_H
|
||||||
Loading…
Add table
Add a link
Reference in a new issue