Sensor nodes can now report their sketch name and version to the gateway for informational purposes. Added class methods sendSketchName(), sendSketchVersion() and sendSketchInfo() that invokes the aforementioned as a convenience method. Sensor nodes report their sketch information to the gateway by calling sendSketchInfo(const char *name, const char *version) in the Arduino sketch setup() method after initializing the radio by invoking the Sensor::begin() method.

This commit is contained in:
Bruce Lacey
2014-03-07 09:05:25 -08:00
parent 8681e37f48
commit 89e3c4f0ef
4 changed files with 42 additions and 3 deletions
+16 -1
View File
@@ -1,4 +1,4 @@
/*
/*
The Sensor Net Arduino library adds a new layer on top of the RF24 library.
It handles radio network routing, relaying and ids.
@@ -335,6 +335,21 @@ void Sensor::requestStatus(uint8_t nodeId, int8_t childId, uint8_t variableType)
sendData(radioId, nodeId, childId, M_REQ_VARIABLE, variableType, "", 0, false);
}
void Sensor::sendSketchInfo(const char *name, const char *version) {
sendSketchName(name);
sendSketchVersion(version);
}
void Sensor::sendSketchName(const char *name) {
if (name != NULL)
sendInternal(I_SKETCH_NAME, name);
}
void Sensor::sendSketchVersion(const char *version) {
if (version != NULL)
sendInternal(I_SKETCH_VERSION, version);
}
void Sensor::sendBatteryLevel(int value) {
sendInternal(I_BATTERY_LEVEL, ltoa(value, convBuffer, 10));
}
+20 -2
View File
@@ -22,7 +22,7 @@
#include <avr/pgmspace.h>
#include <stdarg.h>
//#define DEBUG
#define DEBUG
#ifdef DEBUG
#define debug(x,...) debugPrint(x, ##__VA_ARGS__)
@@ -80,7 +80,7 @@ typedef enum {
typedef enum {
I_BATTERY_LEVEL, I_BATTERY_DATE, I_LAST_TRIP, I_TIME, I_VERSION, I_REQUEST_ID,
I_INCLUSION_MODE, I_RELAY_NODE, I_LAST_UPDATE, I_PING, I_PING_ACK,
I_LOG_MESSAGE, I_CHILDREN, I_UNIT
I_LOG_MESSAGE, I_CHILDREN, I_UNIT, I_SKETCH_NAME, I_SKETCH_VERSION
} internalMessageType;
// Sensor types
@@ -176,6 +176,24 @@ class Sensor : public RF24
void sendVariable(uint8_t radioId, uint8_t childId, uint8_t variableType, unsigned int value);
void sendVariable(uint8_t radioId, uint8_t childId, uint8_t variableType, int value);
/**
* Sends sketch info to sensor net gateway for this radio node.
* @param name String containing a short Sketch name
* @param version String containing a short Sketch version
*/
void sendSketchInfo(const char *name, const char *version);
/**
* Sends sketch name to sensor net gateway for this radio node.
* @param info String containing a short Sketch name and version
*/
void sendSketchName(const char *name);
/**
* Sends sketch version to sensor net gateway for this radio node.
* @param info String containing a short Sketch name and version
*/
void sendSketchVersion(const char *version);
/**
* Sends battery status to sensor net gateway for this radio node.
@@ -22,6 +22,9 @@ void setup()
gw.begin();
dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
// Send the Sketch Version Information to the Gateway
gw.sendSketchInfo("Humidity", "1.0")
// Register all sensors to gw (they will be created as child devices)
gw.sendSensorPresentation(CHILD_ID_HUM, S_HUM);
gw.sendSensorPresentation(CHILD_ID_TEMP, S_TEMP);
@@ -14,6 +14,9 @@ Relay gw;
void setup()
{
gw.begin();
//Send the sensor node sketch version information to the gateway
gw.sendSketchInfo("RelayingNode", "1.2");
}
void loop()