Are there any diagnostics to be had out of the gpy re lte attachment after a deepsleep? I generally get attachment after 1 or 2 seconds but occasionally (a few times per day) it hasn't happened after 30 & I'm curious to find out why. These intervals, where there is no attachment after the 30s timeout I've allowed can persist for an hour or two so I'd like to get to the bottom of it.
import network, machine wdt=machine.WDT(timeout 60000) #allow 60s per deepsleep cycle if 'lte' not in globals(): lte=network.lte() #new modem instance if previous is gone cause=machine.reset_cause() #check if previous cycle ended via watchdog if cause==2: lte.send_at_cmd('AT^RESET') #reset the modem if it did
I haven't tried LTE with deepsleep yet but am planning on doing. Could you share any code on your modem resetting logic?
Interesting discovery should anyone stumble in here. If I reset the modem every deepsleep cycle attachments take 3-4s but if I reset the modem only after there has been a wdt event then attachment drops to 1s. NB: This requires a bit of effort. Since wdt timeouts generally prevent the disconnect/dettach/deinnit from the end of the previous deepsleep cycle, I need check if lte is in globals then setup a new lte=network.LTE() if it isn't, then send the modem the reset cmd.
But modem reset seems a great cure all. Not only does it fix reluctance to attach (which I think happens when the modem is actually attached but thinks it's not) but it also fixes urequest OSErrors, which surprised me somewhat.