Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sensor System
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Institut für Informatik
QE Research Group
FORTE
Sensor System
Commits
874123df
Commit
874123df
authored
2 years ago
by
Moritz Perschke
Browse files
Options
Downloads
Patches
Plain Diff
fipy now saves peers, uses rtc_time.py
parent
55ec2957
No related branches found
Branches containing commit
No related tags found
Tags containing commit
4 merge requests
!39
Merge Develop into Main
,
!19
development into master
,
!17
Inital Host, initial Client
,
!5
fipy host broadcasts its mac + timestamp on start, main function of client...
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
client/client/src/main.cpp
+3
-1
3 additions, 1 deletion
client/client/src/main.cpp
host/fipy/lib/espnow.py
+15
-11
15 additions, 11 deletions
host/fipy/lib/espnow.py
host/fipy/lib/rtc_time.py
+35
-0
35 additions, 0 deletions
host/fipy/lib/rtc_time.py
host/fipy/main.py
+2
-6
2 additions, 6 deletions
host/fipy/main.py
with
55 additions
and
18 deletions
client/client/src/main.cpp
+
3
−
1
View file @
874123df
...
...
@@ -15,6 +15,8 @@ void setup()
esp_err_t
result
=
espnow_setup
();
esptime
::
rtc
=
ESP32Time
();
StaticJsonDocument
<
96
>
doc
;
doc
[
"sensor"
]
=
"gps"
;
...
...
@@ -42,7 +44,7 @@ void loop()
// resend_message->send();
// delete resend_message;
// }
Serial
.
println
(
"Current Time: "
+
(
String
)
esptime
::
rtc
.
getMillis
());
Serial
.
println
(
esptime
::
rtc
.
getMillis
());
Serial
.
println
(
"delaying..."
);
Serial
.
flush
();
delay
(
5000
);
...
...
This diff is collapsed.
Click to expand it.
host/fipy/lib/espnow.py
+
15
−
11
View file @
874123df
import
network
from
network
import
ESPNOW
import
time
# from lib.rtc_time import RTCTime
from
lib.rtc_time
import
RTCTime
import
struct
w
=
network
.
WLAN
()
self_mac
,
sta
=
w
.
mac
()
peer_list
=
[]
class
Forte_ESPNOW
:
class
Forte_ESPNOW
:
def
__init__
(
self
):
ESPNOW
.
init
()
p
=
ESPNOW
.
add_peer
(
"
58CF7904412C
"
)
# TODO: make management of peers dynamic (line 37)
ESPNOW
.
on_recv
(
espnow_recv
)
def
add_peer
(
mac
):
peer_list
.
append
(
ESPNOW
.
add_peer
(
mac
))
def
espnow_respond
(
mac
):
msg
=
struct
.
pack
(
"
<6sl
"
,
self_mac
,
time
.
time
()
*
1000
)
print
(
time
.
time
()
*
1000
)
msg
=
struct
.
pack
(
"
<6sl
"
,
self_mac
,
time
.
time
())
print
(
int
(
time
.
time
()))
ESPNOW
.
send
(
mac
,
msg
)
print
(
"
response sent
"
)
...
...
@@ -26,15 +29,16 @@ def espnow_recv(result):
data
=
bytes_to_data
(
msg
)
try
:
print
(
data
[
"
amountData
"
])
print
(
data
[
"
timestamp
"
])
print
(
data
[
"
data
"
])
print
(
"
amount data:
"
+
str
(
data
[
"
amountData
"
])
)
#
print(data["timestamp"])
#
print(data["data"])
except
Exception
as
error
:
print
(
error
)
# if(result not in ESPNOW.get_peers()):
# ESPNOW.add_peer(mac)
if
(
peer
not
in
peer_list
):
Forte_ESPNOW
.
add_peer
(
mac
)
espnow_respond
(
mac
)
def
bytes_to_data
(
msg
):
...
...
This diff is collapsed.
Click to expand it.
host/fipy/lib/rtc_time.py
0 → 100644
+
35
−
0
View file @
874123df
from
time
import
sleep
from
machine
import
RTC
class
RTCTime
:
# def __init__(
# self,
# main_ntp_server: str = "pool.ntp.org",
# backup_ntp_server: str = "time.nist.gov",
# update_interval_seconds: int = 3600,
# ):
# self.rtc = RTC()
# self._setup_ntp(main_ntp_server, backup_ntp_server, update_interval_seconds)
def
__init__
(
self
,
datetime
):
self
.
rtc
=
RTC
()
self
.
rtc
.
init
(
datetime
)
def
_setup_ntp
(
self
,
main_ntp_server
:
str
,
backup_ntp_server
:
str
,
update_interval_seconds
:
int
):
print
(
"
Setting up NTP
"
)
self
.
rtc
.
ntp_sync
(
main_ntp_server
,
update_interval_seconds
,
backup_ntp_server
)
while
not
self
.
rtc
.
synced
():
print
(
self
.
rtc
.
synced
())
sleep
(
1
)
def
get_time
(
self
):
return
self
.
rtc
.
now
()
def
is_synchronized
(
self
):
return
self
.
rtc
.
synced
()
This diff is collapsed.
Click to expand it.
host/fipy/main.py
+
2
−
6
View file @
874123df
# main.py -- put your code here!
from
network
import
WLAN
from
pycom
import
rgbled
# from network import ESPNOW
import
binascii
import
struct
from
time
import
sleep
from
lib.server_transfer
import
DataTransferWiFi
from
lib.espnow
import
Forte_ESPNOW
from
lib.rtc_time
import
RTCTime
# data = DataTransferWiFi()
# data.connect("Z", "AbsoluteSandwich")
...
...
@@ -15,9 +12,8 @@ from lib.espnow import Forte_ESPNOW
# )
# data.disconnect()
#
rtc_time
=
RTCTime
((
2014
,
5
,
1
,
4
,
13
,
0
,
0
,
0
))
espnow
=
Forte_ESPNOW
()
w
=
WLAN
()
while
True
:
rgbled
(
0x007f00
)
sleep
(
5
)
pass
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