<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fwolf's Blog &#187; bluetooth - Fwolf's Blog</title>
	<atom:link href="http://www.fwolf.com/blog/post/tag/bluetooth/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fwolf.com/blog</link>
	<description>随心·随意·随缘·努力～</description>
	<lastBuildDate>Wed, 07 Jul 2010 07:07:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Ubuntu和手机通过蓝牙互传文件</title>
		<link>http://www.fwolf.com/blog/post/393</link>
		<comments>http://www.fwolf.com/blog/post/393#comments</comments>
		<pubDate>Sat, 29 Mar 2008 17:28:56 +0000</pubDate>
		<dc:creator>Fwolf</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bluetooth]]></category>
		<category><![CDATA[hardy]]></category>
		<category><![CDATA[nokia]]></category>
		<category><![CDATA[obex]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.fwolf.com/blog/post/393</guid>
		<description><![CDATA[Ubuntu 7.10 Gutsy，手机Nokia 6120c，蓝牙适配器是让朋友帮买的，朋友不懂Linux，卖这个的也不懂，随便买了一个叫什么艾思凯（issk）蓝牙博士（BLUETOOTH DOCTOR）的，还行，一插机器上就认出来了，就是不知道各种参数如何，初步使用感觉传输距离或者说穿透力不强： $ lsusb Bus 001 Device 002: ID 1131:1001 Integrated System Solution Corp. KY-BT100 Bluetooth Adapter 首先安装一些必要的东东： sudo aptitude install gnome-bluetooth gnome-phone-manager 然后配置/etc/bluetooth/hcid.conf： # Security Manager mode # 安全设置模式，改成auto security auto; ... # Default PIN code for incoming connections # 匹配码/通行码，为安全起见，建议自己设一个。 passkey "1234"; ... # Local device name # %d - [...]]]></description>
			<content:encoded><![CDATA[<p>Ubuntu 7.10 Gutsy，手机Nokia 6120c，蓝牙适配器是让朋友帮买的，朋友不懂Linux，卖这个的也不懂，随便买了一个叫什么艾思凯（issk）蓝牙博士（BLUETOOTH DOCTOR）的，还行，一插机器上就认出来了，就是不知道各种参数如何，初步使用感觉传输距离或者说穿透力不强：</p>

<pre><code>$ lsusb
Bus 001 Device 002: ID 1131:1001 Integrated System Solution Corp. KY-BT100 Bluetooth Adapter
</code></pre>

<p>首先安装一些必要的东东：</p>

<pre><code>sudo aptitude install gnome-bluetooth gnome-phone-manager
</code></pre>

<p>然后配置<code>/etc/bluetooth/hcid.conf</code>：</p>

<pre><code># Security Manager mode
# 安全设置模式，改成auto
security auto; 
...
# Default PIN code for incoming connections
# 匹配码/通行码，为安全起见，建议自己设一个。
passkey "1234"; 
...
# Local device name
#   %d - device id
#   %h - host name
# 电脑在蓝牙设备中显示的名称，改不改无所谓，自己认识就行。
name "%h-%d"; 
</code></pre>

<p>重启服务/etc/init.d/bluetooth，从手机上查找匹配设备，找到电脑以后，输入刚才设定的匹配码；匹配成功之后，提示“授权设备自动连接”选“是”。</p>

<p>配置/etc/bluetooth/rfcomm.conf</p>

<pre><code>rfcomm0 {
    # 启动时自动绑定地址（什么意思？）
    bind yes;
    # 蓝牙设备地址（用$ hcitool scan查找，用$ sdptool browse [地址]查看频道）
    device 00:1C:D6:AC:7D:88;
    # 通迅频道
    channel 11;
    # 说明，自己随便写
    comment "Fwolf Nokia 6120c";
}
</code></pre>

<p>然后就可以用<code>rfcomm connect 0</code>连接手机了（测试一下）：</p>

<pre><code>$ rfcomm connect 0
Connected /dev/rfcomm0 to 00:1C:D6:AC:7D:88 on channel 1
Press CTRL-C for hangup
Disconnected
</code></pre>

<p>现在就可以传文件了：从电脑向手机发送文件用<code>gnome-obex-send 文件名</code>，按照提示选择蓝牙设备后，成功完成文件传输；从手机向电脑发送文件，电脑上要先运行<code>gnome-obex-server</code>，收到文件发送信号之后，会提示是否接收，接收完成后还会弹出一个如何处理的提示框，同时传多个文件的时候会比较烦人。传过来的文件都保存在<code>$HOME/Desktop</code>下，重名文件会自动更名。不过两个方向的传送方式传中文文件名都会乱码，文件内容没事（用usb数据线传没这问题）。</p>

<p>但gnome-phone-manager能发现手机但就是连不上，不知道是不是channel设置的问题，又好像是软件本身的问题，不知道回头升级到Hardy能好些不。</p>

<p>下面是一些网上搜到可能有用的东东：</p>

<h5>电脑上寻找蓝牙设备：</h5>

<pre><code>$ hcitool scan
Scanning ...
        00:1C:D6:AC:7D:88       Fwolf Nokia 6120c
</code></pre>

<h5>电脑上查询蓝牙手机（有时候只在适配器刚插上的时候能查询出数据，后来再用就连接超时）：</h5>

<pre><code>$ sdptool browse 00:1C:D6:AC:7D:88
Service Name: AVRCP Target
Service Description: Audio Video Remote Control
Service Provider: Symbian Software Ltd.
Service RecHandle: 0x10000
Service Class ID List:
  "AV Remote Target" (0x110c)
Protocol Descriptor List:
  "L2CAP" (0x0100)
    PSM: 23
  "AVCTP" (0x0017)
    uint16: 0x100
Profile Descriptor List:
  "AV Remote" (0x110e)
    Version: 0x0100

Service Name: Hands-Free Audio Gateway
Service RecHandle: 0x10004
Service Class ID List:
  "Handfree Audio Gateway" (0x111f)
  "Generic Audio" (0x1203)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 1
Language Base Attr List:
  code_ISO639: 0x454e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Handsfree" (0x111e)
    Version: 0x0105

Service Name: Headset Audio Gateway
Service RecHandle: 0x10005
Service Class ID List:
  "Headset Audio Gateway" (0x1112)
  "Generic Audio" (0x1203)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 2
Language Base Attr List:
  code_ISO639: 0x454e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Headset" (0x1108)
    Version: 0x0100

Service Name: Audio Source
Service RecHandle: 0x10011
Service Class ID List:
  "Audio Source" (0x110a)
Protocol Descriptor List:
  "L2CAP" (0x0100)
    PSM: 25
  "AVDTP" (0x0019)
    uint16: 0x100
Language Base Attr List:
  code_ISO639: 0x454e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Advanced Audio" (0x110d)
    Version: 0x0100

Service Name: AVRCP Controller
Service Description: Audio Video Remote Control
Service Provider: Symbian Software Ltd.
Service RecHandle: 0x10012
Service Class ID List:
  "AV Remote" (0x110e)
Protocol Descriptor List:
  "L2CAP" (0x0100)
    PSM: 23
  "AVCTP" (0x0017)
    uint16: 0x100
Profile Descriptor List:
  "AV Remote" (0x110e)
    Version: 0x0100

Service Name: SyncMLClient
Service RecHandle: 0x10013
Service Class ID List:
  UUID 128: 00000002-0000-1000-8000-0002ee000002
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 10
  "OBEX" (0x0008)
Language Base Attr List:
  code_ISO639: 0x454e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "" (0x00000002-0000-1000-8000-0002ee000002)
    Version: 0x0100

Service Name: OBEX File Transfer
Service RecHandle: 0x10014
Service Class ID List:
  "OBEX File Transfer" (0x1106)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 11
  "OBEX" (0x0008)
Language Base Attr List:
  code_ISO639: 0x454e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "OBEX File Transfer" (0x1106)
    Version: 0x0100

Service Name: Nokia OBEX PC Suite Services
Service RecHandle: 0x10015
Service Class ID List:
  UUID 128: 00005005-0000-1000-8000-0002ee000001
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 12
  "OBEX" (0x0008)
Language Base Attr List:
  code_ISO639: 0x454e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "" (0x00005005-0000-1000-8000-0002ee000001)
    Version: 0x0100

Service Name: Nokia SyncML Server
Service RecHandle: 0x10016
Service Class ID List:
  UUID 128: 00005601-0000-1000-8000-0002ee000001
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 13
  "OBEX" (0x0008)
Language Base Attr List:
  code_ISO639: 0x454e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "" (0x00005601-0000-1000-8000-0002ee000001)
    Version: 0x0100

Service RecHandle: 0x10017
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 3

Service Name: OBEX Object Push
Service RecHandle: 0x10018
Service Class ID List:
  "OBEX Object Push" (0x1105)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 9
  "OBEX" (0x0008)
Language Base Attr List:
  code_ISO639: 0x454e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "OBEX Object Push" (0x1105)
    Version: 0x0100

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

Service Name: Imaging
Service RecHandle: 0x1001a
Service Class ID List:
  "Imaging Responder" (0x111b)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 15
  "OBEX" (0x0008)
Language Base Attr List:
  code_ISO639: 0x454e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Imaging" (0x111a)
    Version: 0x0100
</code></pre>

<p>这个可以用来查channel号码，不同手机的号码可能会不同，大概是要选择<code>OBEX File Transfer</code>所在的channel（我的手机是11），也有人说是用<code>OBEX Object Push</code>的频道（我的手机是9）,再好像有时候瞎设一个或者干脆用1也能进行文件传输，总之有点深奥没弄明白，期待明白人发言。</p>

<h5>在手机上查看蓝牙设备地址：*#2820</h5>

<h5>备注：gnome-obex-send找不到手机的解决办法（未测试）</h5>

<pre><code>sudo hciconfig hci0 inqmode 0
</code></pre>

<h4>参考</h4>

<ul>
<li><a href="http://forum.ubuntu.org.cn/viewtopic.php?t=43475">[原创]linux下手机与蓝牙的连接配置</a></li>
</ul>

<h4>Update @ 2008-07-04</h4>

<p>升级到Ubuntu 8.04 hardy后，可以用<code>bluetooth-sendto</code>从电脑向手机发送文件，但从手机向电脑发总是不成功，可能和适配器有关系，<a href="http://forum.ubuntu.org.cn/viewtopic.php?p=826513">也有人遇到了同样的问题</a>，<a href="http://www.google.cn/search?aq=f&amp;complete=1&amp;hl=zh-CN&amp;newwindow=1&amp;as_qdr=all&amp;q=bluetooth+conn_complete%3A+status+0x00+bluetooth+gnome-obex-server+not+working">还有很多</a>，怀疑是<a href="http://lists.gnomehack.com/pipermail/gnome-bluetooth/2007-June/001270.html">和无线局域网的信号有干扰</a>，但关闭无线网之后仍不行；最后，终于发现是<a href="https://bugs.launchpad.net/ubuntu/+source/obex-data-server/+bug/211252">bluz-utils</a>的问题，按照其中有一个留言的提示，把<a href="https://launchpad.net/ubuntu/intrepid/i386/bluez-utils/3.30-3ubuntu2">intrepid里的bluez-utils包</a>下载下来装上，就ok啦。</p>

	Tags: <a href="http://www.fwolf.com/blog/post/tag/bluetooth" title="bluetooth" rel="tag">bluetooth</a>, <a href="http://www.fwolf.com/blog/post/tag/hardy" title="hardy" rel="tag">hardy</a>, <a href="http://www.fwolf.com/blog/post/tag/linux" title="Linux" rel="tag">Linux</a>, <a href="http://www.fwolf.com/blog/post/tag/nokia" title="nokia" rel="tag">nokia</a>, <a href="http://www.fwolf.com/blog/post/tag/obex" title="obex" rel="tag">obex</a>, <a href="http://www.fwolf.com/blog/post/tag/ubuntu" title="Ubuntu" rel="tag">Ubuntu</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.fwolf.com/blog/post/392" title="virtualbox连接usb设备 (2008-03-27)">virtualbox连接usb设备</a> (0)</li>
	<li><a href="http://www.fwolf.com/blog/post/403" title="Ubuntu从Gutsy升级到Hardy，php5-sybase又掉链子 (2008-06-12)">Ubuntu从Gutsy升级到Hardy，php5-sybase又掉链子</a> (2)</li>
	<li><a href="http://www.fwolf.com/blog/post/372" title="Linux下使用华为h3c Aolynk WuB320G无线网卡 (2007-12-02)">Linux下使用华为h3c Aolynk WuB320G无线网卡</a> (0)</li>
	<li><a href="http://www.fwolf.com/blog/post/279" title="配置ssh的自动登录 (2007-01-05)">配置ssh的自动登录</a> (12)</li>
	<li><a href="http://www.fwolf.com/blog/post/400" title="选择Eclipse PHP Development Tools(PDT)作为PHP开发工具 (2008-05-03)">选择Eclipse PHP Development Tools(PDT)作为PHP开发工具</a> (8)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.fwolf.com/blog/post/393/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
