Skip to content

Commit 10cc08c

Browse files
committed
pygate: say hello and wait for ntp
1 parent 2d9be2b commit 10cc08c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

content/tutorials/PyGate.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import machine
5656
from machine import RTC
5757
import pycom
5858

59+
print('\nStarting LoRaWAN concentrator')
5960
# Disable Hearbeat
6061
pycom.heartbeat(False)
6162

@@ -75,19 +76,26 @@ def machine_cb (arg):
7576
# register callback function
7677
machine.callback(trigger = (machine.PYGATE_START_EVT | machine.PYGATE_STOP_EVT | machine.PYGATE_ERROR_EVT), handler=machine_cb)
7778

79+
print('Connecting to WiFi...', end='')
7880
# Connect to a Wifi Network
7981
wlan = WLAN(mode=WLAN.STA)
8082
wlan.connect(ssid='<SSID>', auth=(WLAN.WPA2, "<PASSWORD>"))
8183

8284
while not wlan.isconnected():
85+
print('.', end='')
8386
time.sleep(1)
84-
85-
print("Wifi Connection established")
87+
print(" OK")
8688

8789
# Sync time via NTP server for GW timestamps on Events
90+
print('Syncing RTC via ntp...', end='')
8891
rtc = RTC()
8992
rtc.ntp_sync(server="0.pool.ntp.org")
9093

94+
while not rtc.synced():
95+
print('.', end='')
96+
time.sleep(.5)
97+
print(" OK\n")
98+
9199
# Read the GW config file from Filesystem
92100
fp = open('/flash/config.json','r')
93101
buf = fp.read()

0 commit comments

Comments
 (0)