示例#1
0
from network import LTE


def send_at_cmd_pretty(cmd):
    response = lte.send_at_cmd(cmd).split('\r\n')
    for line in response:
        if (len(line) > 0):
            print(line)


lte = LTE()
print("imei", lte.imei())
print("is_connected", lte.isconnected())
print("ue_coverage", lte.ue_coverage())
print("iccid", lte.iccid())
print("time", lte.time())

send_at_cmd_pretty('AT+CGMI')
# PYCOM
send_at_cmd_pretty('AT+CGMM')
# FiPy
send_at_cmd_pretty('AT+CGMR')
# UE5.0.0.0d
send_at_cmd_pretty('AT+CGSN=0')

send_at_cmd_pretty('AT+CGSN=1')

send_at_cmd_pretty('AT+CGSN=2')

send_at_cmd_pretty('AT+CGSN=3')
# +CGSN: "00"
示例#2
0
else:
    nb_iot_connection = True
    func_lvl = 1  # full modem functionality

# set up modem
try:
    set_modem_func_lvl(lte, func_lvl)
except Exception as e:
    set_led(LED_PURPLE)
    sys.print_exception(e)
    reset()

# set up network connection
if nb_iot_connection:
    # check Network Coverage for UE device (i.e LTE modem)
    if not lte.ue_coverage():
        print("!! There seems to be no Netwok Coverage !! Try to attach and connect anyway ...")

    # initialize LTE and connect to LTE network
    try:
        lte_setup(lte, nb_iot_connection, cfg.get("apn"))
    except Exception as e:
        set_led(LED_PURPLE)
        sys.print_exception(e)
        lte_shutdown(lte)
        reset()
else:
    # initialize wifi connection
    wlan = WLAN(mode=WLAN.STA)
    try:
        wifi_connect(wlan, cfg["wifi"]["ssid"], cfg["wifi"]["pass"])