⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 network-bluetooth.html

📁 FreeBSD安装说明概述 FreeBSD 提供了一个以文字为主
💻 HTML
📖 第 1 页 / 共 2 页
字号:
        pin     "1234";      }</pre><p>There is no limitation on PIN codes (except length). Some devices (for exampleBluetooth headsets) may have a fixed PIN code built in. The <var class="OPTION">-d</var>switch forces the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">hcsecd</span>(8)</span> daemon to stay in the foreground, so it iseasy to see what is happening. Set the remote device to receive pairing and initiate theBluetooth connection to the remote device. The remote device should say that pairing wasaccepted, and request the PIN code. Enter the same PIN code as you have in <ttclass="FILENAME">hcsecd.conf</tt>. Now your PC and the remote device are paired.Alternatively, you can initiate pairing on the remote device. Below in the sample <ttclass="COMMAND">hcsecd</tt> output.</p><pre class="PROGRAMLISTING">hcsecd[16484]: Got Link_Key_Request event from 'ubt0hci', remote bdaddr 0:80:37:29:19:a4hcsecd[16484]: Found matching entry, remote bdaddr 0:80:37:29:19:a4, name 'Pav's T39', link key doesn't existhcsecd[16484]: Sending Link_Key_Negative_Reply to 'ubt0hci' for remote bdaddr 0:80:37:29:19:a4hcsecd[16484]: Got PIN_Code_Request event from 'ubt0hci', remote bdaddr 0:80:37:29:19:a4hcsecd[16484]: Found matching entry, remote bdaddr 0:80:37:29:19:a4, name 'Pav's T39', PIN code existshcsecd[16484]: Sending PIN_Code_Reply to 'ubt0hci' for remote bdaddr 0:80:37:29:19:a4</pre></div><div class="SECT2"><h2 class="SECT2"><a id="AEN25866" name="AEN25866">19.4.7. Service Discovery Protocol(SDP)</a></h2><p>The Service Discovery Protocol (SDP) provides the means for client applications todiscover the existence of services provided by server applications as well as theattributes of those services. The attributes of a service include the type or class ofservice offered and the mechanism or protocol information needed to utilize theservice.</p><p>SDP involves communication between a SDP server and a SDP client. The server maintainsa list of service records that describe the characteristics of services associated withthe server. Each service record contains information about a single service. A client mayretrieve information from a service record maintained by the SDP server by issuing a SDPrequest. If the client, or an application associated with the client, decides to use aservice, it must open a separate connection to the service provider in order to utilizethe service. SDP provides a mechanism for discovering services and their attributes, butit does not provide a mechanism for utilizing those services.</p><p>Normally, a SDP client searches for services based on some desired characteristics ofthe services. However, there are times when it is desirable to discover which types ofservices are described by an SDP server's service records without any a prioriinformation about the services. This process of looking for any offered services iscalled <span class="emphasis"><i class="EMPHASIS">browsing</i></span>.</p><p>Currently Bluetooth SDP server and client are implemented in a third-party package <bclass="APPLICATION">sdp-1.5</b> that can be downloaded from <ahref="http://www.geocities.com/m_evmenkin/" target="_top">here</a>. The <bclass="APPLICATION">sdptool</b> is a command line SDP client. The following example showshow to perform a SDP browse query.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">sdptool browse 00:80:37:29:19:a4</kbd>Browsing 00:80:37:29:19:A4 ...Service Name: Dial-up NetworkingProtocol Descriptor List: "L2CAP" (0x0100) "RFCOMM" (0x0003)   Channel: 1Service Name: FaxProtocol Descriptor List: "L2CAP" (0x0100) "RFCOMM" (0x0003)   Channel: 2Service Name: Voice gatewayService Class ID List: "Headset Audio Gateway" (0x1112) "Generic Audio" (0x1203)Protocol Descriptor List: "L2CAP" (0x0100) "RFCOMM" (0x0003)   Channel: 3</pre><p>... and so on. Note that each service has a list of attributes (RFCOMM channel forexample). Depending on the service you might need to make a note of some of theattributes. Some Bluetooth implementations do not support service browsing and may returnan empty list. In this case it is possible to search for the specific service. Theexample below shows how to search for the OBEX Object Push (OPUSH) service.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">sdptool search --bdaddr 00:07:e0:00:0b:ca OPUSH</kbd></pre><p>Offering services on FreeBSD to Bluetooth clients is done with the <bclass="APPLICATION">sdpd</b> server.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">sdpd</kbd></pre><p>The <b class="APPLICATION">sdptool</b> is also used to register a service with thelocal SDP server. The example below shows how to register the Network Access with PPP(LAN) service. Note that some services require attributes (RFCOMM channel forexample).</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">sdptool add --channel=7 LAN</kbd></pre><p>The list of services registered with local SDP server can be obtained by issuing SDPbrowse query to a ``special'' BD_ADDR.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">sdptool browse ff:ff:ff:00:00:00</kbd></pre></div><div class="SECT2"><h2 class="SECT2"><a id="AEN25898" name="AEN25898">19.4.8. Dial-Up Networking (DUN) andNetwork Access with PPP (LAN) Profiles</a></h2><p>The Dial-Up Networking (DUN) profile is mostly used with modems and cellular phones.The scenarios covered by this profile are the following:</p><ul><li><p>use of a cellular phone or modem by a computer as a wireless modem for connecting to adial-up internet access server, or using other dial-up services;</p></li><li><p>use of a cellular phone or modem by a computer to receive data calls.</p></li></ul><p>Network Access with PPP (LAN) profile can be used in the following situations:</p><ul><li><p>LAN access for a single Bluetooth device;</p></li><li><p>LAN access for multiple Bluetooth devices;</p></li><li><p>PC to PC (using PPP networking over serial cable emulation).</p></li></ul><p>In FreeBSD both profiles are implemented with <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">ppp</span>(8)</span> and <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">rfcomm_pppd</span>(8)</span> - a wrapper that converts RFCOMMBluetooth connection into something PPP can operate with. Before any profile can be used,a new PPP label in <tt class="FILENAME">/etc/ppp/ppp.conf</tt> must be created. Consult<span class="CITEREFENTRY"><span class="REFENTRYTITLE">rfcomm_pppd</span>(8)</span>manual page for examples.</p><p>In the following example <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">rfcomm_pppd</span>(8)</span> will be used to open RFCOMM connectionto remote device with BD_ADDR 00:80:37:29:19:a4 on DUN RFCOMM channel. The actual RFCOMMchannel number will be obtained from the remote device via SDP. It is possible to specifyRFCOMM channel by hand, and in this case <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">rfcomm_pppd</span>(8)</span> will not perform SDP query. Use <bclass="APPLICATION">sdptool</b> to find out RFCOMM channel on the remote device.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">rfcomm_pppd -a 00:80:37:29:19:a4 -c -C dun -l rfcomm-dialup</kbd></pre><p>In order to provide Network Access with PPP (LAN) service <bclass="APPLICATION">sdpd</b> server must be running. It is also required to register LANservice with the local SDP server. Note that LAN service requires RFCOMM channelattribute. A new entry for LAN clients must be created in <ttclass="FILENAME">/etc/ppp/ppp.conf</tt> file. Consult <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">rfcomm_pppd</span>(8)</span> manual page for examples. Finally,RFCOMM PPP server must be running and listening on the same RFCOMM channel as registeredwith the local SDP server. The example below shows how to start RFCOMM PPP server.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">rfcomm_pppd -s -C 7 -l rfcomm-server</kbd></pre></div><div class="SECT2"><h2 class="SECT2"><a id="AEN25947" name="AEN25947">19.4.9. OBEX Push (OPUSH)Profile</a></h2><p>OBEX is a widely used protocol for simple file transfers between mobile devices. Itsmain use is in infrared communication, where it is used for generic file transfersbetween notebooks or Palm handhelds, and for sending business cards or calendar entriesbetween cellular phones and other devices with PIM applications.</p><p>The OBEX server and client are implemented as a third-party package <bclass="APPLICATION">obexapp-1.0</b> that can be downloaded from <ahref="http://www.geocities.com/m_evmenkin/" target="_top">here</a>. The package requiresthe <b class="APPLICATION">openobex</b> library (included) and the <ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/devel/glib12/pkg-descr"><ttclass="FILENAME">devel/glib12</tt></a> port. Note that <b class="APPLICATION">obexapp</b>does not require root privileges to operate.</p><p>OBEX client is used to push and/or pull objects from the OBEX server. An object can,for example, be a business card or an appointment. The OBEX client can obtain RFCOMMchannel number from the remote device via SDP. This can be done by specifying servicename instead of RFCOMM channel number. Supported service names are: IrMC, FTRN and OPUSH.It is possible to specify RFCOMM channel as a number. Below is an example of an OBEXsession, where device information object is pulled from the cellular phone, and a newobject (business card) is pushed into the phone's directory.</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbdclass="USERINPUT">obexapp -a 00:80:37:29:19:a4 -C IrMC</kbd>obex&gt; getget: remote file&gt; telecom/devinfo.txtget: local file&gt; devinfo-t39.txtSuccess, response: OK, Success (0x20)obex&gt; putput: local file&gt; new.vcfput: remote file&gt; new.vcfSuccess, response: OK, Success (0x20)obex&gt; diSuccess, response: OK, Success (0x20)</pre><p>In order to provide OBEX Push service, <b class="APPLICATION">sdpd</b> server must berunning. It is also required to register OPUSH service with the local SDP server. Notethat OPUSH service requires RFCOMM channel attribute. A root folder, where all incomingobjects will be stored, must be created. The default path to the root folder is <ttclass="FILENAME">/var/spool/obex</tt>. Finally, OBEX server must be running and listeningon the same RFCOMM channel as registered with the local SDP server. The example belowshows how to start OBEX server.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">obexapp -s -C 10</kbd></pre></div><div class="SECT2"><h2 class="SECT2"><a id="AEN25966" name="AEN25966">19.4.10. Serial Port (SP)Profile</a></h2><p>The Serial Port (SP) profile allows Bluetooth device to perform RS232 (or similar)serial cable emulation. The scenario covered by this profile deals with legacyapplications using Bluetooth as a cable replacement, through a virtual serial portabstraction.</p><p>The <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">rfcomm_sppd</span>(1)</span> utility implements the Serial Portprofile. Pseudo tty is used as a virtual serial port abstraction. The example below showshow to connect to a remote device Serial Port service. Note that you do not have tospecify RFCOMM channel - <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">rfcomm_sppd</span>(1)</span> can obtain it from the remote devicevia SDP. If you would like to override this, specify RFCOMM channel in the commandline.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">rfcomm_sppd -a 00:07:E0:00:0B:CA -t /dev/ttyp6</kbd>rfcomm_sppd[94692]: Starting on /dev/ttyp6...</pre><p>Once connected pseudo tty can be used as serial port.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cu -l ttyp6</kbd></pre></div><div class="SECT2"><h2 class="SECT2"><a id="AEN25983" name="AEN25983">19.4.11. Troubleshooting</a></h2><div class="SECT3"><h3 class="SECT3"><a id="AEN25985" name="AEN25985">19.4.11.1. A remote device cannotconnect</a></h3><p>Some older Bluetooth devices do not support role switching. By default, when FreeBSDis accepting a new connection, it tries to perform role switch and become a master.Devices, which do not support this will not be able to connect. Note the role switchingis performed when a new connection is being established, so it is not possible to ask theremote device if it does support role switching. There is a HCI option to disable roleswitching on the local side.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">hccontrol -n ubt0hci write_node_role_switch 0</kbd></pre></div><div class="SECT3"><h3 class="SECT3"><a id="AEN25991" name="AEN25991">19.4.11.2. Something is going wrong,can I see what exactly is happening?</a></h3><p>Yes, you can. Use the <b class="APPLICATION">hcidump-1.5</b> third-party package thatcan be downloaded from from <a href="http://www.geocities.com/m_evmenkin/"target="_top">here</a>. The <b class="APPLICATION">hcidump</b> utility is similar to<span class="CITEREFENTRY"><span class="REFENTRYTITLE">tcpdump</span>(1)</span>. It canused to display the content of the Bluetooth packets on the terminal and to dump theBluetooth packets to a file.</p></div></div></div><div class="NAVFOOTER"><hr align="LEFT" width="100%" /><table summary="Footer navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="network-wireless.html"accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="network-bridging.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Wireless Networking</td><td width="34%" align="center" valign="top"><a href="advanced-networking.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Bridging</td></tr></table></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -