Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICBM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
detectors
DSSC
ICBM
Commits
cf7969fc
Commit
cf7969fc
authored
1 month ago
by
Cyril Danilevski
Browse files
Options
Downloads
Patches
Plain Diff
Add setChannelAndWait
parent
a089192e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mpod.cpp
+23
-0
23 additions, 0 deletions
mpod.cpp
mpod.hpp
+1
-0
1 addition, 0 deletions
mpod.hpp
rest.cpp
+11
-14
11 additions, 14 deletions
rest.cpp
with
35 additions
and
14 deletions
mpod.cpp
+
23
−
0
View file @
cf7969fc
...
@@ -190,3 +190,26 @@ void initializeSNMP() {
...
@@ -190,3 +190,26 @@ void initializeSNMP() {
snmp
.
onMessage
(
onMessage
);
snmp
.
onMessage
(
onMessage
);
Serial
.
println
(
"SNMP Server Started"
);
Serial
.
println
(
"SNMP Server Started"
);
}
}
/* setChannelAndWait
* Set a channel's parameters and wait until it's settled.
*/
void
setChannelAndWait
(
IPAddress
*
ipAddr
,
uint16_t
channel
,
uint8_t
output
)
{
// Send set command
SNMP
::
Message
*
snmp_msg
=
mpod
.
output
(
channel
,
output
);
snmp
.
send
(
snmp_msg
,
*
ipAddr
,
SNMP
::
Port
::
SNMP
);
delete
snmp_msg
;
// wait for channel reply
delay
(
MPOD_UPDATE_LATENCY
);
snmp
.
loop
();
// Poll channel until it's settled
do
{
SNMP
::
Message
*
snmp_msg
=
mpod
.
read
(
channel
);
snmp
.
send
(
snmp_msg
,
*
ipAddr
,
SNMP
::
Port
::
SNMP
);
delete
snmp_msg
;
delay
(
MPOD_UPDATE_LATENCY
);
snmp
.
loop
();
}
while
(
mpod
.
isOn
()
!=
(
bool
)
output
||
mpod
.
isRampingDown
()
||
mpod
.
isRampingUp
());
}
This diff is collapsed.
Click to expand it.
mpod.hpp
+
1
−
0
View file @
cf7969fc
...
@@ -95,4 +95,5 @@ extern MPOD mpod;
...
@@ -95,4 +95,5 @@ extern MPOD mpod;
// Event handler to process SNMP messages
// Event handler to process SNMP messages
void
onSNMPMessage
(
const
SNMP
::
Message
*
message
,
const
IPAddress
remote
,
const
uint16_t
port
);
void
onSNMPMessage
(
const
SNMP
::
Message
*
message
,
const
IPAddress
remote
,
const
uint16_t
port
);
void
initializeSNMP
();
void
initializeSNMP
();
void
setChannelAndWait
(
IPAddress
*
,
uint16_t
,
uint8_t
);
This diff is collapsed.
Click to expand it.
rest.cpp
+
11
−
14
View file @
cf7969fc
...
@@ -117,9 +117,9 @@ void restart() {
...
@@ -117,9 +117,9 @@ void restart() {
}
}
enum
{
enum
{
OFF
,
OFF
=
0
,
ON
,
ON
=
1
,
NONE
,
NONE
=
-
1
,
};
};
void
sendSNMP
()
{
void
sendSNMP
()
{
...
@@ -140,17 +140,10 @@ void sendSNMP() {
...
@@ -140,17 +140,10 @@ void sendSNMP() {
}
}
auto
ipAddr
=
IPAddress
(
192
,
168
,
140
,
79
);
auto
ipAddr
=
IPAddress
(
192
,
168
,
140
,
79
);
if
(
output
!=
NONE
&&
channel
!=
0
)
{
SNMP
::
Message
*
snmp_msg
=
mpod
.
output
(
channel
,
output
);
snmp
.
send
(
snmp_msg
,
ipAddr
,
SNMP
::
Port
::
SNMP
);
delete
snmp_msg
;
success
=
true
;
}
if
(
success
)
{
if
(
output
!=
NONE
&&
channel
!=
0
)
{
SNMP
::
Message
*
snmp_msg
=
mpod
.
read
(
channel
);
setChannelAndWait
(
&
ipAddr
,
channel
,
output
);
snmp
.
send
(
snmp_msg
,
ipAddr
,
SNMP
::
Port
::
SNMP
);
success
=
true
;
// validates input parameters, not MPOD status, reported separately
delete
snmp_msg
;
}
}
String
http_msg
=
"{
\n
"
;
String
http_msg
=
"{
\n
"
;
...
@@ -186,7 +179,11 @@ void pollMPODChannel() {
...
@@ -186,7 +179,11 @@ void pollMPODChannel() {
SNMP
::
Message
*
snmp_msg
=
mpod
.
read
(
channel
);
SNMP
::
Message
*
snmp_msg
=
mpod
.
read
(
channel
);
snmp
.
send
(
snmp_msg
,
ipAddr
,
SNMP
::
Port
::
SNMP
);
snmp
.
send
(
snmp_msg
,
ipAddr
,
SNMP
::
Port
::
SNMP
);
delete
snmp_msg
;
delete
snmp_msg
;
ret
=
mpod
.
toJSON
();
// TODO: This has stale info at this stage!
delay
(
MPOD_UPDATE_LATENCY
);
snmp
.
loop
();
// Force loop to update now
ret
=
mpod
.
toJSON
();
}
}
String
http_msg
=
"{
\n
"
;
String
http_msg
=
"{
\n
"
;
...
...
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