Skip to content

Commit c3dbcd1

Browse files
committed
Accept Time Broadcasts
NodeJsController sending Time broadcasts every few minutes. Sensor accepting not just Time messages addressed to the specific sensor.
1 parent 7a304a0 commit c3dbcd1

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

NodeJsController/NodeJsController.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,5 +706,8 @@ dbc.connect('mongodb://' + dbAddress + ':' + dbPort + '/' + dbName, function(err
706706
} else {
707707
throw new Error('unknown Gateway type');
708708
}
709+
setInterval(function() {
710+
sendTime(BROADCAST_ADDRESS, NODE_SENSOR_ID, gw);
711+
}, 5*60*1000);
709712
});
710713

libraries/MySensors/MySensor.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,11 @@ boolean MySensor::process() {
322322
delay(millis() & 0x3ff);
323323
sendWrite(sender, build(msg, nc.nodeId, sender, NODE_SENSOR_ID, C_INTERNAL, I_FIND_PARENT_RESPONSE, false).set(nc.distance));
324324
return false;
325+
} else if (command == C_INTERNAL && type == I_TIME) {
326+
if (timeCallback != NULL) {
327+
// Deliver time to callback
328+
timeCallback(msg.getULong());
329+
}
325330
} else if (destination == nc.nodeId) {
326331
// Check if sender requests an ack back.
327332
if (mGetRequestAck(msg)) {
@@ -397,11 +402,6 @@ boolean MySensor::process() {
397402
}
398403
sendRoute(build(msg, nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_CHILDREN,false).set(""));
399404
}
400-
} else if (type == I_TIME) {
401-
if (timeCallback != NULL) {
402-
// Deliver time to callback
403-
timeCallback(msg.getULong());
404-
}
405405
}
406406
return false;
407407
}

0 commit comments

Comments
 (0)