______________________________________________________________

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相关推荐

  1. Android 8.0 BLE 低功耗蓝牙开发记录

    Android 8.0 BLE 低功耗蓝牙开发记录(1-3)--------------(权限申请篇未完待续) 目的:开源博客,希望大家一起修改博客错误地方,共同完善并会鸣谢提供意见的朋友.为大家提供 ...

  2. windows 蓝牙程序开发 ble低功耗蓝牙

    1.需要使用到的动态库 Bluetooth Microsoft.Windows.SDK.Contracts 2.需要使用到的命名控件 using System.Threading.Tasks; usi ...

  3. android蓝牙4.0(BLE)开发之ibeacon初步

    一个april beacon里携带的信息如下 ? 1 <code class=" hljs ">0201061AFF4C0002159069BDB88C11416BAC ...

  4. android ble蓝牙接收不到数据_Android蓝牙4.0 Ble读写数据详解 -2

    Android蓝牙4.0 Ble读写数据详解 -2 上一篇说了如何扫描与链接蓝牙 这篇文章讲讲与蓝牙的数据传输,与一些踩到的坑. 先介绍一款调试工具,专门调试Ble蓝牙的app.名字叫:nRF-Con ...

  5. android蓝牙4.0 BLE低功耗应用

    转自    http://www.cnblogs.com/zdz8207/archive/2012/10/17/bluetooth_ble_android.html 谈谈几个月以来开发android蓝 ...

  6. 谈谈几个月以来开发android蓝牙4.0 BLE低功耗应用的感受

    谈谈几个月以来开发android蓝牙4.0 BLE低功耗应用的感受 谈谈几个月以来开发android蓝牙4.0 BLE低功耗应用的感受,注明下时间:2012-10-17写的博客,后期更新的也注明了时间 ...

  7. 开发android蓝牙4.0 BLE低功耗应用的感受

    文章转自: http://www.cnblogs.com/zdz8207/archive/2012/10/17/bluetooth_ble_android.html 谈谈几个月以来开发android蓝 ...

  8. Android 蓝牙4.0(BLE)Demo

    给大家分享一下蓝牙4.0的Demo,本篇介绍基本使用 最终效果 如何获取UUID 使用 Android 蓝牙4.0(BLE) Demo下载 最终效果 如何获取UUID 去手机华为应用市场下载一个叫蓝牙 ...

  9. Android开发:IBeacon系列——安卓蓝牙4.0(BLE)开发之检测IBeacon热点初步

    检测ibeacon热点信号 软硬件要求:Android4.3及以上中支持BLE技术,同时蓝牙需要满足Bluetooth4.0及以上. iBeacon的工作原理是基于Bluetooth Low Ener ...

最新文章

  1. vue 过滤器 filters
  2. OC基础1:一些基本概念
  3. 二维字符数组转字符串c语言,[求助] 怎样转换一个字符二维数组到一维数组~~~...
  4. 程序员职业规划(一篇来自阿里Java工程师对工作3年左右程序员的职业建议和应该掌握的职业技能)...
  5. 在c语言中字母是几个字节的,在c语言中int占几个字节
  6. 西门子s7-200plc下载线驱动
  7. java编码什么时候需要增加空格_Java编码规范之声明和空白,空格
  8. Protus 8.6 及以上如何找到library文件夹
  9. noip2015初赛入围名单
  10. MySQL中的自增主键用完了怎么办?
  11. 分享一个强大的网盘搜索平台-猪猪盘
  12. android listview 上拉图片闪烁,android listview使用glide异步加载图片错位,闪烁问题...
  13. 【大杂烩】杂7杂8的东西
  14. Gilt如何将微服务部署到AWS环境,介绍ION-Roller
  15. 游戏音效的作用以及未来发展
  16. Shopee申请开店需要审核吗?
  17. i5 12400f和i5 12600kf参数对比
  18. PHP 安装与配置及Apache关联
  19. java菜鸟1:jdk 安装
  20. 要脱大家一起脱:网络实名制与官员财产透明化

热门文章

  1. python检测U盘的插入,以及进行自动复制文件并写入文件
  2. DNG预设怎么导入Lightroom ?dng文件怎么导入lr?
  3. 51单片机电路原理图_单片机晶振的必要性
  4. 2020年高压电工答案解析及高压电工考试平台
  5. OTL电路与BTL电路有什么不同?
  6. 拟合时用sigmoid函数代替阶跃函数
  7. 学生综合测评系统(c++课程设计)
  8. FloTHERM 热分析PDF资料大全
  9. JAVA设计模式-13-适配器模式
  10. SdaiBuy 山建大校内购物网开源发布