参考

使用的模块是华为ME909s-821,参考的文章作者使用的是树莓派3B+Ubuntu Mate 16.04+移动卡,我用的是ubuntu18.04+联通卡,但过程和配置完全一样。

测试设备

1
2
3
4
5
pi@pc-pi:~$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 002: ID 12d1:15c1 Huawei Technologies Co., Ltd. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

可以看到第三项为华为4G设备,能正确识别,无需驱动

安装配置wvdial

  • 安装wvdial:i386,其配置文件在 /etc/wvdial.conf

    1
    2
    3
    
    apt remove --purge wvdial ppp # 如果已安装其它版本则卸载
    dpkg --add-architecture i386
    apt install wvdial:i386
    
  • 使用 wvdialconf 命令自动检测,会更新配置文件,我的理解是把能配的都自动给你配好了,剩下的应该只与卡有关了,需要自己手动配置。

  • 已有7项,手动配置5项。Phone, Password, Username 按提示替换,Init3, Auto DNS 是补充的项。

    对于如下[Dialer 2]的块,继承于Defaults,可以使用wvdial 2拨号

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    
    [Dialer Defaults]
    Init1 = ATZ
    Init2 = ATQ0 V1 E1 S0=0
    Modem Type = Analog Modem
    ISDN = 0
    New PPPD = yes
    Modem = /dev/ttyUSB0
    Baud = 9600
    Phone = *99#
    Password = guest
    Username = guest
    Init3 = AT+CGDCONT=1,"IP","3gnet"
    Auto DNS = on
    
    [Dialer 2]
    Modem = /dev/ttyUSB2
    

启动拨号

使用命令 wvdial,最后出现多个pppd即表示成功。此命令是阻塞的,一旦按ctrl+c即退出了,因此打开另一个终端测试ping即可。如果失败,使用route -n命令看看目标为0.0.0.0是否使用ppp0。如果不是去掉第一条再添加。我这直接成功,无需这一步。

1
2
sudo route del -net 0.0.0.0 enp3s0 # 不用做
sudo route add -net 0.0.0.0 ppp0

注意:卡不支持热插拨,插拨需要重启。

设置开机拨号

直接添加文件 /etc/rc.local,内容如下,并添加可执行权限即可。

1
2
#!/bin/bash
nohup wvdial >> /var/wvdial.out &

经过多次重启,并没有感觉到作者所说的不稳定,通常启动半分钟后即可上网。莫非树莓派与此模块有不兼容的地方?

使用桌面拨号

上面的设置已经可以用了,现在由于客户需要使用桌面系统实现。

  1. 刚开始安装ubuntu18.04桌面版,显示红色壁纸后就不动了,以为是intel集成显卡不支持,通过nomodeset模式能安装和进入,但分辨率非常低,部分界面显示不了(安装时全靠回车),类似 网友的这个问题
  2. 换16.04能进入桌面,也能添加 mobile broadband,但添加后没有连接的地方,网上没有找到这方面的问题解决方案。
  3. 再次使用18.04桌面版,开机进入试用菜单,在显示红色壁纸不动后,发现右键可以打开菜单,于是打开命令行,使用命令 gnome-control-panel 打开控制面板,发现有两个显示器,设为 Mirror模式 就出现了1024*768的桌面。
  4. 剩下的就很简单了,添加 mobile broadbandTrun On 即可。还可以开机自动登录,自动拨号上网。

问题

Invalid dial command

拨号时提示:

1
2
3
--> Invalid dial command.
wvdial: utils/wvtask.cc:303: static int WvTaskMan::yield(int): Assertion `*current_task->stack_magic == WVTASK_MAGIC' failed.
Aborted (core dumped)

通过一个韩文网页(可通过谷歌翻译查看)找到了解决方法:

1
2
3
apt remove --purge wvdial ppp
dpkg --add-architecture i386
apt install wvdial:i386

一直Waiting for carrier,NO CARRIER反复

没有信号,信号线应插入M口,卡插到靠近天线的一边。

拨号正常,但ping xxx -I ppp0失败

  • 如果原来关闭了有线网络的网关,则拨号后:可直接上网。

  • 如果原来开启了有线网络的网关,则拨号后:有线无法ping域名了,ppp0域名和ip均无法ping通。

    需要添加一条路由:route add -net 0.0.0.0 ppp0,以下是拨号后路由变化:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    
    Destination  Gateway     Genmask         Flags Metric Ref Use Iface
    # 如果原先不可上网,则拨号后自动新增。否则需手动新增
    0.0.0.0      0.0.0.0     0.0.0.0         U     0      0   0 ppp0
    # 原先可上网时才有
    0.0.0.0      192.168.3.1 0.0.0.0         UG    0      0   0 enp1s0
    # 拨号后都会自动新增的
    10.64.64.64  0.0.0.0     255.255.255.255 UH    0      0   0 ppp0
    172.17.0.0   0.0.0.0     255.255.0.0     U     0      0   0 docker0
    172.18.0.0   0.0.0.0     255.255.0.0     U     0      0   0 br-a5d09d5262c0
    192.168.3.0  0.0.0.0     255.255.255.0   U     0      0   0 enp1s0
    

错误码参考

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
CME ERROR: 0 Phone failure
CME ERROR: 1 No connection to phone
CME ERROR: 2 Phone adapter link reserved
CME ERROR: 3 Operation not allowed
CME ERROR: 4 Operation not supported
CME ERROR: 5 PH_SIM PIN required
CME ERROR: 6 PH_FSIM PIN required
CME ERROR: 7 PH_FSIM PUK required
CME ERROR: 10 SIM not inserted
CME ERROR: 11 SIM PIN required
CME ERROR: 12 SIM PUK required
CME ERROR: 13 SIM failure
CME ERROR: 14 SIM busy
CME ERROR: 15 SIM wrong
CME ERROR: 16 Incorrect password
CME ERROR: 17 SIM PIN2 required
CME ERROR: 18 SIM PUK2 required
CME ERROR: 20 Memory full
CME ERROR: 21 Invalid index
CME ERROR: 22 Not found
CME ERROR: 23 Memory failure
CME ERROR: 24 Text string too long
CME ERROR: 25 Invalid characters in text string
CME ERROR: 26 Dial string too long
CME ERROR: 27 Invalid characters in dial string
CME ERROR: 30 No network service
CME ERROR: 31 Network timeout
CME ERROR: 32 Network not allowed, emergency calls only
CME ERROR: 40 Network personalization PIN required
CME ERROR: 41 Network personalization PUK required
CME ERROR: 42 Network subset personalization PIN required
CME ERROR: 43 Network subset personalization PUK required
CME ERROR: 44 Service provider personalization PIN required
CME ERROR: 45 Service provider personalization PUK required
CME ERROR: 46 Corporate personalization PIN required
CME ERROR: 47 Corporate personalization PUK required
CME ERROR: 48 PH-SIM PUK required
CME ERROR: 58 Invalid command or command format error.
CME ERROR: 100 Unknown error
CME ERROR: 103 Illegal MS
CME ERROR: 106 Illegal ME
CME ERROR: 107 GPRS services not allowed
CME ERROR: 111 PLMN not allowed
CME ERROR: 112 Location area not allowed
CME ERROR: 113 Roaming not allowed in this location area
CME ERROR: 126 Operation temporary not allowed
CME ERROR: 132 Service operation not supported
CME ERROR: 133 Requested service option not subscribed
CME ERROR: 134 Service option temporary out of order
CME ERROR: 148 Unspecified GPRS error
CME ERROR: 149 PDP authentication failure
CME ERROR: 150 Invalid mobile class
CME ERROR: 256 Operation temporarily not allowed
CME ERROR: 257 Call barred
CME ERROR: 258 Phone is busy
CME ERROR: 259 User abort
CME ERROR: 260 Invalid dial string
CME ERROR: 261 SS not executed
CME ERROR: 262 SIM Blocked
CME ERROR: 263 Invalid block
CME ERROR: 772 SIM powered down
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
CMS ERROR: 1 Unassigned number
CMS ERROR: 8 Operator determined barring
CMS ERROR: 10 Call bared
CMS ERROR: 21 Short message transfer rejected
CMS ERROR: 27 Destination out of service
CMS ERROR: 28 Unindentified subscriber
CMS ERROR: 29 Facility rejected
CMS ERROR: 30 Unknown subscriber
CMS ERROR: 38 Network out of order
CMS ERROR: 41 Temporary failure
CMS ERROR: 42 Congestion
CMS ERROR: 47 Recources unavailable
CMS ERROR: 50 Requested facility not subscribed
CMS ERROR: 69 Requested facility not implemented
CMS ERROR: 81 Invalid short message transfer reference value
CMS ERROR: 95 Invalid message unspecified
CMS ERROR: 96 Invalid mandatory information
CMS ERROR: 97 Message type non existent or not implemented
CMS ERROR: 98 Message not compatible with short message protocol
CMS ERROR: 99 Information element non-existent or not implemente
CMS ERROR: 111 Protocol error, unspecified
CMS ERROR: 127 Internetworking , unspecified
CMS ERROR: 128 Telematic internetworking not supported
CMS ERROR: 129 Short message type 0 not supported
CMS ERROR: 130 Cannot replace short message
CMS ERROR: 143 Unspecified TP-PID error
CMS ERROR: 144 Data code scheme not supported
CMS ERROR: 145 Message class not supported
CMS ERROR: 159 Unspecified TP-DCS error
CMS ERROR: 160 Command cannot be actioned
CMS ERROR: 161 Command unsupported
CMS ERROR: 175 Unspecified TP-Command error
CMS ERROR: 176 TPDU not supported
CMS ERROR: 192 SC busy
CMS ERROR: 193 No SC subscription
CMS ERROR: 194 SC System failure
CMS ERROR: 195 Invalid SME address
CMS ERROR: 196 Destination SME barred
CMS ERROR: 197 SM Rejected-Duplicate SM
CMS ERROR: 198 TP-VPF not supported
CMS ERROR: 199 TP-VP not supported
CMS ERROR: 208 D0 SIM SMS Storage full
CMS ERROR: 209 No SMS Storage capability in SIM
CMS ERROR: 210 Error in MS
CMS ERROR: 211 Memory capacity exceeded
CMS ERROR: 212 Sim application toolkit busy
CMS ERROR: 213 SIM data download error
CMS ERROR: 255 Unspecified error cause
CMS ERROR: 300 ME Failure
CMS ERROR: 301 SMS service of ME reserved
CMS ERROR: 302 Operation not allowed
CMS ERROR: 303 Operation not supported
CMS ERROR: 304 Invalid PDU mode parameter
CMS ERROR: 305 Invalid Text mode parameter
CMS ERROR: 310 SIM not inserted
CMS ERROR: 311 SIM PIN required
CMS ERROR: 312 PH-SIM PIN required
CMS ERROR: 313 SIM failure
CMS ERROR: 314 SIM busy
CMS ERROR: 315 SIM wrong
CMS ERROR: 316 SIM PUK required
CMS ERROR: 317 SIM PIN2 required
CMS ERROR: 318 SIM PUK2 required
CMS ERROR: 320 Memory failure
CMS ERROR: 321 Invalid memory index
CMS ERROR: 322 Memory full
CMS ERROR: 330 SMSC address unknown
CMS ERROR: 331 No network service
CMS ERROR: 332 Network timeout
CMS ERROR: 340 No +CNMA expected
CMS ERROR: 500 Unknown error
CMS ERROR: 512 User abort
CMS ERROR: 513 Unable to store
CMS ERROR: 514 Invalid Status
CMS ERROR: 515 Device busy or Invalid Character in string
CMS ERROR: 516 Invalid length
CMS ERROR: 517 Invalid character in PDU
CMS ERROR: 518 Invalid parameter
CMS ERROR: 519 Invalid length or character
CMS ERROR: 520 Invalid character in text
CMS ERROR: 521 Timer expired
CMS ERROR: 522 Operation temporary not allowed
CMS ERROR: 532 SIM not ready
CMS ERROR: 534 Cell Broadcast error unknown
CMS ERROR: 535 Protocol stack busy