createRfcommSocketToServiceRecord
BluetoothSocket createRfcommSocketToServiceRecord (UUID uuid)
Create an RFCOMM BluetoothSocket
ready to start a secure outgoing connection to this remote device using SDP lookup of uuid.
This is designed to be used with listenUsingRfcommWithServiceRecord(String, UUID)
for peer-peer Bluetooth applications.
创建一个RFCOMM BluetoothSocket准备好开始一个安全输出连接到远程设备使用SDP查找的uuid。这是设计用于与listenUsingRfcommWithServiceRecord(String,UUID)对等蓝牙应用程序。
Use connect()
to initiate the outgoing connection. This will also perform an SDP lookup of the given uuid to determine which channel to connect to.使用connect()来初始化输出连接。这也将执行SDP查找给定的uuid,以确定哪些通道连接。
The remote device will be authenticated and communication on this socket will be encrypted.远程设备将认证和通信socket 将被加密。
Use this socket only if an authenticated socket link is possible. Authentication refers to the authentication of the link key to prevent man-in-the-middle type of attacks. For example, for Bluetooth 2.1 devices, if any of the devices does not have an input and output capability or just has the ability to display a numeric key, a secure socket connection is not possible. In such a case, use {#link createInsecureRfcommSocketToServiceRecord}. For more details, refer to the Security Model section 5.2 (vol 3) of Bluetooth Core Specification version 2.1 + EDR.使用此socket 只有一个经过验证的socket 的才可能连接。身份验证是指防止中间人的身份验证链接关键类型的攻击。例如,对于蓝牙2.1设备,如果设备没有任何一个输入和输出能力或有能力显示一个数字键,一个安全的套接字连接是不可能的。在这种情况下,使用{ #链接createInsecureRfcommSocketToServiceRecord }。更多细节,请参考5.2节的安全模型(3卷)蓝牙核心规范的版本2.1 + EDR。
Hint: If you are connecting to a Bluetooth serial board then try using the well-known SPP UUID 00001101-0000-1000-8000-00805F9B34FB.
如果你连接到蓝牙串口板然后试着用通用的SPP UUID 0000 - 0000 - 1000 - 8000 - 1000 - f9b34fb
However if you are connecting to an Android peer then please generate your own unique UUID.
但是如果你是连接到一个Android同行请生成自己的独特的UUID。
Requires BLUETOOTH
Parameters | |
---|---|
uuid | UUID : service record uuid to lookup RFCOMM channel 服务记录uuid查找RFCOMM通道 |
Returns | |
---|---|
BluetoothSocket | a RFCOMM BluetoothServerSocket ready for an outgoing connectionRFCOMM BluetoothServerSocket准备一个外向连接 |
Throws | |
---|---|
IOException | on error, for example Bluetooth not available, or insufficient permissions产生错误,例如蓝牙不能使用,或权限不足 |