Options: -i [hciX|bdaddr] Local HCI device or BD Address -h, --help Display help -r, --raw Switch TTY into raw mode -A, --auth Enable authentication -E, --encrypt Enable encryption -S, --secure Secure connection -M, --master Become the master of a piconet -f, --config [file] Specify alternate config file -a Show all devices (default)
Commands: bind [channel] Bind device release Release device show Show device connect [channel] Connect device listen [channel [cmd]] Listen watch [channel [cmd]] Watch 大概我们要用的命令的样子是这个: rfcomm connect [channel] 这里面有三个参数我们要确定。 第一个是LINUX系统里面的设备,我们自己起个设备名:/dev/rfcomm0 . 第二个是手机的UUID, 这个用 hcitool来找.(在查找前,要先让手机的蓝牙设备处于可被搜索的状态: 017:45:07 /home/j # hcitool scan Scanning ... 00:1A:77:8B:17:D6 MOTOROKR E6 好,找到了. 我的就是这个 00:1A:77:8B:17:D6 然后要确定第三个参数[channel]. 因为拨号是用的串口,所以要找到手机的串口对应的channel,执行下面的指令 018:22:51 /home/j # sdptool -h sdptool - SDP tool v3.19 Usage: sdptool [options] [command parameters] Options: -h Display help -i Specify source interface Commands: search Search for a service browse Browse all available services records Request all records add Add local service del Delete local service get Get local service setattr Set/Add attribute to a SDP record setseq Set/Add attribute sequence to a SDP record
Services: DID SP DUN LAN FAX OPUSH FTP PRINT HS HF HFAG SAP NAP GN PANU HCRP HID KEYB WIIMOTE CIP CTP A2SRC A2SNK AVRCT AVRTG UDIUE UDITE SEMCHLA SR1 SYNCML SYNCMLSERV ACTIVESYNC HOTSYNC PALMOS NOKID PCSUITE NFTP NSYNCML NGAGE APPLE ISYNC 因为没有查到串口的服务名(service_name)对应上面的Services中的哪一个,所以只有猜测了。 哪一个最象呢? 里面最象的就是SP,我们先拿它开刀(SP大概应该是Serial Port的缩写)。 018:28:52 /home/j # sdptool search SP 00:1A:77:8B:17:D6 Inquiring ... Searching for SP on 00:1A:77:8B:17:D6 ... Service Name: Bluetooth Serial Port Service RecHandle: 0x10006 Service Class ID List: "Serial Port" (0x1101) Protocol Descriptor List: "L2CAP" (0x0100) "RFCOMM" (0x0003) Channel: 5 原来SP对应的是 Channel: 5.
现在就可以在LINUX里面建立设备连接到手机的MODEM上面了: 018:29:24 /home/j # rfcomm connect /dev/rfcomm0 00:1A:77:8B:17:D6 5 Connected /dev/rfcomm0 to 00:1A:77:8B:17:D6 on channel 5 Press CTRL-C for hangup
呵呵,连接上了.
这个时候就可以在LINUX里面利用/dev/rfcomm0这个设备拨号了: 020:07:02 /home/j # cat /etc/wvdial.conf [Dialer Defaults] Init1 = at+cgdcont=1,"ip","cmwap" Modem Type = BlueTooth Modem ISDN = 0 Phone = *99***1# Modem = /dev/rfcomm0 Username = "wap" Carrier Check = no Password = "wap" Baud = 460800 Auto DNS = on 先如上配置/etc/wvdial.conf. 并且在/etc/ppp/options里面加入 :192.168.0.254 然后执行wvdial: 018:29:07 /home/j # wvdial WvDial<*1>: WvDial: Internet dialer version 1.56 WvModem<*1>: Cannot get information for serial port. WvDial<*1>: Initializing modem. WvDial<*1>: Sending: at+cgdcont=1,"ip","cmwap" WvDial Modem<*1>: at+cgdcont=1,"ip","cmwap" WvDial Modem<*1>: OK WvDial<*1>: Modem initialized. WvDial<*1>: Sending: ATDT*99***1# WvDial<*1>: Waiting for carrier. WvDial Modem<*1>: ATDT*99***1# WvDial Modem<*1>: CONNECT WvDial<*1>: Carrier detected. Waiting for prompt. WvDial Modem<*1>: ~[7f]}#@!}!}!} }<}!}$}%\}"}&} } } } }#}$@#}%}&h}#} } }'}"}(}"}#}<~ WvDial<*1>: PPP negotiation detected. WvDial: Starting pppd at Sat Mar 1 18:29:47 2008 WvDial: Pid of pppd: 14991 WvDial<*1>: Using interface ppp1 WvDial<*1>: pppd: [18]?[06][08]??[06][08] WvDial<*1>: pppd: [18]?[06][08]??[06][08] WvDial<*1>: pppd: [18]?[06][08]??[06][08] WvDial<*1>: pppd: [18]?[06][08]??[06][08] WvDial<*1>: pppd: [18]?[06][08]??[06][08] WvDial<*1>: pppd: [18]?[06][08]??[06][08] WvDial<*1>: local IP address 10.198.35.182 WvDial<*1>: pppd: [18]?[06][08]??[06][08] WvDial<*1>: remote IP address 192.168.0.254 WvDial<*1>: pppd: [18]?[06][08]??[06][08] 可以看到已经拨号登录上去了,获得IP地址为WvDial<*1>: local IP address 10.198.35.182 查看网络设备WvDial<*1>: Using interface ppp1 DNS也被改变为新的: cat /etc/resolv.conf