gpt4 book ai didi

linux - linux下如何获取蓝牙串口状态?

转载 作者:太空宇宙 更新时间:2023-11-04 03:45:41 25 4
gpt4 key购买 nike

通过 Linux 终端获取串行端口 (ttyS*) 的状态很简单:

sudo cat /proc/tty/driver/serial

然后它显示 serinfo 以及所有 uart 的列表以及有关状态和缓冲区的信息。当我打电话时

sudo cat /proc/tty/drivers

然后我可以看到 rfcomm 驱动程序可用:

rfcomm   /dev/rfcomm   216 0-255 serial

当然,读取来自配对蓝牙设备的数据也不成问题。

问题是:如何获取rfcomm串口(例如蓝牙SPP设备)的状态?此信息是否可以在 /proc 目录中的某个位置(例如 ttyS*)使用,或者我可以使用完全不同的方式吗?

最佳答案

这取决于您正在寻找什么状态。 bluez 附带的“rfcomm”命令确实有一些状态信息。这取决于这是否适合您。

% rfcomm -h
RFCOMM configuration utility ver 4.101
Usage:
rfcomm [options] <command> <dev>

Options:
-i [hciX|bdaddr] Local HCI device or BD Address
-h, --help Display help
-r, --raw Switch TTY into raw mode
-A, --auth Enable authentication
-E, --encrypt Enable encryption
-S, --secure Secure connection
-M, --master Become the master of a piconet
-f, --config [file] Specify alternate config file
-a Show all devices (default)

Commands:
bind <dev> <bdaddr> [channel] Bind device
release <dev> Release device
show <dev> Show device
connect <dev> <bdaddr> [channel] Connect device
listen <dev> [channel [cmd]] Listen
watch <dev> [channel [cmd]] Watch

关于linux - linux下如何获取蓝牙串口状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28308959/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com