请参考:www.ppsbbs.tech/thread-1534.htm
(旧版本,已弃用,请参考另一篇文章)IOS和Android手机通过BLE连接树莓派4B蓝牙(使用BLE作为从端)
1.树莓派4B开启蓝牙服务,发送Advertise 包(被发现3.7微秒,发送间隔超过1.28秒)
#!/bin/bash
sudo rfkill -n
sudo rfkill unblock 1
sudo rfkill -n
sudo hciconfig
sudo hciconfig hci0 down
sudo hciconfig hci0 up
sudo hciconfig hci0 noscan
sudo hciconfig hci0 name raspi1
sudo hciconfig hci0 leadv 3
sudo hciconfig hci0 noleadv
sudo hciconfig hci0 leadv 0
sudo hciconfig hci0 auth
sudo hciconfig hci0 noauth
#sudo hciconfig hci0 piscan
#sudo rfcomm watch hci0
sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 00 00 00 00 C8 00
2.开启btmon(编译bluez会生成该应用)
3.手机开启BLE调试工具,即可看到连接情况