* Changed library to call by reference instead of using pointers. Makes code much cleaner.

* RelayNodes renamed to RepeaterNode to distiguish this from RelayActuator.
* Ack is now possible to request for all message types. Added ack-flag for some of the exposed internal messages and presentation message.
This commit is contained in:
Henrik Ekblad
2014-06-16 00:30:13 +02:00
parent 9ddf442e42
commit 90f79c97cd
15 changed files with 200 additions and 204 deletions
@@ -57,7 +57,7 @@ void loop()
if (lastTemperature[i] != temperature && temperature != -127.00) {
// Send in the new temperature
gw.send(msg.setSensor(i)->set(temperature,1));
gw.send(msg.setSensor(i).set(temperature,1));
lastTemperature[i]=temperature;
}
}
@@ -93,7 +93,7 @@ void loop()
}
}
void incomingMessage(MyMessage message) {
void incomingMessage(const MyMessage &message) {
if (message.type==V_VAR1) {
pulseCount = oldPulseCount = message.getLong();
Serial.print("Received last pulse count from gw:");
@@ -54,7 +54,7 @@ void loop()
void incomingMessage(MyMessage message) {
void incomingMessage(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_LIGHT) {
int incomingRelayStatus = message.getInt();
@@ -29,7 +29,7 @@ unsigned long SLEEP_TIME = 30; // Sleep time between reads (in seconds)
BH1750 lightSensor;
MySensor gw;
MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
int lastlux;
uint16_t lastlux;
void setup()
{
@@ -38,7 +38,7 @@ void loop()
gw.process();
}
void incomingMessage(MyMessage message) {
void incomingMessage(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_LIGHT) {
// Change relay state
@@ -71,8 +71,7 @@ void loop()
void incomingMessage(MyMessage message) {
Serial.println(gw.getInternalTemp());
void incomingMessage(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_LIGHT) {
// Change relay state
@@ -1,8 +1,7 @@
// Example sketch showing how to create a node thay relays messages
// Example sketch showing how to create a node thay repeates messages
// from nodes far from gateway back to gateway.
// Important here is that node uses Relay-class and calls
// gw.messageAvailable() frequently. This sketch should not
// sleep.
// It is important that nodes that has enabled repeater mode calls
// gw.preocess() frequently. This node should never sleep.
#include <MySensor.h>
#include <SPI.h>
@@ -12,11 +11,11 @@ MySensor gw;
void setup()
{
// The third argument enables relaying mode.
// The third argument enables repeater mode.
gw.begin(NULL, AUTO, true);
//Send the sensor node sketch version information to the gateway
gw.sendSketchInfo("Relaying Node", "1.0");
gw.sendSketchInfo("Repeater Node", "1.0");
}
void loop()
@@ -49,7 +49,7 @@ void loop()
}
}
void incomingMessage(MyMessage message) {
void incomingMessage(const MyMessage &message) {
myservo.attach(SERVO_DIGITAL_OUT_PIN);
attachedServo = true;
if (message.type==V_DIMMER) { // This could be M_ACK_VARIABLE or M_SET_VARIABLE
@@ -109,7 +109,7 @@ void loop()
}
}
void incomingMessage(MyMessage message) {
void incomingMessage(const MyMessage &message) {
if (message.type==V_VAR1) {
pulseCount = oldPulseCount = message.getLong();
Serial.print("Received last pulse count from gw:");