pulkin / micropython

MicroPython implementation on Ai-Thinker GPRS module A9 (RDA8955)
https://micropython.org
MIT License
103 stars 30 forks source link

"CellularError: Network is not available" when function is called from main.py #42

Closed BeLikeSohan closed 4 years ago

BeLikeSohan commented 4 years ago

Trying to autostart my code when the board starts or resets. Looks like main.py is executed before the actual board is ready. I can't find any example or docs for how to make the code autostart.

pulkin commented 4 years ago

Duplicate of #38. The board is ready but your network is not available yet. It may happen both when starting up but also during normal operation when you leave cellular coverage, for example. Right now I suggest to check is_network_registered during startup and to start connecting to GPRS data services only once it returns True.

pulkin commented 4 years ago

I added a callback on_status_event(f): f will be triggered each time network status changes (connect/disconnect, gprs, SIM card inserted, etc). That might be helpful for you.

pulkin commented 4 years ago

Feel free to reopen.