Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

Bluetooth 通信

读取和写入 Bluetooth® 设备

Bluetooth 是用于使用短波长无线电传输进行短距离数据交换的无线通信协议。具有 Bluetooth 功能的常见设备包括笔记本电脑、手机和无线传感器。

使用 MATLAB® 中的 Bluetooth 接口传送和接收 ASCII 和二进制数据。此接口使用 Bluetooth 串行端口配置文件 (SPP)。您可以从 MATLAB 识别任何 Bluetooth SPP 设备并与该设备建立双向连接。

要与 Bluetooth 设备通信,您的计算机需要具有内置或外置的 Bluetooth 适配器。有关详细信息,请参阅Configure Bluetooth Communication Settings

要仿真、分析和测试蓝牙通信系统,请参阅Bluetooth Toolbox

函数

全部展开

bluetoothlist扫描附近的 Bluetooth 经典设备 (自 R2020b 起)
bluetooth连接到 Bluetooth 经典设备 (自 R2020b 起)
configureTerminator为与 Bluetooth 设备的 ASCII 字符串通信设置终止符 (自 R2020b 起)
configureCallback为与 Bluetooth 设备的通信设置回调函数和触发条件 (自 R2020b 起)
readBluetooth 设备读取数据 (自 R2020b 起)
readlineBluetooth 设备读取 ASCII 字符串数据行 (自 R2020b 起)
write将数据写入 Bluetooth 设备 (自 R2020b 起)
writeline将 ASCII 数据行写入 Bluetooth 设备 (自 R2020b 起)
flush清空 Bluetooth 设备缓冲区 (自 R2020b 起)

主题

疑难解答

Troubleshooting Bluetooth Communication

Troubleshoot the Bluetooth interface.

Resolve Bluetooth Connection Errors

Troubleshoot connecting to a Bluetooth device.

Resolve Bluetooth Warning: Unable to Read Any Data

Troubleshoot when you receive no data and you get the warning message: Bluetooth unable to read any data.

Resolve Bluetooth Warning: Unable to Read All Data

Troubleshoot when you receive some data and you get the warning message: Bluetooth unable to read all requested data.