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
69720349
Commit
69720349
authored
3 years ago
by
LANGLAIS Charlotte
Browse files
Options
Downloads
Patches
Plain Diff
Delete main.py
parent
b7cc456a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
OTAA/main.py
+0
-57
0 additions, 57 deletions
OTAA/main.py
with
0 additions
and
57 deletions
OTAA/main.py
deleted
100644 → 0
+
0
−
57
View file @
b7cc456a
from
network
import
LoRa
import
socket
import
time
import
struct
import
ubinascii
import
pycom
def
connect_to_ttn
(
lora_object
):
"""
Receives a lora object and tries to join
"""
# join a network using OTAA (Over the Air Activation)
lora_object
.
join
(
activation
=
LoRa
.
OTAA
,
auth
=
(
dev_eui
,
app_eui
,
app_key
),
timeout
=
0
,
dr
=
0
)
# wait until the module has joined the network
while
not
lora_object
.
has_joined
():
time
.
sleep
(
5
)
print
(
'
Not yet joined...
'
)
pycom
.
rgbled
(
0x7f7f00
)
#yellow
app_eui
=
ubinascii
.
unhexlify
(
'
0000000000000000
'
)
app_key
=
ubinascii
.
unhexlify
(
'
310A3C251B1397A74E7DAF902DCD9DD0
'
)
#uncomment to use LoRaWAN application provided dev_eui
dev_eui
=
ubinascii
.
unhexlify
(
'
70B3D5499A64CD75
'
)
#for channel in range(0, 72):
#lora.add_channel(channel, frequency=903900000, dr_min=0, dr_max=3)
pycom
.
rgbled
(
0xff0000
)
#red
lora
=
LoRa
(
mode
=
LoRa
.
LORAWAN
,
region
=
LoRa
.
EU868
,
device_class
=
LoRa
.
CLASS_C
)
lora
.
nvram_restore
()
#if there is nothing to restore it will return a False
connect_to_ttn
(
lora
)
print
(
"
CONNECTED!!
"
)
pycom
.
rgbled
(
0x00ff00
)
#green
lora
.
nvram_erase
()
# create a LoRa socket
s
=
socket
.
socket
(
socket
.
AF_LORA
,
socket
.
SOCK_RAW
)
# set the LoRaWAN data rate
s
.
setsockopt
(
socket
.
SOL_LORA
,
socket
.
SO_DR
,
0
)
# make the socket blocking
s
.
setblocking
(
True
)
for
i
in
range
(
20
):
pkt
=
b
'
PKT
'
+
bytes
([
i
])
print
(
'
Sending:
'
,
pkt
)
s
.
send
(
pkt
)
time
.
sleep
(
4
)
rx
,
port
=
s
.
recvfrom
(
256
)
if
rx
:
print
(
'
Received: {}, on port: {}
'
.
format
(
rx
,
port
))
time
.
sleep
(
6
)
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