GPy Skips LTE Code on First Run

  • I recently got my hands on a GPy for LTE development, and am having a difficult time with the LTE configuration. I am able to get the board attached and connected to the network, but every time I plug in the device and run the code for the first time, it skips all of the AT commands that are sent, and will only execute these after the initial run. This is making me unsure about the reliability of the network connection for the application I plan to use it for.

    Right now I am using some of the example code provided by the LTE example on the Pycom website, as I am unable to find many other projects that use this configuration. The final goal is to read the incoming messages on the sim card, and execute specific responses and functions based on keywords sent to the card.

    Thanks in advance.

    from network import LTE
    import time
    import socket
    lte = LTE()
    def getLTE():
        lte.attach(band=4, apn="MY_APN")
        while not lte.isattached():
            print("not attached.")         # get the System FSM
        print("connecting [##",end='')
        while not lte.isconnected():
            print("not connected.")
        print("] connected!")
        #print(socket.getaddrinfo('', 80))
        print(lte.send_at_cmd('AT+CMEE=1')) # Enable debugging ERROR codes
        print(lte.send_at_cmd('AT+CMGF=1')) # Set modem into TEXT mode (PDU Mode by default)
        lte.send_at_cmd('AT+CPMS="ME","SM","SR"') # Set parameters for send/store sent/store new
        #print(lte.send_at_cmd('AT+CMGL="ALL"')) # List messages that are available
        text = lte.send_at_cmd('AT+CMGR=4') # Read recent message
        text_split = text.split()        # Split AT read into list
        if text_split[3] == "Voltage":   # Check if the message is asking for voltage
            print("Voltage received \n") # Print received message for verification
            # Function will then be executed 
    except Exception:
        pass # do nothing on error

  • @B-Taylor There are always problems with AT commands once you are connected() to LTE.
    To resolve this, execute the AT commands before connecting and seek "data mode" in the modem documentation on how to exit and re-enter data mode.

Log in to reply

Pycom on Twitter