Bluetoothctl 退出后停止广告

Bluetoothctl 退出后停止广告

我正在尝试创建一个 BLE 服务器。为此,我使用 bluetoothctl 和以下命令:

menu advertise
name MyDevice
back
advertise on
menu gatt
register-service 8733587e-8f8a-11ee-b9d1-0242ac120002
yes
register-characteristic 0x0001 broadcast
0x0001
register-characteristic 0x0002 write
0x0001
register-characteristic 0x0003 write
0x0001
register-characteristic 0x0004 write
0x0001
register-characteristic 0x0005 read
0x0001
register-application

之后我可以用手机连接到我的设备。但如果我退出 bluetoothctl - 我无法再次连接并且之前的连接会断开。
我尝试使用 bash 脚本来做到这一点,如下所示:

bluetoothctl << EOF
*commands here*

但它自动从 bluetoothctl 退出,我也无法连接。如何以正确的方式做到这一点?提前致谢。

相关内容