Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NodeManager_GasSensor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SmartHome
NodeManager_GasSensor
Commits
0328c280
Commit
0328c280
authored
8 years ago
by
user2684
Browse files
Options
Downloads
Patches
Plain Diff
Added MAX_SENSORS to limit the size of _sensors
parent
5788ff2e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
NodeManager.cpp
+5
-5
5 additions, 5 deletions
NodeManager.cpp
NodeManager.h
+19
-16
19 additions, 16 deletions
NodeManager.h
with
24 additions
and
21 deletions
NodeManager.cpp
+
5
−
5
View file @
0328c280
...
...
@@ -2193,7 +2193,7 @@ void NodeManager::before() {
if
(
!
_battery_internal_vcc
&&
_battery_pin
>
-
1
)
analogReference
(
INTERNAL
);
#endif
// setup individual sensors
for
(
int
i
=
0
;
i
<
255
;
i
++
)
{
for
(
int
i
=
0
;
i
<
MAX_SENSORS
;
i
++
)
{
if
(
_sensors
[
i
]
==
0
)
continue
;
// call each sensor's setup()
_sensors
[
i
]
->
before
();
...
...
@@ -2217,7 +2217,7 @@ void NodeManager::presentation() {
_process
(
"BATTERY"
);
#endif
// present each sensor
for
(
int
i
=
0
;
i
<
255
;
i
++
)
{
for
(
int
i
=
0
;
i
<
MAX_SENSORS
;
i
++
)
{
if
(
_sensors
[
i
]
==
0
)
continue
;
// call each sensor's presentation()
if
(
_sleep_between_send
>
0
)
sleep
(
_sleep_between_send
);
...
...
@@ -2242,7 +2242,7 @@ void NodeManager::setup() {
_send
(
_msg
.
set
(
"STARTED"
));
#endif
// run setup for all the registered sensors
for
(
int
i
=
0
;
i
<
255
;
i
++
)
{
for
(
int
i
=
0
;
i
<
MAX_SENSORS
;
i
++
)
{
if
(
_sensors
[
i
]
==
0
)
continue
;
// call each sensor's setup()
_sensors
[
i
]
->
setup
();
...
...
@@ -2261,7 +2261,7 @@ void NodeManager::loop() {
if
(
_auto_power_pins
)
powerOn
();
#endif
// run loop for all the registered sensors
for
(
int
i
=
0
;
i
<
255
;
i
++
)
{
for
(
int
i
=
0
;
i
<
MAX_SENSORS
;
i
++
)
{
// skip not configured sensors
if
(
_sensors
[
i
]
==
0
)
continue
;
// if waking up from an interrupt skip all the sensor without that interrupt configured
...
...
@@ -2609,7 +2609,7 @@ void NodeManager::_present(int child_id, int type) {
// return the next available child_id
int
NodeManager
::
_getAvailableChildId
()
{
for
(
int
i
=
1
;
i
<
255
;
i
++
)
{
for
(
int
i
=
1
;
i
<
MAX_SENSORS
;
i
++
)
{
if
(
i
==
CONFIGURATION_CHILD_ID
)
continue
;
if
(
i
==
BATTERY_CHILD_ID
)
continue
;
// empty place, return it
...
...
This diff is collapsed.
Click to expand it.
NodeManager.h
+
19
−
16
View file @
0328c280
...
...
@@ -51,6 +51,10 @@
/***********************************
Default configuration settings
*/
// if enabled, enable debug messages on serial port
#ifndef DEBUG
#define DEBUG 1
#endif
// if enabled, enable the capability to power on sensors with the arduino's pins to save battery while sleeping
#ifndef POWER_MANAGER
...
...
@@ -69,29 +73,15 @@
#define PERSIST 0
#endif
// if enabled, enable debug messages on serial port
#ifndef DEBUG
#define DEBUG 1
#endif
// if enabled, send a SLEEPING and AWAKE service messages just before entering and just after leaving a sleep cycle
#ifndef SERVICE_MESSAGES
#define SERVICE_MESSAGES
1
#define SERVICE_MESSAGES
0
#endif
// if enabled, a battery sensor will be created at BATTERY_CHILD_ID and will report vcc voltage together with the battery level percentage
#ifndef BATTERY_SENSOR
#define BATTERY_SENSOR 1
#endif
// the child id used to allow remote configuration
#ifndef CONFIGURATION_CHILD_ID
#define CONFIGURATION_CHILD_ID 200
#endif
// the child id used to report the battery voltage to the controller
#ifndef BATTERY_CHILD_ID
#define BATTERY_CHILD_ID 201
#endif
// Enable this module to use one of the following sensors: SENSOR_ANALOG_INPUT, SENSOR_LDR, SENSOR_THERMISTOR, SENSOR_MQ, SENSOR_ACS712
#ifndef MODULE_ANALOG_INPUT
#define MODULE_ANALOG_INPUT 0
...
...
@@ -149,6 +139,19 @@
#define MODULE_MCP9808 0
#endif
// the child id used to allow remote configuration
#ifndef CONFIGURATION_CHILD_ID
#define CONFIGURATION_CHILD_ID 200
#endif
// the child id used to report the battery voltage to the controller
#ifndef BATTERY_CHILD_ID
#define BATTERY_CHILD_ID 201
#endif
// define the maximum number of sensors that can be managed
#ifndef MAX_SENSORS
#define MAX_SENSORS 10
#endif
/***********************************
Sensors types
*/
...
...
@@ -1063,7 +1066,7 @@ class NodeManager {
int
_interrupt_2_pull
=
-
1
;
int
_last_interrupt_pin
=
-
1
;
long
_timestamp
=
-
1
;
Sensor
*
_sensors
[
255
]
=
{
0
};
Sensor
*
_sensors
[
MAX_SENSORS
]
=
{
0
};
bool
_ack
=
false
;
void
_process
(
const
char
*
message
);
void
_sleep
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment