https://blog.csdn.net/chenjk10/article/details/90317028
https://blog.csdn.net/zhuo_lee_new/article/details/106626680
首先啟動bluetoothctl啟動
常用命令
power on/off 打開電源或者關閉
scan on/off 開始掃描
pair xx:xx:xx:xx:xx 匹配某個設備
paired-devices顯示已經匹配的設備
connect xx:xx:xx:xx:xx 連接藍牙設備
在手機的setting界面可以搜索到設備,但是用nrf connect app搜索不到ble設備。
首先運行
./bluetoothctl
給芯片上電,
power on
使芯片可發現
menu advertise
Name xxxx (需要設置名稱)
Discoverable on
打開廣播
back
Advertise on
查看屬性值:
顯示設備支持的所有屬性
list-attribution
select-attribution
添加自己的service和characteristic
[bluetoothctl] menu gatt
[bluetoothctl] register-service 0xFFFF # (Choose yes when asked if primary service)
[bluetoothctl] register-characteristic 0xAAAA read # (Select a value of 1 when prompted)# 輸入的值是初始值,每次讀取,會加一
[bluetoothctl] register-characteristic 0xBBBB read,write # (Select a value of 0 when prompted)
[bluetoothctl] register-characteristic 0xCCCC read # (Select a value of 2 when prompted)
[bluetoothctl] register-application # (This commits the services/characteristics and registers the profile)
[bluetoothctl] back
[bluetoothctl] advertise on
作為主機連接從設備
1. # 進入bluetoothctl命令行
2. bluetoothctl
3. # 進入bluetoothctl命令行后,類似:[bluetooth]#
4. # Controller代表arm板上的藍牙設備,Device代表藍牙耳機
5. # 按如下步驟初始化藍牙設備,並連接藍牙耳機
6. # 查看幫組
7. help
8. #
9. power on
10. agent on
11. default-agent
12. # 啟動掃描
13. scan on
14. # 假如藍牙耳機地址為:E3:28:E9:24:21:07
15. trust E3:28:E9:24:21:07
16. # 配對
17. pair E3:28:E9:24:21:07
18. # 連接
19. connect E3:28:E9:24:21:07
20. # 查看藍牙耳機信息
21. info E3:28:E9:24:21:07
22. # 斷開連接
23. disconnect E3:28:E9:24:21:07
24. # 不想自動連接上藍牙耳機,可以刪除配對信息
remove E3:28:E9:24:21:07