Skip to content
Snippets Groups Projects
Commit 4ce2fef6 authored by LANGLAIS Charlotte's avatar LANGLAIS Charlotte
Browse files

Update main_template.py

parent 4f283738
No related branches found
No related tags found
No related merge requests found
......@@ -11,10 +11,12 @@ def connect_to_ttn(lora_object):
# choose dr = 0 if the gateway is not close to your device, try different dr if needed
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
pycom.rgbled(0x7f7f00) #yellow
while not lora_object.has_joined():
time.sleep(5)
time.sleep(2.5)
print('Not yet joined...')
pycom.rgbled(0x7f7f00) #yellow
lora.nvram_erase()
pycom.heartbeat(False)
......@@ -24,6 +26,7 @@ app_key = ubinascii.unhexlify('--------------------------------') # replace the
dev_eui = ubinascii.unhexlify('----------------') # replace the dash by the DevEUI provided to TTN
pycom.rgbled(0xff0000) #red
time.sleep(1)
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
......@@ -32,7 +35,7 @@ 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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment