GPy 1.0R with Firmware 1.20.2.rc6 and Hologram SIM



  • I connected it once a month ago, then restarted working on teh project. Doesn't want to connect anymore.

    Based on many messages, I ran to the following code to diagonise. Output is attached. Can someone help with this issue? Also is there a recommended firmware to run on a GPY v1.0R? Thanks in advance for your help!

    import socket
    import time
    import pycom
    import os
    from machine import RTC
    from network import LTE
    from network import WLAN
    
    HOST = "cloudsocket.hologram.io"
    PORT = 9999
    DEVICE_KEY = "347330" #generated on hologram's portal for each SIM card.
    TOPIC = "TEST"
    
    def send_at_cmd_pretty(cmd):
        response = lte.send_at_cmd(cmd).split('\r\n')
        for line in response:[output.py](/assets/uploads/files/1587447073334-output.py) 
            print(line)
    
    #Need to use global variables.
    #If in each function you delare a new reference, functionality is broken
    lte = LTE()
    
    #Returns a network.LTE object with an active Internet connection.
    def getLTE():
        # If already used, the lte device will have an active connection.
        # If not, need to set up a new connection.
        if lte.isconnected():
            return lte
    
        # Modem does not connect successfully without first being reset.
        print("Resetting LTE modem ... ", end="")
        lte.send_at_cmd('AT^RESET')
        print("OK")
        time.sleep(1)
        # While the configuration of the CGDCONT register survives resets,
        # the other configurations don't. So just set them all up every time.
        print("Configuring LTE ", end='')
        send_at_cmd_pretty('AT+CGDCONT=1,"IP","hologram"')  # Changed this from origninal
        send_at_cmd_pretty('AT!="RRC::addscanfreq band=4 dl-earfcn=2175"') # changed band from 28 to 4. I dont know what earfcn=9410 is;
        send_at_cmd_pretty('AT!="RRC::addscanfreq band=12 dl-earfcn=5095"')
        send_at_cmd_pretty('AT!="RRC::addscanfreq band=13 dl-earfcn=5230"')
        send_at_cmd_pretty('AT+CFUN=1')
    
    
        # If correctly configured for carrier network, attach() should succeed.
        if not lte.isattached():
            print("Attaching to LTE network ", end='')
            lte.attach()
            while(True):
                if lte.isattached():
                    print(" OK")
                    # pycom.rgbled(0x00FF00)
                    # time.sleep(.5)
                    # pycom.rgbled(0x000000)
                    break
                send_at_cmd_pretty('AT!="showphy"')
                send_at_cmd_pretty('AT!="fsm"')
                send_at_cmd_pretty('AT+CEREG?')
                send_at_cmd_pretty('AT+CSQ')
                time.sleep(1)
    
        # Once attached, connect() should succeed.
        if not lte.isconnected():
            print("Connecting on LTE network ", end='')
            lte.connect()
            while(True):
                if lte.isconnected():
                    print(" OK")
                    break
                print('.', end='')
                time.sleep(1)
    
        # Once connect() succeeds, any call requiring Internet access will
        # use the active LTE connection.
        return lte
    
    # Clean disconnection of the LTE network is required for future
    # successful connections without a complete power cycle between.
    def endLTE():
        print("Disonnecting LTE ... ", end='')
        lte.disconnect()
        print("OK")
        time.sleep(1)
        print("Detaching LTE ... ", end='')
        lte.dettach()
        print("OK")
        lte.deinit()
    
    #Program starts here.
    try:
        lte = getLTE()
        print(lte)
        s = socket.socket()
        print(s)
        dns_records = socket.getaddrinfo(HOST, PORT)
        print("got dns_records")
        print(dns_records)
    
        message = "Hello World!"
    
        for record in dns_records:
            try:
                s.connect(record[-1])
                print("connected")
                data = '{"k": "%s", "d": "%s", "t": "%s"}' % (DEVICE_KEY, message, TOPIC)
                s.send(bytes(data, 'ascii'))
                print("sent")
                result = s.recv(8).decode()
                print(result)
                s.close()
                break
            except Exception as err1:
                try:
                    s.close()
                except:
                    pass
                print(err1)
                continue
    
    except Exception as err:
        print(err)
        try:
            s.close()
        except:
            pass
    
    finally:
       endLTE()
    
    


  • Sorry for the late response. Could you define connect? (are you referring to the LTE connection and/or debug cable?)
    Usually helps people answer a question if they have more context.

    I don't regard these boards as suitable to be used in any deployment long term. They invariably crash within a few days or weeks, and need rebooting or reflashing.


Log in to reply
 

Pycom on Twitter