工作需要通过蓝牙低功耗模式配置WIFI STA连接AP。
蓝牙模块为RTL8821CU,拥有5G/2.4G wifi和蓝牙功能。之前以为需要bluetoothd等等工具,后来发现并不需要。
启动蓝牙设备
hciconfig hci0 up
开启扫描
hciconfig hci0 piscan
开启广播
hciconfig hci0 leadv
运行gatt server,提供应用层的数据交互,具体实现参考bluez的btgatt-server.c 代码,添加自己的服务。
btgatt-server -v &
中间有遇到 leadv 返回status 12的情况,需要重新up/down hci0