首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用PyCom FiPy接入长期演进蜂窝网络?

如何使用PyCom FiPy接入长期演进蜂窝网络?
EN

Stack Overflow用户
提问于 2020-07-08 17:00:11
回答 2查看 788关注 0票数 1

我正在尝试使PyCom FiPy板与LTE网络连接工作。我有全息SIM卡。我使用了两段代码。一个来自PyCom docs,另一个来自我在PyCom调试LTE论坛上找到的代码。

来自PyCom LTE文档的第一个代码片段

代码语言:javascript
复制
import time
from network import LTE

print('main-testy.py starting.  This is the code snippet from pycom docs')

#lte = LTE(carrier="verizon")
lte = LTE()


print("trying to attach")
lte.attach(band=13)
while not lte.isattached():
    time.sleep(0.5)
    print('Attaching...')

print("trying to connect")
lte.connect(cid=3)
while not lte.isconnected():
    time.sleep(0.5)
    print('Connecting...')

# Now use sockets as usual...

输出

最初几次我运行这段代码时,它会附加,然后在lte.connect调用中生成一个python错误。最初的样本使用的是“verizon”运营商,但论坛上的一篇帖子称这不是必要的。

代码语言:javascript
复制
>>> Running main-testy.py

>>> 
>>> 
main-testy.py starting.  This is the code snippet from pycom docs
trying to attach
Attaching...
Attaching...
Attaching...
.. never attaches

来自PyCom LTE论坛帖子的第二个代码片段

浏览论坛,我发现其他一些用户也有类似的问题。我将他们的尝试与文档中的一些可用命令结合起来,编写了这段代码。它提供了一些关于simcard和调制解调器的基本信息。以下是代码。

代码语言:javascript
复制
# Determine carrier notes
from network import LTE


# 1817



lte = LTE()

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


print("get phy status")
send_at_cmd_pretty('AT!="showphy"')     # get the PHY status
print("get System FSM")
send_at_cmd_pretty('AT!="fsm"')         # get the System FSM
print("get System COPS.  PLMN Selection: +COPS")
print("!!!!!!!!!1 always generates error !!!!!!!!!!!!")
send_at_cmd_pretty('AT+COPS=?')         # get the System FSM


print("get conformance test modes. List of carriers? ")
send_at_cmd_pretty("AT+SQNCTM=?")       # get list of carriers for
# results are
# "3gpp-conformance", "att", "docomo", "kt", "lgu", "softbank", "standard", "telstra", "verizon")

results = lte.imei()
print("lte.imei results \n{}" . format(results))


results = lte.iccid()
print("lte.iccid results \n{}" . format(results))

输出

所有这些代码都会运行,但其中一个命令(+COPS)会给出错误。我确实检查了AT命令参考,语法是+COPYS=?看起来是正确的。也许这个特定的命令只能在附加后才能发出。

代码语言:javascript
复制
>> Running lte-basic-operations.py

>>> 
>>> 
get phy status

DL SYNCHRO STATISTICS
=====================
    Synchro state                         : OFF
    PPU SIB1 ACQ watchdog                 : 0
    Frequency Hypothesis RF  (Hz)         : 0
    RSRP (dBm)                            : 0.00
    RSRQ  (dB)                            : 0.00
    Channel estimation state (Cell-spec.) : LOW CINR
    Channel estimation state (UE-spec.)   : LOW CINR
    Channel estimation state (MBSFN)      : LOW CINR
    Channel estimation CINR               : 0.00
    Channel length                        : SHORT
  AGC
    AGC RX gain (dB)                      : 0.00
    RX PSD BO (dBFs)                      : 0.00
    RX PSD (dBm)                          : 0.00
    Noise level RS (dBm)                  : 0.00
    Digital gain (dB)                     : 0.00
    CINR RS (dB)                          : 0.00
  NARROWBANDS
    Last DL NB                            : 0
    Last UL NB                            : 0
  AFC
    Frequency offset RF  (Hz)             : 0
    Frequency offset BB  (Hz)             : 0
  PBCH
    MIB received quantity                 : 0
    MIB timeout quantity                  : 0

OK

get System FSM

SYSTEM FSM
==========
    +--------------------------+--------------------+
    |            FSM           |        STATE       |
    +--------------------------+--------------------+
    | RRC TOP FSM              |STOPPED             |
    | RRC SEARCH FSM           |NULL                |
    | RRC ACTIVE FSM           |NULL                |
    | PMM PLMN FSM             |NULL                |
    | EMM MAIN FSM             |NULL                |
    | EMM AUTH FSM             |NULL                |
    | EMM CONN FSM             |NULL                |
    | EMM TAU FSM              |NULL                |
    | EMM TEST FSM             |NULL                |
    | ESM BEARER FSM           |BEARER_NULL         |
    | SMS MT FSM               |IDLE                |
    | SMS MO FSM               |IDLE                |
    | HP MAIN FSM              |IDLE                |
    | HP USIM FSM              |NULL                |
    | HP SMS MO FSM            |IDLE                |
    | HP SMS MT FSM            |IDLE                |
    | HP CAT FSM               |NULL                |
    +--------------------------+--------------------+

OK

get System COPS.  PLMN Selection: +COPS
!!!!!!!!!1 always generates error !!!!!!!!!!!!

ERROR

get conformance test modes. List of carriers? 

+SQNCTM: ("3gpp-conformance", "att", "docomo", "kt", "lgu", "softbank", "standard", "telstra", "verizon")

OK

lte.imei results 
354346095554902
lte.iccid results 
8944500208186565235
>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-07-11 09:09:12

我确实设法让LTE与全息图卡一起工作。然而,它并不是100%可靠的。有时它会停滞或挂起。任何意见都是值得感谢的。

代码语言:javascript
复制
import time
from network import LTE
import utime
import machine
import _thread

print('main-testy.py starting.  This is the code snippet from pycom docs')

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

def do_ntp(a_server):
    # Syncing time
    RTCI = machine.RTC()
    print('Syncing time with %s' % a_server, end='')
    RTCI.ntp_sync(a_server)
    while not RTCI.synced():
        print('.', end='')
        utime.sleep(1)
    print('')

def get_time_as_string():
    year, month, mday, hour, minute, second, weekday, yearday = utime.localtime()
    # form an iso time string
    # eg. 1985-12-04T23:20:50
    a_string = '{}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}' . format(year, month, mday, hour, minute, second)
    return a_string


###############################################


lte = LTE()
lte.reset()
lte.init()



print("trying to attach")
#lte.attach(band=13)
lte.attach()
while not lte.isattached():
    time.sleep(0.5)
    #print('Attaching...')
    print('Attaching...', end='')
    send_at_cmd_pretty('AT+CEREG?')         # get the System FSM

time.sleep(5)


print("trying to connect")
#lte.connect(cid=3)
lte.connect()
while not lte.isconnected():
    time.sleep(0.5)
    print('Connecting...')

time.sleep(5)



# Now use sockets as usual...
print('**** connected ***********************')


do_ntp('time.google.com')
#do_ntp('pool.ntp.org')
time.sleep(5)
print(get_time_as_string())
票数 0
EN

Stack Overflow用户

发布于 2020-07-11 01:42:36

当使用全息SIM卡时,您不应该使用Verizon配置文件,因为这只适用于Verizon SIM卡。此外,对于全息图,CID应为1,3仅适用于Verizon SIM卡。

即使ICCID命令返回结果,SIM卡似乎也有问题,因为HP USIM FSM报告NULL。

您可以先尝试lte.factory_reset(),然后再使用cid=1重试吗?

如果问题仍然存在,请联系Pycom support https://pycom.io/community/contact-support/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62791167

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档