LTE driver appears to be stopped?
-
Hello everyone,
I'm currently trying to connect to an LTE CAT M1 network.
However, I'm seeing some things that I think aren't quite correct, and I'm not sure what to do.Here is the code I'm using to attempt to connect:
from network import LTE import pycom import machine import time lte = LTE() def pretty(cmd): print(cmd) response = lte.send_at_cmd(cmd).split('\r\n') for line in response: if line != '': print(line) print("Test") pycom.heartbeat(False) pycom.rgbled(0xFF0000) if not lte.isattached(): lte.attach() while (not lte.isattached()): print("Attaching to LTE... ") pycom.rgbled(0xFF0000) pretty('AT!="showphy"') time.sleep(5) pycom.rgbled(0x000000) pretty('AT!="fsm"') time.sleep(5) if not lte.isconnected(): lte.connect() while not (lte.isconnected()): print("Connecting...") time.sleep(1) pycom.rgbled(0x00FF00) time.sleep(0.5) pycom.rgbled(0x000000)It doesn't even get past the attaching phase.
This is the output of the FSM AT command:SYSTEM FSM ========== +--------------------------+--------------------+ | FSM | STATE | +--------------------------+--------------------+ | RRC TOP FSM |STOPPED | | RRC SEARCH FSM |NULL | | RRC ACTIVE FSM |NULL | | PMM PLMN FSM |NULL | | EMM MAIN FSM |NULL | | EMM AUTH FSM |NULL | | EMM CONN FSM |NULL | | EMM TAU FSM |NULL | | EMM TEST FSM |NULL | | ESM BEARER FSM |BEARER_NULL | | SMS MT FSM |IDLE | | SMS MO FSM |IDLE | | HP MAIN FSM |NULL | | HP USIM FSM |NULL | | HP SMS MO FSM |IDLE | | HP SMS MT FSM |IDLE | | HP CAT FSM |NULL | +--------------------------+--------------------+Here is the output of the 'showphy' AT command:
DL SYNCHRO STATISTICS ===================== Synchro state : OFF PPU SIB1 ACQ watchdog : 0 Frequency Hypothesis RF (Hz) : 0 RSRP (dBm) : 0.00 RSRQ (dB) : 0.00 Channel estimation state (Cell-spec.) : LOW CINR Channel estimation state (UE-spec.) : LOW CINR Channel estimation state (MBSFN) : LOW CINR Channel estimation CINR : 0.00 Channel length : SHORT AGC AGC RX gain (dB) : 0.00 RX PSD BO (dBFs) : 0.00 RX PSD (dBm) : 0.00 Noise level RS (dBm) : 0.00 Digital gain (dB) : 0.00 CINR RS (dB) : 0.00 NARROWBANDS Last DL NB : 0 Last UL NB : 0 AFC Frequency offset RF (Hz) : 0 Frequency offset BB (Hz) : 0 PBCH MIB received quantity : 0 MIB timeout quantity : 0 OKI should note I have entered AT commands in the past before taking a simpler approach, such as "AT!=clearscanconfig". Is this command persistant after resetting the device?
I've also updated the LTE driver as described in https://docs.pycom.io/tutorials/lte/firmware.html
-
This example may help.
import pycom import socket import ssl import sys import time from network import LTE from utime import sleep_ms BLACK = 0x000000 WHITE = 0xFFFFFF RED = 0xFF0000 GREEN = 0x00FF00 BLUE = 0x0000FF YELLOW = 0xFFFF00 lte = None # send AT command to modem and return response as list def at(cmd): global lte print("modem command: {}".format(cmd)) r = lte.send_at_cmd(cmd).split('\r\n') r = list(filter(None, r)) print("response={}".format(r)) return r # blink LED def blink(rgb, n): for i in range(n): pycom.rgbled(rgb) time.sleep(0.25) pycom.rgbled(BLACK) time.sleep(0.1) # run test def run(): global lte print("GPy CAT M1 Test - V0.6 - 2/26/19") try: print("disable MicroPython control of LED") pycom.heartbeat(False) pycom.rgbled(WHITE) print("instantiate LTE object") lte = LTE() print("reset modem...") lte.reset() # resolves issue of iccid() not working after reset() LTE.reconnect_uart() lte.init() sleep_ms(1500) # 750 works iccid = lte.iccid() carrier = iccid[0:5] print("iccid = {0}".format(iccid)) imei = lte.imei() print("imei = {0}".format(imei)) apnx = "10569.mcs" # apn based on SIM card used lte.attach(apn=apnx) while not lte.isattached(): print("waiting for attach...") blink(RED, 1) print("connect: start a data session and obtain an IP address") lte.connect() while not lte.isconnected(): print("waiting for connection...") blink(GREEN, 1) print("connected!!!") pycom.rgbled(BLUE) print("read first 16 bytes of www.google.com site") s = socket.socket() # must be called only if connecting to secure site s = ssl.wrap_socket(s) print("get www.google.com address") addr = socket.getaddrinfo('www.google.com', 443) print(addr) print("connect to {}".format(addr[0][-1])) s.connect(addr[0][-1]) print("GET 16 bytes from google") s.send(b"GET / HTTP/1.0\r\n\r\n") print(s.recv(16)) # receive 16 bytes print("close socket") s.close() lte.disconnect() pycom.rgbled(BLACK) print("end of test") except Exception as ex: sys.print_exception(ex) -
Sadly, that didn't seem to change anything. I'm not sure why, but the synchro state continues to be OFF, and all other values remain 0, as if nothing has been initialized:
DL SYNCHRO STATISTICS ===================== Synchro state : OFF PPU SIB1 ACQ watchdog : 0 Frequency Hypothesis RF (Hz) : 0 RSRP (dBm) : 0.00 RSRQ (dB) : 0.00 Channel estimation state (Cell-spec.) : LOW CINR Channel estimation state (UE-spec.) : LOW CINR Channel estimation state (MBSFN) : LOW CINR Channel estimation CINR : 0.00 Channel length : SHORT AGC AGC RX gain (dB) : 0.00 RX PSD BO (dBFs) : 0.00 RX PSD (dBm) : 0.00 Noise level RS (dBm) : 0.00 Digital gain (dB) : 0.00 CINR RS (dB) : 0.00 NARROWBANDS Last DL NB : 0 Last UL NB : 0 AFC Frequency offset RF (Hz) : 0 Frequency offset BB (Hz) : 0 PBCH MIB received quantity : 0 MIB timeout quantity : 0 OKFurthermore, 'AT+COPS=?' returns an ERROR. Which I find weird considering that I did upgrade the modem firmware. I'm not sure what is going on here.
-
Have you added an APN to the attach method call?
apnx = "10569.mcs" # apn based on SIM card used
lte.attach(apn=apnx) -
I managed to get it working. Thank you for your responses, @tlanier.
Is it true the RTS and CTS jumpers on the Pymakr board can make a difference in the modem functioning? I had connected them before, a colleague suggested taking them off.
Here is the initialization code:
print("init lte") lte.init() print("reset lte") lte.reset() pretty('AT^RESET') time.sleep(5) pretty('AT+CFUN=0') pretty('AT!="clearscanconfig"') pretty('AT!="addscanfreq band=20 dl-earfcn=6400"') pretty('AT+CGDCONT=1, "IP", "ltem.internet.m2m"') pretty('AT+CFUN=1') pretty('AT+CEREG?') pretty('AT+COPS=?') -
@recurracy If you mean Expansion board - yes, RTS and CTS jumpers must be removed for modem communication.
https://docs.pycom.io/gettingstarted/connection/fipy.html
When using the expansion board with a FiPy, you will need to remove the CTS and RTS jumpers as these interfere with communication with the cellular modem.
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