Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iotlab4
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
zhengxu3
iotlab4
Commits
0c3966d1
Commit
0c3966d1
authored
2 years ago
by
yangsen2
Browse files
Options
Downloads
Patches
Plain Diff
f
parent
0ff08b69
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
create-device-folder.py
+0
-9
0 additions, 9 deletions
create-device-folder.py
process_emission.py
+42
-0
42 additions, 0 deletions
process_emission.py
with
42 additions
and
9 deletions
create-device-folder.py
deleted
100644 → 0
+
0
−
9
View file @
0ff08b69
import
os
root_folder
=
"
./certificates
"
for
i
in
range
(
5
):
folder_name
=
f
"
device_
{
i
}
"
folder_path
=
os
.
path
.
join
(
root_folder
,
folder_name
)
os
.
makedirs
(
folder_path
,
exist_ok
=
True
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
process_emission.py
0 → 100644
+
42
−
0
View file @
0c3966d1
import
json
import
logging
import
sys
import
platform
from
threading
import
Timer
import
greengrasssdk
# Logging
logger
=
logging
.
getLogger
(
__name__
)
logging
.
basicConfig
(
stream
=
sys
.
stdout
,
level
=
logging
.
DEBUG
)
# SDK Client
client
=
greengrasssdk
.
client
(
"
iot-data
"
)
# Counter
max_co2_vals
=
[
0
]
*
5
def
lambda_handler
(
event
,
context
):
global
max_co2_vals
# Get your data
co2_val
,
time_stamp
,
vehicle
=
event
[
'
message
'
],
event
[
'
time_stamp
'
],
event
[
'
vehicle
'
]
# Update max CO2 value
vehicle_index
=
int
(
vehicle
)
max_co2_vals
[
vehicle_index
]
=
max
(
co2_val
,
max_co2_vals
[
vehicle_index
])
# Publish result
client
.
publish
(
topic
=
"
iot/vehicle
"
,
queueFullPolicy
=
"
AllOrException
"
,
payload
=
json
.
dumps
({
"
co2
"
:
co2_val
,
"
max_co2
"
:
max_co2_vals
[
vehicle_index
],
"
time_stamp
"
:
time_stamp
,
"
vehicle
"
:
vehicle
}),
)
return
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