问题描述
我已经连接到蓝牙设备。
我能读charectristic使用
I have connected to a bluetooth device.I am able to read charectristic using
mGatt.readCharacteristic(getMiliService().getCharacteristic(uuid));
但我无法注册指示特点。结果
我试了一下
But I am not able to register indicate for a characteristic.
What I tried
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特性)
方法获取调用。从未happend。结果
我不知道什么,我在这里失踪。结果
谁能给一个工作示例说明什么?
method getting called. which never happend.
I am not sure what I am missing here.
Can anyone give a working example for indicate?
推荐答案
这允许您连接到BLE装置,并包含许可的所有方法:写
,读
,显示
和的通知
this project allow you to connect to a BLE device, and contain all the methods of permission: write
,read
,indicate
and notification
有关指示,必须设置 CCCD
到它的价值。你将在项目找到。
for the indication, you must set the CCCD
to it's value. you will find this in the project.
这篇关于例如,对于认购BLE表明机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!