Closed sebi5361 closed 4 years ago
You may try something like:
import cellular
import time
timeout = time.ticks_ms() + 1e4
while time.ticks_ms() < timeout:
try:
cellular.gprs("apn", "user", "pass")
break
except CellularError:
if time.ticks_ms() < timeout:
time.sleep(1)
else:
raise
I added a callback on_status_event(f)
for your convenience. The function you input will be triggered each time the network status changed. You may invent something like
def f(status):
if status == 1:
cellular.on_status_event(None)
cellular.gprs("internet", "", "")
cellular.on_status_event(f)
and it will hopefully work.
Feel free to reopen.
Could you provide an example on how to automatically connect to the APN when booting? I implemented a loop but often it just won't connect forever.