Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Projects
Groups
Snippets
Sign up now
Login
Sign in
Toggle navigation
Menu
Open sidebar
SmartHome
NodeManager_BME280_EasyPCB
Commits
6864f0bf
Commit
6864f0bf
authored
Apr 12, 2017
by
user2684
Browse files
Add option to send ack #69
parent
33eab368
Changes
3
Hide whitespace changes
Inline
Side-by-side
NodeManager.cpp
View file @
6864f0bf
...
...
@@ -126,6 +126,9 @@ int Sensor::getType() {
void
Sensor
::
setDescription
(
char
*
value
)
{
_description
=
value
;
}
void
Sensor
::
setAck
(
bool
value
)
{
_ack
=
value
;
}
void
Sensor
::
setRetries
(
int
value
)
{
_retries
=
value
;
}
...
...
@@ -173,7 +176,7 @@ void Sensor::presentation() {
Serial
.
print
(
F
(
" T="
));
Serial
.
println
(
_presentation
);
#endif
present
(
_child_id
,
_presentation
,
_description
);
present
(
_child_id
,
_presentation
,
_description
,
_ack
);
}
// call the sensor-specific implementation of before
...
...
@@ -283,7 +286,7 @@ void Sensor::_send(MyMessage & message) {
Serial
.
print
(
F
(
" F="
));
Serial
.
println
(
message
.
getFloat
());
#endif
send
(
message
);
send
(
message
,
_ack
);
}
}
...
...
@@ -1447,6 +1450,9 @@ void NodeManager::setInterrupt(int pin, int mode, int pull) {
void
NodeManager
::
setSleepBetweenSend
(
int
value
)
{
_sleep_between_send
=
value
;
}
void
NodeManager
::
setAck
(
bool
value
)
{
_ack
=
value
;
}
// register a sensor to this manager
int
NodeManager
::
registerSensor
(
int
sensor_type
,
int
pin
,
int
child_id
)
{
...
...
@@ -1701,22 +1707,10 @@ void NodeManager::presentation() {
// Send the sketch version information to the gateway and Controller
sendSketchInfo
(
SKETCH_NAME
,
SKETCH_VERSION
);
// present the service as a custom sensor to the controller
#if DEBUG == 1
Serial
.
print
(
F
(
"PRES I="
));
Serial
.
print
(
CONFIGURATION_CHILD_ID
);
Serial
.
print
(
F
(
", T="
));
Serial
.
println
(
S_CUSTOM
);
#endif
present
(
CONFIGURATION_CHILD_ID
,
S_CUSTOM
);
_present
(
CONFIGURATION_CHILD_ID
,
S_CUSTOM
);
#if BATTERY_MANAGER == 1 && BATTERY_SENSOR == 1
#if DEBUG == 1
Serial
.
print
(
F
(
"PRES I="
));
Serial
.
print
(
BATTERY_CHILD_ID
);
Serial
.
print
(
F
(
", T="
));
Serial
.
println
(
S_MULTIMETER
);
#endif
// present the battery service
present
(
BATTERY_CHILD_ID
,
S_MULTIMETER
);
_
present
(
BATTERY_CHILD_ID
,
S_MULTIMETER
);
// report battery level
_process
(
"BATTERY"
);
#endif
...
...
@@ -1832,7 +1826,7 @@ void NodeManager::_send(MyMessage & message) {
Serial
.
print
(
F
(
" F="
));
Serial
.
println
(
message
.
getFloat
());
#endif
send
(
message
);
send
(
message
,
_ack
);
}
}
...
...
@@ -2068,6 +2062,16 @@ void NodeManager::_sleep() {
}
#endif
// present the service
void
NodeManager
::
_present
(
int
child_id
,
int
type
)
{
#if DEBUG == 1
Serial
.
print
(
F
(
"PRES I="
));
Serial
.
print
(
child_id
);
Serial
.
print
(
F
(
", T="
));
Serial
.
println
(
type
);
#endif
present
(
child_id
,
type
,
""
,
_ack
);
}
// return the next available child_id
int
NodeManager
::
_getAvailableChildId
()
{
...
...
NodeManager.h
View file @
6864f0bf
...
...
@@ -278,6 +278,8 @@ class Sensor {
int
getType
();
// description of the sensor (default: '')
void
setDescription
(
char
*
value
);
// set this to true if you want destination node to send ack back to this node (default: false)
void
setAck
(
bool
value
);
// when queried, send the message multiple times (default: 1)
void
setRetries
(
int
value
);
// For some sensors, the measurement can be queried multiple times and an average is returned (default: 1)
...
...
@@ -323,6 +325,7 @@ class Sensor {
int
_presentation
=
S_CUSTOM
;
int
_type
=
V_CUSTOM
;
char
*
_description
=
""
;
bool
_ack
=
false
;
int
_retries
=
1
;
int
_samples
=
1
;
int
_samples_interval
=
0
;
...
...
@@ -781,6 +784,8 @@ class NodeManager {
// manually turn the power off
void
powerOff
();
#endif
// set this to true if you want destination node to send ack back to this node (default: false)
void
setAck
(
bool
value
);
// hook into the main sketch functions
void
before
();
void
presentation
();
...
...
@@ -820,8 +825,10 @@ class NodeManager {
int
_interrupt_2_pull
=
-
1
;
int
_reboot_pin
=
-
1
;
Sensor
*
_sensors
[
255
]
=
{
0
};
bool
_ack
=
false
;
void
_process
(
const
char
*
message
);
void
_sleep
();
void
_present
(
int
child_id
,
int
type
);
int
_getAvailableChildId
();
int
_getInterruptInitialValue
(
int
mode
);
};
...
...
README.md
View file @
6864f0bf
...
...
@@ -173,6 +173,8 @@ Node Manager comes with a reasonable default configuration. If you want/need to
// manually turn the power off
void
powerOff
();
#endif
// set this to true if you want destination node to send ack back to this node (default: false)
void
setAck
(
bool
value
);
~~~
For example
...
...
@@ -260,6 +262,8 @@ The following methods are available for all the sensors:
void
setType
(
int
value
);
// description of the sensor (default: '')
void
setDescription
(
char
*
value
);
// set this to true if you want destination node to send ack back to this node (default: false)
void
setAck
(
bool
value
);
// when queried, send the message multiple times (default: 1)
void
setRetries
(
int
value
);
// For some sensors, the measurement can be queried multiple times and an average is returned (default: 1)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment