歡迎您光臨本站 註冊首頁

linux debian 手機usb線和藍牙撥號上網

←手機掃碼閱讀     火星人 @ 2014-03-08 , reply:0

閑話少說,沒有網路是很難過的,家裡、單位都有網路,但偶爾沒網的地方又想上網,就要充分利用手機的上網包月流量.

本人手機:n97mini(只要支持藍牙就行,呵呵)

筆記本(laptop):華碩A2400(老爺機,256M內存,debian6)

藍牙適配器:Henkel,不知道,反正手機上顯示ISSCBTM,這個linux應該沒問題

參考文檔:首先當然是在官方wiki找:http://wiki.debian.org/UseYourCellPhoneAsModem,用連接線可以了,但是用藍牙卻不行,考慮是不是沒開藍牙撥號服務,在windows下可以,但一直沒找到怎麼看的方法.左搜右搜,最後終於在這篇文檔上找到了答案:http://davesource.com/Solutions/20070520.T-Mobile-Nokia-E65-Ubuntu-Linux.html.原因很簡單,手機不同,所以DUN(Dial Up Networking)服務對應的rfcomm埠不同,官方文檔的是用2埠,見命令:rfcomm connect 0 11:22:33:44:55:66 2 &,後接&表示在後台運行,我的手機卻是在22埠,這是用sdptool命令查到的,後面會說.好,下面就上操作步驟(參考官方文檔,略加修改):

1、首先查看、安裝藍牙服務.

# /etc/init.d/bluetooth status
bluetooth is running
沒有請安裝

#aptitude install bluetooth 或者 啟動# /etc/init.d/bluetooth start
有些是這個命令,隨便
#apt-get install bluez-utils(bluez) (在testing/unstable, bluez代替bluez-utils).

2、插上藍牙適配器,查看識別情況,一般沒問題.

#lsusb | grep -i bluetooth
(should show the bluetooth device)
Bus 004 Device 003: ID 1131:1001 Integrated System Solution Corp.


KY-BT100 Bluetooth Adapter
#hcitool dev
(also lists bluetooth devices)

Devices:
hci0 00:11:22:33:44:55 (這應該顯示的是你的設備mac地址)

3、手機與電腦配對,最好在手機上將電腦端設為授權設備,不用驗證就可連接.

4、設置手機Modem參數.

用usb數據線接上手機,手機選“ovi套件”模式,然後安裝撥號工具包.

# apt-get install wvdial
# wvdialconf

會創建配置文件/etc/wvdial.conf,

[Dialer Defaults]

Init1 = ATZ

Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 FCLASS=0

Phone = <your phone number>

Username = <your username>

Password = <your password>

Baud = 460800

ISDN = 0

Modem Type = USB Modem

Modem = /dev/ttyACM0

修改如下(預設的參數最好不要改,是自動生成的,只需要把號碼、用戶名、密碼修改,然後加上條Init6,配置手機上網的方式):


[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 FCLASS=0
Init6 = AT CGDCONT=1,"IP","cmnet"
New PPPD = yes
Phone = *99***1#
Username = any
Password = any
Baud = 460800
ISDN = 0

[Dialer usb]
Modem Type = USB Modem
Modem = /dev/ttyACM0

[Dialer blz]
Modem = /dev/rfcomm0

然後用ifconfig命令將連網設備down.

5、手機usb數據線撥號上網.

# wvdial usb &

6、手機藍牙撥號上網還需要配置rfcomm參數.

前面用hcitool dev命令看到了藍牙適配器,下面用hcitool scan命令搜索手機.

Scanning...
00:11:22:33:44:55 NameDevice (這顯示的是你的手機mac地址和名字)

或者在手機上撥號"*#2820#",得到手機的mac地址.然後用命令sdptool search dun或者sdptool browse 00:11:22:33:44:55(這裡用你手機的mac地址)查找你手機撥號服務的rfcomm埠.

sdptool search dun
Service Name: Dial-Up Networking
Service RecHandle: 0x1001e
Service Class ID List:
"Dialup Networking" (0x1103)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 2
Language Base Attr List:
code_ISO639: 0x454e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Dialup Networking" (0x1103)
Version: 0x0100

主要看channel的號碼,我的手機是22,所以後面我修改rfcomm.conf埠號為22.我的文件/etc/bluetooth/rfcomm.conf內容.

rfcomm0 {
# # Automatically bind the device at startup
# bind no;
#
# # Bluetooth address of the device
device e4:ec:10:d5:f4:ab;
#
# # RFCOMM channel for the connection
channel 22;
#
# # Description of the connection
comment "wvdial connect blz";
}

rfcomm1 {
# # Automatically bind the device at startup
# bind no;
#
# # Bluetooth address of the device
device e4:ec:10:d5:f4:ab;
#
# # RFCOMM channel for the connection
channel 1;
#
# # Description of the connection
comment "Example Bluetooth device";
}

請參照自己的手機修改.

7、命令:rfcomm connect 0

連接rfcomm0進行撥號上網,前面在rfcomm.conf裡面設置了手機mac地址和埠號,所以這隻要直接連接設備0就行了,如果不做上面設置,請在命令行輸入:

rfcomm connect 0 00:11:22:33:44:55 22 &

8、看著電腦顯示撥號連接信息,大功告成.

本文出自 「我的學習筆記」 博客,請務必保留此出處http://wangyanwen.blog.51cto.com/1207461/702100


[火星人 ] linux debian 手機usb線和藍牙撥號上網已經有1409次圍觀

http://coctec.com/docs/linux/show-post-46518.html