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
1c472fde
Commit
1c472fde
authored
2 weeks ago
by
Cyril Danilevski
Browse files
Options
Downloads
Patches
Plain Diff
Fix JSON result on invalid channel
parent
c8cde2a0
No related branches found
No related tags found
1 merge request
!5
Perform power down sequence from port expander trigger
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mpod.cpp
+0
-3
0 additions, 3 deletions
mpod.cpp
mpod.hpp
+4
-4
4 additions, 4 deletions
mpod.hpp
rest.cpp
+12
-11
12 additions, 11 deletions
rest.cpp
with
16 additions
and
18 deletions
mpod.cpp
+
0
−
3
View file @
1c472fde
...
...
@@ -105,9 +105,6 @@ bool MPOD::message(const SNMP::Message *message) {
found
++
;
break
;
case
OID
::
OUTPUTSWITCH
:
// Use private helper function to extract integer value
Serial
.
print
(
"Output Switch Length: "
);
Serial
.
println
(
varbind
->
getLength
());
_on
=
getIntegerFromVarBind
(
varbind
);
found
++
;
break
;
...
...
This diff is collapsed.
Click to expand it.
mpod.hpp
+
4
−
4
View file @
1c472fde
...
...
@@ -34,7 +34,7 @@ class MPOD {
UNKNOWN
,
COUNT
=
UNKNOWN
,
};
static
inline
const
char
*
NAMES
[]
=
{
// These are incomplete SNMP commands needing to be
// formatted with the channel id after the final dot
...
...
@@ -46,7 +46,7 @@ class MPOD {
"1.3.6.1.4.1.19947.1.3.2.1.12."
,
"1.3.6.1.4.1.19947.1.3.2.1.13."
,
};
// Returns index of OID equals to name
// Returns UNKNOWN if none
static
unsigned
int
match
(
const
char
*
name
)
{
...
...
@@ -58,8 +58,8 @@ class MPOD {
return
UNKNOWN
;
}
};
MPOD
();
MPOD
();
SNMP
::
Message
*
read
(
const
uint16_t
);
SNMP
::
Message
*
setChannelState
(
const
uint16_t
,
const
bool
);
SNMP
::
Message
*
setTargetVoltage
(
const
uint16_t
,
const
float
);
...
...
This diff is collapsed.
Click to expand it.
rest.cpp
+
12
−
11
View file @
1c472fde
...
...
@@ -274,10 +274,9 @@ void pollMPODChannel() {
}
}
String
ret
;
if
(
!
channel
)
{
ret
=
"
\"
reason
\"
:
\"
Invalid channel
\"
"
;
}
else
{
String
ret
=
"
\"
Invalid channel
\"
"
;
if
(
channel
)
{
SNMP
::
Message
*
snmp_msg
=
mpod
.
read
(
channel
);
snmp
.
send
(
snmp_msg
,
pproc
.
ipAddr
,
SNMP
::
Port
::
SNMP
);
delete
snmp_msg
;
...
...
@@ -285,20 +284,22 @@ void pollMPODChannel() {
delay
(
MPOD_UPDATE_LATENCY
);
snmp
.
loop
();
// Force loop to update now
if
(
mpod
.
getChannel
())
{
if
(
mpod
.
getChannel
())
{
// Valid channel requested
ret
=
mpod
.
toJSON
();
}
else
{
ret
=
"
\"
reason
\"
:
\"
Invalid channel
\"
"
;
channel
=
0
;
}
}
String
http_msg
=
"{
\n
"
;
http_msg
+=
"
\"
success
\"
: "
;
http_msg
+=
channel
?
1
:
0
;
http_msg
+=
",
\n
"
;
http_msg
+=
"
\"
arguments
\"
: {"
;
http_msg
+=
"
\"
channel
\"
: "
;
http_msg
+=
channel
;
http_msg
+=
"},
\n
"
;
// arguments
http_msg
+=
"
\"
status
\"
: "
;
http_msg
+=
ret
;
http_msg
+=
",
\"
success
\"
: "
;
http_msg
+=
channel
?
1
:
0
;
http_msg
+=
"
\n
}"
;
http_msg
+=
"}"
;
restServer
.
send
(
channel
?
200
:
406
,
"text/json"
,
http_msg
);
}
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