MATLAB 帮助中心
扫描附近的 Bluetooth 经典设备
devlist = bluetoothlist
devlist = bluetoothlist("Timeout",time)
devlist = bluetoothlist 扫描附近的 Bluetooth® 经典设备。使用 bluetooth 连接到设备。
devlist
bluetooth
示例
devlist = bluetoothlist("Timeout",time) 扫描时间最长为 time 秒。Windows® 的默认超时期限为 35 秒,macOS 的默认超时期限为 20 秒。time 的值必须等于或大于 5。
time
全部折叠
扫描附近的蓝牙经典设备,并检查其连接状态。
使用 bluetoothlist 列出所有附近的设备。如果设备已连接到另一个设备或应用程序,则该设备可能不会出现在此列表中。您可先断开设备与任何其他设备或应用程序的连接,以便 MATLAB® 发现它。
bluetoothlist
devlist=5×4 table Name Address Channel Status _____________ ______________ _______ __________________ "Pixel 3" "3C286DD533CA" 8 "Ready to connect" "HC-06" "98D331FB3B77" 1 "Requires pairing" "mjin-maci" "A886DDA44062" 3 "Requires pairing" "DMTDevice" "B0B448F47A4C" Unknown "Unknown"
Name 和 Address 列用于标识设备。Channel 列指示设备 SPP 通道。Status 列说明当前设备连接状态。
Name
Address
Channel
Status
您还可以指定超时值,该值在 Windows 上小于默认的 35 秒,在 macOS 上小于默认的 20 秒。
devlist = bluetoothlist("Timeout",10)
devlist=3×4 table Name Address Channel Status _____________ ______________ _______ __________________ "Pixel 3" "3C286DD533CA" 8 "Ready to connect" "mjin-maci" "A886DDA44062" 3 "Requires pairing"
附近的 Bluetooth 设备的列表,以表形式返回。该表包含以下列。
设备名称,以字符串标量形式返回。多个设备可以共享同一个名称。
数据类型: string
string
设备标识符,以字符串标量形式返回。
设备 SPP 通道,以分类标量形式返回。如果通道未知,则此列中的值为 Unknown。
Unknown
数据类型: categorical
categorical
"Ready to connect"
"Requires pairing"
"Connected"
"Unsupported"
"Unknown"
设备连接状态,以字符串形式返回。仅当 Bluetooth 设备的状态为 "Ready to connect" 时,才能使用 bluetooth 连接到它。可能的值如下。
在 R2020b 中推出
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处