Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SmartHome
NodeManager_GasSensor
Commits
15fc8d41
Commit
15fc8d41
authored
Apr 04, 2017
by
user2684
Browse files
Use F() macro in Serial.println() #35
parent
5bcfd7b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
NodeManager.cpp
View file @
15fc8d41
...
@@ -4,16 +4,6 @@
...
@@ -4,16 +4,6 @@
#include
"NodeManager.h"
#include
"NodeManager.h"
/*
* Constants
*/
const
char
*
BATTERY
=
"BATTERY"
;
const
char
*
AWAKE
=
"AWAKE"
;
const
char
*
REBOOT
=
"REBOOT"
;
const
char
*
CLEAR
=
"CLEAR"
;
const
char
*
WAKEUP
=
"WAKEUP"
;
const
char
*
STARTED
=
"STARTED"
;
/***************************************
/***************************************
PowerManager
PowerManager
...
@@ -22,9 +12,9 @@ const char* STARTED = "STARTED";
...
@@ -22,9 +12,9 @@ const char* STARTED = "STARTED";
// set the vcc and ground pin the sensor is connected to
// set the vcc and ground pin the sensor is connected to
void
PowerManager
::
setPowerPins
(
int
ground_pin
,
int
vcc_pin
,
long
wait
)
{
void
PowerManager
::
setPowerPins
(
int
ground_pin
,
int
vcc_pin
,
long
wait
)
{
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"PWR G="
);
Serial
.
print
(
F
(
"PWR G="
)
)
;
Serial
.
print
(
ground_pin
);
Serial
.
print
(
ground_pin
);
Serial
.
print
(
" V="
);
Serial
.
print
(
F
(
" V="
)
)
;
Serial
.
println
(
vcc_pin
);
Serial
.
println
(
vcc_pin
);
#endif
#endif
// configure the vcc pin as output and initialize to low (power off)
// configure the vcc pin as output and initialize to low (power off)
...
@@ -48,7 +38,7 @@ bool PowerManager::_hasPowerManager() {
...
@@ -48,7 +38,7 @@ bool PowerManager::_hasPowerManager() {
void
PowerManager
::
powerOn
()
{
void
PowerManager
::
powerOn
()
{
if
(
!
_hasPowerManager
())
return
;
if
(
!
_hasPowerManager
())
return
;
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"ON P="
);
Serial
.
print
(
F
(
"ON P="
)
)
;
Serial
.
println
(
_vcc_pin
);
Serial
.
println
(
_vcc_pin
);
#endif
#endif
// power on the sensor by turning high the vcc pin
// power on the sensor by turning high the vcc pin
...
@@ -61,7 +51,7 @@ void PowerManager::powerOn() {
...
@@ -61,7 +51,7 @@ void PowerManager::powerOn() {
void
PowerManager
::
powerOff
()
{
void
PowerManager
::
powerOff
()
{
if
(
!
_hasPowerManager
())
return
;
if
(
!
_hasPowerManager
())
return
;
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"OFF P="
);
Serial
.
print
(
F
(
"OFF P="
)
)
;
Serial
.
println
(
_vcc_pin
);
Serial
.
println
(
_vcc_pin
);
#endif
#endif
// power off the sensor by turning low the vcc pin
// power off the sensor by turning low the vcc pin
...
@@ -150,9 +140,9 @@ void Sensor::setSleepBetweenSend(int value) {
...
@@ -150,9 +140,9 @@ void Sensor::setSleepBetweenSend(int value) {
// present the sensor to the gateway and controller
// present the sensor to the gateway and controller
void
Sensor
::
presentation
()
{
void
Sensor
::
presentation
()
{
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"PRES I="
);
Serial
.
print
(
F
(
"PRES I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" T="
);
Serial
.
print
(
F
(
" T="
)
)
;
Serial
.
println
(
_presentation
);
Serial
.
println
(
_presentation
);
#endif
#endif
present
(
_child_id
,
_presentation
);
present
(
_child_id
,
_presentation
);
...
@@ -244,19 +234,19 @@ void Sensor::_send(MyMessage & message) {
...
@@ -244,19 +234,19 @@ void Sensor::_send(MyMessage & message) {
// if configured, sleep beetween each send
// if configured, sleep beetween each send
if
(
_sleep_between_send
>
0
)
wait
(
_sleep_between_send
);
if
(
_sleep_between_send
>
0
)
wait
(
_sleep_between_send
);
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"SEND D="
);
Serial
.
print
(
F
(
"SEND D="
)
)
;
Serial
.
print
(
message
.
destination
);
Serial
.
print
(
message
.
destination
);
Serial
.
print
(
" I="
);
Serial
.
print
(
F
(
" I="
)
)
;
Serial
.
print
(
message
.
sensor
);
Serial
.
print
(
message
.
sensor
);
Serial
.
print
(
" C="
);
Serial
.
print
(
F
(
" C="
)
)
;
Serial
.
print
(
message
.
getCommand
());
Serial
.
print
(
message
.
getCommand
());
Serial
.
print
(
" T="
);
Serial
.
print
(
F
(
" T="
)
)
;
Serial
.
print
(
message
.
type
);
Serial
.
print
(
message
.
type
);
Serial
.
print
(
" S="
);
Serial
.
print
(
F
(
" S="
)
)
;
Serial
.
print
(
message
.
getString
());
Serial
.
print
(
message
.
getString
());
Serial
.
print
(
" N="
);
Serial
.
print
(
F
(
" N="
)
)
;
Serial
.
print
(
message
.
getInt
());
Serial
.
print
(
message
.
getInt
());
Serial
.
print
(
" F="
);
Serial
.
print
(
F
(
" F="
)
)
;
Serial
.
println
(
message
.
getFloat
());
Serial
.
println
(
message
.
getFloat
());
#endif
#endif
send
(
message
);
send
(
message
);
...
@@ -302,11 +292,11 @@ void SensorAnalogInput::onLoop() {
...
@@ -302,11 +292,11 @@ void SensorAnalogInput::onLoop() {
int
percentage
=
0
;
int
percentage
=
0
;
if
(
_output_percentage
)
percentage
=
_getPercentage
(
adc
);
if
(
_output_percentage
)
percentage
=
_getPercentage
(
adc
);
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"A-IN I="
);
Serial
.
print
(
F
(
"A-IN I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" V="
);
Serial
.
print
(
F
(
" V="
)
)
;
Serial
.
print
(
adc
);
Serial
.
print
(
adc
);
Serial
.
print
(
" %="
);
Serial
.
print
(
F
(
" %="
)
)
;
Serial
.
println
(
percentage
);
Serial
.
println
(
percentage
);
#endif
#endif
// store the result
// store the result
...
@@ -407,13 +397,13 @@ void SensorThermistor::onLoop() {
...
@@ -407,13 +397,13 @@ void SensorThermistor::onLoop() {
temperature
-=
273.15
;
// convert to C
temperature
-=
273.15
;
// convert to C
if
(
!
getControllerConfig
().
isMetric
)
temperature
=
temperature
*
1.8
+
32
;
if
(
!
getControllerConfig
().
isMetric
)
temperature
=
temperature
*
1.8
+
32
;
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"THER I="
);
Serial
.
print
(
F
(
"THER I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" V="
);
Serial
.
print
(
F
(
" V="
)
)
;
Serial
.
print
(
adc
);
Serial
.
print
(
adc
);
Serial
.
print
(
" T="
);
Serial
.
print
(
F
(
" T="
)
)
;
Serial
.
println
(
temperature
);
Serial
.
println
(
temperature
);
Serial
.
print
(
" M="
);
Serial
.
print
(
F
(
" M="
)
)
;
Serial
.
println
(
getControllerConfig
().
isMetric
);
Serial
.
println
(
getControllerConfig
().
isMetric
);
#endif
#endif
// store the value
// store the value
...
@@ -444,11 +434,11 @@ void SensorDigitalInput::onLoop() {
...
@@ -444,11 +434,11 @@ void SensorDigitalInput::onLoop() {
// read the value
// read the value
int
value
=
digitalRead
(
_pin
);
int
value
=
digitalRead
(
_pin
);
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"D-IN I="
);
Serial
.
print
(
F
(
"D-IN I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" P="
);
Serial
.
print
(
F
(
" P="
)
)
;
Serial
.
print
(
_pin
);
Serial
.
print
(
_pin
);
Serial
.
print
(
" V="
);
Serial
.
print
(
F
(
" V="
)
)
;
Serial
.
println
(
value
);
Serial
.
println
(
value
);
#endif
#endif
// store the value
// store the value
...
@@ -496,15 +486,15 @@ void SensorDigitalOutput::onReceive(const MyMessage & message) {
...
@@ -496,15 +486,15 @@ void SensorDigitalOutput::onReceive(const MyMessage & message) {
int
value
=
message
.
getInt
();
int
value
=
message
.
getInt
();
if
(
value
!=
0
&&
value
!=
1
)
return
;
if
(
value
!=
0
&&
value
!=
1
)
return
;
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"DOUT I="
);
Serial
.
print
(
F
(
"DOUT I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" P="
);
Serial
.
print
(
F
(
" P="
)
)
;
Serial
.
print
(
_pin
);
Serial
.
print
(
_pin
);
Serial
.
print
(
" S="
);
Serial
.
print
(
F
(
" S="
)
)
;
Serial
.
print
(
_initial_value
);
Serial
.
print
(
_initial_value
);
Serial
.
print
(
" V="
);
Serial
.
print
(
F
(
" V="
)
)
;
Serial
.
print
(
value
);
Serial
.
print
(
value
);
Serial
.
print
(
" P="
);
Serial
.
print
(
F
(
" P="
)
)
;
Serial
.
println
(
_pulse_width
);
Serial
.
println
(
_pulse_width
);
#endif
#endif
// set the value
// set the value
...
@@ -585,9 +575,9 @@ void SensorDHT::onLoop() {
...
@@ -585,9 +575,9 @@ void SensorDHT::onLoop() {
// convert it
// convert it
if
(
!
getControllerConfig
().
isMetric
)
temperature
=
temperature
*
1.8
+
32
;
if
(
!
getControllerConfig
().
isMetric
)
temperature
=
temperature
*
1.8
+
32
;
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"DHT I="
);
Serial
.
print
(
F
(
"DHT I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" T="
);
Serial
.
print
(
F
(
" T="
)
)
;
Serial
.
println
(
temperature
);
Serial
.
println
(
temperature
);
#endif
#endif
// store the value
// store the value
...
@@ -599,9 +589,9 @@ void SensorDHT::onLoop() {
...
@@ -599,9 +589,9 @@ void SensorDHT::onLoop() {
float
humidity
=
_dht
->
readHumidity
();
float
humidity
=
_dht
->
readHumidity
();
if
(
isnan
(
humidity
))
return
;
if
(
isnan
(
humidity
))
return
;
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"DHT I="
);
Serial
.
print
(
F
(
"DHT I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" H="
);
Serial
.
print
(
F
(
" H="
)
)
;
Serial
.
println
(
humidity
);
Serial
.
println
(
humidity
);
#endif
#endif
// store the value
// store the value
...
@@ -652,9 +642,9 @@ void SensorSHT21::onLoop() {
...
@@ -652,9 +642,9 @@ void SensorSHT21::onLoop() {
// convert it
// convert it
if
(
!
getControllerConfig
().
isMetric
)
temperature
=
temperature
*
1.8
+
32
;
if
(
!
getControllerConfig
().
isMetric
)
temperature
=
temperature
*
1.8
+
32
;
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"SHT I="
);
Serial
.
print
(
F
(
"SHT I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" T="
);
Serial
.
print
(
F
(
" T="
)
)
;
Serial
.
println
(
temperature
);
Serial
.
println
(
temperature
);
#endif
#endif
// store the value
// store the value
...
@@ -666,9 +656,9 @@ void SensorSHT21::onLoop() {
...
@@ -666,9 +656,9 @@ void SensorSHT21::onLoop() {
float
humidity
=
SHT2x
.
GetHumidity
();
float
humidity
=
SHT2x
.
GetHumidity
();
if
(
isnan
(
humidity
))
return
;
if
(
isnan
(
humidity
))
return
;
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"SHT I="
);
Serial
.
print
(
F
(
"SHT I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" H="
);
Serial
.
print
(
F
(
" H="
)
)
;
Serial
.
println
(
humidity
);
Serial
.
println
(
humidity
);
#endif
#endif
// store the value
// store the value
...
@@ -734,11 +724,11 @@ void SensorSwitch::onLoop() {
...
@@ -734,11 +724,11 @@ void SensorSwitch::onLoop() {
// process the value
// process the value
if
(
(
_mode
==
RISING
&&
value
==
HIGH
)
||
(
_mode
==
FALLING
&&
value
==
LOW
)
||
(
_mode
==
CHANGE
)
)
{
if
(
(
_mode
==
RISING
&&
value
==
HIGH
)
||
(
_mode
==
FALLING
&&
value
==
LOW
)
||
(
_mode
==
CHANGE
)
)
{
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"SWITCH I="
);
Serial
.
print
(
F
(
"SWITCH I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" P="
);
Serial
.
print
(
F
(
" P="
)
)
;
Serial
.
print
(
_pin
);
Serial
.
print
(
_pin
);
Serial
.
print
(
" V="
);
Serial
.
print
(
F
(
" V="
)
)
;
Serial
.
println
(
value
);
Serial
.
println
(
value
);
#endif
#endif
_value_int
=
value
;
_value_int
=
value
;
...
@@ -798,9 +788,9 @@ void SensorDs18b20::onLoop() {
...
@@ -798,9 +788,9 @@ void SensorDs18b20::onLoop() {
// convert it
// convert it
if
(
!
getControllerConfig
().
isMetric
)
temperature
=
temperature
*
1.8
+
32
;
if
(
!
getControllerConfig
().
isMetric
)
temperature
=
temperature
*
1.8
+
32
;
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"DS18 I="
);
Serial
.
print
(
F
(
"DS18 I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" T="
);
Serial
.
print
(
F
(
" T="
)
)
;
Serial
.
println
(
temperature
);
Serial
.
println
(
temperature
);
#endif
#endif
// store the value
// store the value
...
@@ -834,9 +824,9 @@ void SensorBH1750::onLoop() {
...
@@ -834,9 +824,9 @@ void SensorBH1750::onLoop() {
// request the light level
// request the light level
_value_int
=
_lightSensor
->
readLightLevel
();
_value_int
=
_lightSensor
->
readLightLevel
();
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"BH1 I="
);
Serial
.
print
(
F
(
"BH1 I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" L="
);
Serial
.
print
(
F
(
" L="
)
)
;
Serial
.
println
(
_value_int
);
Serial
.
println
(
_value_int
);
#endif
#endif
}
}
...
@@ -874,9 +864,9 @@ void SensorMLX90614::onLoop() {
...
@@ -874,9 +864,9 @@ void SensorMLX90614::onLoop() {
// convert it
// convert it
if
(
!
getControllerConfig
().
isMetric
)
temperature
=
temperature
*
1.8
+
32
;
if
(
!
getControllerConfig
().
isMetric
)
temperature
=
temperature
*
1.8
+
32
;
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"MLX I="
);
Serial
.
print
(
F
(
"MLX I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" T="
);
Serial
.
print
(
F
(
" T="
)
)
;
Serial
.
println
(
temperature
);
Serial
.
println
(
temperature
);
#endif
#endif
if
(
!
isnan
(
temperature
))
_value_float
=
temperature
;
if
(
!
isnan
(
temperature
))
_value_float
=
temperature
;
...
@@ -931,9 +921,9 @@ void SensorBME280::onLoop() {
...
@@ -931,9 +921,9 @@ void SensorBME280::onLoop() {
// convert it
// convert it
if
(
!
getControllerConfig
().
isMetric
)
temperature
=
temperature
*
1.8
+
32
;
if
(
!
getControllerConfig
().
isMetric
)
temperature
=
temperature
*
1.8
+
32
;
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"BME I="
);
Serial
.
print
(
F
(
"BME I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" T="
);
Serial
.
print
(
F
(
" T="
)
)
;
Serial
.
println
(
temperature
);
Serial
.
println
(
temperature
);
#endif
#endif
// store the value
// store the value
...
@@ -945,9 +935,9 @@ void SensorBME280::onLoop() {
...
@@ -945,9 +935,9 @@ void SensorBME280::onLoop() {
float
humidity
=
_bme
->
readHumidity
();
float
humidity
=
_bme
->
readHumidity
();
if
(
isnan
(
humidity
))
return
;
if
(
isnan
(
humidity
))
return
;
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"BME I="
);
Serial
.
print
(
F
(
"BME I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" H="
);
Serial
.
print
(
F
(
" H="
)
)
;
Serial
.
println
(
humidity
);
Serial
.
println
(
humidity
);
#endif
#endif
// store the value
// store the value
...
@@ -959,9 +949,9 @@ void SensorBME280::onLoop() {
...
@@ -959,9 +949,9 @@ void SensorBME280::onLoop() {
float
pressure
=
_bme
->
readPressure
()
/
100.0
F
;
float
pressure
=
_bme
->
readPressure
()
/
100.0
F
;
if
(
isnan
(
pressure
))
return
;
if
(
isnan
(
pressure
))
return
;
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"BME I="
);
Serial
.
print
(
F
(
"BME I="
)
)
;
Serial
.
print
(
_child_id
);
Serial
.
print
(
_child_id
);
Serial
.
print
(
" P="
);
Serial
.
print
(
F
(
" P="
)
)
;
Serial
.
println
(
pressure
);
Serial
.
println
(
pressure
);
#endif
#endif
// store the value
// store the value
...
@@ -1148,7 +1138,7 @@ int NodeManager::registerSensor(int sensor_type, int pin, int child_id) {
...
@@ -1148,7 +1138,7 @@ int NodeManager::registerSensor(int sensor_type, int pin, int child_id) {
Adafruit_BME280
*
bme
=
new
Adafruit_BME280
();
Adafruit_BME280
*
bme
=
new
Adafruit_BME280
();
if
(
!
bme
->
begin
())
{
if
(
!
bme
->
begin
())
{
#if DEBUG == 1
#if DEBUG == 1
Serial
.
println
(
"NO BME"
);
Serial
.
println
(
F
(
"NO BME"
)
)
;
#endif
#endif
return
-
1
;
return
-
1
;
}
}
...
@@ -1161,7 +1151,7 @@ int NodeManager::registerSensor(int sensor_type, int pin, int child_id) {
...
@@ -1161,7 +1151,7 @@ int NodeManager::registerSensor(int sensor_type, int pin, int child_id) {
#endif
#endif
else
{
else
{
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"INVALID "
);
Serial
.
print
(
F
(
"INVALID "
)
)
;
Serial
.
println
(
sensor_type
);
Serial
.
println
(
sensor_type
);
#endif
#endif
return
-
1
;
return
-
1
;
...
@@ -1171,13 +1161,13 @@ int NodeManager::registerSensor(int sensor_type, int pin, int child_id) {
...
@@ -1171,13 +1161,13 @@ int NodeManager::registerSensor(int sensor_type, int pin, int child_id) {
// attach a built-in or custom sensor to this manager
// attach a built-in or custom sensor to this manager
int
NodeManager
::
registerSensor
(
Sensor
*
sensor
)
{
int
NodeManager
::
registerSensor
(
Sensor
*
sensor
)
{
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"REG I="
);
Serial
.
print
(
F
(
"REG I="
)
)
;
Serial
.
print
(
sensor
->
getChildId
());
Serial
.
print
(
sensor
->
getChildId
());
Serial
.
print
(
" P="
);
Serial
.
print
(
F
(
" P="
)
)
;
Serial
.
print
(
sensor
->
getPin
());
Serial
.
print
(
sensor
->
getPin
());
Serial
.
print
(
" P="
);
Serial
.
print
(
F
(
" P="
)
)
;
Serial
.
print
(
sensor
->
getPresentation
());
Serial
.
print
(
sensor
->
getPresentation
());
Serial
.
print
(
" T="
);
Serial
.
print
(
F
(
" T="
)
)
;
Serial
.
println
(
sensor
->
getType
());
Serial
.
println
(
sensor
->
getType
());
#endif
#endif
#if POWER_MANAGER == 1
#if POWER_MANAGER == 1
...
@@ -1199,12 +1189,12 @@ Sensor* NodeManager::get(int child_id) {
...
@@ -1199,12 +1189,12 @@ Sensor* NodeManager::get(int child_id) {
// setup NodeManager
// setup NodeManager
void
NodeManager
::
before
()
{
void
NodeManager
::
before
()
{
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"NodeManager v"
);
Serial
.
print
(
F
(
"NodeManager v"
)
)
;
Serial
.
println
(
VERSION
);
Serial
.
println
(
VERSION
);
#endif
#endif
if
(
_reboot_pin
>
-
1
)
{
if
(
_reboot_pin
>
-
1
)
{
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"REB P="
);
Serial
.
print
(
F
(
"REB P="
)
)
;
Serial
.
println
(
_reboot_pin
);
Serial
.
println
(
_reboot_pin
);
#endif
#endif
// setup the reboot pin
// setup the reboot pin
...
@@ -1228,9 +1218,9 @@ void NodeManager::before() {
...
@@ -1228,9 +1218,9 @@ void NodeManager::before() {
if
(
_interrupt_2_pull
>
-
1
)
digitalWrite
(
INTERRUPT_PIN_2
,
_interrupt_2_pull
);
if
(
_interrupt_2_pull
>
-
1
)
digitalWrite
(
INTERRUPT_PIN_2
,
_interrupt_2_pull
);
}
}
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"INT1 M="
);
Serial
.
print
(
F
(
"INT1 M="
)
)
;
Serial
.
println
(
_interrupt_1_mode
);
Serial
.
println
(
_interrupt_1_mode
);
Serial
.
print
(
"INT2 M="
);
Serial
.
print
(
F
(
"INT2 M="
)
)
;
Serial
.
println
(
_interrupt_2_mode
);
Serial
.
println
(
_interrupt_2_mode
);
#endif
#endif
#if REMOTE_CONFIGURATION == 1 && SLEEP_MANAGER == 1 && PERSIST == 1
#if REMOTE_CONFIGURATION == 1 && SLEEP_MANAGER == 1 && PERSIST == 1
...
@@ -1245,11 +1235,11 @@ void NodeManager::before() {
...
@@ -1245,11 +1235,11 @@ void NodeManager::before() {
else
if
(
major
==
3
)
_sleep_time
=
_sleep_time
+
250
*
3
;
else
if
(
major
==
3
)
_sleep_time
=
_sleep_time
+
250
*
3
;
_sleep_unit
=
loadState
(
EEPROM_SLEEP_UNIT
);
_sleep_unit
=
loadState
(
EEPROM_SLEEP_UNIT
);
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"LOADSLP M="
);
Serial
.
print
(
F
(
"LOADSLP M="
)
)
;
Serial
.
print
(
_sleep_mode
);
Serial
.
print
(
_sleep_mode
);
Serial
.
print
(
" T="
);
Serial
.
print
(
F
(
" T="
)
)
;
Serial
.
print
(
_sleep_time
);
Serial
.
print
(
_sleep_time
);
Serial
.
print
(
" U="
);
Serial
.
print
(
F
(
" U="
)
)
;
Serial
.
println
(
_sleep_unit
);
Serial
.
println
(
_sleep_unit
);
#endif
#endif
}
}
...
@@ -1269,27 +1259,27 @@ void NodeManager::before() {
...
@@ -1269,27 +1259,27 @@ void NodeManager::before() {
// present NodeManager and its sensors
// present NodeManager and its sensors
void
NodeManager
::
presentation
()
{
void
NodeManager
::
presentation
()
{
#if DEBUG == 1
#if DEBUG == 1
Serial
.
println
(
"RADIO OK"
);
Serial
.
println
(
F
(
"RADIO OK"
)
)
;
#endif
#endif
// present the service as a custom sensor to the controller
// present the service as a custom sensor to the controller
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"PRES I="
);
Serial
.
print
(
F
(
"PRES I="
)
)
;
Serial
.
print
(
CONFIGURATION_CHILD_ID
);
Serial
.
print
(
CONFIGURATION_CHILD_ID
);
Serial
.
print
(
", T="
);
Serial
.
print
(
F
(
", T="
)
)
;
Serial
.
println
(
S_CUSTOM
);
Serial
.
println
(
S_CUSTOM
);
#endif
#endif
present
(
CONFIGURATION_CHILD_ID
,
S_CUSTOM
);
present
(
CONFIGURATION_CHILD_ID
,
S_CUSTOM
);
#if BATTERY_MANAGER == 1 && BATTERY_SENSOR == 1
#if BATTERY_MANAGER == 1 && BATTERY_SENSOR == 1
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"PRES I="
);
Serial
.
print
(
F
(
"PRES I="
)
)
;
Serial
.
print
(
BATTERY_CHILD_ID
);
Serial
.
print
(
BATTERY_CHILD_ID
);
Serial
.
print
(
", T="
);
Serial
.
print
(
F
(
", T="
)
)
;
Serial
.
println
(
S_MULTIMETER
);
Serial
.
println
(
S_MULTIMETER
);
#endif
#endif
// present the battery service
// present the battery service
present
(
BATTERY_CHILD_ID
,
S_MULTIMETER
);
present
(
BATTERY_CHILD_ID
,
S_MULTIMETER
);
// report battery level
// report battery level
_process
(
BATTERY
);
_process
(
"
BATTERY
"
);
#endif
#endif
// present each sensor
// present each sensor
for
(
int
i
=
0
;
i
<
255
;
i
++
)
{
for
(
int
i
=
0
;
i
<
255
;
i
++
)
{
...
@@ -1298,7 +1288,7 @@ void NodeManager::presentation() {
...
@@ -1298,7 +1288,7 @@ void NodeManager::presentation() {
_sensors
[
i
]
->
presentation
();
_sensors
[
i
]
->
presentation
();
}
}
#if DEBUG == 1
#if DEBUG == 1
Serial
.
println
(
"READY"
);
Serial
.
println
(
F
(
"READY"
)
)
;
Serial
.
println
(
""
);
Serial
.
println
(
""
);
#endif
#endif
}
}
...
@@ -1307,13 +1297,13 @@ void NodeManager::presentation() {
...
@@ -1307,13 +1297,13 @@ void NodeManager::presentation() {
// setup NodeManager
// setup NodeManager
void
NodeManager
::
setup
()
{
void
NodeManager
::
setup
()
{
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"MY I="
);
Serial
.
print
(
F
(
"MY I="
)
)
;
Serial
.
print
(
getNodeId
());
Serial
.
print
(
getNodeId
());
Serial
.
print
(
" M="
);
Serial
.
print
(
F
(
" M="
)
)
;
Serial
.
println
(
getControllerConfig
().
isMetric
);
Serial
.
println
(
getControllerConfig
().
isMetric
);
#endif
#endif
#if SERVICE_MESSAGES == 1
#if SERVICE_MESSAGES == 1
_send
(
_msg
.
set
(
STARTED
));
_send
(
_msg
.
set
(
"
STARTED
"
));
#endif
#endif
}
}
...
@@ -1347,15 +1337,15 @@ void NodeManager::loop() {
...
@@ -1347,15 +1337,15 @@ void NodeManager::loop() {
// dispacth inbound messages
// dispacth inbound messages
void
NodeManager
::
receive
(
const
MyMessage
&
message
)
{
void
NodeManager
::
receive
(
const
MyMessage
&
message
)
{
#if DEBUG == 1
#if DEBUG == 1
Serial
.
print
(
"RECV S="
);
Serial
.
print
(
F
(
"RECV S="
)
)
;
Serial
.
print
(
message
.
sender
);
Serial
.
print
(
message
.
sender
);
Serial
.
print
(
" I="
);
Serial
.
print
(
F
(
" I="
)
)
;
Serial
.
print
(
message
.
sensor
);
Serial
.
print
(
message
.
sensor
);
Serial
.
print
(
" C="
);
Serial
.
print
(
F
(
" C="
)
)
;
Serial
.
print
(
message
.
getCommand
());
Serial
.
print
(
message
.
getCommand
());
Serial
.
print
(
" T="
);
Serial
.
print
(
F
(
" T="
)
)
;
Serial
.
print
(
message
.
type
);
Serial
.
print
(
message
.
type
);
Serial
.
print
(
" D="
);
Serial
.
print
(
F
(
" D="
)
)
;
Serial
.
println
(
message
.
getString
());
Serial
.
println
(
message
.
getString
());
#endif
#endif
// process incoming service messages
// process incoming service messages
...
@@ -1384,19 +1374,19 @@ void NodeManager::_send(MyMessage & message) {
...
@@ -1384,19 +1374,19 @@ void NodeManager::_send(MyMessage & message) {