diff --git a/NodeManager.cpp b/NodeManager.cpp index 721eb4d6dc424fb3f9c593d1ac5c59e7e4bd06a6..4d379a61ce4df6262bc0ee2e89da11e959c5ca2a 100644 --- a/NodeManager.cpp +++ b/NodeManager.cpp @@ -2176,10 +2176,28 @@ bool NodeManager::renameSensor(int old_child_id, int new_child_id) { // setup NodeManager void NodeManager::before() { + // print out the version #if DEBUG == 1 Serial.print(F("NodeManager v")); Serial.println(VERSION); #endif + // print out MySensors' library capabilities + #if DEBUG == 1 + Serial.print(F("LIB R=")); + Serial.print(MY_CAP_RADIO); + #ifdef MY_CAP_ENCR + Serial.print(F(" E=")); + Serial.print(MY_CAP_ENCR); + #endif + Serial.print(F(" T=")); + Serial.print(MY_CAP_TYPE); + Serial.print(F(" A=")); + Serial.print(MY_CAP_ARCH); + Serial.print(F(" S=")); + Serial.print(MY_CAP_SIGN); + Serial.print(F(" B=")); + Serial.println(MY_CAP_RXBUF); + #endif // setup the sleep interrupt pin if (_sleep_interrupt_pin > -1) { // set the interrupt when the pin is connected to ground diff --git a/NodeManager.h b/NodeManager.h index 9da43189fbaf726fb56a2d22d39b3d5077e77571..c6fa7c3a344790c88503878ef02856ef79496393 100644 --- a/NodeManager.h +++ b/NodeManager.h @@ -257,6 +257,7 @@ enum supported_sensors { // include MySensors libraries #include <core/MySensorsCore.h> +#include <core/MyCapabilities.h> // include third party libraries #if MODULE_DHT == 1 diff --git a/README.md b/README.md index 22eb60c8cb6a0cd389c3799f73d0513c3e77dec6..07ab3b01a104b0a6dedf336a7d78d64c42e45fc2 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Since NodeManager has to communicate with the MySensors gateway on your behalf, * Sketch configuration */ -#define SKETCH_NAME "NodeManagerTemplate" +#define SKETCH_NAME "NodeManager" #define SKETCH_VERSION "1.0" /********************************** @@ -397,7 +397,7 @@ The following methods are available for all the sensors: Each sensor class can expose additional methods. -* SensorAnalogInput / SensorLDR / SensorRain / SensorSoilMoisture * +* SensorAnalogInput / SensorLDR / SensorRain / SensorSoilMoisture ~~~c // the analog reference to use (default: not set, can be either INTERNAL or DEFAULT) void setReference(int value); @@ -411,7 +411,7 @@ Each sensor class can expose additional methods. void setRangeMax(int value); ~~~ -* SensorThermistor * +* SensorThermistor ~~~c // resistance at 25 degrees C (default: 10000) void setNominalResistor(long value); @@ -425,7 +425,7 @@ Each sensor class can expose additional methods. void setOffset(float value); ~~~ -* SensorMQ * +* SensorMQ ~~~c // define the target gas whose ppm has to be returned. 0: LPG, 1: CO, 2: Smoke (default: 1); void setTargetGas(int value); @@ -451,7 +451,7 @@ Each sensor class can expose additional methods. void setSmokeCurve(float *value); ~~~ -* SensorDigitalOutput / SensorRelay / SensorLatchingRelay * +* SensorDigitalOutput / SensorRelay / SensorLatchingRelay ~~~c // set how to initialize the output (default: LOW) void setInitialValue(int value); @@ -463,7 +463,7 @@ Each sensor class can expose additional methods. void setLegacyMode(bool value); ~~~ -* SensorSwitch / SensorDoor / SensorMotion * +* SensorSwitch / SensorDoor / SensorMotion ~~~c // set the interrupt mode. Can be CHANGE, RISING, FALLING (default: CHANGE) void setMode(int value); @@ -487,13 +487,13 @@ Each sensor class can expose additional methods. void setSleepDuringConversion(bool value); ~~~ -* SensorBME280 * +* SensorBME280 ~~~c // define how many pressure samples to keep track of for calculating the forecast (default: 5) void setForecastSamplesCount(int value); ~~~ -* SensorSonoff * +* SensorSonoff ~~~c // set the button's pin (default: 0) void setButtonPin(int value); @@ -503,13 +503,13 @@ Each sensor class can expose additional methods. void setLedPin(int value); ~~~ -* SensorBMP085 * +* SensorBMP085 ~~~c // define how many pressure samples to keep track of for calculating the forecast (default: 5) void setForecastSamplesCount(int value); ~~~ -* SensorHCSR04 * +* SensorHCSR04 ~~~c // Arduino pin tied to trigger pin on the ultrasonic sensor (default: the pin set while registering the sensor) void setTriggerPin(int value); @@ -519,7 +519,7 @@ Each sensor class can expose additional methods. void setMaxDistance(int value); ~~~ -* SensorACS712 * +* SensorACS712 ~~~c // set how many mV are equivalent to 1 Amp. The value depends on the module (100 for 20A Module, 66 for 30A Module) (default: 185); void setmVPerAmp(int value); @@ -527,7 +527,7 @@ Each sensor class can expose additional methods. void setOffset(int value); ~~~ -* SensorRainGauge * +* SensorRainGauge ~~~c // set how frequently to report back to the controller in minutes. After reporting the measure is resetted (default: 60); void setReportInterval(int value); @@ -594,38 +594,38 @@ If `PERSIST` is enabled, the settings provided with `INTVLnnnX` and `MODEx` are A NodeManager object must be created and called from within your sketch during `before()`, `presentation()`, `loop()` and `receive()` to work properly. NodeManager will do the following during each phase: -* NodeManager::before() * +NodeManager::before(): * Setup the interrupt pins to wake up the board based on the configured interrupts (e.g. stop sleeping when the pin is connected to ground or wake up and notify when a motion sensor has trigger) * If persistance is enabled, restore from the EEPROM the latest sleeping settings * Call `before()` of each registered sensor -* Sensor::before() * +Sensor::before(): * Call sensor-specific implementation of before by invoking `onBefore()` to initialize the sensor -* NodeManager::setup() * +NodeManager::setup(): * Send a custom message with a STARTED payload to the controller * Call `setup()` of each registered sensor -* Sensor::setup() * +Sensor::setup(): * Call sensor-specific implementation of setup by invoking `onSetup()` to initialize the sensor -* NodeManager::loop() * +NodeManager::loop(): * If all the sensors are powered by an arduino pin, this is set to HIGH * Call `loop()` of each registered sensor * If all the sensors are powered by an arduino pin, this is set to LOW -* Sensor::loop() * +Sensor::loop(): * If the sensor is powered by an arduino pin, this is set to HIGH * For each registered sensor, the sensor-specific `onLoop()` is called. If multiple samples are requested, this is run multiple times. * In case multiple samples have been collected, the average is calculated * A message is sent to the gateway with the calculated value. Depending on the configuration, this is not sent if it is the same as the previous value or sent anyway after a given number of cycles. These functionalies are not sensor-specific and common to all the sensors inheriting from the `Sensor` class. * If the sensor is powered by an arduino pin, this is set to LOW -* NodeManager::receive() * +NodeManager::receive(): * Receive a message from the radio network * If the destination child id is the configuration node, it will handle the incoming message, otherwise will dispatch the message to the recipient sensor -* Sensor::receive() * +Sensor::receive(): * Invoke `Sensor::loop()` which will execute the sensor main taks and eventually call `Sensor::onReceive()` ## Examples @@ -698,7 +698,7 @@ Register a latching relay connecting to pin 6 (set) and pin 7 (unset): ## Example Sketches -* Analog Light and Temperature Sensor * +* Analog Light and Temperature Sensor The following sketch can be used to report the temperature and the light level based on a thermistor and LDR sensors attached to two analog pins of the arduino board (A1 and A2). Both the thermistor and the LDR are connected to ground on one side and to vcc via a resistor on the other so to measure the voltage drop across each of them through the analog pins. @@ -780,7 +780,7 @@ void receiveTime(unsigned long ts) { } ~~~ -* Motion Sensor * +* Motion Sensor The following sketch can be used to report back to the controller when a motion sensor attached to the board's pin 3 triggers. In this example, the board will be put to sleep just after startup and will report a heartbeat every hour. NodeManager will take care of configuring an interrupt associated to the provided pin so automatically wake up when a motion is detected and report a V_TRIPPED message back. This sketch requires MODULE_SWITCH to be enabled in the global config.h file. @@ -862,7 +862,7 @@ void receiveTime(unsigned long ts) { } ~~~ -* Boiler Sensor * +* Boiler Sensor The following sketch controls a latching relay connected to a boiler. A latching relay (requiring only a pulse to switch) has been chosen to minimize the power consumption required by a traditional relay to stay on. This relay has normally two pins, one for closing and the other for opening the controlled circuit, connected to pin 6 and 7 of the arduino board. This is why we have to register two sensors against NodeManager so to control the two funtions indipendently. Since using a SENSOR_LATCHING_RELAY type of sensor, NodeManager will take care of just sending out a single pulse only when a REQ command of type V_STATUS is sent to one or the other child id. @@ -952,7 +952,7 @@ void receiveTime(unsigned long ts) { ~~~ -* Rain and Soil Moisture Sensor * +* Rain and Soil Moisture Sensor The following sketch can be used to report the rain level and the soil moisture based on two sensors connected to the board's analog pins (A1 and A2). In this case we are customizing the out-of-the-box SENSOR_ANALOG_INPUT sensor type since we just need to measure an analog input but we also want to provide the correct type and presentation for each sensor. @@ -1076,8 +1076,8 @@ For reporting an issue, requesting support for a new sensor or any other kind of If you want to contribute to the code, a pull request on Github is the way to go. First of all setup your development environment: -* Create a copy of the project in your Github account by clicking on the "Fork" button on https://github.com/mysensors/NodeManager. -* Check the copy actually exists on https://github.com/<username>/NodeManager +* Create a copy of the project in your Github account by clicking on the "Fork" button on `https://github.com/mysensors/NodeManager` +* Check the copy actually exists on `https://github.com/<username>/NodeManager` * Clone your repository on your computer: `git clone https://github.com/<username>/NodeManager.git` * Configure the main project's repository as an upstream: `git remote add upstream https://github.com/mysensors/NodeManager.git` * Create and switch to a local development branch: `git checkout -b development origin/development` @@ -1086,18 +1086,21 @@ Before applying any change, ensure you have the latest development version avail * Switch to your local development branch: `git checkout development` * Fetch the latest version from the main project's repository: `git fetch upstream` * Merge into your development copy all the changes from the main repository: `git merge development upstream/development` +* Update the development branch of your repository: `git push origin development` Create a branch for the fix/feature you want to work on and apply changes to the code: * Create and switch to a new branch (give it a significant name, e.g. fix/enum-sensors): `git checkout -b <yourbranch>` * Do any required change to the code * Include all the files changed for your commit: `git add .` * Commit the changes: `git commit -m"Use enum instead of define for defining each sensor #121"` +* Ensure both the main sketch and the config.h file do not present any change * Push the branch with the changes to your repository: `git push origin <yourbranch>` -* Visit https://github.com/<username>/NodeManager/branches and click the "New pull request" button just aside your newly created branch +* Visit `https://github.com/<username>/NodeManager/branches` and click the "New pull request" button just aside your newly created branch * Fill in the request with a significant title and description and select the "development" branch from the main repository to be compared against your branch * Submit the request and start the discussion * Any additional commits to your branch which will be presented within the same pull request -* When the pull request is merged, delete your working branch: `git branch -d <yourbranch>` +* When the pull request is merged, delete your working branch: `git branch -D <yourbranch>` +* Update your local and remote development branch as per the instructions above If there are changes introduced to the development branch that conflicts with an open pull request, you will have to resolve the conflicts and update the PR: * Fetch and merge into development any change from upstream/development as detailed above