Accept Time Broadcasts

NodeJsController sending Time broadcasts every few minutes.
Sensor accepting not just Time messages addressed to the specific
sensor.
This commit is contained in:
ToSa27
2014-09-28 23:47:22 +02:00
parent 7a304a0523
commit c3dbcd1fea
2 changed files with 8 additions and 5 deletions
+3
View File
@@ -706,5 +706,8 @@ dbc.connect('mongodb://' + dbAddress + ':' + dbPort + '/' + dbName, function(err
} else {
throw new Error('unknown Gateway type');
}
setInterval(function() {
sendTime(BROADCAST_ADDRESS, NODE_SENSOR_ID, gw);
}, 5*60*1000);
});
+5 -5
View File
@@ -322,6 +322,11 @@ boolean MySensor::process() {
delay(millis() & 0x3ff);
sendWrite(sender, build(msg, nc.nodeId, sender, NODE_SENSOR_ID, C_INTERNAL, I_FIND_PARENT_RESPONSE, false).set(nc.distance));
return false;
} else if (command == C_INTERNAL && type == I_TIME) {
if (timeCallback != NULL) {
// Deliver time to callback
timeCallback(msg.getULong());
}
} else if (destination == nc.nodeId) {
// Check if sender requests an ack back.
if (mGetRequestAck(msg)) {
@@ -397,11 +402,6 @@ boolean MySensor::process() {
}
sendRoute(build(msg, nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_CHILDREN,false).set(""));
}
} else if (type == I_TIME) {
if (timeCallback != NULL) {
// Deliver time to callback
timeCallback(msg.getULong());
}
}
return false;
}