# ble開發觀念&&藍芽開發工具 ## 基礎觀念 ### spp-serial port profile(classic bluetooth) [範例用途解說](https://wenku.csdn.net/answer/67k5gjkum9) ### gatt & gap (ble) gatt server esp32參考專案:gatt_server_service_table gatt clinet esp32參考專案:gatt_client 1. gatt定義了service和character 2. gap讓周遭的設備被知道,然後用gatt形成連接 3. gatt形成後server(週邊)和clinet(中心)會定期發封包確定連線狀況 [gap 和gatt觀念解析](https://blog.csdn.net/liwei16611/article/details/80958842) * read/write是client主动发起,notification/indication是server端主动发起 * notification不需要client回ack,但indication要回ack [Indication and Notification](https://community.nxp.com/t5/Wireless-Connectivity-Knowledge/Indication-and-Notification/ta-p/1129270) rfkill list - 顯示目前的無線裝置 rfkill unblock 1 - 活化裝置 hciconfig hci0 up - 讓hci裝置界面啟動 hcitool lescan - 搜尋ble裝置 ## 工具 ### bluetoothctl * power on * agent * scan on * pair [mac address] * connect [mac address] * disconect [mac address] * remove [mac address] ### gatttool 適用於gatt client ```bash= gatttool -b [MAC Address] -I (interactive) //連接ble裝置 connect // 看service primary // 看特徵(characteristics) characteristic //寫入(properties:0x08,write) char-write-req 0x0010(characteristic handler) char-write-cmd 0x0010 01 //寫入(properties:0x02,read) char-read-uuid uuid ``` --- 適用於建立gatt server ```bash= bluetoothctl # set advertise information menu advertise name name_data manufacturer 0xffff 0x11 0x33 back #set gatt information menu gatt register-service 0xFFFF register-characteristic 0xAAAA read register-characteristic 0xBBBB read,write register-characteristic 0xCCCC read register-application back advertise on ``` [參考資料1](https://blog.csdn.net/love131452098/article/details/116258471) [參考資料2](https://itecnote.com/tecnote/linux-bluez-how-to-set-up-a-gatt-server-from-the-command-line/) --- ## 參考資料 [1. Raspberry Pi IoT無線傳輸技術介紹 - Bluetooth篇](https://www.slideshare.net/raspberrypi-tw/raspberry-pi-iot-bluetooth) [2. 樹莓派 - 藍牙 (1) 試試Beacon](https://www.twblogs.net/a/5b8179c02b71772165acc682) [3. 在 Linux 下使用 rfkill 软开关蓝牙及无线功能](https://linux.cn/article-5957-1.html) [4. 【蓝牙】蓝牙,调试 hcitool与gatttool实例](https://www.cnblogs.com/chenxiaomeng/p/9128565.html) [5. 蓝牙工具hcitool和gatttool的使用](https://blog.csdn.net/Chuck_lin/article/details/78846165) [6.BLE 測試工具: bluez gatttool](https://www.dazhuanlan.com/2019/12/13/5df2eb0cf1db4/) [7. An Introduction to Bluetooth Programming](https://people.csail.mit.edu/albert/bluez-intro/index.html) [8. RPi Bluetooth LE](https://elinux.org/RPi_Bluetooth_LE) [9.藍牙技術-L2CAP介紹](https://tingchuchi.github.io/2018/01/30/bluetooth-ch6/) ###### tags: `nrf52` `bluetooth` `ble`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up