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

一、.安装
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 [MAC] [channel]

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

rfcomm bind /dev/rfcomm0 00: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 [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x6df58d43> <pcomp> <accomp>]
rcvd [LCP ConfRej id=0x1 <magic 0x6df58d43> <pcomp> <accomp>]
sent [LCP ConfReq id=0x2 <asyncmap 0x0>]
rcvd [LCP ConfAck id=0x2 <asyncmap 0x0>]
rcvd [LCP ConfReq id=0x0 <auth pap> <mru 1500> <asyncmap 0xa0000>]
sent [LCP ConfAck id=0x0 <auth pap> <mru 1500> <asyncmap 0xa0000>]
sent [PAP AuthReq id=0x1 user="MagicLinux" password=<hidden>]
sent [PAP AuthReq id=0x2 user="MagicLinux" password=<hidden>]
rcvd [PAP AuthAck id=0x2 ""]
PAP authentication succeeded
sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15>]
sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [IPCP ConfReq id=0x0 <addr 10.6.6.6>]
sent [IPCP ConfAck id=0x0 <addr 10.6.6.6>]
rcvd [LCP ProtRej id=0x0 80 fd 01 01 00 0c 1a 04 78 00 18 04 78 00]
rcvd [IPCP ConfRej id=0x1 <compress VJ 0f 01>]
sent [IPCP ConfReq id=0x2 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [IPCP ConfNak id=0x2 <addr 10.213.77.9> <ms-dns1 0.0.0.19> <ms-dns3 0.71.35.128>]
sent [IPCP ConfReq id=0x3 <addr 10.213.77.9> <ms-dns1 0.0.0.19> <ms-dns3 0.71.35.128>]
rcvd [IPCP ConfAck id=0x3 <addr 10.213.77.9> <ms-dns1 0.0.0.19> <ms-dns3 0.71.35.128>]
local IP 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 3208)
Script /etc/ppp/ip-up finished (pid 3208), status = 0x0

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

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

注意:要退出系统时最好把kbluetoothd退出,并选择不要在系统启动时运行,不然下次启动系统会导致kbluetoothd出错并失去响应。 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值