免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 5589 | 回复: 10
打印 上一主题 下一主题

[OpenBSD] WCDMA USB modem在OpenBSD拨号/发短信 [复制链接]

论坛徽章:
1
技术图书徽章
日期:2014-04-16 11:36:47
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-11-07 12:12 |只看该作者 |倒序浏览
本帖最后由 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。



待续……

论坛徽章:
89
水瓶座
日期:2014-04-01 08:53:31天蝎座
日期:2014-04-01 08:53:53天秤座
日期:2014-04-01 08:54:02射手座
日期:2014-04-01 08:54:15子鼠
日期:2014-04-01 08:55:35辰龙
日期:2014-04-01 08:56:36未羊
日期:2014-04-01 08:56:27戌狗
日期:2014-04-01 08:56:13亥猪
日期:2014-04-01 08:56:02亥猪
日期:2014-04-08 08:38:58程序设计版块每日发帖之星
日期:2016-01-05 06:20:00程序设计版块每日发帖之星
日期:2016-01-07 06:20:00
2 [报告]
发表于 2011-11-07 12:23 |只看该作者
哈哈,发短信。

论坛徽章:
4
CU大牛徽章
日期:2013-03-13 15:29:07CU大牛徽章
日期:2013-03-13 15:29:49CU大牛徽章
日期:2013-03-13 15:30:192015年迎新春徽章
日期:2015-03-04 09:57:09
3 [报告]
发表于 2011-11-07 14:34 |只看该作者
这个卡具体是什么型号的 ? 还是均可以通过这种方式实现?

论坛徽章:
1
技术图书徽章
日期:2014-04-16 11:36:47
4 [报告]
发表于 2011-11-07 15:15 |只看该作者
to ls:

man umsm

Qualcomm MSM modem device

论坛徽章:
0
5 [报告]
发表于 2011-11-07 17:24 |只看该作者
讚!收藏

论坛徽章:
0
6 [报告]
发表于 2011-11-07 19:24 |只看该作者
还真没试过短信功能。

论坛徽章:
0
7 [报告]
发表于 2011-11-07 20:44 |只看该作者
这样发短信息还额外花钱不?

论坛徽章:
1
数据库技术版块每日发帖之星
日期:2015-08-09 06:20:00
8 [报告]
发表于 2011-11-07 21:07 |只看该作者
收藏个,或许以后有用

论坛徽章:
4
CU大牛徽章
日期:2013-03-13 15:29:07CU大牛徽章
日期:2013-03-13 15:29:49CU大牛徽章
日期:2013-03-13 15:30:192015年迎新春徽章
日期:2015-03-04 09:57:09
9 [报告]
发表于 2011-11-07 23:04 |只看该作者
貌似会赠送短信条数吧,算这个的吧。

论坛徽章:
20
CU大牛徽章
日期:2013-04-17 11:48:26羊年新春福章
日期:2015-03-10 22:39:202015年中国系统架构师大会
日期:2015-06-29 16:11:282015亚冠之平阳省
日期:2015-07-31 09:19:042015七夕节徽章
日期:2015-08-21 11:06:17IT运维版块每日发帖之星
日期:2015-09-30 06:20:002015亚冠之柏太阳神
日期:2015-10-19 20:29:5915-16赛季CBA联赛之天津
日期:2016-11-29 14:03:4315-16赛季CBA联赛之北控
日期:2016-12-24 20:51:492015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-12 20:58:532014年中国系统架构师大会
日期:2014-10-14 15:59:00
10 [报告]
发表于 2011-11-08 08:42 |只看该作者
真折腾啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP