NodeManager.ino 1.84 KB
Newer Older
DV's avatar
DV committed
1
2
3
4
5
6
7
8
9
10
/*
NodeManager is intended to take care on your behalf of all those common tasks a MySensors node has to accomplish, speeding up the development cycle of your projects.

NodeManager includes the following main components:
- Sleep manager: allows managing automatically the complexity behind battery-powered sensors spending most of their time sleeping
- Power manager: allows powering on your sensors only while the node is awake
- Battery manager: provides common functionalities to read and report the battery level
- Remote configuration: allows configuring remotely the node without the need to have physical access to it
- Built-in personalities: for the most common sensors, provide embedded code so to allow their configuration with a single line 

11
Documentation available on: https://github.com/mysensors/NodeManager
DV's avatar
DV committed
12
13
14
15
16
 */

 
// load user settings
#include "config.h"
17
18
19
20
// include supporting libraries
#ifdef MY_GATEWAY_ESP8266
  #include <ESP8266WiFi.h>
#endif
DV's avatar
DV committed
21
22
23
24
25
26
27
28
29
30
31
// load MySensors library
#include <MySensors.h>
// load NodeManager library
#include "NodeManager.h"

// create a NodeManager instance
NodeManager nodeManager;

// before
void before() {
  // setup the serial port baud rate
user2684's avatar
user2684 committed
32
  Serial.begin(MY_BAUD_RATE);  
DV's avatar
DV committed
33
34
  /*
   * Register below your sensors
DV's avatar
DV committed
35
  */
36
  
user2684's avatar
user2684 committed
37

38
  
DV's avatar
DV committed
39
40
  /*
   * Register above your sensors
DV's avatar
DV committed
41
  */
DV's avatar
DV committed
42
43
44
45
46
47
48
49
50
51
52
  nodeManager.before();
}

// presentation
void presentation() {
  // call NodeManager presentation routine
  nodeManager.presentation();
}

// setup
void setup() {
DV's avatar
DV committed
53
54
  // call NodeManager setup routine
  nodeManager.setup();
DV's avatar
DV committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
}

// loop
void loop() {
  // call NodeManager loop routine
  nodeManager.loop();

}

// receive
void receive(const MyMessage &message) {
  // call NodeManager receive routine
  nodeManager.receive(message);
}

70
71
72
73
74
75
// receiveTime
void receiveTime(unsigned long ts) {
  // call NodeManager receiveTime routine
  nodeManager.receiveTime(ts);
}

DV's avatar
DV committed
76