Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TP lora COOC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Monitor
Incidents
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LANGLAIS Charlotte
TP lora COOC
Commits
a6273c9f
Commit
a6273c9f
authored
1 year ago
by
LANGLAIS Charlotte
Browse files
Options
Downloads
Patches
Plain Diff
new file: PingPong/main.py
parent
20971d8c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
PingPong/main.py
+41
-0
41 additions, 0 deletions
PingPong/main.py
with
41 additions
and
0 deletions
PingPong/main.py
0 → 100644
+
41
−
0
View file @
a6273c9f
# main.py -- put your code here!
from
network
import
LoRa
import
socket
import
time
# Please pick the region that matches where you are using the device
lora
=
LoRa
(
mode
=
LoRa
.
LORA
,
region
=
LoRa
.
EU868
)
print
(
'
Coding rate {}
'
.
format
(
lora
.
coding_rate
()))
#lora.sf(12)
print
(
'
SF {}
'
.
format
(
lora
.
sf
()))
s
=
socket
.
socket
(
socket
.
AF_LORA
,
socket
.
SOCK_RAW
)
s
.
setblocking
(
False
)
# Code pour le Pong ; réception puis émission
i
=
0
while
True
:
if
s
.
recv
(
64
)
==
b
'
Ping
'
:
print
(
'
je recois Ping du Node A
'
)
print
(
lora
.
stats
())
#print(lora.coding_rate())
s
.
send
(
'
Pong
'
)
print
(
'
Pong {}
'
.
format
(
i
))
i
=
i
+
1
time
.
sleep
(
5
)
# Code pour le Ping ; uniquement émission
# msg = 'Ping'
# #msg = 'Ping hello i m devui' + (ubinascii.hexlify(lora.mac()).decode('ascii'))
# #print(msg)
# i = 0
# while True:
# s.send(msg)
# print('Ping {}'.format(i))
# print(lora.stats())
# i= i+1
# time.sleep(5)
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