3667755 发表于 2008-9-12 07:58

magic Linux2.0+蓝牙+Nokia+EDGE上网,整理的。

magic 2.0下使用杂牌蓝牙适配器并通过手机gprs上网

小弟有一P3的本本,装了magice2.0,运行得很好。近日想通过手机上网,体验一下无线的乐趣。于是买了一个杂牌蓝牙适配器。就是电脑城几十块钱一个,没有印上牌子的那种。买的时候在winxp下试用,一切正常。。但回家后在magic2.0上无法使用。。。在论坛上也找不到解决方法。难道真的是便宜没好货。不死心的在网上搜索,经过一翻折腾。终于成功。不敢独享,贴上来请各位大大指点,看有什么可以改进的。

一、.安装
bluez-libs 2.24   http://download.chinaunix.net/download/0001000/990.shtml
bluez-utils 2.24   http://download.chinaunix.net/download/0001000/991.shtml
官方网站上有提供3.7版的下载。但经过小弟试验,好像因为3.x版的不支持kdebluetooth1.0-0.beta1版的kbluepin。导致无法与手机配对。我在ChinaUnix.net下载了这两个程序的源码包。(很奇怪,2.25版的在我的机器上无法编译.......)

二、.装完这两个程序后,插上蓝牙适配器。打开Konsole,su 取得root权限。

1. 运行命令 lsusb 应该可以看到: (如果没有请确认你的适配器有正确插入,usb插口跟适配器无损坏,还是没有的话,那以下就可以不用看了)

Bus 001 Device 002: ID 1131:1001 Integrated System Solution Corp. KY-BT100 Bluetooth Adapter                  <------不同型号显示有所不同,能认出就行

运行 hciconfig 可以看到:

hci0:   Type: USB
      BD Address: 00:00:00:00:00:00 ACL MTU: 0:0 SCO MTU: 0:0
      DOWN
      RX bytes:0 acl:0 sco:0 events:0 errors:0
      TX bytes:0 acl:0 sco:0 commands:0 errors:0

没有激活。激活它。运行:

hciconfig hci0 up

2. 配置 Bluez
修改/etc/bluetooth/hcid.conf 文件

*********************************************************************
#
# HCI daemon configuration file.
#

# HCId options
options {
      # Automatically initialize new devices
      autoinit yes;

      # Security Manager mode
      #   none - Security manager disabled
      #   auto - Use local PIN for incoming connections
      #   user - Always ask user for a PIN
      #
      security user;                           <--------安全模式,需要手动输入密码

      # Pairing mode
      #   none- Pairing disabled
      #   multi - Allow pairing with already paired devices
      #   once- Pair once and deny successive attempts
      pairing multi;

      # PIN helper
      pin_helper /usr/lib/kdebluetooth/kbluepin;                      <--------pin_helper 的位置。

      # D-Bus PIN helper
      #dbus_pin_helper;
}

# Default settings for HCI devices
device {
      # Local device name
      #   %d - device id
      #   %h - host name
      name "BlueZ (%d)";                              <---------设备名称,可以自己修改双引号内的内容为自己想要的名称

      # Local device class
      class 0xff0100;

      # Default packet type
      #pkt_type DH1,DM1,HV1;

      # Inquiry and Page scan
      iscan enable; pscan enable;

      # Default link mode
      #   none   - no specific policy
      #   accept - always accept incoming connections
      #   master - become master on incoming connections,
      #            deny role switch on outgoing connections
      lm accept;

      # Default link policy
      #   none    - no specific policy
      #   rswitch - allow role switch
      #   hold    - allow hold mode
      #   sniff   - allow sniff mode
      #   park    - allow park mode
      lp rswitch,hold,sniff,park;

      # Authentication and Encryption (Security Mode 3)
      #auth enable;
      #encrypt enable;
}

********************************************************************************

3. 打开手机的蓝牙。运行 hcitool scan 可以得到:

Scanning ...
      00:13:70:2D:0E:08       Nokia 3230                   <---------你的手机。偶的是“挪积压 3230”。前面是手机的MAC地址。

运行命令
sdpd
hcid start
kbluetoothd    或者是K菜单--->互联网--->kbluetoothd (蓝牙服务器)
然后在手机上进行蓝牙配对。成功后,就可以试试在电脑上右键点任一文件,动作-->通过蓝牙发送,将文件发送给手机。手机也可以传送文件进电脑了。

三、现在,要设置蓝牙连接手机WAP代理上网了         (忘记在哪个网看到的了,原文是E文的。)
所用的工具:
pppd(用来拨号的)
rfcomm(用来连接手机拨号服务)

1. 需要建立编辑的文件有2个:
第一个:/etc/ppp/peers/gprs
内容如下:

/dev/rfcomm0
230400
defaultroute
usepeerdns
user ''
password bobo
nodetach
crtscts
lock
noauth
local
debug
connect "/usr/sbin/chat -v -f /etc/ppp/chat-gprs"

第二个:/etc/ppp/chat-gprs
内容如下:

TIMEOUT 10
ABORT 'BUSY'
ABORT 'NO ANSWER'
ABORT 'ERROR'
"" 'ATZ'
OK 'AT+CGDCONT=1,"IP","cmwap" '          <---------如果你是使用cmnet节点的,可以将cmwap改成cmnet,那不用代理就能上网,不过钱就..贵啊!
ABORT 'NO CARRIER'
SAY 'Dialing....\n'
OK 'ATD*99#'                              <---------"*99#"
CONNECT ''


2.运行 sdptool search DUN 搜索设备的DUN服务,即网络拨号服务。

Inquiring ...
Searching for DUN on 00:13:70:2D:0E:08 ...
Service Name: Dial-Up Networking
Service RecHandle: 0x10005
Service Class ID List:
"Dialup Networking" (0x1103)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
    Channel: 2                                  <---------你手机RFCOMM的工作信道。记住了啊。不同机型是不同的
Language Base Attr List:
code_ISO639: 0x454e
encoding:    0x6a
base_offset: 0x100
Profile Descriptor List:
"Dialup Networking" (0x1103)
    Version: 0x0100

3. 修改/etc/bluetooth/rfcomm.conf

*******************************************************************************
#
# RFCOMM configuration file.
#

rfcomm0 {
      # Automatically bind the device at startup
      bind yes;                              <---------将 no 改为 yes

      # Bluetooth address of the device
      device 00:13:70:2D:0E:08;                              <---------改为你手机的MAC地址

      # RFCOMM channel for the connection
      channel      2;                        <---------改为你手机RFCOMM的工作信道。

      # Description of the connection
      comment "Example Bluetooth device";
}
**********************************************************************************

4. 绑定rfcomm0到手机上:

rfcomm bind /dev/rfcomm0

根据你手机的情况编写。这里的命令应该写成:

rfcomm bind /dev/rfcomm000:13:70:2D:0E:08 2

所谓绑定,类似于设定/dev/rfcomm0对应某个确定的蓝牙设备和它的某个channel。可以把它想像为将一条串口电缆连接到某台计算机上的某个串口上。

5. 运行命令进行拨号:

pppd call gprs

输出差不多如下的东东,那么恭喜你 ,成功了!!!
Dialing....
Serial connection established.
using channel 3
Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm0
sent
rcvd
sent
rcvd
rcvd
sent
sent
sent
rcvd
PAP authentication succeeded
sent
sent
rcvd
sent
rcvd
rcvd
sent
rcvd
sent
rcvd
localIP address 10.213.77.9
remote IP address 10.6.6.6
primary   DNS address 0.0.0.19
secondary DNS address 0.71.35.128
Script /etc/ppp/ip-up started (pid 320
Script /etc/ppp/ip-up finished (pid 320, status = 0x0

6.打开firefox浏览器,(其它的浏览器请自己查找代理服器的设置)
编辑--->首选项--->高级--->网络--->连接--->设置--->手动配置代理
HTTP 代理填上 10.0.0.172端口为 80
OK!!现在可以上网了,速度跟用MODEM拨号差不多。。

PS:如果没有配对或是没有设置电脑为授权设备,会要求确认联接,另外,每次开机都要以root权限运行
hciconfig hci0 up
sdpd
hcid start
rfcomm bind /dev/rfcomm000:13:70:2D:0E:08 2
你可以将以上命令编成一个Shell脚本。嘿嘿。

最后修改/etc/resolv.conf

nameserver 221.130.33.52
search localhost
不然可以拔号但是打不开网页。

我写了一个shell。
hciconfig hci0 up
sdpd
hcid start
rfcomm bind /dev/rfcomm000:13:70:2D:0E:08
pppd call gprs
保存为/opt/gprs.sh

oerw 发表于 2008-9-12 08:06

正准备用LINUX,留个记号,下次试验一下

shenxf 发表于 2008-9-12 08:42

苦劳

number1988 发表于 2008-9-12 13:11

ycren 发表于 2008-9-12 13:16

^o^ 强帖留名,收藏了!!!

wokin 发表于 2008-9-12 14:02

你这个怎么这么复杂^^? ^^? ^^?

huang719113 发表于 2008-9-12 19:37

这个是比较复杂哦,看的晕啊。可以在简单点不?

3667755 发表于 2008-9-13 12:21

简单点的不知道怎么弄,我不懂Linux,一般30分钟可以搞定,将就吧
页: [1]
查看完整版本: magic Linux2.0+蓝牙+Nokia+EDGE上网,整理的。