不過可惜的是我手邊目前並沒有NB-IoT的Sim卡,所以使用normal SIM卡搭配SIM7000C這張module做了些練習。
以下是我的測試設備:
- Rasberry Pi 2B
- Waveshare SIM7000C NB-IoT HAT
- CHT(中華電信) normal SIM
- OS: Ubuntu Server 18.04
How to connect with CHT cell site via AT commands:
Connect to SIM7000C via USB-console:
$ sudo screen /dev/ttyUSB3 115200
|
Examine SIM7000C is ready to use
at
|
Check PIN status
at+cpin?
|
Ready: SIM is not pending for any password.
Configure APN(Access Point Name) automatically
at+cgdcont=1,”ip”,””
|
1: cid
ip: packet data protocol type
“”: apn
Check signal
at+csq
|
+csq: rssi, ber
rssi:
0 -115 dBm or less
1 -111 dBm
2...30 -110... -54 dBm
31 -52 dBm or greater
99 not known or not detectable
ber:0...7 As RXQUAL values in the table in GSM 05.08 [20] subclause 7.2.4
Scan cell site:
It will take about 120 secs or more, and 46692 is CHT.
at+cops=?
|
+cops=?
(index,format,oper)
Index: Integer type: order number of operator in SIM preferred
Format: 3GPP MCC/MNC
MCC
|
MNC
|
ISP
|
466
|
11
|
中華電信 (CHT)
|
466
|
92
|
中華電信 (CHT)
|
466
|
93
|
台灣大哥大
|
466
|
97
|
台灣大哥大
|
466
|
99
|
台灣電信
|
466
|
03
|
遠傳電信
|
466
|
01
|
遠傳電信
|
466
|
88
|
遠傳電信
|
466
|
89
|
台灣之星
|
466
|
12
|
亞太電信
|
466
|
12
|
亞太電信
|
oper: String type(string should be included in quotation marks)
Number
|
Type
|
0
|
GSM
|
7
|
CAT-M1
|
9
|
NB-IoT
|
Connect to CHT cell site:
at+cops=1,2,”46692”
at+cgatt?
at+cpsi?
|
+cops=index,format,oper
Get APN
We need APN for connecting to the Internet.
It seems normal CHT SIM card is used internet as APN, and NB-IoT of CHT is internet.iot.
at+cgnapn
|
+cgnapn valid,APN
0: The network did not sent APN parameter to UE.In the case, is NULL.
1: The network sent APN parameter to UE.
Connect to the Internet
at+cstt=”internet”
|
+cstt APN,username,password
Initial mobile data network
at+ciicr
|
Check public IP address
at+cifsr
|
Test1: Ping testing
at+cipping=”168.95.1.1”
|
Test2: TCP testing
at+cipstart=”tcp”,”ftp.isu.edu.tw”,21
|
+cipstart=mode,ip,port
Mode: tcp,udp
看到這裡相信很多人已經放棄了,不過請別氣餒其實有更簡單好用的方法唷!
Connect to the Internet via nmcli and mmcli
Issue: nmcli cannot manage interfaces
# nmcli c up id GSM
|
Error: Connection activation failed: No suitable device found for this connection.
|
Workaround:
# mv /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf_orig
# touch /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf
# systemctl restart network-manager
|
Ensure that mmcli can recognize and scan cell site
# mmcli -m 0
|
--------------------------------
General | dbus path: /org/freedesktop/ModemManager1/Modem/0
| device id: fa2d54b8e3ad72c95e99f28ba51b4ce48565684b
--------------------------------
Hardware | manufacturer: QUALCOMM INCORPORATED
| model: 0
| revision: MPSS.JO.3.0.2.c3-00140-9607_LTEONLY_PACK-1 1 [Feb 01 2018 07:00:00]
| h/w revision: 10000
| supported: gsm-umts, lte
| current: gsm-umts, lte
| equipment id: 865233030789763
--------------------------------
System | device: /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3
| drivers: option1, qmi_wwan
| plugin: SimTech
| primary port: cdc-wdm0
| ports: ttyUSB0 (qcdm), ttyUSB2 (at), cdc-wdm0 (qmi), wwan0 (net),
| ttyUSB3 (at)
--------------------------------
Status | lock: sim-pin2
| unlock retries: sim-pin (3), sim-pin2 (3), sim-puk (10), sim-puk2 (10)
| state: registered
| power state: on
| access tech: lte
| signal quality: 94% (recent)
--------------------------------
Modes | supported: allowed: 2g; preferred: none
| allowed: 4g; preferred: none
| allowed: 2g, 4g; preferred: 4g
| allowed: 2g, 4g; preferred: 2g
| current: allowed: 2g, 4g; preferred: 4g
--------------------------------
Bands | supported: egsm, dcs, pcs, g850, eutran-1, eutran-3, eutran-5, eutran-8
| current: egsm, dcs, pcs, g850, eutran-1, eutran-3, eutran-5, eutran-8
--------------------------------
IP | supported: ipv4, ipv6, ipv4v6
--------------------------------
3GPP | imei: 865233030789763
| operator id: 46692
| operator name: 466 92
| registration: home
--------------------------------
3GPP EPS | ue mode of operation: csps-2
--------------------------------
SIM | dbus path: /org/freedesktop/ModemManager1/SIM/0
|
# mmcli -m 0 --3gpp-scan --timeout=120
|
---------------------
3GPP scan | networks: 46612 - 466 12 (lte, available)
| 46692 - 466 92 (lte, current)
| 46605 - 466 05 (gsm, forbidden)
|
Connect to the Internet with nmcli
# nmcli c add type gsm ifname "*" con-name GSM apn "internet"
|
Connection 'GSM' (e79462c8-d02d-4ae0-b3f4-a08db28087af) successfully added.
|
# nmcli c up id GSM
|
相信這個方法簡單了許多吧!不過了解一下底層的AT command如何運作也是相當不錯的機會啦!以下是AT command完整的說明文件: http://www.waveshare.net/w/upload/4/49/SIM7000_Series_AT_Command_Manual_V1.02.pdf
Appendix:
AT+CMNB Preferred selection between CAT-M and NB-IoT.
+cmnb: mode
1 LTE CAT-M
2 NB-IoT
3 CAT-M and NB-IoT
SIM7000C + pppd撥接上網
- To remove modemmanager firstly, otherwise ppp0 connection will be terminated by it.
$ sudo apt remove modemmanager
|
- To install ppp
$ sudo apt install ppp
|
- Configured ppp script for adding some AT commands.
$ cd /etc/ppp
$ vi gprs-connect-chat
|
TIMEOUT 15
ABORT "DELAYED"
ABORT "BUSY"
ABORT "ERROR"
ABORT "NO DIALTONE"
ABORT "NO CARRIER"
TIMEOUT 40
'' \rat
OK at+cstt=\"internet\"
OK at+cgatt?
OK at+cpsi?
OK at+ciicr
OK ATD*99***1#
CONNECT
|
- Configured ppp dial-in configuration file:
$ cd /etc/ppp/peers
$ vi gprsdial
|
/dev/ttyUSB3
115200
crtscts
modem
debug
nodetach
usepeerdns
noipdefault
defaultroute
0.0.0.0:0.0.0.0
connect '/usr/sbin/chat -s -v -f /etc/ppp/gprs-connect-chat'
|
- Added “noauth” parameter in /etc/ppp/options
- Plug-in SIM7000C.
- To execute pppd call
$ sudo pppd call gprsdial
|
root@Lawrence-ThinkPad-T420S:/etc/ppp/peers# pppd call gprsdial
timeout set to 15 seconds
abort on (DELAYED)
abort on (BUSY)
abort on (ERROR)
abort on (NO DIALTONE)
abort on (NO CARRIER)
timeout set to 40 seconds
send (^Mat^M)
expect (OK)
^M
DST: 0^M
^M
*PSUTTZ: 19/06/26,08:14:58","+32",0^M
at^M^M
OK
-- got it
send (at+cstt=\"internet\"^M)
expect (OK)
^M
at+cstt="internet"^M^M
OK
-- got it
send (at+cgatt?^M)
expect (OK)
^M
at+cgatt?^M^M
+CGATT: 1^M
^M
OK
-- got it
send (at+cpsi?^M)
expect (OK)
^M
at+cpsi?^M^M
+CPSI: LTE NB-IOT,Online,466-92,0xC8C9,54027119,280,EUTRAN-BAND8,3640,0,0,-9,-59
,-50,20^M
^M
OK
-- got it
send (at+ciicr^M)
expect (OK)
^M
at+ciicr^M^M
OK
-- got it
send (ATD*99***1#^M)
expect (CONNECT)
^M
ATD*99***1#^M^M
CONNECT
-- got it
Script /usr/sbin/chat -s -v -f /etc/ppp/gprs-connect-chat finished (pid 2813), status = 0x0
Serial connection established.
using channel 12
Using interface ppp0
Connect: ppp0 <--> /dev/ttyUSB3-->
sent [LCP ConfReq id=0x1
rcvd [LCP ConfReq id=0x0
sent [LCP ConfNak id=0x0
rcvd [LCP ConfAck id=0x1
rcvd [LCP ConfReq id=0x1
sent [LCP ConfAck id=0x1
sent [LCP EchoReq id=0x0 magic=0x640f0536]
sent [PAP AuthReq id=0x1 user="Lawrence-ThinkPad-T420S" password=
rcvd [LCP DiscReq id=0x2 magic=0xd41b8a15]
rcvd [LCP EchoRep id=0x0 magic=0xd41b8a15 64 0f 05 36]
rcvd [PAP AuthAck id=0x1 ""]
PAP authentication succeeded
sent [CCP ConfReq id=0x1
sent [IPCP ConfReq id=0x1
rcvd [LCP ProtRej id=0x3 80 fd 01 01 00 0f 1a 04 78 00 18 04 78 00 15 03 2f]
Protocol-Reject for 'Compression Control Protocol' (0x80fd) received
rcvd [IPCP ConfReq id=0x0]
sent [IPCP ConfNak id=0x0
rcvd [IPCP ConfRej id=0x1
sent [IPCP ConfReq id=0x2
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfAck id=0x1]
rcvd [IPCP ConfNak id=0x2
sent [IPCP ConfReq id=0x3
rcvd [IPCP ConfAck id=0x3
Could not determine remote IP address: defaulting to 10.64.64.64
not replacing default route to enp0s25 [10.101.47.1]
local IP address 10.169.25.71
remote IP address 10.64.64.64
primary DNS address 168.95.1.1
secondary DNS address 168.95.192.1
Script /etc/ppp/ip-up started (pid 2824)
Script /etc/ppp/ip-up finished (pid 2824), status = 0x0
$ ifconfig ppp0
ppp0: flags=4305
inet 10.169.25.71 netmask 255.255.255.255 destination 10.64.64.64
ppp txqueuelen 3 (Point-to-Point Protocol)
RX packets 9 bytes 382 (382.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 18 bytes 1385 (1.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
$ ping 168.95.1.1 -I ppp0 -c 3
PING 168.95.1.1 (168.95.1.1) from 10.169.121.115 ppp0: 56(84) bytes of data.
64 bytes from 168.95.1.1: icmp_seq=1 ttl=248 time=292 ms
64 bytes from 168.95.1.1: icmp_seq=2 ttl=248 time=460 ms
64 bytes from 168.95.1.1: icmp_seq=3 ttl=248 time=267 ms
--- 168.95.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 267.265/340.248/460.987/85.994 ms
|
2 comments:
The potential of IOT Sims in disaster management is crucial for early warning and response
This post is really nice and informative. IoT SIM cards, also known as M2M (machine-to-machine) SIM cards, are specialized SIM cards designed for Internet of Things (IoT) devices. They provide connectivity for devices like sensors, meters, and trackers, enabling them to communicate data over cellular networks. These SIM cards typically offer features like low power consumption, remote management, and support for various IoT protocols. They play a crucial role in enabling the widespread adoption and functionality of IoT devices across industries. For comprehensive insights into our iot sims, please click here to visit our detailed page and explore how it can meet your needs.
Post a Comment