Rainfall
API implementation of the Rainfall protocol, used in home automation. This application protocol can use almost any netowrk infrastructure to communicate (see the drivers folder and check out which network protocol are already supported). The protocol is designed to provide a common language for all devices in your home communicate and it envolves three node classes:
Sensor
This node sends collected data to the controller.
Actuator
This node receives commands from the controller and eventually sends to the controller commands received from other sources.
Controller
This node controls all the sensors and actuators in the network, they only communicate with this node and do not between each other.
Actually, the protocol is flexible enough to let you define a node as both a sensor and an actuator.
Documentation
For documentation on how to use the API, refer to this
Usage
First of all you need to choose which driver you'll use, and then instantiate it:
const Driver = ;Driver;
Then, we instantiate the Rainfall, passing the driver
object to it:
const Rainfall = ; var rainfall = driver;
The complete initialization would be something like this:
const Driver = ;const Rainfall = ;Driver;
With the rainfall
object we can send messages:
rainfall;
With the rainfall
object we can listen for messages:
rainfall;
With the rainfall
object we can broadcast messages:
rainfall;
We can also stop listeners:
rainfall;
And of course, we can shutdown the role thing:
rainfall;
Examples
In the examples below, we will use the TCP driver.
Discovering Controller
This example asks who is controller and waits for response
const Driver = ;const Rainfall = ;Driver;
Answering who is the controller
This example asks who is controller and waits for response
const Driver = ;const Rainfall = ;Driver;