【发布时间】:2015-09-10 16:02:04
【问题描述】:
我已连接到蓝牙设备。 我可以使用
阅读特征mGatt.readCharacteristic(getMiliService().getCharacteristic(uuid));
但我无法为某个特征注册指示。
我尝试了什么
boolean flag1 = m_Gatt.setCharacteristicNotification(bluetoothgattcharacteristic, flag);
BluetoothGattDescriptor descriptor= bluetoothgattcharacteristic.getDescriptor(Helper.UUID_DESCRIPTOR_CLIENT_CHARACTERISTIC_CONFIGURATION);
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mGatt.writeDescriptor(descriptor);
descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
mGatt.writeDescriptor(descriptor);
等待
onCharacteristicChanged(BluetoothGatt bluetoothgatt, final BluetoothGattCharacteristic 特征)
方法被调用。这从未发生过。
我不确定我在这里缺少什么。
任何人都可以给出一个指示的工作示例吗?
【问题讨论】:
标签: android bluetooth bluetooth-lowenergy android-bluetooth