【发布时间】:2023-02-13 17:19:41
【问题描述】:
我正在尝试使用 GATT 为 Android 编写蓝牙键盘的最小实现。那里有很多例子,但仍然缺少一些东西。该设备连接到我的 Windows 机器。然后读取 GATT 数据库:
onCharacteristicReadRequest: 00002a50-0000-1000-8000-00805f9b34fb, id: 7, offset: 0, data: 02 00 00 00 00 00 00
onCharacteristicReadRequest: 00002a4a-0000-1000-8000-00805f9b34fb, id: 8, offset: 0, data: 01 11 00 02
onCharacteristicReadRequest: 00002a4d-0000-1000-8000-00805f9b34fb, id: 9, offset: 0, data: 00 00
onDescriptorReadRequest: 00002908-0000-1000-8000-00805f9b34fb, id: 10, offset: 0, data: 00 01
onDescriptorReadRequest: 00002902-0000-1000-8000-00805f9b34fb, id: 11, offset: 0, data: 00 00
onCharacteristicReadRequest: 00002a4b-0000-1000-8000-00805f9b34fb, id: 12, offset: 0, data: 05 0c 09 01 a1 01 05 07 15 00 25 01 75 01 95 08 09 e0 09 e1 09 e2 09 e3 09 e4 09 e5 09 e6 09 e7 81 02 05 07 95 01 75 08 15 04 25 df 19 04 29 df 81 00 c0
onDescriptorReadRequest: 00002907-0000-1000-8000-00805f9b34fb, id: 13, offset: 0, data: 2a 4d
onDescriptorWriteRequest: 00002902-0000-1000-8000-00805f9b34fb, id: 18, offset: 0, data: 01 00
之后,我尝试按如下方式发送键 H 的击键:
public void sendTestNotification(BluetoothDevice device) {
BluetoothGattCharacteristic report = gattServer.getService(UUID.fromString(HID_SERVICE)).getCharacteristic(
UUID.fromString(BtConstants.REPORT_CHARACTERISTIC));
byte[] data = {0x0, 0xB};
report.setValue(data);
// (permission check - omitted)
gattServer.notifyCharacteristicChanged(device, report, true);
}
但是没有任何反应。
GATT 配置明显有问题吗?
【问题讨论】: