# 执行蓝牙 OPP 客户端功能

您可以使用 `obexctl` 主菜单中提供的命令来验证蓝牙 OPP 客户端功能。

## 以客户端角色发送文件

开始之前，请按照[为蓝牙 OPP 功能设置设备](https://docs.qualcomm.com/doc/80-70018-13SC/topic/bluez-opp.html#section-qyc-wdd-rcc-navyanka-09-09-24-2148-41-416)中的说明设置设备。

以客户端角色发送文件，执行以下操作：

1. 通过从 `obexctl` 菜单运行以下命令连接到远程设备：

connect <bt_address> <profile_name>
        Copy to clipboard

    **参数**

    - `<bt_address>` 是远程设备的蓝牙地址。
    - `<profile_name>` 是 `opp`.

    **示例**

    要使用 `<bt_address>` `22:22:5A:A5:56:6B` 连接到远程设备，请运行以下命令：

connect 22:22:5A:A5:56:6B opp
        Copy to clipboard

    **示例输出**

[obex]# connect 22:22:5A:A5:56:6B opp
        Attempting to connect to 22:22:5A:A5:56:6B
        [NEW] Session /org/bluez/obex/client/session1 [default]
        [NEW] ObjectPush /org/bluez/obex/client/session1
        Connection successful
        [22:22:5A:A5:56:6B]#
        Copy to clipboard
2. 在 DUT 的本地目录中创建一个文本文件。
3. 通过从 `obexctl` 菜单：运行以下命令将此文本文件发送至远程设备

send <filepath>
        Copy to clipboard

    **参数**

    `<filepath>` 是文本文件的文件路径。

    **示例**

    要发送文本文件 `temp.txt` `/local/mnt/workspace/`，可运行以下命令：

send /local/mnt/workspace/temp.txt
        Copy to clipboard

    **示例输出**

[22:22:5A:A5:56:6B]# send /local/mnt/workspace/temp.txt
        Attempting to send /local/mnt/workspace/temp.txt to /org/bluez/obex/client/session1
        [NEW] Transfer /org/bluez/obex/client/session1/transfer1
        Transfer /org/bluez/obex/client/session1/transfer1
           Status: queued
           Name: temp.txt
           Size: 36
           Filename: /local/mnt/workspace/temp.txt
           Session: /org/bluez/obex/client/session1
        [CHG] Transfer /org/bluez/obex/client/session1/transfer1 Status: complete
        [DEL] Transfer /org/bluez/obex/client/session1/transfer1
        [22:22:5A:A5:56:6B]#
        Copy to clipboard
4. 在远程设备上，接受提示以接收文件。

    文件已成功发送至远程设备。

Last Published: Apr 30, 2025

[Previous Topic
执行蓝牙 OPP 服务器功能](https://docs.qualcomm.com/bundle/publicresource/80-70018-13SC/topics/bluez-perform-bluetooth-opp-server-functions.md) [Next Topic
文件传输协议 (File Transfer Protocol)](https://docs.qualcomm.com/bundle/publicresource/80-70018-13SC/topics/bluez-ftp.md)