Chinaunix

标题: WCDMA USB modem在OpenBSD拨号/发短信 [打印本页]

作者: x-fish    时间: 2011-11-07 12:12
标题: WCDMA USB modem在OpenBSD拨号/发短信
本帖最后由 x-fish 于 2011-11-08 09:55 编辑

3G卡拨号方法一:
具体查看 /etc/ppp/ppp.conf.sample 和man ppp , man chat 等

# To connect via a GPRS or UMTS device (e.g. a mobile phone or a PC Card),
# it's often necessary to set the access-point name (in this case 'internet')
# which requires quotes in the dial string. This section shows the escaping
# required. Devices that have not already authenticated the SIM card (like a
# PC Card) need to issue the "AT+CPIN=xxxx" (xxxx being the PIN for the SIM
# card) first.
# For certain devices it is necessary to adjust the baud rate (speed setting)
# and/or change the dial string to "*99***1#".

# UMTS devices often allow control of the connect mode (UMTS only, GPRS only
# or default to which is available); this can be controlled with the number
# passed to the AT+CGDCONT command and is device dependant.
# Some ISPs do special things in their IPCP session in order to negotiate
# the IP addresses; in this case it may be necessary to play with the ifaddr
1.驱动支持
在OpenBSD下已经有Huawei的3G USB Modem驱动,一般都是使用了高通的芯片.
执行以下命令可以看到支持设备的名称:
  1. #man umsm
复制代码
2.查看是否可以识别设备:
  1. #dmesg
复制代码
可以看到
umsm0 at uhub0 port 3 configuration 1 interface 0 "Huawei Technologies HUAWEI Mobile" rev 2.00/0.00 addr 2
ucom0 at umsm0
umsm1 at uhub0 port 3 configuration 1 interface 1 "Huawei Technologies HUAWEI Mobile" rev 2.00/0.00 addr 2
ucom1 at umsm1
umsm2 at uhub0 port 3 configuration 1 interface 2 "Huawei Technologies HUAWEI Mobile" rev 2.00/0.00 addr 2
ucom2 at umsm2
umsm3 at uhub0 port 3 configuration 1 interface 3 "Huawei Technologies HUAWEI Mobile" rev 2.00/0.00 addr 2
ucom3 at umsm3
umsm4 at uhub0 port 3 configuration 1 interface 4 "Huawei Technologies HUAWEI Mobile" rev 2.00/0.00 addr 2
umsm5 at uhub0 port 3 configuration 1 interface 5 "Huawei Technologies HUAWEI Mobile" rev 2.00/0.00 addr 2
  1. #usbdevs -v
复制代码
# usbdevs -v
Controller /dev/usb0:
addr 1: high speed, self powered, config 1, EHCI root hub(0x0000), Intel(0x8086), rev 1.00
port 1 powered
port 2 powered
port 3 addr 2: high speed, power 500 mA, config 1, HUAWEI Mobile(0x14ac), Huawei Technologies(0x12d1), rev 0.00
port 4 powered
port 5 powered
port 6 powered
port 7 powered
port 8 powered


3.配置文件

  1. default:
  2. #注意该设备名称,发现在我的机器上为 /dev/cuaU0 ,而中兴的一款3G USB WCDMA Modem却为 /dev/cuaU2
  3. set device /dev/cuaU0
  4. set speed 115200
  5. set phone "*99***1#"
  6. #set phone "*99#"
  7. # set phone 里以上两个都可以通过
  8. #set server +3001 aa
  9. set dial "ABORT ERROR ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \
  10.            \"\" ATZ OK-ATZ-OK AT+CMGF=1 OK AT+CGDCONT=1,\\\"IP\\\",\\\"internet\\\" OK \\dATD\\T TIMEOUT 40 CONNECT"
  11. enable dns
  12. set login
  13. set log Phase Chat LCP IPCP CCP tun command
  14. set ifaddr 0.0.0.1/0 0.0.0.2/0 255.255.255.0 0.0.0.0
  15. set redial 10.3 0
  16. add! default HISADDR
  17. disable ipv6cp
  18. disable mppe
复制代码
4.拨号
  1. #ppp -ddial
复制代码
成功后可以看到(部分):
Nov  7 12:12:09 fw1 ppp[26127]: tun0: IPCP:  IPADDR[6] 10.5.16.80
Nov  7 12:12:09 fish1 ppp[26127]: tun0: IPCP:  PRIDNS[6] 221.5.88.88
Nov  7 12:12:09 fish1 ppp[26127]: tun0: IPCP:  SECDNS[6] 255.255.255.255
Nov  7 12:12:09 fish1 ppp[26127]: tun0: IPCP: deflink: State change Ack-Sent --> Opened
Nov  7 12:12:09 fish1 ppp[26127]: tun0: IPCP: deflink: LayerUp.
Nov  7 12:12:09 fish1 ppp[26127]: tun0: IPCP: myaddr 10.5.16.80 hisaddr = 0.0.0.2
Nov  7 12:12:09 fish1 ppp[26127]: tun0: Warning: 0.0.0.0/0: Change route failed: errno: No such process
Nov  7 12:12:09 fish1 ppp[26127]: tun0: Warning: ff01:9::/32: Change route failed: errno: Network is unreachable
Nov  7 12:12:09 fish1 ppp[26127]: tun0: Warning: ff02:9::/32: Change route failed: errno: Network is unreachable



二.发送短信:
方法1:
以下命令将发送短信给13800138000
Howto: http://www.developershome.com/sms/howToSendSMSFromPC.asp
http://en.wikipedia.org/wiki/Motorola_phone_AT_commands
  1. # cu -l /dev/cuaU0
  2. Connected
  3. t
  4. OK
  5. at
  6. OK
  7. at+cmgf=1
  8. ERROR
  9. at+cmgf=1
  10. OK
  11. at+cmgs="+8613800138000"
  12. > hello world

  13. +CMGS: 56

  14. 注意,以上在> 后面输完发送文字后,按ctrl+z 或者Esc 完成发送。

  15. OK
复制代码
或者在
OpenBSD下安装一package:  smstools3-3.1.14
  1. # pkg_info |grep sms
  2. smstools3-3.1.14    gateway to send and receive SMS through GSM mobile phones
复制代码
配置很普通,简单如下:

  1. devices = GSM1
  2. loglevel = 7

  3. trust_outgoing = yes
  4. user = _smsd
  5. pidfile = /var/spool/sms/smsd.pid
  6. infofile = /var/spool/sms/smsd.info

  7. logfile = syslog

  8. [GSM1]
  9. device = /dev/cuaU0
  10. incoming = no
  11. rtscts = no
  12. send_delay = 0
  13. report_device_details = yes
复制代码
安装完毕后,运行:
  1. #smsd
复制代码
发送短信:
  1. #sendsms +8613711111111 "hello world"
复制代码
发送中文的话,需要转换编码,测试成功:
  1. echo "To: +8613711111111\nAlphabet: UCS2\n\n`iconv -f GB2312 -t UNICODE-1-1 sms.txt `" > /var/spool/sms/outgoing/send_tofish
复制代码
注意,其中sms.txt 为GB2312编码的中文内容 。如果运行了 smsd ,只要把正确格式的内容放到放到/var/spool/sms/outgoing/ 目录下,文件命名大概为 send_xxxxx 就可以发送SMS。



待续……
作者: fender0107401    时间: 2011-11-07 12:23
哈哈,发短信。
作者: dooros    时间: 2011-11-07 14:34
这个卡具体是什么型号的 ? 还是均可以通过这种方式实现?
作者: x-fish    时间: 2011-11-07 15:15
to ls:

man umsm

Qualcomm MSM modem device
作者: zeissoctopus    时间: 2011-11-07 17:24
讚!收藏
作者: macafee    时间: 2011-11-07 19:24
还真没试过短信功能。
作者: hniu    时间: 2011-11-07 20:44
这样发短信息还额外花钱不?
作者: 5sky    时间: 2011-11-07 21:07
收藏个,或许以后有用
作者: dooros    时间: 2011-11-07 23:04
貌似会赠送短信条数吧,算这个的吧。
作者: beyondfly    时间: 2011-11-08 08:42
真折腾啊
作者: 韩城小胖。    时间: 2011-12-09 09:11
回复 1# x-fish 前辈能否帮忙看下我在FreeBSD下该如何配置呢 ?http://www.freebsdchina.org/forum/viewtopic.php?t=52746




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2