android 蓝牙4.0 ble,Android 蓝牙4.0开启Notification 和 Indication
______________________________________________________________
Android BLE 框架发布,功能全面,简单易用:
______________________________________________________________
前言:关于Notification 和Indication 的区别,请见我另一篇帖子:(心情好了再写)
直接放代码:
开启Notification :
private boolean enableNotification(boolean enable,
BluetoothGattCharacteristic characteristic) {
if (mBluetoothGatt == null || characteristic == null)
return false;
if (!mBluetoothGatt.setCharacteristicNotification(characteristic,
enable))
return false;
BluetoothGattDescriptor clientConfig = characteristic
.getDescriptor(UUIDUtils.CCC);
if (clientConfig == null)
return false;
if (enable) {
clientConfig
.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
} else {
clientConfig
.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
}
return mBluetoothGatt.writeDescriptor(clientConfig);
}
public final static UUID CCC = UUID
.fromString("00002902-0000-1000-8000-00805f9b34fb");
开启Indication:
private boolean enableIndication(boolean enable,
BluetoothGattCharacteristic characteristic) {
if (mBluetoothGatt == null || characteristic == null)
return false;
if (!mBluetoothGatt.setCharacteristicNotification(characteristic,
enable))
return false;
BluetoothGattDescriptor clientConfig = characteristic
.getDescriptor(UUIDUtils.CCC);
if (clientConfig == null)
return false;
if (enable) {
clientConfig
.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
} else {
clientConfig
.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
}
return mBluetoothGatt.writeDescriptor(clientConfig);
}
android 蓝牙4.0 ble,Android 蓝牙4.0开启Notification 和 Indication相关推荐
- Android 8.0 BLE 低功耗蓝牙开发记录
Android 8.0 BLE 低功耗蓝牙开发记录(1-3)--------------(权限申请篇未完待续) 目的:开源博客,希望大家一起修改博客错误地方,共同完善并会鸣谢提供意见的朋友.为大家提供 ...
- windows 蓝牙程序开发 ble低功耗蓝牙
1.需要使用到的动态库 Bluetooth Microsoft.Windows.SDK.Contracts 2.需要使用到的命名控件 using System.Threading.Tasks; usi ...
- android蓝牙4.0(BLE)开发之ibeacon初步
一个april beacon里携带的信息如下 ? 1 <code class=" hljs ">0201061AFF4C0002159069BDB88C11416BAC ...
- android ble蓝牙接收不到数据_Android蓝牙4.0 Ble读写数据详解 -2
Android蓝牙4.0 Ble读写数据详解 -2 上一篇说了如何扫描与链接蓝牙 这篇文章讲讲与蓝牙的数据传输,与一些踩到的坑. 先介绍一款调试工具,专门调试Ble蓝牙的app.名字叫:nRF-Con ...
- android蓝牙4.0 BLE低功耗应用
转自 http://www.cnblogs.com/zdz8207/archive/2012/10/17/bluetooth_ble_android.html 谈谈几个月以来开发android蓝 ...
- 谈谈几个月以来开发android蓝牙4.0 BLE低功耗应用的感受
谈谈几个月以来开发android蓝牙4.0 BLE低功耗应用的感受 谈谈几个月以来开发android蓝牙4.0 BLE低功耗应用的感受,注明下时间:2012-10-17写的博客,后期更新的也注明了时间 ...
- 开发android蓝牙4.0 BLE低功耗应用的感受
文章转自: http://www.cnblogs.com/zdz8207/archive/2012/10/17/bluetooth_ble_android.html 谈谈几个月以来开发android蓝 ...
- Android 蓝牙4.0(BLE)Demo
给大家分享一下蓝牙4.0的Demo,本篇介绍基本使用 最终效果 如何获取UUID 使用 Android 蓝牙4.0(BLE) Demo下载 最终效果 如何获取UUID 去手机华为应用市场下载一个叫蓝牙 ...
- Android开发:IBeacon系列——安卓蓝牙4.0(BLE)开发之检测IBeacon热点初步
检测ibeacon热点信号 软硬件要求:Android4.3及以上中支持BLE技术,同时蓝牙需要满足Bluetooth4.0及以上. iBeacon的工作原理是基于Bluetooth Low Ener ...
最新文章
- vue 过滤器 filters
- OC基础1:一些基本概念
- 二维字符数组转字符串c语言,[求助] 怎样转换一个字符二维数组到一维数组~~~...
- 程序员职业规划(一篇来自阿里Java工程师对工作3年左右程序员的职业建议和应该掌握的职业技能)...
- 在c语言中字母是几个字节的,在c语言中int占几个字节
- 西门子s7-200plc下载线驱动
- java编码什么时候需要增加空格_Java编码规范之声明和空白,空格
- Protus 8.6 及以上如何找到library文件夹
- noip2015初赛入围名单
- MySQL中的自增主键用完了怎么办?
- 分享一个强大的网盘搜索平台-猪猪盘
- android listview 上拉图片闪烁,android listview使用glide异步加载图片错位,闪烁问题...
- 【大杂烩】杂7杂8的东西
- Gilt如何将微服务部署到AWS环境,介绍ION-Roller
- 游戏音效的作用以及未来发展
- Shopee申请开店需要审核吗?
- i5 12400f和i5 12600kf参数对比
- PHP 安装与配置及Apache关联
- java菜鸟1:jdk 安装
- 要脱大家一起脱:网络实名制与官员财产透明化