老兔新传IT版

穷困潦倒的IT公司职员的故事

  博客园 :: :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
本文记录了我在Ubuntu中通过蓝牙连接Nokia E71并通过E71作为Modem上网的过程。
使用的硬件是安装了Ubuntu 9.04 32位桌面版的IBM T60笔记本;装载联通WCDMA卡的Nokia E71港行(版本号是200开头的)。
参考网站:http://davesource.com/Solutions/20070520.T-Mobile-Nokia-E65-Ubuntu-Linux.html (懒得听我废话的直接看这个网站就行了)

声明:这不是一篇技术翻译,只是我自己参考其他站点的内容所实施实践的一个记录。

1、打开手机的蓝牙,并通过Ubuntu连接到手机(这个时候只能浏览手机上的文件)。
如果你的电脑有安装蓝牙设备,默认状况下Ubuntu的桌面的右上方的通知栏里面会有蓝牙的图标,如果没有显示的话可以键入以下两个命令确认安装了相关的组件。并通过[系统]>[首选项]>[蓝牙]的方式呼出连接菜单。
# 安装bluez-utils
% apt-get install bluez-utils
# 如果安装过了的话apt会告知这个时候就直接跳到“安装图形配置工具”
#
 如果启动了下载和安装的话就说明原来没有那就继续执行下面的命令:
% /etc/init.d/bluetooth restart
% lsusb | grep -i bluetooth
(should show the bluetooth device)
% hcitool dev
(also lists bluetooth devices)

# 安装图形配置工具
% apt-get install bluez-gnome


2、使用sdptool命令确认你的手机的"Dialup Networking"服务,只要能够找到这个服务基本就没有问题。
# browse后面的MAC地址换成你自己手机的
#
 如果不知道MAC地址的话在手机上输入*#2820#
% sdptool browse 11:22:BE:EF:44:33
# 你会得到很多很多输出
……省略……
Service Name: Dial
-Up Networking
Service RecHandle: 
0x10002
Service Class ID List:
  
"Dialup Networking" (0x1103)  # 我们只关心这个服务
Protocol Descriptor List:
  
"L2CAP" (0x0100)
  
"RFCOMM" (0x0003)
    Channel: 
2            # 确认这个Channel,一般都是2
Language Base Attr List:
  code_ISO639: 
0x454e
  encoding:    
0x6a
  base_offset: 
0x100
Profile Descriptor List:
  
"Dialup Networking" (0x1103)
    Version: 
0x0100
……省略……

3、利用rfcomm命令绑定设备
# 将0后面的MAC地址换成你自己的(刚才用过了)
#
 最后一个数字就是刚才得到的Channel
% rfcomm bind 0 11:22:BE:EF:44:33 2

# 再用一次rfcomm命令确认一下绑定的结果
% rfcomm
rfcomm0: 
11:22:BE:EF:44:33 channel 2 clean # 这种输出就对了

# 看一下dev下是不是有了一个rfcomm0的设备
% ls /dev/rf*
/dev/rfcomm0

4、编辑pppd的配置文件
# 进入配置文件的存放目录
% cd /etc/ppp/peers
# 通过ls命令可以看到一个名为provider的配置文件模板
#
 将其复制一份
% cp provider gprs
# 编辑新的配置文件
% vi gprs
配置文件比较长,本文最后会贴出我用的那个配置文件,这里就说下几个修改项目:
  •  首先有一个user的配置项,我们不需要验证,清空双引号内的内容
  •  下面是connect将*****替换为要拨的号码,请替换为*99#(虽然比较奇怪,但就是这个)
  •  后面是device的配置,原本应该是/dev/modem,我们题换成刚刚绑定好的/dev/rfcomm0即可
  •  速度的设定我尝试下来不是非常重要,大家按实际设置吧,我随便设了一个
其他的选项不用动了,就这样保存即可。

5、启动连接,启动之前建议关闭现有的Internet(如果有的话),这样才能测试出效果
# 启动连接
% pppd call gprs
# 这个时候手机上应该会出现是否允许连接的认证提示,义无反顾的按下yes吧

# 如果没有任何错误提示就代表成功了
#
 用ifconfig命令来确认
% ifconfig
……省略……
ppp0      Link encap:点对点协议  
          inet 地址:
172.18.77.114  点对点:10.6.6.6  掩码:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:
1500  跃点数:1
          接收数据包:
4 错误:0 丢弃:0 过载:0 帧数:0
          发送数据包:
5 错误:0 丢弃:0 过载:0 载波:0
          碰撞:
0 发送队列长度:3 
          接收字节:
64 (64.0 B)  发送字节:97 (97.0 B)
……省略……
# 看到ppp0这段就代表确实成功了

开始上网吧,这篇博客就是在手机连接Internet的状态下发表的。
Ubuntu上这件事确实搞的比较麻烦,不如Windows和OS X。
虽然我用的是联通的WCDMA但是如果是移动或者联通的GPRS网络的话应该也能适用完全相同的设定。
最后附上我的配置文件:
# example configuration for a dialup connection authenticated with PAP or CHAP
#
#
 This is the default configuration used by pon(1) and poff(1).
#
 See the manual page pppd(8) for information on all the options.

# MUST CHANGE: replace myusername@realm with the PPP login name given to
#
 your by your provider.
#
 There should be a matching entry with the password in /etc/ppp/pap-secrets
#
 and/or /etc/ppp/chap-secrets.
user ""

# MUST CHANGE: replace ******** with the phone number of your provider.
#
 The /etc/chatscripts/pap chat script may be modified to change the
#
 modem initialization string.
connect "/usr/sbin/chat -v -f /etc/chatscripts/pap -T *99#"

# Serial device to which the modem is connected.
/dev/rfcomm0

# Speed of the serial line.
4096000

# Assumes that your IP address is allocated dynamically by the ISP.
noipdefault
# Try to get the name server addresses from the ISP.
usepeerdns
# Use this connection as the default route.
defaultroute

# Makes pppd "dial again" when the connection is lost.
persist

# Do not ask the remote to authenticate.
noauth
posted on 2009-10-13 17:05  老兔  阅读(1153)  评论(0编辑  收藏  举报