Added sendHeatbeat()

Allow a sensor to send a "dummy" message to controller to say "I'm still
alive!". The payload will be an incremental uint16.
This commit is contained in:
Henrik Ekblad
2015-08-04 21:38:10 +02:00
parent cb83bfbdb3
commit 2343d8ae8f
3 changed files with 14 additions and 1 deletions
+5
View File
@@ -487,6 +487,11 @@ void MySensor::sendBatteryLevel(uint8_t value, bool enableAck) {
sendRoute(build(msg, nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_BATTERY_LEVEL, enableAck).set(value));
}
void MySensor::sendHeartbeat(void) {
sendRoute(build(msg, nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_HEARTBEAT, false).set(heartbeat++));
}
void MySensor::present(uint8_t childSensorId, uint8_t sensorType, const char *description, bool enableAck) {
sendRoute(build(msg, nc.nodeId, GATEWAY_ADDRESS, childSensorId, C_PRESENTATION, sensorType, enableAck).set(childSensorId==NODE_SENSOR_ID?LIBRARY_VERSION:description));
}