Read ICCID Not Working



  • We have just finished our design and PCB layout using the GPy. Everything was working great. I decided to upgrade the modem firmware to 41065. We're running release candidate v1.20.0.rc9. Now the lte.iccid() command is no longer working after a modem reset and init. If you attach to the cell network, the iccid() command then works. In our design we use the ICCID returned value to determine the proper APN to use in the attach command. Now we can't read the ICCID until we properly attach. Below is the sequence that doesn't work. I've also tried just querying the modem with the AT+SQNCCID? command, but that returns a null string until the modem is attached.

    Does anyone have any ideas how to read the SIM's ICCID value before attaching? This used to work.

    from network import LTE
    lte = LTE()
    lte.reset()
    LTE.reconnect_uart()    #in the past this command would fix problem, now it doesn't
    lte.init()
    lte.iccid()    # does not work!
    lte.send_at_cmd('AT+SQNCCID?')   # this returns null string for ICCID
    lte.attach(apn='10569.mcs')
    lte.iccid()    # now it works!
    


  • We have now discovered that even sending the "AT+CFUN=4" does not solve the problem. Yesterday we had a GPy stuck in a mode where it would not return the ICCID even after power on/off, modem reset command, and the AT+CFUN=4 command. The only thing that resolved the issue was to send a dummy attach command lte.attach(apn='unknown'). Then the lte.iccid() command worked from that point forward (even through power on/off and resets). We do not know what causes the GPy to get in this crazy mode; however, it seems to be related to low signal situations.



  • @robert-hh On push button reset it works like you said; however, if you call the lte.reset() the lte.iccid() no longer works.

    I'm now trying to decide should we do an modem.at('AT+CFUN=4') or modem.at('AT+CFUN=1')?

    1 - full functionality, enable SIM card
    4 - disable phone both transmit and receive RF circuits, enable SIM card

    Is there a downside to setting the functionality to "1 - full" always? I really don't care about power usage, but I do care about best connectivity at all times.



  • @tlanier I do not have this issue. I can run the following commands below after power on or reset:

    Pycom MicroPython 1.20.0.rc13 [43fa900-dirty] on 2019-09-07; FiPy with ESP32
    Type "help()" for more information.
    >>> from network import LTE
    >>> lte=LTE()
    >>> lte.iccid()
    '89882806660000016750'
    >>> lte.send_at_cmd('AT+SQNCCID?')
    '\r\n+SQNCCID: "89882806660000016750",""\r\n\r\nOK\r\n'
    


  • We have today discovered a better method to solve the problem where the lte.iccid() does not return the iccid after a modem reset. Rather that do the dummy lte.attach(apn='unknown'), doing the following works. Apparently the lte.init() command does not always properly enable the SIM card.

    Executing an "AT+CFUN=4" after the modem reset solves the problem!

    #####################################################################
    #                           Reset Modem
    #####################################################################
    def reset_modem():
        global lte
    
        g.modem_state = g.MS_RESET_MODEM
        log("reset modem...")
    
        if lte == None:
            try:
                lte = LTE()
            except Exception as ex:
                sys.print_exception(ex)
                util.reset(27, "LTE exception")
    
        sleep_ms(0)
        lte.reset()
        sleep_ms(0)
        at('AT+CFUN=4')     # enable SIM card
    


  • Below is the revised code that now works. I'm going to repost this in a more appropriate location on forum in hopes that the problem may be seen by someone who can fix it.

    from network import LTE
    lte = LTE()
    lte.reset()
    lte.init()
    sleep_ms(1500)
    iccid = lte.iccid()    # does not work
    lte.attach(apn='unknown')    # attempt attach so iccid() will work
    sleep_ms(1500)
    iccid = lte.iccid()    # iccid() now works
    lte.detach(reset=False)
    # compute apn from iccid
    lte.attach(apn=computed_apn)    # attach  with correct apn
    


  • Regrettably, I see I've posted the message to the wrong section of the forum.

    I have discovered a workaround to the problem.

    By adding a dummy call to the attach function, I can resolve my problem.

    Revised code below:

    from network import LTE
    lte = LTE()
    lte.reset()
    lte.init()
    sleep_ms(1500)    # not sure why delay is needed
    lte.attach(apn='unknown')    # this will fail since apn is invalid
    sleep_ms(1500)    # not sure why delay is needed
    iccid = lte.iccid()    # iccid now works
    # compute apn from iccid
    lte.attach(apn=computed_apn)    # attach now works

Log in to reply
 

Pycom on Twitter