You*_*eed 13 linux bluetooth bluetooth-lowenergy bluez gatt
我想知道是否有办法从Linux命令行设置gatt服务器.我知道BlueZ gatttool命令允许你充当gatt客户端并询问远程gatt服务器,但是,我不认为这个工具可以用来设置服务器.
我想要实现的是一个gatt服务器,从命令行创建,可以被任何中央设备(例如iOS或Android设备)查询,以连接到GATT服务器,发现服务和特性,并操纵数据.特点.
例:
Gatt Server具有1个服务,包含3个特征.
我使用的是内核版本3.11.0和BlueZ 5.19
因此,现在可以使用新的bluetoothctl工具进行处理。可以使用此工具按以下方式设置gatt表:-
#bluetoothctl
[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
Run Code Online (Sandbox Code Playgroud)
我已经尝试了几种服务/功能组合,并且能够使其正常工作。默认情况下,GAP(0x1800)和GATT(0x1801)服务可用,并且在您做广告时将成为GATT表的一部分。您也可以使用以下命令查看可用的服务:
[bluetoothctl] show
Controller 00:AA:BB:CC:DD:EE (public)
Name: MyMachine
Alias: MyMachine
Class: 0x000c0000
Powered: yes
Discoverable: no
Pairable: yes
UUID: Headset AG (00001112-0000-1000-8000-00805f9b34fb)
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb)
UUID: Audio Sink (0000110b-0000-1000-8000-00805f9b34fb)
**UUID: Unknown (0000ffff-0000-1000-8000-00805f9b34fb)**
UUID: Headset (00001108-0000-1000-8000-00805f9b34fb)
Modalias: usb:v1D6Bp0246d0532
Discovering: no
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7016 次 |
| 最近记录: |