if lte.is attached() makes it think it's not
-
I can run this program repeatedly & it works OK
import time, pycom, machine import urequests as requests from network import LTE lte = LTE() pycom.heartbeat(False) def getLTE(): if lte.isconnected(): return lte if not lte.isattached(): print('attaching ', end=''); lte.attach() while not lte.isattached(): print('.', end=''); time.sleep(1) if not lte.isconnected(): print('connnecting ', end=''); lte.connect() while not lte.isconnected(): print('.', end=''); time.sleep(1) return lte getLTE() r=requests.get('http://micropython.org/ks/test.html'); print(r.text) lte.disconnect()But if I add one extra line to check the modem is still attached
import time, pycom, machine import urequests as requests from network import LTE lte = LTE(); rtc = RTC() pycom.heartbeat(False) def getLTE(): if lte.isconnected(): return lte if not lte.isattached(): print('attaching ', end=''); lte.attach() while not lte.isattached(): print('.', end=''); time.sleep(1) if not lte.isconnected(): print('connnecting ', end=''); lte.connect() while not lte.isconnected(): print('.', end=''); time.sleep(1) return lte getLTE() r=requests.get('http://micropython.org/ks/test.html'); print(r.text) if lte.isattached(): pycom.rgbled(0x007f00) lte.disconnect()it won't run a second time. On the second run it behaves like it thinks it's not attached. It looks like asking if it's attached makes it think it's not?!
attaching Traceback (most recent call last): File "<stdin>", line 18, in <module> File "<stdin>", line 11, in getLTE OSError: the requested operation failed
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login