例如,对于认购BLE表明机器人 [英] Example for subscribing for BLE indicate in android

查看:236
本文介绍了例如,对于认购BLE表明机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经连接到蓝牙设备。
我能读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特性)

onCharacteristicChanged(BluetoothGatt bluetoothgatt, final BluetoothGattCharacteristic characteristic)

方法获取调用。从未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表明机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆