我已连接到蓝牙设备。
我能够使用读取特征
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, 最终的BluetoothGattCharacteristic 特征)
方法被调用。这从未发生过。
我不确定我在这里缺少什么。
任何人都可以给出一个工作示例来指示吗?
请务必注意,Android BLE 堆栈允许您一次仅写入一个特征。
这是一个对我帮助很大的工作示例:
https://github.com/devunwired/accessory-samples/blob/master/BluetoothGatt/src/com/example/bluetoothgatt/MainActivity.java https://github.com/devunwired/accessory-samples/blob/master/BluetoothGatt/src/com/example/bluetoothgatt/MainActivity.java
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)