LTE M1 Melbourne - May help others



  • #---------- Comments Below ---------------
    #Where I'm @ - 20 March 2018, micksta.
    #p.s. I wish I knew what I was doing - wife and kids would agree
    #Telstra LTE M1 - Melbourne, March 2018
    #Hardware - Gpy + LTE E antenna + Expansion bd
    #note: thks forum guy's, put this together from various threads, you guy's :)
    #Delay's thrown in, else modem becomes flaky/hangs then hard boot/reset's required

    #import os
    #os.uname() -- Had all sorts of hanging and other stuff going on with later f/w the below seems semi ok
    #(sysname='GPy', nodename='GPy', release='1.17.0.b1', version='v1.8.6-849-d0dc708 on 2018-02-27', machine='GPy with #ESP32')

    #Atom & pymakr installed for dev.
    #All jumpers on breakout board removed except for Rx/Tx using usb/serial lead for debugging
    #Had to clean out Boot.py & Main.py to nothing
    #E Antenna orientation and placement seem important (have the E antenna in E orientation and highish location)
    #Broughts Aldi nano sim $5.00 (aka telstra) network, registerd sim & chk'd in phone first
    #Aldi APN = mdata.net.au / got this when sim was in phone
    #()"towel.blinkenlights.nl", 23) runs well - Txt Animation, slow due to ~300 kbs LTE M1 - but otherwise ok for testing #connection
    #If locks up - have to do hard reset (i.e pull usb lead out/in), port was/is copping a flogging
    #---------- Comments Above ---------------

    from network import LTE
    import time
    import usocket
    import gc

    time.sleep(1.0)

    print('Begin')
    lte = LTE() # instantiate LTE object
    time.sleep(4.0)

    lte.reset()
    print ('01') # used for debugging
    time.sleep(10.0)

    lte.send_at_cmd('AT+CGDCONT=1,"IP","mdata.net.au"') # Aldi (APN = "mdata.net.au", nano sim - aka telstra network
    print ('02') # used for debugging
    time.sleep(4.0)

    lte.send_at_cmd('AT!="addscanfreq band=28 dl-earfcn=9410"') # lte frequency band - from forum
    print ('03') # used for debugging
    time.sleep(1.0)

    lte.send_at_cmd('AT+CFUN=1') # Set the full functionality mode with a complete software reset
    print ('04') # used for debugging
    time.sleep(1.0)

    lte.attach() # attach the cellular modem to a base station
    while not lte.isattached():
    ----time.sleep(4.0)# should be indented!
    print ('attached') # used for debugging

    lte.connect() # start a data session and obtain an IP address
    while not lte.isconnected():
    ----time.sleep(4.0) # should be indented!
    print ('connected') # used for debugging

    print("ok good to go") # used for debugging

    #---------------------------------------------------------------------------------------------
    #---------- Star Wars Animation -----test if connected---------------
    #---------------------------------------------------------------------------------------------
    addr_info = usocket.getaddrinfo("towel.blinkenlights.nl", 23)
    addr = addr_info[0][-1]

    s = usocket.socket()
    s.connect(addr)

    xx=0
    while xx < 10: # else entire animation will play out
    ----data = s.recv(500) # should be indented!
    ----print(str(data, 'utf8'), end='') # should be indented!
    ----xx+=1# should be indented!

    print('----> Finished/Out')
    print(str(xx))

    lte.disconnect()
    lte.dettach()
    s.close()
    gc.collect()

    Re: Gpy on Telstra Australia - Melbourne LTE-M1



  • @micksta

    15 Oct 2018 - Ran this code on Telstra SIM (Adelaide) using AT+CGDCONT=1,"IP","telstra.internet



  • @nathanh
    RRC::addscanfreq and addscanfreq are the same, the RRC:: just makes it explicit this is a command that is part the RRC module (there are some ambiguous command which need the explicit declaration)

    But true none of these commands is documented by Sequans, we had to find out ourselves. You can at least get some help by calling AT!="help command_you_want"



  • @micksta
    Just a quick observation I noted, the AT command to set the scan band is slightly different in your code than it is in the firmware (ignoring the EARFCN).

    From the firmware the AT command is/would be:

    AT!="RRC::addscanfreq band=28 dl-earfcn=9410"
    

    And yours being:

    AT!="addscanfreq band=28 dl-earfcn=9410"
    

    I guess if you have it working that RRC:: is not required but just something I noticed. Would be nice if Sequans would release more of their commands so we knew what they did and help us work these issues out.



  • #Where I'm @ - 17 April 2018, micksta.
    #p.s. I wish I knew what I was doing - the boss would also
    #code below is mix from forum, again thks lads, nice for debugging
    #upgraded fw (cheers) in Gpy & Modem (M1 only) to latest , had issue not being able to upload entire ~5.4mb M1 file to sd #card, got there with a few minor scratch's!
    #note:
    #during day have found modem can take ~5 sec --> min's. to attach, @ night connect time seems improved!!

    import os
    import time
    import gc
    import usocket
    #import socket - I've had issues with this in past, swapped to usocket!
    import ssl
    from network import LTE
    
    #print(os.uname())
    #(sysname='GPy', nodename='GPy', release='1.17.3.b1', version='v1.8.6-849-83e2f7f on 2018-03-19', machine='GPy with ESP32')
    
    lte = LTE()
    
    def send_at_cmd_pretty(cmd):
        response = lte.send_at_cmd(cmd).split('\r\n')
        for line in response:
            print(line)
    
    send_at_cmd_pretty('AT+CFUN=0')
    send_at_cmd_pretty('AT!="clearscanconfig"')
    send_at_cmd_pretty('AT!="addscanfreq band=28 dl-earfcn=9410"') # lte frequency band - from forum
    send_at_cmd_pretty('AT+CGDCONT=1,"IP","mdata.net.au"') # Aldi sim / "mdata.net.au" Aldi APN (aka Telstra network)
    send_at_cmd_pretty('AT+CEREG=2') # pg 150 Monarch_4G_EZ...pdf, sets --> enable network registration and location information unsolicited result code
    send_at_cmd_pretty('AT+CFUN=1') # enable modem & set to full functionality mode
    
    while not lte.isattached():
        time.sleep(1)
        send_at_cmd_pretty('AT!="showphy"')
        send_at_cmd_pretty('AT!="fsm"')
        send_at_cmd_pretty('AT+CEREG?') #--> pg 150 Monarch_4G_EZ...pdf -- returns info see below,
        # +CREG: <n>,<stat>[,[<lac>],[<ci>],[<AcT>][,<cause_type>,<reject_cause>]]
        # i.e. +CEREG: 2,1,"3052","08195A0B",7
        # <n> is the initial setting of CEREG config i.e 2 --> ('AT+CEREG=2' / enable network registration and location information..)
        # ,<stat> -- Network registration status i.e. 1 (registered, home network)
        #      0 not registered, MT is not currently searching an operator to register to
        #      1 registered, home network
        #      2 not registered, but MT is currently searching a new operator to register to
        #      3 registration denied
        #      4 unknown (e.g. out of GERAN/UTRAN/E-UTRAN coverage)
        #      5.....10
        # ,<tac> String type; two byte tracking area code in hexadecimal format (e.g. "3052" equals 12370 in decimal).
        # ,<ci> String type; four byte E-UTRAN cell ID in hexadecimal format (e.g. "08195A0B" cell iD in Hex )
        # ,<AcT> Integer. The parameter sets/shows the access technology of the serving cell. (e.g 7 = E-UTRAN)
    
    lte.connect()       # start a data session and obtain an IP address
    while not lte.isconnected():
        time.sleep(4.0)
    print ('connected - lets get some data') # used for debugging
    time.sleep(1.0)
    
    try:
        #--------------------------------------------------------------------
        #--- Star Wars Animation --------------------------------------------
        #--------------------------------------------------------------------
        addr_info = usocket.getaddrinfo("towel.blinkenlights.nl", 23)
        addr = addr_info[0][-1]
    
        # If you type addr_info and addr at the prompt you will see exactly
        # what information they hold.
        s = usocket.socket()
        s.connect(addr)
        xx=0
        while xx < 30: # else entire animation will play out
            data = s.recv(500)
            print(str(data, 'utf8'), end='')
            xx+=1
        #s = socket.socket()
        #s = ssl.wrap_socket(s)
        #s.connect(socket.getaddrinfo('www.google.com', 443)[0][-1])
        #s.send(b"GET / HTTP/1.0\r\n\r\n")
        #print(s.recv(4096))
    except:
        print('data/socket error')
    else:
        s.close()
    
    print('disconnect & detach modem')
    lte.disconnect()
    lte.dettach()
    
    print('clean up')
    lte = None
    gc.collect()
    time.sleep(.2)
    
    


  • @micksta This was quite helpful indeed. I have added a couple of lines after the LTE instantiation that disconnect/dettach it otherwise it seems to hang sometimes if something goes wrong with the code and I reboot it.

    Also, I am having some trouble running the program sometimes or reprogramming the device. I think this is related to the network -> LTE class. I spend up to several minutes getting the REPL back, once I do I erase the flash quickly to prevent further glitches...



  • @micksta That's very encouraging. Thanks for that Mick.



  • @Paddy
    0_1522452859614_LTE.jpg

    re: Aldi sim (works, sure) / cat-m1 or nb-iot

    read these posts, others as well

    --> Home / Getting Started / FiPy / Telstra LTE Cat-M Working on FiPy .... Just..
    --> Home / Getting Started / FiPy / Successful network connections?

    Google
    https://www.telstra.com.au/aboutus/media/media-releases/Telstra-adds-narrowband-capability-to-Australias-leading-IoT-network

    Network Test
    https://docs.micropython.org/en/v1.8/esp8266/esp8266/tutorial/network_tcp.html



  • G'day Mick,

    So does this work ? Are you getting connectivity using the ALDI sim on the Telstra network. Is this cat-m1 or nb-iot.

    Cheers.

    Paddy


Log in to reply
 

Pycom on Twitter